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
a915c7ea
Commit
a915c7ea
authored
Feb 26, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add scroll option - #42
parent
8b90724d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
c3.js
c3.js
+18
-10
c3.min.js
c3.min.js
+0
-0
No files found.
c3.js
View file @
a915c7ea
...
@@ -38,6 +38,8 @@
...
@@ -38,6 +38,8 @@
var
__padding_left
=
getConfig
([
'padding'
,
'left'
],
null
),
var
__padding_left
=
getConfig
([
'padding'
,
'left'
],
null
),
__padding_right
=
getConfig
([
'padding'
,
'right'
],
null
);
__padding_right
=
getConfig
([
'padding'
,
'right'
],
null
);
var
__scroll_enabled
=
getConfig
([
'scroll'
,
'enabled'
],
false
);
var
__zoom_enabled
=
getConfig
([
'zoom'
,
'enabled'
],
false
),
var
__zoom_enabled
=
getConfig
([
'zoom'
,
'enabled'
],
false
),
__zoom_extent
=
getConfig
([
'zoom'
,
'extent'
],
null
),
__zoom_extent
=
getConfig
([
'zoom'
,
'extent'
],
null
),
__zoom_privileged
=
getConfig
([
'zoom'
,
'privileged'
],
false
);
__zoom_privileged
=
getConfig
([
'zoom'
,
'privileged'
],
false
);
...
@@ -1436,7 +1438,7 @@
...
@@ -1436,7 +1438,7 @@
//-- Define brush/zoom -//
//-- Define brush/zoom -//
var
brush
=
d3
.
svg
.
brush
().
on
(
"brush"
,
redrawForBrush
);
var
brush
=
d3
.
svg
.
brush
().
on
(
"brush"
,
redrawForBrush
);
var
zoom
=
d3
.
behavior
.
zoom
().
on
(
"zoomstart"
,
function
()
{
zoom
.
altDomain
=
d3
.
event
.
sourceEvent
.
altKey
?
x
.
orgDomain
()
:
null
;
}).
on
(
"zoom"
,
__zoom_enabled
?
redrawForZoom
:
null
);
var
zoom
=
d3
.
behavior
.
zoom
().
on
(
"zoomstart"
,
function
()
{
zoom
.
altDomain
=
d3
.
event
.
sourceEvent
.
altKey
?
x
.
orgDomain
()
:
null
;
}).
on
(
"zoom"
,
__zoom_enabled
||
__scroll_enabled
?
redrawForZoom
:
null
);
// define functions for c3
// define functions for c3
brush
.
update
=
function
()
{
brush
.
update
=
function
()
{
...
@@ -1454,9 +1456,15 @@
...
@@ -1454,9 +1456,15 @@
return
[
extent
[
0
],
Math
.
max
(
getMaxDataCount
()
/
extent
[
1
],
extent
[
1
])];
return
[
extent
[
0
],
Math
.
max
(
getMaxDataCount
()
/
extent
[
1
],
extent
[
1
])];
};
};
zoom
.
updateScaleExtent
=
function
()
{
zoom
.
updateScaleExtent
=
function
()
{
var
ratio
=
diffDomain
(
x
.
orgDomain
())
/
diffDomain
(
orgXDomain
),
extent
=
this
.
orgScaleExtent
();
var
ratio
,
orgExtent
,
extent
;
this
.
scaleExtent
([
extent
[
0
]
*
ratio
,
extent
[
1
]
*
ratio
]);
if
(
__zoom_enabled
)
{
return
this
;
ratio
=
diffDomain
(
x
.
orgDomain
())
/
diffDomain
(
orgXDomain
);
orgExtent
=
this
.
orgScaleExtent
();
extent
=
[
orgExtent
[
0
]
*
ratio
,
orgExtent
[
1
]
*
ratio
];
}
else
if
(
__scroll_enabled
)
{
extent
=
[
1
,
1
];
}
return
this
.
scaleExtent
(
extent
);
};
};
/*-- Draw Chart --*/
/*-- Draw Chart --*/
...
@@ -1505,7 +1513,7 @@
...
@@ -1505,7 +1513,7 @@
// Set initialized scales to brush and zoom
// Set initialized scales to brush and zoom
brush
.
scale
(
subX
);
brush
.
scale
(
subX
);
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
);
}
if
(
__zoom_enabled
||
__scroll_enabled
)
{
zoom
.
scale
(
x
);
}
/*-- Basic Elements --*/
/*-- Basic Elements --*/
...
@@ -1657,7 +1665,7 @@
...
@@ -1657,7 +1665,7 @@
eventRect
=
main
.
select
(
'.chart'
).
append
(
"g"
)
eventRect
=
main
.
select
(
'.chart'
).
append
(
"g"
)
.
attr
(
"class"
,
"event-rects"
)
.
attr
(
"class"
,
"event-rects"
)
.
style
(
'fill-opacity'
,
0
)
.
style
(
'fill-opacity'
,
0
)
.
style
(
'cursor'
,
__zoom_enabled
?
__axis_rotated
?
'ns-resize'
:
'ew-resize'
:
null
);
.
style
(
'cursor'
,
__zoom_enabled
||
__scroll_enabled
?
__axis_rotated
?
'ns-resize'
:
'ew-resize'
:
null
);
// Define g for bar chart area
// Define g for bar chart area
main
.
select
(
".chart"
).
append
(
"g"
)
main
.
select
(
".chart"
).
append
(
"g"
)
...
@@ -1676,7 +1684,7 @@
...
@@ -1676,7 +1684,7 @@
.
style
(
"text-anchor"
,
"middle"
)
.
style
(
"text-anchor"
,
"middle"
)
.
text
(
__arc_title
);
.
text
(
__arc_title
);
if
(
__zoom_enabled
)
{
// TODO: __zoom_privileged here?
if
(
__zoom_enabled
||
__scroll_enabled
)
{
// TODO: __zoom_privileged here?
// if zoom privileged, insert rect to forefront
// if zoom privileged, insert rect to forefront
main
.
insert
(
'rect'
,
__zoom_privileged
?
null
:
'g.grid'
)
main
.
insert
(
'rect'
,
__zoom_privileged
?
null
:
'g.grid'
)
.
attr
(
'class'
,
'zoom-rect'
)
.
attr
(
'class'
,
'zoom-rect'
)
...
@@ -1951,7 +1959,7 @@
...
@@ -1951,7 +1959,7 @@
if
(
hasArcType
(
c3
.
data
.
targets
))
{
return
;
}
if
(
hasArcType
(
c3
.
data
.
targets
))
{
return
;
}
if
(
!
__data_selection_enabled
)
{
return
;
}
// do nothing if not selectable
if
(
!
__data_selection_enabled
)
{
return
;
}
// do nothing if not selectable
if
(
__zoom_enabled
&&
!
zoom
.
altDomain
)
{
return
;
}
// skip if zoomable because of conflict drag dehavior
if
(
(
__zoom_enabled
||
__scroll_enabled
)
&&
!
zoom
.
altDomain
)
{
return
;
}
// skip if zoomable because of conflict drag dehavior
sx
=
dragStart
[
0
];
sx
=
dragStart
[
0
];
sy
=
dragStart
[
1
];
sy
=
dragStart
[
1
];
...
@@ -2052,7 +2060,7 @@
...
@@ -2052,7 +2060,7 @@
// ATTENTION: call here to update tickOffset
// ATTENTION: call here to update tickOffset
if
(
withUpdateXDomain
)
{
if
(
withUpdateXDomain
)
{
x
.
domain
(
brush
.
empty
()
?
orgXDomain
:
brush
.
extent
());
x
.
domain
(
brush
.
empty
()
?
orgXDomain
:
brush
.
extent
());
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
if
(
__zoom_enabled
||
__scroll_enabled
)
{
zoom
.
scale
(
x
).
updateScaleExtent
();
}
}
}
y
.
domain
(
getYDomain
(
'y'
));
y
.
domain
(
getYDomain
(
'y'
));
y2
.
domain
(
getYDomain
(
'y2'
));
y2
.
domain
(
getYDomain
(
'y2'
));
...
@@ -2376,7 +2384,7 @@
...
@@ -2376,7 +2384,7 @@
// Set x for brush again because of scale update
// Set x for brush again because of scale update
brush
.
scale
(
subX
);
brush
.
scale
(
subX
);
// Set x for zoom again because of scale update
// Set x for zoom again because of scale update
if
(
__zoom_enabled
)
{
zoom
.
scale
(
x
);
}
if
(
__zoom_enabled
||
__scroll_enabled
)
{
zoom
.
scale
(
x
);
}
// Update sizes
// Update sizes
svg
.
attr
(
'width'
,
currentWidth
).
attr
(
'height'
,
currentHeight
);
svg
.
attr
(
'width'
,
currentWidth
).
attr
(
'height'
,
currentHeight
);
svg
.
select
(
'#'
+
clipId
).
select
(
'rect'
).
attr
(
'width'
,
width
).
attr
(
'height'
,
height
);
svg
.
select
(
'#'
+
clipId
).
select
(
'rect'
).
attr
(
'width'
,
width
).
attr
(
'height'
,
height
);
...
...
c3.min.js
View file @
a915c7ea
This diff is collapsed.
Click to expand it.
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