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
05ab78dc
Commit
05ab78dc
authored
Nov 08, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dungsaga-master'
parents
32ac19d9
091d11f8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
6 deletions
+36
-6
c3.js
c3.js
+7
-3
c3.min.js
c3.min.js
+0
-0
axis-spec.js
spec/axis-spec.js
+22
-0
c3.axis.js
src/c3.axis.js
+7
-3
No files found.
c3.js
View file @
05ab78dc
...
@@ -6474,9 +6474,13 @@
...
@@ -6474,9 +6474,13 @@
// this should be called only when category axis
// this should be called only when category axis
function
splitTickText
(
d
,
maxWidth
)
{
function
splitTickText
(
d
,
maxWidth
)
{
var
tickText
=
textFormatted
(
d
)
+
""
,
var
tickText
=
textFormatted
(
d
),
subtext
,
spaceIndex
,
textWidth
,
splitted
=
[];
subtext
,
spaceIndex
,
textWidth
,
splitted
=
[];
if
(
Object
.
prototype
.
toString
.
call
(
tickText
)
===
"[object Array]"
)
{
return
tickText
;
}
if
(
!
maxWidth
||
maxWidth
<=
0
)
{
if
(
!
maxWidth
||
maxWidth
<=
0
)
{
maxWidth
=
isVertical
?
95
:
params
.
isCategory
?
(
tickOffset
*
2
-
10
)
:
110
;
maxWidth
=
isVertical
?
95
:
params
.
isCategory
?
(
tickOffset
*
2
-
10
)
:
110
;
}
}
...
@@ -6500,7 +6504,7 @@
...
@@ -6500,7 +6504,7 @@
return
splitted
.
concat
(
text
);
return
splitted
.
concat
(
text
);
}
}
return
split
(
splitted
,
tickText
);
return
split
(
splitted
,
tickText
+
""
);
}
}
function
tspanDy
(
d
,
i
)
{
function
tspanDy
(
d
,
i
)
{
...
@@ -6523,7 +6527,7 @@
...
@@ -6523,7 +6527,7 @@
text
=
tick
.
select
(
"text"
);
text
=
tick
.
select
(
"text"
);
tspan
=
text
.
selectAll
(
'tspan'
)
tspan
=
text
.
selectAll
(
'tspan'
)
.
data
(
function
(
d
,
i
)
{
.
data
(
function
(
d
,
i
)
{
var
splitted
=
params
.
tickMultiline
?
splitTickText
(
d
,
params
.
tickWidth
)
:
[
textFormatted
(
d
)]
;
var
splitted
=
params
.
tickMultiline
?
splitTickText
(
d
,
params
.
tickWidth
)
:
[
].
concat
(
textFormatted
(
d
))
;
counts
[
i
]
=
splitted
.
length
;
counts
[
i
]
=
splitted
.
length
;
return
splitted
.
map
(
function
(
s
)
{
return
splitted
.
map
(
function
(
s
)
{
return
{
index
:
i
,
splitted
:
s
};
return
{
index
:
i
,
splitted
:
s
};
...
...
c3.min.js
View file @
05ab78dc
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/axis-spec.js
View file @
05ab78dc
...
@@ -435,6 +435,28 @@ describe('c3 chart axis', function () {
...
@@ -435,6 +435,28 @@ describe('c3 chart axis', function () {
});
});
});
});
});
});
describe
(
'with axis.x.tick.format'
,
function
()
{
it
(
'should update args to use axis.x.tick.format'
,
function
()
{
args
.
axis
.
x
.
tick
.
format
=
function
()
{
return
[
'this is a very long tick text'
,
'on category axis'
];
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should have multiline tick text'
,
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'
];
expect
(
tspans
.
size
()).
toBe
(
2
);
tspans
.
each
(
function
(
d
,
i
)
{
var
tspan
=
d3
.
select
(
this
);
expect
(
tspan
.
text
()).
toBe
(
expectedTickTexts
[
i
]);
});
});
});
});
});
describe
(
'axis.x.tick.rotate'
,
function
()
{
describe
(
'axis.x.tick.rotate'
,
function
()
{
...
...
src/c3.axis.js
View file @
05ab78dc
...
@@ -103,9 +103,13 @@ function c3_axis(d3, params) {
...
@@ -103,9 +103,13 @@ function c3_axis(d3, params) {
// this should be called only when category axis
// this should be called only when category axis
function
splitTickText
(
d
,
maxWidth
)
{
function
splitTickText
(
d
,
maxWidth
)
{
var
tickText
=
textFormatted
(
d
)
+
""
,
var
tickText
=
textFormatted
(
d
),
subtext
,
spaceIndex
,
textWidth
,
splitted
=
[];
subtext
,
spaceIndex
,
textWidth
,
splitted
=
[];
if
(
Object
.
prototype
.
toString
.
call
(
tickText
)
===
"[object Array]"
)
{
return
tickText
;
}
if
(
!
maxWidth
||
maxWidth
<=
0
)
{
if
(
!
maxWidth
||
maxWidth
<=
0
)
{
maxWidth
=
isVertical
?
95
:
params
.
isCategory
?
(
tickOffset
*
2
-
10
)
:
110
;
maxWidth
=
isVertical
?
95
:
params
.
isCategory
?
(
tickOffset
*
2
-
10
)
:
110
;
}
}
...
@@ -129,7 +133,7 @@ function c3_axis(d3, params) {
...
@@ -129,7 +133,7 @@ function c3_axis(d3, params) {
return
splitted
.
concat
(
text
);
return
splitted
.
concat
(
text
);
}
}
return
split
(
splitted
,
tickText
);
return
split
(
splitted
,
tickText
+
""
);
}
}
function
tspanDy
(
d
,
i
)
{
function
tspanDy
(
d
,
i
)
{
...
@@ -152,7 +156,7 @@ function c3_axis(d3, params) {
...
@@ -152,7 +156,7 @@ function c3_axis(d3, params) {
text
=
tick
.
select
(
"text"
);
text
=
tick
.
select
(
"text"
);
tspan
=
text
.
selectAll
(
'tspan'
)
tspan
=
text
.
selectAll
(
'tspan'
)
.
data
(
function
(
d
,
i
)
{
.
data
(
function
(
d
,
i
)
{
var
splitted
=
params
.
tickMultiline
?
splitTickText
(
d
,
params
.
tickWidth
)
:
[
textFormatted
(
d
)]
;
var
splitted
=
params
.
tickMultiline
?
splitTickText
(
d
,
params
.
tickWidth
)
:
[
].
concat
(
textFormatted
(
d
))
;
counts
[
i
]
=
splitted
.
length
;
counts
[
i
]
=
splitted
.
length
;
return
splitted
.
map
(
function
(
s
)
{
return
splitted
.
map
(
function
(
s
)
{
return
{
index
:
i
,
splitted
:
s
};
return
{
index
:
i
,
splitted
:
s
};
...
...
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