Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
c3-closed
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charts
c3-closed
Commits
bc987b21
Commit
bc987b21
authored
Mar 26, 2016
by
Дмитрий Никулин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Y axis tick culling for rotated charts
parent
6ffc9a1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
c3.axis.js
src/c3.axis.js
+26
-0
No files found.
src/c3.axis.js
View file @
bc987b21
...
...
@@ -26,6 +26,25 @@ function c3_axis(d3, params, $$) {
var
start
=
domain
[
0
],
stop
=
domain
[
domain
.
length
-
1
];
return
start
<
stop
?
[
start
,
stop
]
:
[
stop
,
start
];
}
function
shouldDrawTickText
(
id
){
if
(
!
$$
.
config
.
axis_rotated
)
return
true
;
var
widthLimits
=
[
// Left is width, right is number of tick labels to be removed
[
-
Infinity
],
[
200
,
10
],
[
300
,
5
],
[
450
,
2
],
[
Infinity
,
1
]
];
var
divisor
;
for
(
var
i
=
widthLimits
.
length
-
1
;
i
--
;
){
if
(
$$
.
currentWidth
>
widthLimits
[
i
][
0
])
{
divisor
=
widthLimits
[
i
+
1
][
1
];
break
;
}
}
return
!
(
id
%
divisor
);
}
function
generateTicks
(
scale
)
{
var
i
,
domain
,
ticks
=
[];
if
(
scale
.
ticks
)
{
...
...
@@ -161,6 +180,13 @@ function c3_axis(d3, params, $$) {
}
text
=
tick
.
select
(
"text"
);
if
(
$$
.
config
.
axis_rotated
&&
orient
===
'bottom'
)
{
text
.
style
(
'display'
,
function
(
d
,
i
){
return
shouldDrawTickText
(
i
)
?
'block'
:
'none'
;
});
}
tspan
=
text
.
selectAll
(
'tspan'
)
.
data
(
function
(
d
,
i
)
{
var
splitted
=
params
.
tickMultiline
?
splitTickText
(
d
,
params
.
tickWidth
)
:
[].
concat
(
textFormatted
(
d
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment