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
a2575010
Commit
a2575010
authored
Mar 27, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix event handler for data selection
parent
1bc841df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
c3.js
c3.js
+27
-17
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
a2575010
...
@@ -67,7 +67,10 @@
...
@@ -67,7 +67,10 @@
__data_selection_enabled
=
getConfig
([
'data'
,
'selection'
,
'enabled'
],
false
),
__data_selection_enabled
=
getConfig
([
'data'
,
'selection'
,
'enabled'
],
false
),
__data_selection_grouped
=
getConfig
([
'data'
,
'selection'
,
'grouped'
],
false
),
__data_selection_grouped
=
getConfig
([
'data'
,
'selection'
,
'grouped'
],
false
),
__data_selection_isselectable
=
getConfig
([
'data'
,
'selection'
,
'isselectable'
],
function
()
{
return
true
;
}),
__data_selection_isselectable
=
getConfig
([
'data'
,
'selection'
,
'isselectable'
],
function
()
{
return
true
;
}),
__data_selection_multiple
=
getConfig
([
'data'
,
'selection'
,
'multiple'
],
true
);
__data_selection_multiple
=
getConfig
([
'data'
,
'selection'
,
'multiple'
],
true
),
__data_onclick
=
getConfig
([
'data'
,
'onclick'
],
function
()
{}),
__data_onselected
=
getConfig
([
'data'
,
'onselected'
],
function
()
{}),
__data_onunselected
=
getConfig
([
'data'
,
'onunselected'
],
function
()
{});
// subchart
// subchart
var
__subchart_show
=
getConfig
([
'subchart'
,
'show'
],
false
),
var
__subchart_show
=
getConfig
([
'subchart'
,
'show'
],
false
),
...
@@ -129,10 +132,7 @@
...
@@ -129,10 +132,7 @@
__point_focus_line_enabled
=
getConfig
([
'point'
,
'focus'
,
'line'
,
'enabled'
],
true
),
__point_focus_line_enabled
=
getConfig
([
'point'
,
'focus'
,
'line'
,
'enabled'
],
true
),
__point_focus_expand_enabled
=
getConfig
([
'point'
,
'focus'
,
'expand'
,
'enabled'
],
true
),
__point_focus_expand_enabled
=
getConfig
([
'point'
,
'focus'
,
'expand'
,
'enabled'
],
true
),
__point_focus_expand_r
=
getConfig
([
'point'
,
'focus'
,
'expand'
,
'r'
],
__point_focus_expand_enabled
?
4
:
__point_r
),
__point_focus_expand_r
=
getConfig
([
'point'
,
'focus'
,
'expand'
,
'r'
],
__point_focus_expand_enabled
?
4
:
__point_r
),
__point_select_r
=
getConfig
([
'point'
,
'focus'
,
'select'
,
'r'
],
8
),
__point_select_r
=
getConfig
([
'point'
,
'focus'
,
'select'
,
'r'
],
8
);
__point_onclick
=
getConfig
([
'point'
,
'onclick'
],
function
()
{}),
__point_onselected
=
getConfig
([
'point'
,
'onselected'
],
function
()
{}),
__point_onunselected
=
getConfig
([
'point'
,
'onunselected'
],
function
()
{});
// pie
// pie
var
__pie_label_show
=
getConfig
([
'pie'
,
'label'
,
'show'
],
true
),
var
__pie_label_show
=
getConfig
([
'pie'
,
'label'
,
'show'
],
true
),
...
@@ -1754,7 +1754,7 @@
...
@@ -1754,7 +1754,7 @@
//-- Selection --//
//-- Selection --//
function
selectPoint
(
target
,
d
,
i
)
{
function
selectPoint
(
target
,
d
,
i
)
{
__
point_onselected
(
target
,
d
);
__
data_onselected
(
d
,
target
.
node
()
);
// add selected-circle on low layer g
// add selected-circle on low layer g
main
.
select
(
".selected-circles"
+
getTargetSelectorSuffix
(
d
.
id
)).
selectAll
(
'.selected-circle-'
+
i
)
main
.
select
(
".selected-circles"
+
getTargetSelectorSuffix
(
d
.
id
)).
selectAll
(
'.selected-circle-'
+
i
)
.
data
([
d
])
.
data
([
d
])
...
@@ -1768,7 +1768,7 @@
...
@@ -1768,7 +1768,7 @@
.
attr
(
"r"
,
__point_select_r
);
.
attr
(
"r"
,
__point_select_r
);
}
}
function
unselectPoint
(
target
,
d
,
i
)
{
function
unselectPoint
(
target
,
d
,
i
)
{
__
point_onunselected
(
target
,
d
);
__
data_onunselected
(
d
,
target
.
node
()
);
// remove selected-circle from low layer g
// remove selected-circle from low layer g
main
.
select
(
".selected-circles"
+
getTargetSelectorSuffix
(
d
.
id
)).
selectAll
(
".selected-circle-"
+
i
)
main
.
select
(
".selected-circles"
+
getTargetSelectorSuffix
(
d
.
id
)).
selectAll
(
".selected-circle-"
+
i
)
.
transition
().
duration
(
100
).
attr
(
'r'
,
0
)
.
transition
().
duration
(
100
).
attr
(
'r'
,
0
)
...
@@ -1779,9 +1779,11 @@
...
@@ -1779,9 +1779,11 @@
}
}
function
selectBar
(
target
,
d
)
{
function
selectBar
(
target
,
d
)
{
__data_onselected
(
d
,
target
.
node
());
target
.
transition
().
duration
(
100
).
style
(
"fill"
,
function
()
{
return
d3
.
rgb
(
color
(
d
.
id
)).
darker
(
1
);
});
target
.
transition
().
duration
(
100
).
style
(
"fill"
,
function
()
{
return
d3
.
rgb
(
color
(
d
.
id
)).
darker
(
1
);
});
}
}
function
unselectBar
(
target
,
d
)
{
function
unselectBar
(
target
,
d
)
{
__data_onunselected
(
d
,
target
.
node
());
target
.
transition
().
duration
(
100
).
style
(
"fill"
,
function
()
{
return
color
(
d
.
id
);
});
target
.
transition
().
duration
(
100
).
style
(
"fill"
,
function
()
{
return
color
(
d
.
id
);
});
}
}
function
toggleBar
(
selected
,
target
,
d
,
i
)
{
function
toggleBar
(
selected
,
target
,
d
,
i
)
{
...
@@ -2518,7 +2520,7 @@
...
@@ -2518,7 +2520,7 @@
isSelected
?
c3
.
unselect
()
:
c3
.
select
([
d
.
id
],
[
i
],
true
);
isSelected
?
c3
.
unselect
()
:
c3
.
select
([
d
.
id
],
[
i
],
true
);
}
}
}
}
__
point_onclick
(
d
,
_this
);
// TODO: should be __data_onclick
__
data_onclick
(
d
,
target
);
}
}
}
}
...
@@ -3538,16 +3540,20 @@
...
@@ -3538,16 +3540,20 @@
c3
.
select
=
function
(
ids
,
indices
,
resetOther
)
{
c3
.
select
=
function
(
ids
,
indices
,
resetOther
)
{
if
(
!
__data_selection_enabled
)
{
return
;
}
if
(
!
__data_selection_enabled
)
{
return
;
}
main
.
selectAll
(
'.-shapes'
).
selectAll
(
'.-shape'
).
each
(
function
(
d
,
i
)
{
main
.
selectAll
(
'.-shapes'
).
selectAll
(
'.-shape'
).
each
(
function
(
d
,
i
)
{
var
selectShape
=
(
this
.
nodeName
===
'circle'
)
?
selectPoint
:
selectBar
,
var
shape
=
d3
.
select
(
this
),
unselectShape
=
(
this
.
nodeName
===
'circle'
)
?
unselectPoint
:
unselectBar
,
select
=
(
this
.
nodeName
===
'circle'
)
?
selectPoint
:
selectBar
,
unselect
=
(
this
.
nodeName
===
'circle'
)
?
unselectPoint
:
unselectBar
,
isTargetId
=
__data_selection_grouped
||
!
ids
||
ids
.
indexOf
(
d
.
id
)
>=
0
,
isTargetId
=
__data_selection_grouped
||
!
ids
||
ids
.
indexOf
(
d
.
id
)
>=
0
,
isTargetIndex
=
!
indices
||
indices
.
indexOf
(
i
)
>=
0
;
isTargetIndex
=
!
indices
||
indices
.
indexOf
(
i
)
>=
0
,
isSelected
=
shape
.
classed
(
SELECTED
);
if
(
isTargetId
&&
isTargetIndex
)
{
if
(
isTargetId
&&
isTargetIndex
)
{
if
(
__data_selection_isselectable
(
d
))
{
if
(
__data_selection_isselectable
(
d
)
&&
!
isSelected
)
{
select
Shape
(
d3
.
select
(
this
)
.
classed
(
SELECTED
,
true
),
d
,
i
);
select
(
shape
.
classed
(
SELECTED
,
true
),
d
,
i
);
}
}
}
else
if
(
isDefined
(
resetOther
)
&&
resetOther
)
{
}
else
if
(
isDefined
(
resetOther
)
&&
resetOther
)
{
unselectShape
(
d3
.
select
(
this
).
classed
(
SELECTED
,
false
),
d
,
i
);
if
(
isSelected
)
{
unselect
(
shape
.
classed
(
SELECTED
,
false
),
d
,
i
);
}
}
}
});
});
};
};
...
@@ -3555,12 +3561,16 @@
...
@@ -3555,12 +3561,16 @@
c3
.
unselect
=
function
(
ids
,
indices
)
{
c3
.
unselect
=
function
(
ids
,
indices
)
{
if
(
!
__data_selection_enabled
)
{
return
;
}
if
(
!
__data_selection_enabled
)
{
return
;
}
main
.
selectAll
(
'.-shapes'
).
selectAll
(
'.-shape'
).
each
(
function
(
d
,
i
)
{
main
.
selectAll
(
'.-shapes'
).
selectAll
(
'.-shape'
).
each
(
function
(
d
,
i
)
{
var
unselectShape
=
(
this
.
nodeName
===
'circle'
)
?
unselectPoint
:
unselectBar
,
var
shape
=
d3
.
select
(
this
),
unselect
=
(
this
.
nodeName
===
'circle'
)
?
unselectPoint
:
unselectBar
,
isTargetId
=
__data_selection_grouped
||
!
ids
||
ids
.
indexOf
(
d
.
id
)
>=
0
,
isTargetId
=
__data_selection_grouped
||
!
ids
||
ids
.
indexOf
(
d
.
id
)
>=
0
,
isTargetIndex
=
!
indices
||
indices
.
indexOf
(
i
)
>=
0
;
isTargetIndex
=
!
indices
||
indices
.
indexOf
(
i
)
>=
0
,
isSelected
=
shape
.
classed
(
SELECTED
);
if
(
isTargetId
&&
isTargetIndex
)
{
if
(
isTargetId
&&
isTargetIndex
)
{
if
(
__data_selection_isselectable
(
d
))
{
if
(
__data_selection_isselectable
(
d
))
{
unselectShape
(
d3
.
select
(
this
).
classed
(
SELECTED
,
false
),
d
,
i
);
if
(
isSelected
)
{
unselect
(
shape
.
classed
(
SELECTED
,
false
),
d
,
i
);
}
}
}
}
}
});
});
...
...
c3.min.js
View file @
a2575010
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