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
444f2b5f
Commit
444f2b5f
authored
Jan 30, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix x tick format for categorized axis
parent
8ed33531
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
c3.js
c3.js
+14
-3
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
444f2b5f
...
...
@@ -2069,7 +2069,9 @@
};
function
categoryAxis
()
{
var
scale
=
d3
.
scale
.
linear
(),
orient
=
"bottom"
,
tickMajorSize
=
6
,
/*tickMinorSize = 6,*/
tickEndSize
=
6
,
tickPadding
=
3
,
tickCentered
=
false
,
tickTextNum
=
10
,
tickOffset
=
0
,
categories
=
[];
var
scale
=
d3
.
scale
.
linear
(),
orient
=
"bottom"
;
var
tickMajorSize
=
6
,
/*tickMinorSize = 6,*/
tickEndSize
=
6
,
tickPadding
=
3
,
tickCentered
=
false
,
tickTextNum
=
10
,
tickOffset
=
0
,
tickFormat
=
null
;
var
categories
=
[];
function
axisX
(
selection
,
x
)
{
selection
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
(
x
(
d
)
+
tickOffset
)
+
", 0)"
;
...
...
@@ -2100,6 +2102,10 @@
function
category
(
i
)
{
return
i
<
categories
.
length
?
categories
[
i
]
:
i
;
}
function
formattedCategory
(
i
)
{
var
c
=
category
(
i
);
return
tickFormat
?
tickFormat
(
c
)
:
c
;
}
function
axis
(
g
)
{
g
.
each
(
function
()
{
var
g
=
d3
.
select
(
this
);
...
...
@@ -2135,7 +2141,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
(
function
(
i
)
{
return
shouldShowTickText
(
ticks
,
i
)
?
c
ategory
(
i
)
:
""
;
});
text
.
text
(
function
(
i
)
{
return
shouldShowTickText
(
ticks
,
i
)
?
formattedC
ategory
(
i
)
:
""
;
});
pathUpdate
.
attr
(
"d"
,
"M"
+
range
[
0
]
+
","
+
tickEndSize
+
"V0H"
+
range
[
1
]
+
"V"
+
tickEndSize
);
}
...
...
@@ -2161,7 +2167,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
(
function
(
i
)
{
return
shouldShowTickText
(
ticks
,
i
)
?
c
ategory
(
i
)
:
""
;
});
text
.
text
(
function
(
i
)
{
return
shouldShowTickText
(
ticks
,
i
)
?
formattedC
ategory
(
i
)
:
""
;
});
pathUpdate
.
attr
(
"d"
,
"M"
+
-
tickEndSize
+
","
+
range
[
0
]
+
"H0V"
+
range
[
1
]
+
"H"
+
-
tickEndSize
);
break
;
}
...
...
@@ -2217,6 +2223,11 @@
tickTextNum
=
x
;
return
axis
;
};
axis
.
tickFormat
=
function
(
format
)
{
if
(
!
arguments
.
length
)
{
return
tickFormat
;
}
tickFormat
=
format
;
return
axis
;
};
axis
.
tickOffset
=
function
()
{
return
tickOffset
;
};
...
...
c3.min.js
View file @
444f2b5f
This diff is collapsed.
Click to expand it.
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