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
Evgeny
c3-closed
Commits
6cf97b72
Commit
6cf97b72
authored
Feb 26, 2015
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix legend state when reverted
parent
c6e719ac
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
24 deletions
+26
-24
c3.js
c3.js
+6
-12
c3.min.js
c3.min.js
+0
-0
api.focus-spec.js
spec/api.focus-spec.js
+14
-0
api.focus.js
src/api.focus.js
+5
-1
legend.js
src/legend.js
+1
-11
No files found.
c3.js
View file @
6cf97b72
...
...
@@ -3873,7 +3873,6 @@
var
paddingTop
=
4
,
paddingRight
=
10
,
maxWidth
=
0
,
maxHeight
=
0
,
posMin
=
10
,
tileWidth
=
15
;
var
l
,
totalLength
=
0
,
offsets
=
{},
widths
=
{},
heights
=
{},
margins
=
[
0
],
steps
=
{},
step
=
0
;
var
withTransition
,
withTransitionForTransform
;
var
hasFocused
=
$$
.
legend
.
selectAll
(
'.'
+
CLASS
.
legendItemFocused
).
size
();
var
texts
,
rects
,
tiles
,
background
;
options
=
options
||
{};
...
...
@@ -4063,16 +4062,7 @@
// toggle legend state
$$
.
legend
.
selectAll
(
'.'
+
CLASS
.
legendItem
)
.
classed
(
CLASS
.
legendItemHidden
,
function
(
id
)
{
return
!
$$
.
isTargetToShow
(
id
);
})
.
transition
()
.
style
(
'opacity'
,
function
(
id
)
{
var
This
=
$$
.
d3
.
select
(
this
);
if
(
$$
.
isTargetToShow
(
id
))
{
return
!
hasFocused
||
This
.
classed
(
CLASS
.
legendItemFocused
)
?
$$
.
opacityForLegend
(
This
)
:
$$
.
opacityForUnfocusedLegend
(
This
);
}
else
{
return
null
;
// c3-legend-item-hidden will be applied
}
});
.
classed
(
CLASS
.
legendItemHidden
,
function
(
id
)
{
return
!
$$
.
isTargetToShow
(
id
);
});
// Update all to reflect change of legend
$$
.
updateLegendItemWidth
(
maxWidth
);
...
...
@@ -5809,7 +5799,6 @@
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
candidates
=
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
.
filter
(
$$
.
isTargetToShow
,
$$
))),
this
.
revert
();
candidates
.
classed
(
CLASS
.
focused
,
false
).
classed
(
CLASS
.
defocused
,
true
);
if
(
$$
.
hasArcType
())
{
$$
.
unexpandArc
(
targetIds
);
...
...
@@ -5834,6 +5823,11 @@
}
if
(
$$
.
config
.
legend_show
)
{
$$
.
showLegend
(
targetIds
.
filter
(
$$
.
isLegendToShow
.
bind
(
$$
)));
$$
.
legend
.
selectAll
(
$$
.
selectorLegends
(
targetIds
))
.
filter
(
function
()
{
return
$$
.
d3
.
select
(
this
).
classed
(
CLASS
.
legendItemFocused
);
})
.
classed
(
CLASS
.
legendItemFocused
,
false
);
}
$$
.
focusedTargetIds
=
[];
...
...
c3.min.js
View file @
6cf97b72
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/api.focus-spec.js
View file @
6cf97b72
...
...
@@ -219,6 +219,7 @@ describe('c3 api focus', function () {
});
legendItems
.
each
(
function
()
{
var
item
=
d3
.
select
(
this
);
expect
(
item
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
+
item
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
});
done
();
...
...
@@ -241,6 +242,7 @@ describe('c3 api focus', function () {
});
legendItems
.
each
(
function
()
{
var
item
=
d3
.
select
(
this
);
expect
(
item
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
+
item
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
});
done
();
...
...
@@ -271,6 +273,9 @@ describe('c3 api focus', function () {
expect
(
+
legendItems
.
data1
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
+
legendItems
.
data2
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
+
legendItems
.
data3
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
legendItems
.
data1
.
classed
(
'c3-legend-item-focused'
)).
toBeTruthy
();
expect
(
legendItems
.
data2
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
legendItems
.
data3
.
classed
(
'c3-legend-item-focused'
)).
toBeTruthy
();
done
();
},
1000
);
},
1000
);
...
...
@@ -299,6 +304,9 @@ describe('c3 api focus', function () {
expect
(
+
legendItems
.
data1
.
style
(
'opacity'
)).
toBeCloseTo
(
0.3
);
expect
(
+
legendItems
.
data2
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
+
legendItems
.
data3
.
style
(
'opacity'
)).
toBeCloseTo
(
0.3
);
expect
(
legendItems
.
data1
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
legendItems
.
data2
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
legendItems
.
data3
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
done
();
},
1000
);
},
1000
);
...
...
@@ -327,6 +335,9 @@ describe('c3 api focus', function () {
expect
(
+
legendItems
.
data1
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
+
legendItems
.
data2
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
+
legendItems
.
data3
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
legendItems
.
data1
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
legendItems
.
data2
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
legendItems
.
data3
.
classed
(
'c3-legend-item-focused'
)).
toBeTruthy
();
done
();
},
1000
);
},
1000
);
...
...
@@ -355,6 +366,9 @@ describe('c3 api focus', function () {
expect
(
+
legendItems
.
data1
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
+
legendItems
.
data2
.
style
(
'opacity'
)).
toBeCloseTo
(
1
);
expect
(
+
legendItems
.
data3
.
style
(
'opacity'
)).
toBeCloseTo
(
0.3
);
expect
(
legendItems
.
data1
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
legendItems
.
data2
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
expect
(
legendItems
.
data3
.
classed
(
'c3-legend-item-focused'
)).
toBeFalsy
();
done
();
},
1000
);
},
1000
);
...
...
src/api.focus.js
View file @
6cf97b72
...
...
@@ -24,7 +24,6 @@ c3_chart_fn.defocus = function (targetIds) {
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
candidates
=
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
.
filter
(
$$
.
isTargetToShow
,
$$
))),
this
.
revert
();
candidates
.
classed
(
CLASS
.
focused
,
false
).
classed
(
CLASS
.
defocused
,
true
);
if
(
$$
.
hasArcType
())
{
$$
.
unexpandArc
(
targetIds
);
...
...
@@ -49,6 +48,11 @@ c3_chart_fn.revert = function (targetIds) {
}
if
(
$$
.
config
.
legend_show
)
{
$$
.
showLegend
(
targetIds
.
filter
(
$$
.
isLegendToShow
.
bind
(
$$
)));
$$
.
legend
.
selectAll
(
$$
.
selectorLegends
(
targetIds
))
.
filter
(
function
()
{
return
$$
.
d3
.
select
(
this
).
classed
(
CLASS
.
legendItemFocused
);
})
.
classed
(
CLASS
.
legendItemFocused
,
false
);
}
$$
.
focusedTargetIds
=
[];
...
...
src/legend.js
View file @
6cf97b72
...
...
@@ -117,7 +117,6 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
var
paddingTop
=
4
,
paddingRight
=
10
,
maxWidth
=
0
,
maxHeight
=
0
,
posMin
=
10
,
tileWidth
=
15
;
var
l
,
totalLength
=
0
,
offsets
=
{},
widths
=
{},
heights
=
{},
margins
=
[
0
],
steps
=
{},
step
=
0
;
var
withTransition
,
withTransitionForTransform
;
var
hasFocused
=
$$
.
legend
.
selectAll
(
'.'
+
CLASS
.
legendItemFocused
).
size
();
var
texts
,
rects
,
tiles
,
background
;
options
=
options
||
{};
...
...
@@ -307,16 +306,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
// toggle legend state
$$
.
legend
.
selectAll
(
'.'
+
CLASS
.
legendItem
)
.
classed
(
CLASS
.
legendItemHidden
,
function
(
id
)
{
return
!
$$
.
isTargetToShow
(
id
);
})
.
transition
()
.
style
(
'opacity'
,
function
(
id
)
{
var
This
=
$$
.
d3
.
select
(
this
);
if
(
$$
.
isTargetToShow
(
id
))
{
return
!
hasFocused
||
This
.
classed
(
CLASS
.
legendItemFocused
)
?
$$
.
opacityForLegend
(
This
)
:
$$
.
opacityForUnfocusedLegend
(
This
);
}
else
{
return
null
;
// c3-legend-item-hidden will be applied
}
});
.
classed
(
CLASS
.
legendItemHidden
,
function
(
id
)
{
return
!
$$
.
isTargetToShow
(
id
);
});
// Update all to reflect change of legend
$$
.
updateLegendItemWidth
(
maxWidth
);
...
...
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