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
09002b4b
Commit
09002b4b
authored
Apr 12, 2016
by
Дмитрий Никулин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose legendText as a method of ChartInternal
parent
84e8a053
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
legend.js
src/legend.js
+10
-6
No files found.
src/legend.js
View file @
09002b4b
...
@@ -123,6 +123,14 @@ var legendItemTextBox = {};
...
@@ -123,6 +123,14 @@ var legendItemTextBox = {};
c3_chart_internal_fn
.
clearLegendItemTextBoxCache
=
function
()
{
c3_chart_internal_fn
.
clearLegendItemTextBoxCache
=
function
()
{
legendItemTextBox
=
{};
legendItemTextBox
=
{};
};
};
c3_chart_internal_fn
.
legendText
=
function
(
id
){
var
$$
=
this
;
return
isDefined
(
$$
.
config
.
data_names
[
id
])
?
$$
.
config
.
data_names
[
id
]
:
isDefined
(
$$
.
config
.
data_names
.
id
)
?
$$
.
config
.
data_names
.
id
:
id
;
};
c3_chart_internal_fn
.
updateLegend
=
function
(
targetIds
,
options
,
transitions
)
{
c3_chart_internal_fn
.
updateLegend
=
function
(
targetIds
,
options
,
transitions
)
{
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
var
xForLegend
,
xForLegendText
,
xForLegendRect
,
yForLegend
,
yForLegendText
,
yForLegendRect
;
var
xForLegend
,
xForLegendText
,
xForLegendRect
,
yForLegend
,
yForLegendText
,
yForLegendRect
;
...
@@ -140,10 +148,6 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
...
@@ -140,10 +148,6 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
$$
.
clearLegendItemTextBoxCache
();
$$
.
clearLegendItemTextBoxCache
();
function
legendText
(
id
){
return
isDefined
(
config
.
data_names
[
id
])
?
config
.
data_names
[
id
]
:
isDefined
(
config
.
data_names
.
id
)
?
config
.
data_names
.
id
:
id
;
}
function
getTextBox
(
textElement
,
id
)
{
function
getTextBox
(
textElement
,
id
)
{
if
(
!
legendItemTextBox
[
id
])
{
if
(
!
legendItemTextBox
[
id
])
{
legendItemTextBox
[
id
]
=
$$
.
getTextRect
(
textElement
.
textContent
,
'.c3-legend-item'
);
legendItemTextBox
[
id
]
=
$$
.
getTextRect
(
textElement
.
textContent
,
'.c3-legend-item'
);
...
@@ -280,7 +284,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
...
@@ -280,7 +284,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
}
}
});
});
l
.
append
(
'text'
)
l
.
append
(
'text'
)
.
text
(
legendText
)
.
text
(
$$
.
legendText
.
bind
(
$$
)
)
.
each
(
function
(
id
,
i
)
{
updatePositions
(
this
,
id
,
i
);
})
.
each
(
function
(
id
,
i
)
{
updatePositions
(
this
,
id
,
i
);
})
.
style
(
"pointer-events"
,
"none"
)
.
style
(
"pointer-events"
,
"none"
)
.
attr
(
'x'
,
$$
.
isLegendRight
||
$$
.
isLegendInset
?
xForLegendText
:
-
200
)
.
attr
(
'x'
,
$$
.
isLegendRight
||
$$
.
isLegendInset
?
xForLegendText
:
-
200
)
...
@@ -309,7 +313,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
...
@@ -309,7 +313,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
texts
=
$$
.
legend
.
selectAll
(
'text'
)
texts
=
$$
.
legend
.
selectAll
(
'text'
)
.
data
(
targetIds
)
.
data
(
targetIds
)
.
text
(
legendText
)
// MEMO: needed for update
.
text
(
$$
.
legendText
.
bind
(
$$
)
)
// MEMO: needed for update
.
each
(
function
(
id
,
i
)
{
updatePositions
(
this
,
id
,
i
);
});
.
each
(
function
(
id
,
i
)
{
updatePositions
(
this
,
id
,
i
);
});
(
withTransition
?
texts
.
transition
()
:
texts
)
(
withTransition
?
texts
.
transition
()
:
texts
)
.
attr
(
'x'
,
xForLegendText
)
.
attr
(
'x'
,
xForLegendText
)
...
...
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