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
ae1584aa
Commit
ae1584aa
authored
Jun 03, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add zoom.enable API - #304
parent
0230172e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
30 deletions
+35
-30
c3.js
c3.js
+35
-30
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
ae1584aa
...
...
@@ -2742,23 +2742,21 @@
return
__axis_rotated
?
this
.
y
(
scale
)
:
this
.
x
(
scale
);
};
if
(
__zoom_enabled
)
{
zoom
=
d3
.
behavior
.
zoom
()
.
on
(
"zoomstart"
,
function
()
{
zoom
.
altDomain
=
d3
.
event
.
sourceEvent
.
altKey
?
x
.
orgDomain
()
:
null
;
})
.
on
(
"zoom"
,
__zoom_enabled
?
redrawForZoom
:
null
);
zoom
.
scale
=
function
(
scale
)
{
return
__axis_rotated
?
this
.
y
(
scale
)
:
this
.
x
(
scale
);
};
zoom
.
orgScaleExtent
=
function
()
{
var
extent
=
__zoom_extent
?
__zoom_extent
:
[
1
,
10
];
return
[
extent
[
0
],
Math
.
max
(
getMaxDataCount
()
/
extent
[
1
],
extent
[
1
])];
};
zoom
.
updateScaleExtent
=
function
()
{
var
ratio
=
diffDomain
(
x
.
orgDomain
())
/
diffDomain
(
orgXDomain
),
extent
=
this
.
orgScaleExtent
();
this
.
scaleExtent
([
extent
[
0
]
*
ratio
,
extent
[
1
]
*
ratio
]);
return
this
;
};
}
zoom
=
d3
.
behavior
.
zoom
()
.
on
(
"zoomstart"
,
function
()
{
zoom
.
altDomain
=
d3
.
event
.
sourceEvent
.
altKey
?
x
.
orgDomain
()
:
null
;
})
.
on
(
"zoom"
,
redrawForZoom
);
zoom
.
scale
=
function
(
scale
)
{
return
__axis_rotated
?
this
.
y
(
scale
)
:
this
.
x
(
scale
);
};
zoom
.
orgScaleExtent
=
function
()
{
var
extent
=
__zoom_extent
?
__zoom_extent
:
[
1
,
10
];
return
[
extent
[
0
],
Math
.
max
(
getMaxDataCount
()
/
extent
[
1
],
extent
[
1
])];
};
zoom
.
updateScaleExtent
=
function
()
{
var
ratio
=
diffDomain
(
x
.
orgDomain
())
/
diffDomain
(
orgXDomain
),
extent
=
this
.
orgScaleExtent
();
this
.
scaleExtent
([
extent
[
0
]
*
ratio
,
extent
[
1
]
*
ratio
]);
return
this
;
};
/*-- Draw Chart --*/
...
...
@@ -2933,8 +2931,7 @@
// Cover whole with rects for events
eventRect
=
main
.
select
(
'.'
+
CLASS
.
chart
).
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
eventRects
)
.
style
(
'fill-opacity'
,
0
)
.
style
(
'cursor'
,
__zoom_enabled
?
__axis_rotated
?
'ns-resize'
:
'ew-resize'
:
null
);
.
style
(
'fill-opacity'
,
0
);
// Define g for bar chart area
main
.
select
(
'.'
+
CLASS
.
chart
).
append
(
"g"
)
...
...
@@ -2988,16 +2985,14 @@
main
.
select
(
'.'
+
CLASS
.
chart
).
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
chartTexts
);
if
(
__zoom_enabled
)
{
// TODO: __zoom_privileged here?
// if zoom privileged, insert rect to forefront
main
.
insert
(
'rect'
,
__zoom_privileged
?
null
:
'g.'
+
CLASS
.
grid
)
.
attr
(
'class'
,
CLASS
.
zoomRect
)
.
attr
(
'width'
,
width
)
.
attr
(
'height'
,
height
)
.
style
(
'opacity'
,
0
)
.
style
(
'cursor'
,
__axis_rotated
?
'ns-resize'
:
'ew-resize'
)
.
call
(
zoom
).
on
(
"dblclick.zoom"
,
null
);
}
// if zoom privileged, insert rect to forefront
main
.
insert
(
'rect'
,
__zoom_privileged
?
null
:
'g.'
+
CLASS
.
grid
)
.
attr
(
'class'
,
CLASS
.
zoomRect
)
.
attr
(
'width'
,
width
)
.
attr
(
'height'
,
height
)
.
style
(
'opacity'
,
0
)
.
style
(
'cursor'
,
__axis_rotated
?
'ns-resize'
:
'ew-resize'
)
.
call
(
zoom
).
on
(
"dblclick.zoom"
,
null
);
// Set default extent if defined
if
(
__axis_x_default
)
{
...
...
@@ -3914,7 +3909,8 @@
if
(
__interaction_enabled
)
{
// rect for mouseover
eventRect
=
main
.
select
(
'.'
+
CLASS
.
eventRects
);
eventRect
=
main
.
select
(
'.'
+
CLASS
.
eventRects
)
.
style
(
'cursor'
,
__zoom_enabled
?
__axis_rotated
?
'ns-resize'
:
'ew-resize'
:
null
);
if
(
notEmpty
(
__data_xs
)
&&
!
isSingleX
(
__data_xs
))
{
if
(
!
eventRect
.
classed
(
CLASS
.
eventRectsMultiple
))
{
...
...
@@ -4150,6 +4146,9 @@
});
}
function
redrawForZoom
()
{
if
(
!
__zoom_enabled
)
{
return
;
}
if
(
filterTargetsToShow
(
c3
.
data
.
targets
).
length
===
0
)
{
return
;
}
...
...
@@ -4790,6 +4789,12 @@
brush
.
clear
().
update
();
redraw
({
withUpdateXDomain
:
true
});
};
c3
.
zoom
=
function
()
{
};
c3
.
zoom
.
enable
=
function
(
enabled
)
{
__zoom_enabled
=
enabled
;
updateAndRedraw
();
};
c3
.
load
=
function
(
args
)
{
// update xs if specified
...
...
c3.min.js
View file @
ae1584aa
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