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
Evgeny
c3-closed
Commits
533ce17e
Commit
533ce17e
authored
Apr 12, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tick culling on categorized axis and add axis.x.tick.values option - #149
parent
29e871ff
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
c3.js
c3.js
+14
-10
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
533ce17e
...
...
@@ -170,9 +170,10 @@
__axis_x_tick_centered
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'centered'
],
false
),
__axis_x_tick_format
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'format'
]),
__axis_x_tick_culling
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'culling'
],
{}),
__axis_x_tick_culling_max
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'culling'
,
'max'
],
__axis_x_type
===
'categorized'
?
Infinity
:
10
),
__axis_x_tick_culling_max
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'culling'
,
'max'
],
10
),
__axis_x_tick_count
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'count'
]),
__axis_x_tick_fit
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'fit'
],
false
),
__axis_x_tick_values
=
getConfig
([
'axis'
,
'x'
,
'tick'
,
'values'
],
[]),
__axis_x_max
=
getConfig
([
'axis'
,
'x'
,
'max'
]),
__axis_x_min
=
getConfig
([
'axis'
,
'x'
,
'min'
]),
__axis_x_default
=
getConfig
([
'axis'
,
'x'
,
'default'
]),
...
...
@@ -621,6 +622,9 @@
axis
.
tickFormat
(
tickFormat
);
if
(
isCategorized
)
{
axis
.
tickCentered
(
__axis_x_tick_centered
);
if
(
isEmpty
(
__axis_x_tick_culling
))
{
__axis_x_tick_culling
=
false
;
}
}
else
{
axis
.
tickOffset
=
function
()
{
var
base
=
__axis_rotated
?
height
:
width
;
...
...
@@ -830,10 +834,6 @@
}
return
ticks
;
}
function
shouldShowTickText
(
ticks
,
i
)
{
var
length
=
ticks
.
length
-
1
;
return
length
<=
tickTextNum
||
i
%
Math
.
ceil
(
length
/
tickTextNum
)
===
0
;
}
function
category
(
i
)
{
return
i
<
categories
.
length
?
categories
[
i
]
:
i
;
}
...
...
@@ -876,7 +876,7 @@
lineUpdate
.
attr
(
"x1"
,
tickX
).
attr
(
"x2"
,
tickX
).
attr
(
"y2"
,
tickMajorSize
);
textUpdate
.
attr
(
"x"
,
0
).
attr
(
"y"
,
Math
.
max
(
tickMajorSize
,
0
)
+
tickPadding
);
text
.
attr
(
"dy"
,
".71em"
).
style
(
"text-anchor"
,
"middle"
);
text
.
text
(
f
unction
(
i
)
{
return
shouldShowTickText
(
ticks
,
i
)
?
formattedCategory
(
i
)
:
""
;
}
);
text
.
text
(
f
ormattedCategory
);
pathUpdate
.
attr
(
"d"
,
"M"
+
range
[
0
]
+
","
+
tickEndSize
+
"V0H"
+
range
[
1
]
+
"V"
+
tickEndSize
);
break
;
}
...
...
@@ -901,7 +901,7 @@
lineUpdate
.
attr
(
"x2"
,
-
tickMajorSize
).
attr
(
"y2"
,
0
);
textUpdate
.
attr
(
"x"
,
-
(
Math
.
max
(
tickMajorSize
,
0
)
+
tickPadding
)).
attr
(
"y"
,
tickOffset
);
text
.
attr
(
"dy"
,
".32em"
).
style
(
"text-anchor"
,
"end"
);
text
.
text
(
f
unction
(
i
)
{
return
shouldShowTickText
(
ticks
,
i
)
?
formattedCategory
(
i
)
:
""
;
}
);
text
.
text
(
f
ormattedCategory
);
pathUpdate
.
attr
(
"d"
,
"M"
+
-
tickEndSize
+
","
+
range
[
0
]
+
"H0V"
+
range
[
1
]
+
"H"
+
-
tickEndSize
);
break
;
}
...
...
@@ -3009,7 +3009,7 @@
// update axis tick values according to options, except for scatter plot
if
(
!
hasScatterType
(
targetsToShow
))
{
// TODO: fix this
tickValues
=
generateTickValues
(
mapTargetsToUniqueXs
(
targetsToShow
));
tickValues
=
__axis_x_tick_values
?
__axis_x_tick_values
:
generateTickValues
(
mapTargetsToUniqueXs
(
targetsToShow
));
xAxis
.
tickValues
(
tickValues
);
subXAxis
.
tickValues
(
tickValues
);
}
...
...
@@ -3030,7 +3030,8 @@
main
.
select
(
'.'
+
CLASS
.
axisY2
).
style
(
"opacity"
,
hideAxis
?
0
:
1
).
transition
().
duration
(
durationForAxis
).
call
(
yAxis2
);
// show/hide if manual culling needed
if
(
withUpdateXDomain
&&
__axis_x_tick_culling
&&
tickValues
)
{
if
(
withUpdateXDomain
)
{
if
(
__axis_x_tick_culling
&&
tickValues
)
{
for
(
i
=
1
;
i
<
tickValues
.
length
;
i
++
)
{
if
(
tickValues
.
length
/
i
<
__axis_x_tick_culling_max
)
{
intervalForCulling
=
i
;
...
...
@@ -3039,10 +3040,13 @@
}
d3
.
selectAll
(
'.'
+
CLASS
.
axisX
+
' .tick text'
).
each
(
function
(
e
)
{
var
index
=
tickValues
.
indexOf
(
e
);
if
(
index
>
0
)
{
if
(
index
>=
0
)
{
d3
.
select
(
this
).
style
(
'display'
,
index
%
intervalForCulling
?
'none'
:
'block'
);
}
});
}
else
{
d3
.
selectAll
(
'.'
+
CLASS
.
axisX
+
' .tick text'
).
style
(
'display'
,
'block'
);
}
}
// setup drawer - MEMO: these must be called after axis updated
...
...
c3.min.js
View file @
533ce17e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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