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
ed534fc5
Commit
ed534fc5
authored
May 31, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix width for data label
parent
abfc67ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
c3.js
c3.js
+9
-7
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
ed534fc5
...
...
@@ -1234,7 +1234,7 @@
}
// add padding for data label
if
(
showHorizontalDataLabel
)
{
widths
=
getDataLabelWidth
(
yDomainMin
,
yDomainMax
);
widths
=
getDataLabelWidth
(
yDomainMin
,
yDomainMax
,
axisId
);
diff
=
diffDomain
(
y
.
range
());
ratio
=
[
widths
[
0
]
/
diff
,
widths
[
1
]
/
diff
];
padding_top
+=
domainLength
*
(
ratio
[
1
]
/
(
1
-
ratio
[
0
]
-
ratio
[
1
]));
...
...
@@ -1806,13 +1806,15 @@
}
return
false
;
}
function
getDataLabelWidth
(
min
,
max
)
{
function
getDataLabelWidth
(
min
,
max
,
axisId
)
{
var
widths
=
[],
paddingCoef
=
1.3
;
selectChart
.
select
(
'svg'
).
selectAll
(
'.dummy'
)
.
data
([
min
,
max
])
.
enter
().
append
(
'text'
)
.
text
(
function
(
d
)
{
return
formatByAxisId
(
d
.
id
)(
d
.
value
,
d
.
id
);
})
.
each
(
function
(
d
,
i
)
{
widths
[
i
]
=
this
.
getBoundingClientRect
().
width
*
paddingCoef
;
})
.
text
(
function
(
d
)
{
return
formatByAxisId
(
axisId
)(
d
);
})
.
each
(
function
(
d
,
i
)
{
widths
[
i
]
=
this
.
getBoundingClientRect
().
width
*
paddingCoef
;
})
.
remove
();
return
widths
;
}
...
...
@@ -1838,8 +1840,8 @@
function
defaultArcValueFormat
(
v
,
ratio
)
{
return
(
ratio
*
100
).
toFixed
(
1
)
+
'%'
;
}
function
formatByAxisId
(
i
d
)
{
var
defaultFormat
=
function
(
v
)
{
return
isValue
(
v
)
?
+
v
:
""
;
},
axisId
=
getAxisId
(
id
),
format
=
defaultFormat
;
function
formatByAxisId
(
axisI
d
)
{
var
format
=
function
(
v
)
{
return
isValue
(
v
)
?
+
v
:
""
;
}
;
// find format according to axis id
if
(
typeof
__data_labels
.
format
===
'function'
)
{
format
=
__data_labels
.
format
;
...
...
@@ -3710,7 +3712,7 @@
.
style
(
"fill"
,
color
)
.
style
(
"fill-opacity"
,
0
);
mainText
.
text
(
function
(
d
)
{
return
formatByAxisId
(
d
.
id
)(
d
.
value
,
d
.
id
);
})
.
text
(
function
(
d
)
{
return
formatByAxisId
(
getAxisId
(
d
.
id
)
)(
d
.
value
,
d
.
id
);
})
.
style
(
"fill-opacity"
,
initialOpacityForText
);
mainText
.
exit
()
.
transition
().
duration
(
durationForExit
)
...
...
c3.min.js
View file @
ed534fc5
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