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
dbd64612
Commit
dbd64612
authored
Nov 20, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add legend.hide option - #731
parent
91fcd44c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
0 deletions
+53
-0
c3.js
c3.js
+4
-0
c3.min.js
c3.min.js
+0
-0
legend-spec.js
spec/legend-spec.js
+45
-0
config.js
src/config.js
+1
-0
core.js
src/core.js
+3
-0
No files found.
c3.js
View file @
dbd64612
...
@@ -179,6 +179,9 @@
...
@@ -179,6 +179,9 @@
if
(
config
.
data_hide
)
{
if
(
config
.
data_hide
)
{
$$
.
addHiddenTargetIds
(
config
.
data_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
data_hide
);
$$
.
addHiddenTargetIds
(
config
.
data_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
data_hide
);
}
}
if
(
config
.
legend_hide
)
{
$$
.
addHiddenLegendIds
(
config
.
legend_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
legend_hide
);
}
// when gauge, hide legend // TODO: fix
// when gauge, hide legend // TODO: fix
if
(
$$
.
hasType
(
'gauge'
))
{
if
(
$$
.
hasType
(
'gauge'
))
{
...
@@ -988,6 +991,7 @@
...
@@ -988,6 +991,7 @@
color_threshold
:
{},
color_threshold
:
{},
// legend
// legend
legend_show
:
true
,
legend_show
:
true
,
legend_hide
:
false
,
legend_position
:
'bottom'
,
legend_position
:
'bottom'
,
legend_inset_anchor
:
'top-left'
,
legend_inset_anchor
:
'top-left'
,
legend_inset_x
:
10
,
legend_inset_x
:
10
,
...
...
c3.min.js
View file @
dbd64612
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/legend-spec.js
View file @
dbd64612
...
@@ -106,4 +106,49 @@ describe('c3 chart legend', function () {
...
@@ -106,4 +106,49 @@ describe('c3 chart legend', function () {
});
});
describe
(
'legend.hide'
,
function
()
{
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
130
,
100
,
200
,
100
,
250
,
150
]
]
},
legend
:
{
hide
:
true
}
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should not show legends'
,
function
()
{
d3
.
selectAll
(
'.c3-legend-item'
).
each
(
function
()
{
expect
(
d3
.
select
(
this
).
style
(
'visibility'
)).
toBe
(
'hidden'
);
});
});
it
(
'should update args'
,
function
()
{
args
=
{
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
130
,
100
,
200
,
100
,
250
,
150
]
]
},
legend
:
{
hide
:
'data2'
}
};
expect
(
true
).
toBeTruthy
();
});
it
(
'should not show legends'
,
function
()
{
expect
(
d3
.
select
(
'.c3-legend-item-data1'
).
style
(
'visibility'
)).
toBe
(
'visible'
);
expect
(
d3
.
select
(
'.c3-legend-item-data2'
).
style
(
'visibility'
)).
toBe
(
'hidden'
);
});
});
});
});
src/config.js
View file @
dbd64612
...
@@ -68,6 +68,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
...
@@ -68,6 +68,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
color_threshold
:
{},
color_threshold
:
{},
// legend
// legend
legend_show
:
true
,
legend_show
:
true
,
legend_hide
:
false
,
legend_position
:
'bottom'
,
legend_position
:
'bottom'
,
legend_inset_anchor
:
'top-left'
,
legend_inset_anchor
:
'top-left'
,
legend_inset_x
:
10
,
legend_inset_x
:
10
,
...
...
src/core.js
View file @
dbd64612
...
@@ -174,6 +174,9 @@ c3_chart_internal_fn.initWithData = function (data) {
...
@@ -174,6 +174,9 @@ c3_chart_internal_fn.initWithData = function (data) {
if
(
config
.
data_hide
)
{
if
(
config
.
data_hide
)
{
$$
.
addHiddenTargetIds
(
config
.
data_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
data_hide
);
$$
.
addHiddenTargetIds
(
config
.
data_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
data_hide
);
}
}
if
(
config
.
legend_hide
)
{
$$
.
addHiddenLegendIds
(
config
.
legend_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
legend_hide
);
}
// when gauge, hide legend // TODO: fix
// when gauge, hide legend // TODO: fix
if
(
$$
.
hasType
(
'gauge'
))
{
if
(
$$
.
hasType
(
'gauge'
))
{
...
...
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