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
3334ef86
Commit
3334ef86
authored
Nov 21, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache tick text size - #730
parent
1c350229
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
c3.js
c3.js
+6
-0
c3.min.js
c3.min.js
+0
-0
axis-spec.js
spec/axis-spec.js
+12
-11
c3.axis.js
src/c3.axis.js
+6
-0
No files found.
c3.js
View file @
3334ef86
...
...
@@ -6455,6 +6455,8 @@
// Features:
// 1. category axis
// 2. ceil values of translate/x/y to int for half pixel antialiasing
// 3. multiline tick text
var
tickTextCharSize
;
function
c3_axis
(
d3
,
params
)
{
var
scale
=
d3
.
scale
.
linear
(),
orient
=
"bottom"
,
innerTickSize
=
6
,
outerTickSize
,
tickPadding
=
3
,
tickValues
=
null
,
tickFormat
,
tickArguments
;
...
...
@@ -6503,6 +6505,9 @@
return
tickFormat
?
tickFormat
(
v
)
:
v
;
}
function
getSizeFor1Char
(
tick
)
{
if
(
tickTextCharSize
)
{
return
tickTextCharSize
;
}
var
size
=
{
h
:
11.5
,
w
:
5.5
...
...
@@ -6517,6 +6522,7 @@
size
.
w
=
w
;
}
}).
text
(
''
);
tickTextCharSize
=
size
;
return
size
;
}
function
axis
(
g
)
{
...
...
c3.min.js
View file @
3334ef86
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/axis-spec.js
View file @
3334ef86
...
...
@@ -206,7 +206,7 @@ describe('c3 chart axis', function () {
it
(
'should split x axis tick text to multiple lines'
,
function
()
{
var
ticks
=
chart
.
internal
.
main
.
select
(
'.c3-axis-x'
).
selectAll
(
'g.tick'
),
expectedTexts
=
[
'very long tick text
on x'
,
'
axis'
],
expectedTexts
=
[
'very long tick text
'
,
'on x
axis'
],
expectedX
=
'0'
;
expect
(
ticks
.
size
()).
toBe
(
6
);
ticks
.
each
(
function
()
{
...
...
@@ -286,7 +286,7 @@ describe('c3 chart axis', function () {
it
(
'should split x axis tick text to multiple lines'
,
function
()
{
var
ticks
=
chart
.
internal
.
main
.
select
(
'.c3-axis-x'
).
selectAll
(
'g.tick'
),
expectedTexts
=
[
'very long tick
text on'
,
'
x axis'
],
expectedTexts
=
[
'very long tick
'
,
'text on
x axis'
],
expectedX
=
'-9'
;
expect
(
ticks
.
size
()).
toBe
(
6
);
ticks
.
each
(
function
()
{
...
...
@@ -378,12 +378,13 @@ describe('c3 chart axis', function () {
var
tick
=
chart
.
internal
.
main
.
select
(
'.c3-axis-x'
).
select
(
'g.tick'
),
tspans
=
tick
.
selectAll
(
'tspan'
),
expectedTickTexts
=
[
'this is a very long'
,
'tick text on'
,
'category axis'
'this is a very'
,
'long tick text'
,
'on category'
,
'axis'
,
],
expectedX
=
'0'
;
expect
(
tspans
.
size
()).
toBe
(
3
);
expect
(
tspans
.
size
()).
toBe
(
4
);
tspans
.
each
(
function
(
d
,
i
)
{
var
tspan
=
d3
.
select
(
this
);
expect
(
tspan
.
text
()).
toBe
(
expectedTickTexts
[
i
]);
...
...
@@ -426,9 +427,9 @@ describe('c3 chart axis', function () {
var
tick
=
chart
.
internal
.
main
.
select
(
'.c3-axis-x'
).
select
(
'g.tick'
),
tspans
=
tick
.
selectAll
(
'tspan'
),
expectedTickTexts
=
[
'this is a very
long
'
,
'
tick text on category
'
,
'axis'
'this is a very'
,
'
long tick text on
'
,
'
category
axis'
],
expectedX
=
'-9'
;
expect
(
tspans
.
size
()).
toBe
(
3
);
...
...
@@ -479,8 +480,8 @@ describe('c3 chart axis', function () {
var
tick
=
chart
.
internal
.
main
.
select
(
'.c3-axis-x'
).
select
(
'g.tick'
),
tspans
=
tick
.
selectAll
(
'tspan'
),
expectedTickTexts
=
[
'this is a very long tick
text on
'
,
'category axis'
'this is a very long tick'
,
'
text on
category axis'
],
expectedX
=
'-9'
;
expect
(
tspans
.
size
()).
toBe
(
2
);
...
...
src/c3.axis.js
View file @
3334ef86
// Features:
// 1. category axis
// 2. ceil values of translate/x/y to int for half pixel antialiasing
// 3. multiline tick text
var
tickTextCharSize
;
function
c3_axis
(
d3
,
params
)
{
var
scale
=
d3
.
scale
.
linear
(),
orient
=
"bottom"
,
innerTickSize
=
6
,
outerTickSize
,
tickPadding
=
3
,
tickValues
=
null
,
tickFormat
,
tickArguments
;
...
...
@@ -49,6 +51,9 @@ function c3_axis(d3, params) {
return
tickFormat
?
tickFormat
(
v
)
:
v
;
}
function
getSizeFor1Char
(
tick
)
{
if
(
tickTextCharSize
)
{
return
tickTextCharSize
;
}
var
size
=
{
h
:
11.5
,
w
:
5.5
...
...
@@ -63,6 +68,7 @@ function c3_axis(d3, params) {
size
.
w
=
w
;
}
}).
text
(
''
);
tickTextCharSize
=
size
;
return
size
;
}
function
axis
(
g
)
{
...
...
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