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
93a6ca4e
Commit
93a6ca4e
authored
Nov 30, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bobbyrenwick-master'
parents
7148dea7
cbb4b600
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
0 deletions
+52
-0
c3.js
c3.js
+10
-0
c3.min.js
c3.min.js
+0
-0
legend-spec.js
spec/legend-spec.js
+32
-0
legend.js
src/legend.js
+10
-0
No files found.
c3.js
View file @
93a6ca4e
...
...
@@ -3666,13 +3666,19 @@
c3_chart_internal_fn
.
initLegend
=
function
()
{
var
$$
=
this
;
$$
.
legendHasRendered
=
false
;
$$
.
legend
=
$$
.
svg
.
append
(
"g"
).
attr
(
"transform"
,
$$
.
getTranslate
(
'legend'
));
if
(
!
$$
.
config
.
legend_show
)
{
$$
.
legend
.
style
(
'visibility'
,
'hidden'
);
$$
.
hiddenLegendIds
=
$$
.
mapToIds
(
$$
.
data
.
targets
);
return
;
}
// MEMO: call here to update legend box and tranlate for all
// MEMO: translate will be upated by this, so transform not needed in updateLegend()
$$
.
updateLegendWithDefaults
();
};
c3_chart_internal_fn
.
updateLegendWithDefaults
=
function
()
{
var
$$
=
this
;
$$
.
updateLegend
(
$$
.
mapToIds
(
$$
.
data
.
targets
),
{
withTransform
:
false
,
withTransitionForTransform
:
false
,
withTransition
:
false
});
};
c3_chart_internal_fn
.
updateSizeForLegend
=
function
(
legendHeight
,
legendWidth
)
{
...
...
@@ -3747,6 +3753,9 @@
if
(
!
config
.
legend_show
)
{
config
.
legend_show
=
true
;
$$
.
legend
.
style
(
'visibility'
,
'visible'
);
if
(
!
$$
.
legendHasRendered
)
{
$$
.
updateLegendWithDefaults
();
}
}
$$
.
removeHiddenLegendIds
(
targetIds
);
$$
.
legend
.
selectAll
(
$$
.
selectorLegends
(
targetIds
))
...
...
@@ -3986,6 +3995,7 @@
$$
.
updateSvgSize
();
// Update g positions
$$
.
transformAll
(
withTransitionForTransform
,
transitions
);
$$
.
legendHasRendered
=
true
;
};
c3_chart_internal_fn
.
initAxis
=
function
()
{
...
...
c3.min.js
View file @
93a6ca4e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/legend-spec.js
View file @
93a6ca4e
...
...
@@ -151,4 +151,36 @@ describe('c3 chart legend', function () {
});
describe
(
'legend.show'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
130
,
100
,
200
,
100
,
250
,
150
]
]
},
legend
:
{
show
:
false
}
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should not initially have rendered any legend items'
,
function
()
{
expect
(
d3
.
selectAll
(
'.c3-legend-item'
).
empty
()).
toBe
(
true
);
});
it
(
'allows us to show the legend on showLegend call'
,
function
()
{
chart
.
legend
.
show
();
d3
.
selectAll
(
'.c3-legend-item'
).
each
(
function
()
{
expect
(
d3
.
select
(
this
).
style
(
'visibility'
)).
toBe
(
'visible'
);
// This selects all the children, but we expect it to be empty
expect
(
d3
.
select
(
this
).
selectAll
(
"*"
).
length
).
not
.
toEqual
(
0
);
});
});
});
});
src/legend.js
View file @
93a6ca4e
c3_chart_internal_fn
.
initLegend
=
function
()
{
var
$$
=
this
;
$$
.
legendHasRendered
=
false
;
$$
.
legend
=
$$
.
svg
.
append
(
"g"
).
attr
(
"transform"
,
$$
.
getTranslate
(
'legend'
));
if
(
!
$$
.
config
.
legend_show
)
{
$$
.
legend
.
style
(
'visibility'
,
'hidden'
);
$$
.
hiddenLegendIds
=
$$
.
mapToIds
(
$$
.
data
.
targets
);
return
;
}
// MEMO: call here to update legend box and tranlate for all
// MEMO: translate will be upated by this, so transform not needed in updateLegend()
$$
.
updateLegendWithDefaults
();
};
c3_chart_internal_fn
.
updateLegendWithDefaults
=
function
()
{
var
$$
=
this
;
$$
.
updateLegend
(
$$
.
mapToIds
(
$$
.
data
.
targets
),
{
withTransform
:
false
,
withTransitionForTransform
:
false
,
withTransition
:
false
});
};
c3_chart_internal_fn
.
updateSizeForLegend
=
function
(
legendHeight
,
legendWidth
)
{
...
...
@@ -81,6 +87,9 @@ c3_chart_internal_fn.showLegend = function (targetIds) {
if
(
!
config
.
legend_show
)
{
config
.
legend_show
=
true
;
$$
.
legend
.
style
(
'visibility'
,
'visible'
);
if
(
!
$$
.
legendHasRendered
)
{
$$
.
updateLegendWithDefaults
();
}
}
$$
.
removeHiddenLegendIds
(
targetIds
);
$$
.
legend
.
selectAll
(
$$
.
selectorLegends
(
targetIds
))
...
...
@@ -320,4 +329,5 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
$$
.
updateSvgSize
();
// Update g positions
$$
.
transformAll
(
withTransitionForTransform
,
transitions
);
$$
.
legendHasRendered
=
true
;
};
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