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
beed6436
You need to sign in or sign up before continuing.
Commit
beed6436
authored
Sep 03, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix onclick on step chart - #489
parent
fd2cbf8d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
5 deletions
+32
-5
c3.js
c3.js
+15
-2
c3.min.js
c3.min.js
+0
-0
chart_step.html
htdocs/samples/chart_step.html
+2
-1
interaction.js
src/interaction.js
+7
-0
selection.js
src/selection.js
+8
-2
No files found.
c3.js
View file @
beed6436
...
@@ -2119,6 +2119,10 @@
...
@@ -2119,6 +2119,10 @@
if
(
$$
.
dragging
)
{
return
;
}
// do nothing when dragging
if
(
$$
.
dragging
)
{
return
;
}
// do nothing when dragging
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
$$
.
isStepType
(
d
)
&&
d3
.
mouse
(
this
)[
0
]
<
$$
.
x
(
$$
.
getXValue
(
d
.
id
,
index
)))
{
index
-=
1
;
}
// Show tooltip
// Show tooltip
selectedData
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
).
map
(
function
(
t
)
{
selectedData
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
).
map
(
function
(
t
)
{
return
$$
.
addName
(
$$
.
getValueOnIndex
(
t
.
values
,
index
));
return
$$
.
addName
(
$$
.
getValueOnIndex
(
t
.
values
,
index
));
...
@@ -2175,6 +2179,9 @@
...
@@ -2175,6 +2179,9 @@
$$
.
cancelClick
=
false
;
$$
.
cancelClick
=
false
;
return
;
return
;
}
}
if
(
$$
.
isStepType
(
d
)
&&
d3
.
mouse
(
this
)[
0
]
<
$$
.
x
(
$$
.
getXValue
(
d
.
id
,
index
)))
{
index
-=
1
;
}
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shape
+
'-'
+
index
).
each
(
function
(
d
)
{
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shape
+
'-'
+
index
).
each
(
function
(
d
)
{
$$
.
toggleShape
(
this
,
d
,
index
);
$$
.
toggleShape
(
this
,
d
,
index
);
});
});
...
@@ -4672,8 +4679,14 @@
...
@@ -4672,8 +4679,14 @@
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
shape
=
d3
.
select
(
that
),
isSelected
=
shape
.
classed
(
CLASS
.
SELECTED
),
isWithin
,
toggle
;
shape
=
d3
.
select
(
that
),
isSelected
=
shape
.
classed
(
CLASS
.
SELECTED
),
isWithin
,
toggle
;
if
(
that
.
nodeName
===
'circle'
)
{
if
(
that
.
nodeName
===
'circle'
)
{
isWithin
=
$$
.
isWithinCircle
(
that
,
$$
.
pointSelectR
(
d
)
*
1.5
);
if
(
$$
.
isStepType
(
d
))
{
toggle
=
$$
.
togglePoint
;
// circle is hidden in step chart, so treat as within the click area
isWithin
=
true
;
toggle
=
function
()
{};
// TODO: how to select step chart?
}
else
{
isWithin
=
$$
.
isWithinCircle
(
that
,
$$
.
pointSelectR
(
d
)
*
1.5
);
toggle
=
$$
.
togglePoint
;
}
}
}
else
if
(
that
.
nodeName
===
'path'
)
{
else
if
(
that
.
nodeName
===
'path'
)
{
if
(
shape
.
classed
(
CLASS
.
bar
))
{
if
(
shape
.
classed
(
CLASS
.
bar
))
{
...
...
c3.min.js
View file @
beed6436
This source diff could not be displayed because it is too large. You can
view the blob
instead.
htdocs/samples/chart_step.html
View file @
beed6436
...
@@ -17,7 +17,8 @@
...
@@ -17,7 +17,8 @@
types
:
{
types
:
{
data1
:
'step'
,
data1
:
'step'
,
data2
:
'area-step'
data2
:
'area-step'
}
},
onclick
:
function
(
d
)
{
console
.
log
(
'clicked'
,
d
);
}
},
},
subchart
:
{
subchart
:
{
show
:
true
show
:
true
...
...
src/interaction.js
View file @
beed6436
...
@@ -144,6 +144,10 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
...
@@ -144,6 +144,10 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
if
(
$$
.
dragging
)
{
return
;
}
// do nothing when dragging
if
(
$$
.
dragging
)
{
return
;
}
// do nothing when dragging
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
$$
.
isStepType
(
d
)
&&
d3
.
mouse
(
this
)[
0
]
<
$$
.
x
(
$$
.
getXValue
(
d
.
id
,
index
)))
{
index
-=
1
;
}
// Show tooltip
// Show tooltip
selectedData
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
).
map
(
function
(
t
)
{
selectedData
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
).
map
(
function
(
t
)
{
return
$$
.
addName
(
$$
.
getValueOnIndex
(
t
.
values
,
index
));
return
$$
.
addName
(
$$
.
getValueOnIndex
(
t
.
values
,
index
));
...
@@ -200,6 +204,9 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
...
@@ -200,6 +204,9 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
$$
.
cancelClick
=
false
;
$$
.
cancelClick
=
false
;
return
;
return
;
}
}
if
(
$$
.
isStepType
(
d
)
&&
d3
.
mouse
(
this
)[
0
]
<
$$
.
x
(
$$
.
getXValue
(
d
.
id
,
index
)))
{
index
-=
1
;
}
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shape
+
'-'
+
index
).
each
(
function
(
d
)
{
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shape
+
'-'
+
index
).
each
(
function
(
d
)
{
$$
.
toggleShape
(
this
,
d
,
index
);
$$
.
toggleShape
(
this
,
d
,
index
);
});
});
...
...
src/selection.js
View file @
beed6436
...
@@ -54,8 +54,14 @@ c3_chart_internal_fn.toggleShape = function (that, d, i) {
...
@@ -54,8 +54,14 @@ c3_chart_internal_fn.toggleShape = function (that, d, i) {
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
shape
=
d3
.
select
(
that
),
isSelected
=
shape
.
classed
(
CLASS
.
SELECTED
),
isWithin
,
toggle
;
shape
=
d3
.
select
(
that
),
isSelected
=
shape
.
classed
(
CLASS
.
SELECTED
),
isWithin
,
toggle
;
if
(
that
.
nodeName
===
'circle'
)
{
if
(
that
.
nodeName
===
'circle'
)
{
isWithin
=
$$
.
isWithinCircle
(
that
,
$$
.
pointSelectR
(
d
)
*
1.5
);
if
(
$$
.
isStepType
(
d
))
{
toggle
=
$$
.
togglePoint
;
// circle is hidden in step chart, so treat as within the click area
isWithin
=
true
;
toggle
=
function
()
{};
// TODO: how to select step chart?
}
else
{
isWithin
=
$$
.
isWithinCircle
(
that
,
$$
.
pointSelectR
(
d
)
*
1.5
);
toggle
=
$$
.
togglePoint
;
}
}
}
else
if
(
that
.
nodeName
===
'path'
)
{
else
if
(
that
.
nodeName
===
'path'
)
{
if
(
shape
.
classed
(
CLASS
.
bar
))
{
if
(
shape
.
classed
(
CLASS
.
bar
))
{
...
...
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