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
80714867
Commit
80714867
authored
May 09, 2013
by
Masayuki Tanaka
Committed by
masayuki
May 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bar selection
parent
f48bed7b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
c3.js
c3.js
+17
-15
No files found.
c3.js
View file @
80714867
...
...
@@ -426,14 +426,15 @@
//-- Util --//
function
dist
(
_this
,
_x
,
_y
)
{
var
mouse
=
d3
.
mouse
(
_this
)
return
Math
.
sqrt
(
Math
.
pow
(
x
(
_x
)
-
mouse
[
0
],
2
)
+
Math
.
pow
(
y
(
_y
)
-
mouse
[
1
],
2
))
}
function
isWithinBar
(
_this
,
_x
,
_y
)
{
var
mouse
=
d3
.
mouse
(
_this
)
var
xoffset
=
d3
.
select
(
_this
).
attr
(
"width"
)
/
2
+
10
,
yoffset
=
10
var
sx
=
_x
-
xoffset
,
ex
=
_x
+
xoffset
,
ey
=
_y
-
yoffset
function
isWithinCircle
(
_this
,
_r
)
{
var
mouse
=
d3
.
mouse
(
_this
),
d3_this
=
d3
.
select
(
_this
)
var
cx
=
d3_this
.
attr
(
"cx"
)
*
1
,
cy
=
d3_this
.
attr
(
"cy"
)
*
1
return
Math
.
sqrt
(
Math
.
pow
(
cx
-
mouse
[
0
],
2
)
+
Math
.
pow
(
cy
-
mouse
[
1
],
2
))
<
_r
}
function
isWithinBar
(
_this
)
{
var
mouse
=
d3
.
mouse
(
_this
),
d3_this
=
d3
.
select
(
_this
)
var
x
=
d3_this
.
attr
(
"x"
)
*
1
,
y
=
d3_this
.
attr
(
"y"
)
*
1
,
w
=
d3_this
.
attr
(
"width"
)
*
1
var
sx
=
x
-
10
,
ex
=
x
+
w
+
10
,
ey
=
y
-
10
return
sx
<
mouse
[
0
]
&&
mouse
[
0
]
<
ex
&&
ey
<
mouse
[
1
]
}
function
isWithinRegions
(
x
,
regions
)
{
...
...
@@ -725,11 +726,12 @@
d3
.
select
(
'.event-rect-'
+
i
).
style
(
'cursor'
,
null
)
})
.
filter
(
function
(
d
){
var
_this
=
d3
.
select
(
this
)
if
(
this
.
nodeName
===
'circle'
)
{
return
dist
(
this
,
d
.
x
,
d
.
value
)
<
__point_select_r
return
isWithinCircle
(
this
,
__point_select_r
)
}
else
if
(
this
.
nodeName
===
'rect'
)
{
return
isWithinBar
(
this
,
x
(
d
.
x
),
y
(
d
.
value
))
return
isWithinBar
(
this
,
_this
.
attr
(
'x'
),
_this
.
attr
(
'y'
))
}
})
.
each
(
function
(
d
){
...
...
@@ -747,11 +749,11 @@
_selected
=
_this
.
classed
(
'_s_'
)
var
isWithin
=
false
,
toggle
if
(
this
.
nodeName
===
'circle'
)
{
isWithin
=
dist
(
this
,
d
.
x
,
d
.
value
)
<
__point_select_r
*
1.5
isWithin
=
isWithinCircle
(
this
,
__point_select_r
*
1.5
)
toggle
=
togglePoint
}
else
if
(
this
.
nodeName
===
'rect'
)
{
isWithin
=
isWithinBar
(
this
,
x
(
d
.
x
),
y
(
d
.
value
)
)
isWithin
=
isWithinBar
(
this
)
toggle
=
toggleBar
}
if
(
__data_selection_grouped
||
isWithin
)
{
...
...
@@ -801,9 +803,9 @@
var
_this
=
d3
.
select
(
this
),
_selected
=
_this
.
classed
(
'_s_'
),
_included
=
_this
.
classed
(
'_i_'
),
_x
=
x
(
d
.
x
),
_y
=
y
(
d
.
value
),
_
offset
=
_this
.
attr
(
'width'
)
/
2
,
_within
=
min_x
<
_x
+
_
offset
&&
_x
-
_offset
<
max_x
&&
min_y
<
_y
&&
_y
<
max_y
_x
=
_this
.
attr
(
"x"
)
*
1
,
_y
=
_this
.
attr
(
"y"
)
*
1
_
w
=
_this
.
attr
(
'width'
)
*
1
,
_within
=
min_x
<
_x
+
_
w
&&
_x
<
max_x
&&
_y
<
max_y
if
(
_within
^
_included
)
{
_this
.
classed
(
'_i_'
,
!
_included
)
// TODO: included/unincluded callback here
...
...
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