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
6b11a1f7
Commit
6b11a1f7
authored
Jan 18, 2015
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip transition when transition.duration = 0 - #172
parent
193f8f41
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
396 additions
and
304 deletions
+396
-304
c3.js
c3.js
+198
-152
c3.min.js
c3.min.js
+0
-0
core.js
src/core.js
+56
-36
grid.js
src/grid.js
+18
-14
region.js
src/region.js
+11
-8
shape.bar.js
src/shape.bar.js
+8
-7
shape.line.js
src/shape.line.js
+29
-25
subchart.js
src/subchart.js
+67
-53
text.js
src/text.js
+9
-9
No files found.
c3.js
View file @
6b11a1f7
...
...
@@ -553,22 +553,22 @@
.
style
(
'opacity'
,
targetsToShow
.
length
?
0
:
1
);
// grid
$$
.
redraw
Grid
(
duration
);
$$
.
update
Grid
(
duration
);
// rect for regions
$$
.
redraw
Region
(
duration
);
$$
.
update
Region
(
duration
);
// bars
$$
.
redraw
Bar
(
durationForExit
);
$$
.
update
Bar
(
durationForExit
);
// lines, areas and cricles
$$
.
redraw
Line
(
durationForExit
);
$$
.
redraw
Area
(
durationForExit
);
$$
.
redraw
Circle
();
$$
.
update
Line
(
durationForExit
);
$$
.
update
Area
(
durationForExit
);
$$
.
update
Circle
();
// text
if
(
$$
.
hasDataLabel
())
{
$$
.
redraw
Text
(
durationForExit
);
$$
.
update
Text
(
durationForExit
);
}
// arc
...
...
@@ -598,40 +598,60 @@
cx
=
(
$$
.
config
.
axis_rotated
?
$$
.
circleY
:
$$
.
circleX
).
bind
(
$$
);
cy
=
(
$$
.
config
.
axis_rotated
?
$$
.
circleX
:
$$
.
circleY
).
bind
(
$$
);
// transition should be derived from one transition
d3
.
transition
().
duration
(
duration
).
each
(
function
()
{
var
transitions
=
[];
if
(
options
.
flow
)
{
flow
=
$$
.
generateFlow
({
targets
:
targetsToShow
,
flow
:
options
.
flow
,
duration
:
duration
,
drawBar
:
drawBar
,
drawLine
:
drawLine
,
drawArea
:
drawArea
,
cx
:
cx
,
cy
:
cy
,
xv
:
xv
,
xForText
:
xForText
,
yForText
:
yForText
});
}
$$
.
addTransitionForBar
(
transitions
,
drawBar
);
$$
.
addTransitionForLine
(
transitions
,
drawLine
);
$$
.
addTransitionForArea
(
transitions
,
drawArea
);
$$
.
addTransitionForCircle
(
transitions
,
cx
,
cy
);
$$
.
addTransitionForText
(
transitions
,
xForText
,
yForText
,
options
.
flow
);
$$
.
addTransitionForRegion
(
transitions
);
$$
.
addTransitionForGrid
(
transitions
);
if
(
duration
)
{
// transition should be derived from one transition
d3
.
transition
().
duration
(
duration
).
each
(
function
()
{
var
transitionsToWait
=
[];
// redraw and gather transitions
[
$$
.
redrawBar
(
drawBar
,
true
),
$$
.
redrawLine
(
drawLine
,
true
),
$$
.
redrawArea
(
drawArea
,
true
),
$$
.
redrawCircle
(
cx
,
cy
,
true
),
$$
.
redrawText
(
xForText
,
yForText
,
options
.
flow
,
true
),
$$
.
redrawRegion
(
true
),
$$
.
redrawGrid
(
true
),
].
forEach
(
function
(
transitions
)
{
transitions
.
forEach
(
function
(
transition
)
{
transitionsToWait
.
push
(
transition
);
});
});
// Wait for end of transitions if called from flow API
if
(
options
.
flow
)
{
// Wait for end of transitions to call flow and onrendered callback
waitForDraw
=
$$
.
generateWait
();
transitions
.
forEach
(
function
(
t
)
{
transitions
ToWait
.
forEach
(
function
(
t
)
{
waitForDraw
.
add
(
t
);
});
flow
=
$$
.
generateFlow
({
targets
:
targetsToShow
,
flow
:
options
.
flow
,
duration
:
duration
,
drawBar
:
drawBar
,
drawLine
:
drawLine
,
drawArea
:
drawArea
,
cx
:
cx
,
cy
:
cy
,
xv
:
xv
,
xForText
:
xForText
,
yForText
:
yForText
});
}
})
.
call
(
waitForDraw
||
function
()
{},
flow
||
function
()
{});
})
.
call
(
waitForDraw
,
function
()
{
if
(
flow
)
{
flow
();
}
// onrendered callback
});
}
else
{
$$
.
redrawBar
(
drawBar
);
$$
.
redrawLine
(
drawLine
);
$$
.
redrawArea
(
drawArea
);
$$
.
redrawCircle
(
cx
,
cy
);
// onrendered callback
}
// update fadein condition
$$
.
mapToIds
(
$$
.
data
.
targets
).
forEach
(
function
(
id
)
{
...
...
@@ -2711,7 +2731,7 @@
// MEMO: can not keep same color...
//mainLineUpdate.exit().remove();
};
c3_chart_internal_fn
.
redraw
Line
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Line
=
function
(
durationForExit
)
{
var
$$
=
this
;
$$
.
mainLine
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
lines
).
selectAll
(
'.'
+
CLASS
.
line
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
...
...
@@ -2726,12 +2746,13 @@
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForLine
=
function
(
transitions
,
drawLine
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainLine
.
transition
()
.
attr
(
"d"
,
drawLine
)
.
style
(
"stroke"
,
$$
.
color
)
.
style
(
"opacity"
,
1
));
c3_chart_internal_fn
.
redrawLine
=
function
(
drawLine
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainLine
.
transition
()
:
this
.
mainLine
)
.
attr
(
"d"
,
drawLine
)
.
style
(
"stroke"
,
this
.
color
)
.
style
(
"opacity"
,
1
)
];
};
c3_chart_internal_fn
.
generateDrawLine
=
function
(
lineIndices
,
isSub
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
@@ -2871,7 +2892,7 @@
};
c3_chart_internal_fn
.
redraw
Area
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Area
=
function
(
durationForExit
)
{
var
$$
=
this
,
d3
=
$$
.
d3
;
$$
.
mainArea
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
areas
).
selectAll
(
'.'
+
CLASS
.
area
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
...
...
@@ -2885,12 +2906,13 @@
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForArea
=
function
(
transitions
,
drawArea
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainArea
.
transition
()
.
attr
(
"d"
,
drawArea
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
$$
.
orgAreaOpacity
));
c3_chart_internal_fn
.
redrawArea
=
function
(
drawArea
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainArea
.
transition
()
:
this
.
mainArea
)
.
attr
(
"d"
,
drawArea
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"opacity"
,
this
.
orgAreaOpacity
)
];
};
c3_chart_internal_fn
.
generateDrawArea
=
function
(
areaIndices
,
isSub
)
{
var
$$
=
this
,
config
=
$$
.
config
,
area
=
$$
.
d3
.
svg
.
area
(),
...
...
@@ -2954,7 +2976,7 @@
};
c3_chart_internal_fn
.
redraw
Circle
=
function
()
{
c3_chart_internal_fn
.
update
Circle
=
function
()
{
var
$$
=
this
;
$$
.
mainCircle
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
circles
).
selectAll
(
'.'
+
CLASS
.
circle
)
.
data
(
$$
.
lineOrScatterData
.
bind
(
$$
));
...
...
@@ -2966,16 +2988,18 @@
.
style
(
"opacity"
,
$$
.
initialOpacityForCircle
.
bind
(
$$
));
$$
.
mainCircle
.
exit
().
remove
();
};
c3_chart_internal_fn
.
addTransitionForCircle
=
function
(
transitions
,
cx
,
cy
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainCircle
.
transition
()
.
style
(
'opacity'
,
$$
.
opacityForCircle
.
bind
(
$$
))
.
style
(
"fill"
,
$$
.
color
)
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
));
transitions
.
push
(
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
selectedCircle
).
transition
()
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
));
c3_chart_internal_fn
.
redrawCircle
=
function
(
cx
,
cy
,
withTransition
)
{
var
selectedCircles
=
this
.
main
.
selectAll
(
'.'
+
CLASS
.
selectedCircle
);
return
[
(
withTransition
?
this
.
mainCircle
.
transition
()
:
this
.
mainCircle
)
.
style
(
'opacity'
,
this
.
opacityForCircle
.
bind
(
this
))
.
style
(
"fill"
,
this
.
color
)
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
),
(
withTransition
?
selectedCircles
.
transition
()
:
selectedCircles
)
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
)
];
};
c3_chart_internal_fn
.
circleX
=
function
(
d
)
{
return
d
.
x
||
d
.
x
===
0
?
this
.
x
(
d
.
x
)
:
null
;
...
...
@@ -3060,7 +3084,7 @@
.
style
(
"cursor"
,
function
(
d
)
{
return
config
.
data_selection_isselectable
(
d
)
?
"pointer"
:
null
;
});
};
c3_chart_internal_fn
.
redraw
Bar
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Bar
=
function
(
durationForExit
)
{
var
$$
=
this
,
barData
=
$$
.
barData
.
bind
(
$$
),
classBar
=
$$
.
classBar
.
bind
(
$$
),
...
...
@@ -3078,12 +3102,13 @@
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForBar
=
function
(
transitions
,
drawBar
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainBar
.
transition
()
.
attr
(
'd'
,
drawBar
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
1
));
c3_chart_internal_fn
.
redrawBar
=
function
(
drawBar
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainBar
.
transition
()
:
this
.
mainBar
)
.
attr
(
'd'
,
drawBar
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"opacity"
,
1
)
];
};
c3_chart_internal_fn
.
getBarW
=
function
(
axis
,
barTargetsNum
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
@@ -3179,7 +3204,7 @@
mainTextEnter
.
append
(
'g'
)
.
attr
(
'class'
,
classTexts
);
};
c3_chart_internal_fn
.
redraw
Text
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Text
=
function
(
durationForExit
)
{
var
$$
=
this
,
config
=
$$
.
config
,
barOrLineData
=
$$
.
barOrLineData
.
bind
(
$$
),
classText
=
$$
.
classText
.
bind
(
$$
);
...
...
@@ -3198,14 +3223,14 @@
.
style
(
'fill-opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForText
=
function
(
transitions
,
xForText
,
yForText
,
forFlow
)
{
var
$$
=
this
,
opacityForText
=
forFlow
?
0
:
$$
.
opacityForText
.
bind
(
$$
);
transitions
.
push
(
$$
.
mainText
.
transition
(
)
.
attr
(
'x'
,
x
ForText
)
.
attr
(
'y'
,
yForText
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"fill-opacity"
,
opacityForText
))
;
c3_chart_internal_fn
.
redrawText
=
function
(
xForText
,
yForText
,
forFlow
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainText
.
transition
()
:
this
.
mainText
)
.
attr
(
'x'
,
xForText
)
.
attr
(
'y'
,
y
ForText
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"fill-opacity"
,
forFlow
?
0
:
this
.
opacityForText
.
bind
(
this
)
)
]
;
};
c3_chart_internal_fn
.
getTextRect
=
function
(
text
,
cls
)
{
var
body
=
this
.
d3
.
select
(
'body'
).
classed
(
'c3'
,
true
),
...
...
@@ -3433,7 +3458,7 @@
};
c3_chart_internal_fn
.
redraw
Grid
=
function
(
duration
)
{
c3_chart_internal_fn
.
update
Grid
=
function
(
duration
)
{
var
$$
=
this
,
main
=
$$
.
main
,
config
=
$$
.
config
,
xgridLine
,
ygridLine
,
yv
;
...
...
@@ -3501,19 +3526,23 @@
.
style
(
"opacity"
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForGrid
=
function
(
transitions
)
{
var
$$
=
this
,
config
=
$$
.
config
,
xv
=
$$
.
xv
.
bind
(
$$
);
transitions
.
push
(
$$
.
xgridLines
.
select
(
'line'
).
transition
()
.
attr
(
"x1"
,
config
.
axis_rotated
?
0
:
xv
)
.
attr
(
"x2"
,
config
.
axis_rotated
?
$$
.
width
:
xv
)
.
attr
(
"y1"
,
config
.
axis_rotated
?
xv
:
$$
.
margin
.
top
)
.
attr
(
"y2"
,
config
.
axis_rotated
?
xv
:
$$
.
height
)
.
style
(
"opacity"
,
1
));
transitions
.
push
(
$$
.
xgridLines
.
select
(
'text'
).
transition
()
.
attr
(
"x"
,
config
.
axis_rotated
?
$$
.
width
:
0
)
.
attr
(
"y"
,
xv
)
.
text
(
function
(
d
)
{
return
d
.
text
;
})
.
style
(
"opacity"
,
1
));
c3_chart_internal_fn
.
redrawGrid
=
function
(
withTransition
)
{
var
$$
=
this
,
config
=
$$
.
config
,
xv
=
$$
.
xv
.
bind
(
$$
),
lines
=
$$
.
xgridLines
.
select
(
'line'
),
texts
=
$$
.
xgridLines
.
select
(
'text'
);
return
[
(
withTransition
?
lines
.
transition
()
:
lines
)
.
attr
(
"x1"
,
config
.
axis_rotated
?
0
:
xv
)
.
attr
(
"x2"
,
config
.
axis_rotated
?
$$
.
width
:
xv
)
.
attr
(
"y1"
,
config
.
axis_rotated
?
xv
:
$$
.
margin
.
top
)
.
attr
(
"y2"
,
config
.
axis_rotated
?
xv
:
$$
.
height
)
.
style
(
"opacity"
,
1
),
(
withTransition
?
texts
.
transition
()
:
texts
)
.
attr
(
"x"
,
config
.
axis_rotated
?
$$
.
width
:
0
)
.
attr
(
"y"
,
xv
)
.
text
(
function
(
d
)
{
return
d
.
text
;
})
.
style
(
"opacity"
,
1
)
];
};
c3_chart_internal_fn
.
showXGridFocus
=
function
(
selectedData
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
@@ -4893,7 +4922,7 @@
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
"class"
,
CLASS
.
regions
);
};
c3_chart_internal_fn
.
redraw
Region
=
function
(
duration
)
{
c3_chart_internal_fn
.
update
Region
=
function
(
duration
)
{
var
$$
=
this
,
config
=
$$
.
config
;
// hide if arc type
...
...
@@ -4909,18 +4938,21 @@
.
style
(
"opacity"
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForRegion
=
function
(
transitions
)
{
c3_chart_internal_fn
.
redrawRegion
=
function
(
withTransition
)
{
var
$$
=
this
,
regions
=
$$
.
mainRegion
.
selectAll
(
'rect'
),
x
=
$$
.
regionX
.
bind
(
$$
),
y
=
$$
.
regionY
.
bind
(
$$
),
w
=
$$
.
regionWidth
.
bind
(
$$
),
h
=
$$
.
regionHeight
.
bind
(
$$
);
transitions
.
push
(
$$
.
mainRegion
.
selectAll
(
'rect'
).
transition
()
.
attr
(
"x"
,
x
)
.
attr
(
"y"
,
y
)
.
attr
(
"width"
,
w
)
.
attr
(
"height"
,
h
)
.
style
(
"fill-opacity"
,
function
(
d
)
{
return
isValue
(
d
.
opacity
)
?
d
.
opacity
:
0.1
;
}));
return
[
(
withTransition
?
regions
.
transition
()
:
regions
)
.
attr
(
"x"
,
x
)
.
attr
(
"y"
,
y
)
.
attr
(
"width"
,
w
)
.
attr
(
"height"
,
h
)
.
style
(
"fill-opacity"
,
function
(
d
)
{
return
isValue
(
d
.
opacity
)
?
d
.
opacity
:
0.1
;
})
];
};
c3_chart_internal_fn
.
regionX
=
function
(
d
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
@@ -5206,15 +5238,66 @@
.
attr
(
"class"
,
classAreas
);
}
};
c3_chart_internal_fn
.
updateBarForSubchart
=
function
(
durationForExit
)
{
var
$$
=
this
;
$$
.
contextBar
=
$$
.
context
.
selectAll
(
'.'
+
CLASS
.
bars
).
selectAll
(
'.'
+
CLASS
.
bar
)
.
data
(
$$
.
barData
.
bind
(
$$
));
$$
.
contextBar
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
$$
.
classBar
.
bind
(
$$
))
.
style
(
"stroke"
,
'none'
)
.
style
(
"fill"
,
$$
.
color
);
$$
.
contextBar
.
style
(
"opacity"
,
$$
.
initialOpacity
.
bind
(
$$
));
$$
.
contextBar
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
redrawBarForSubchart
=
function
(
drawBarOnSub
,
withTransition
,
duration
)
{
(
withTransition
?
this
.
contextBar
.
transition
().
duration
(
duration
)
:
this
.
contextBar
)
.
attr
(
'd'
,
drawBarOnSub
)
.
style
(
'opacity'
,
1
);
};
c3_chart_internal_fn
.
updateLineForSubchart
=
function
(
durationForExit
)
{
var
$$
=
this
;
$$
.
contextLine
=
$$
.
context
.
selectAll
(
'.'
+
CLASS
.
lines
).
selectAll
(
'.'
+
CLASS
.
line
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
$$
.
contextLine
.
enter
().
append
(
'path'
)
.
attr
(
'class'
,
$$
.
classLine
.
bind
(
$$
))
.
style
(
'stroke'
,
$$
.
color
);
$$
.
contextLine
.
style
(
"opacity"
,
$$
.
initialOpacity
.
bind
(
$$
));
$$
.
contextLine
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
redrawLineForSubchart
=
function
(
drawLineOnSub
,
withTransition
,
duration
)
{
(
withTransition
?
this
.
contextLine
.
transition
().
duration
(
duration
)
:
this
.
contextLine
)
.
attr
(
"d"
,
drawLineOnSub
)
.
style
(
'opacity'
,
1
);
};
c3_chart_internal_fn
.
updateAreaForSubchart
=
function
(
durationForExit
)
{
var
$$
=
this
,
d3
=
$$
.
d3
;
$$
.
contextArea
=
$$
.
context
.
selectAll
(
'.'
+
CLASS
.
areas
).
selectAll
(
'.'
+
CLASS
.
area
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
$$
.
contextArea
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
$$
.
classArea
.
bind
(
$$
))
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
function
()
{
$$
.
orgAreaOpacity
=
+
d3
.
select
(
this
).
style
(
'opacity'
);
return
0
;
});
$$
.
contextArea
.
style
(
"opacity"
,
0
);
$$
.
contextArea
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
redrawAreaForSubchart
=
function
(
drawAreaOnSub
,
withTransition
,
duration
)
{
(
withTransition
?
this
.
contextArea
.
transition
().
duration
(
duration
)
:
this
.
contextArea
)
.
attr
(
"d"
,
drawAreaOnSub
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"opacity"
,
this
.
orgAreaOpacity
);
};
c3_chart_internal_fn
.
redrawSubchart
=
function
(
withSubchart
,
transitions
,
duration
,
durationForExit
,
areaIndices
,
barIndices
,
lineIndices
)
{
var
$$
=
this
,
d3
=
$$
.
d3
,
context
=
$$
.
context
,
config
=
$$
.
config
,
contextLine
,
contextArea
,
contextBar
,
drawAreaOnSub
,
drawBarOnSub
,
drawLineOnSub
,
barData
=
$$
.
barData
.
bind
(
$$
),
lineData
=
$$
.
lineData
.
bind
(
$$
),
classBar
=
$$
.
classBar
.
bind
(
$$
),
classLine
=
$$
.
classLine
.
bind
(
$$
),
classArea
=
$$
.
classArea
.
bind
(
$$
),
initialOpacity
=
$$
.
initialOpacity
.
bind
(
$$
);
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
drawAreaOnSub
,
drawBarOnSub
,
drawLineOnSub
;
// subchart
if
(
config
.
subchart_show
)
{
...
...
@@ -5233,51 +5316,14 @@
drawAreaOnSub
=
$$
.
generateDrawArea
(
areaIndices
,
true
);
drawBarOnSub
=
$$
.
generateDrawBar
(
barIndices
,
true
);
drawLineOnSub
=
$$
.
generateDrawLine
(
lineIndices
,
true
);
// bars
contextBar
=
context
.
selectAll
(
'.'
+
CLASS
.
bars
).
selectAll
(
'.'
+
CLASS
.
bar
)
.
data
(
barData
);
contextBar
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
classBar
)
.
style
(
"stroke"
,
'none'
)
.
style
(
"fill"
,
$$
.
color
);
contextBar
.
style
(
"opacity"
,
initialOpacity
)
.
transition
().
duration
(
duration
)
.
attr
(
'd'
,
drawBarOnSub
)
.
style
(
'opacity'
,
1
);
contextBar
.
exit
().
transition
().
duration
(
duration
)
.
style
(
'opacity'
,
0
)
.
remove
();
// lines
contextLine
=
context
.
selectAll
(
'.'
+
CLASS
.
lines
).
selectAll
(
'.'
+
CLASS
.
line
)
.
data
(
lineData
);
contextLine
.
enter
().
append
(
'path'
)
.
attr
(
'class'
,
classLine
)
.
style
(
'stroke'
,
$$
.
color
);
contextLine
.
style
(
"opacity"
,
initialOpacity
)
.
transition
().
duration
(
duration
)
.
attr
(
"d"
,
drawLineOnSub
)
.
style
(
'opacity'
,
1
);
contextLine
.
exit
().
transition
().
duration
(
duration
)
.
style
(
'opacity'
,
0
)
.
remove
();
// area
contextArea
=
context
.
selectAll
(
'.'
+
CLASS
.
areas
).
selectAll
(
'.'
+
CLASS
.
area
)
.
data
(
lineData
);
contextArea
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
classArea
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
function
()
{
$$
.
orgAreaOpacity
=
+
d3
.
select
(
this
).
style
(
'opacity'
);
return
0
;
});
contextArea
.
style
(
"opacity"
,
0
)
.
transition
().
duration
(
duration
)
.
attr
(
"d"
,
drawAreaOnSub
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
$$
.
orgAreaOpacity
);
contextArea
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
$$
.
updateBarForSubchart
(
duration
);
$$
.
updateLineForSubchart
(
duration
);
$$
.
updateAreaForSubchart
(
duration
);
$$
.
redrawBarForSubchart
(
drawBarOnSub
,
duration
,
duration
);
$$
.
redrawLineForSubchart
(
drawLineOnSub
,
duration
,
duration
);
$$
.
redrawAreaForSubchart
(
drawAreaOnSub
,
duration
,
duration
);
}
}
};
...
...
c3.min.js
View file @
6b11a1f7
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/core.js
View file @
6b11a1f7
...
...
@@ -548,22 +548,22 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
.
style
(
'opacity'
,
targetsToShow
.
length
?
0
:
1
);
// grid
$$
.
redraw
Grid
(
duration
);
$$
.
update
Grid
(
duration
);
// rect for regions
$$
.
redraw
Region
(
duration
);
$$
.
update
Region
(
duration
);
// bars
$$
.
redraw
Bar
(
durationForExit
);
$$
.
update
Bar
(
durationForExit
);
// lines, areas and cricles
$$
.
redraw
Line
(
durationForExit
);
$$
.
redraw
Area
(
durationForExit
);
$$
.
redraw
Circle
();
$$
.
update
Line
(
durationForExit
);
$$
.
update
Area
(
durationForExit
);
$$
.
update
Circle
();
// text
if
(
$$
.
hasDataLabel
())
{
$$
.
redraw
Text
(
durationForExit
);
$$
.
update
Text
(
durationForExit
);
}
// arc
...
...
@@ -593,40 +593,60 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
cx
=
(
$$
.
config
.
axis_rotated
?
$$
.
circleY
:
$$
.
circleX
).
bind
(
$$
);
cy
=
(
$$
.
config
.
axis_rotated
?
$$
.
circleX
:
$$
.
circleY
).
bind
(
$$
);
// transition should be derived from one transition
d3
.
transition
().
duration
(
duration
).
each
(
function
()
{
var
transitions
=
[];
if
(
options
.
flow
)
{
flow
=
$$
.
generateFlow
({
targets
:
targetsToShow
,
flow
:
options
.
flow
,
duration
:
duration
,
drawBar
:
drawBar
,
drawLine
:
drawLine
,
drawArea
:
drawArea
,
cx
:
cx
,
cy
:
cy
,
xv
:
xv
,
xForText
:
xForText
,
yForText
:
yForText
});
}
$$
.
addTransitionForBar
(
transitions
,
drawBar
);
$$
.
addTransitionForLine
(
transitions
,
drawLine
);
$$
.
addTransitionForArea
(
transitions
,
drawArea
);
$$
.
addTransitionForCircle
(
transitions
,
cx
,
cy
);
$$
.
addTransitionForText
(
transitions
,
xForText
,
yForText
,
options
.
flow
);
$$
.
addTransitionForRegion
(
transitions
);
$$
.
addTransitionForGrid
(
transitions
);
if
(
duration
)
{
// transition should be derived from one transition
d3
.
transition
().
duration
(
duration
).
each
(
function
()
{
var
transitionsToWait
=
[];
// redraw and gather transitions
[
$$
.
redrawBar
(
drawBar
,
true
),
$$
.
redrawLine
(
drawLine
,
true
),
$$
.
redrawArea
(
drawArea
,
true
),
$$
.
redrawCircle
(
cx
,
cy
,
true
),
$$
.
redrawText
(
xForText
,
yForText
,
options
.
flow
,
true
),
$$
.
redrawRegion
(
true
),
$$
.
redrawGrid
(
true
),
].
forEach
(
function
(
transitions
)
{
transitions
.
forEach
(
function
(
transition
)
{
transitionsToWait
.
push
(
transition
);
});
});
// Wait for end of transitions if called from flow API
if
(
options
.
flow
)
{
// Wait for end of transitions to call flow and onrendered callback
waitForDraw
=
$$
.
generateWait
();
transitions
.
forEach
(
function
(
t
)
{
transitions
ToWait
.
forEach
(
function
(
t
)
{
waitForDraw
.
add
(
t
);
});
flow
=
$$
.
generateFlow
({
targets
:
targetsToShow
,
flow
:
options
.
flow
,
duration
:
duration
,
drawBar
:
drawBar
,
drawLine
:
drawLine
,
drawArea
:
drawArea
,
cx
:
cx
,
cy
:
cy
,
xv
:
xv
,
xForText
:
xForText
,
yForText
:
yForText
});
}
})
.
call
(
waitForDraw
||
function
()
{},
flow
||
function
()
{});
})
.
call
(
waitForDraw
,
function
()
{
if
(
flow
)
{
flow
();
}
// onrendered callback
});
}
else
{
$$
.
redrawBar
(
drawBar
);
$$
.
redrawLine
(
drawLine
);
$$
.
redrawArea
(
drawArea
);
$$
.
redrawCircle
(
cx
,
cy
);
// onrendered callback
}
// update fadein condition
$$
.
mapToIds
(
$$
.
data
.
targets
).
forEach
(
function
(
id
)
{
...
...
src/grid.js
View file @
6b11a1f7
...
...
@@ -70,7 +70,7 @@ c3_chart_internal_fn.updateYGrid = function () {
};
c3_chart_internal_fn
.
redraw
Grid
=
function
(
duration
)
{
c3_chart_internal_fn
.
update
Grid
=
function
(
duration
)
{
var
$$
=
this
,
main
=
$$
.
main
,
config
=
$$
.
config
,
xgridLine
,
ygridLine
,
yv
;
...
...
@@ -138,19 +138,23 @@ c3_chart_internal_fn.redrawGrid = function (duration) {
.
style
(
"opacity"
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForGrid
=
function
(
transitions
)
{
var
$$
=
this
,
config
=
$$
.
config
,
xv
=
$$
.
xv
.
bind
(
$$
);
transitions
.
push
(
$$
.
xgridLines
.
select
(
'line'
).
transition
()
.
attr
(
"x1"
,
config
.
axis_rotated
?
0
:
xv
)
.
attr
(
"x2"
,
config
.
axis_rotated
?
$$
.
width
:
xv
)
.
attr
(
"y1"
,
config
.
axis_rotated
?
xv
:
$$
.
margin
.
top
)
.
attr
(
"y2"
,
config
.
axis_rotated
?
xv
:
$$
.
height
)
.
style
(
"opacity"
,
1
));
transitions
.
push
(
$$
.
xgridLines
.
select
(
'text'
).
transition
()
.
attr
(
"x"
,
config
.
axis_rotated
?
$$
.
width
:
0
)
.
attr
(
"y"
,
xv
)
.
text
(
function
(
d
)
{
return
d
.
text
;
})
.
style
(
"opacity"
,
1
));
c3_chart_internal_fn
.
redrawGrid
=
function
(
withTransition
)
{
var
$$
=
this
,
config
=
$$
.
config
,
xv
=
$$
.
xv
.
bind
(
$$
),
lines
=
$$
.
xgridLines
.
select
(
'line'
),
texts
=
$$
.
xgridLines
.
select
(
'text'
);
return
[
(
withTransition
?
lines
.
transition
()
:
lines
)
.
attr
(
"x1"
,
config
.
axis_rotated
?
0
:
xv
)
.
attr
(
"x2"
,
config
.
axis_rotated
?
$$
.
width
:
xv
)
.
attr
(
"y1"
,
config
.
axis_rotated
?
xv
:
$$
.
margin
.
top
)
.
attr
(
"y2"
,
config
.
axis_rotated
?
xv
:
$$
.
height
)
.
style
(
"opacity"
,
1
),
(
withTransition
?
texts
.
transition
()
:
texts
)
.
attr
(
"x"
,
config
.
axis_rotated
?
$$
.
width
:
0
)
.
attr
(
"y"
,
xv
)
.
text
(
function
(
d
)
{
return
d
.
text
;
})
.
style
(
"opacity"
,
1
)
];
};
c3_chart_internal_fn
.
showXGridFocus
=
function
(
selectedData
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
src/region.js
View file @
6b11a1f7
...
...
@@ -4,7 +4,7 @@ c3_chart_internal_fn.initRegion = function () {
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
"class"
,
CLASS
.
regions
);
};
c3_chart_internal_fn
.
redraw
Region
=
function
(
duration
)
{
c3_chart_internal_fn
.
update
Region
=
function
(
duration
)
{
var
$$
=
this
,
config
=
$$
.
config
;
// hide if arc type
...
...
@@ -20,18 +20,21 @@ c3_chart_internal_fn.redrawRegion = function (duration) {
.
style
(
"opacity"
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForRegion
=
function
(
transitions
)
{
c3_chart_internal_fn
.
redrawRegion
=
function
(
withTransition
)
{
var
$$
=
this
,
regions
=
$$
.
mainRegion
.
selectAll
(
'rect'
),
x
=
$$
.
regionX
.
bind
(
$$
),
y
=
$$
.
regionY
.
bind
(
$$
),
w
=
$$
.
regionWidth
.
bind
(
$$
),
h
=
$$
.
regionHeight
.
bind
(
$$
);
transitions
.
push
(
$$
.
mainRegion
.
selectAll
(
'rect'
).
transition
()
.
attr
(
"x"
,
x
)
.
attr
(
"y"
,
y
)
.
attr
(
"width"
,
w
)
.
attr
(
"height"
,
h
)
.
style
(
"fill-opacity"
,
function
(
d
)
{
return
isValue
(
d
.
opacity
)
?
d
.
opacity
:
0.1
;
}));
return
[
(
withTransition
?
regions
.
transition
()
:
regions
)
.
attr
(
"x"
,
x
)
.
attr
(
"y"
,
y
)
.
attr
(
"width"
,
w
)
.
attr
(
"height"
,
h
)
.
style
(
"fill-opacity"
,
function
(
d
)
{
return
isValue
(
d
.
opacity
)
?
d
.
opacity
:
0.1
;
})
];
};
c3_chart_internal_fn
.
regionX
=
function
(
d
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
src/shape.bar.js
View file @
6b11a1f7
...
...
@@ -22,7 +22,7 @@ c3_chart_internal_fn.updateTargetsForBar = function (targets) {
.
style
(
"cursor"
,
function
(
d
)
{
return
config
.
data_selection_isselectable
(
d
)
?
"pointer"
:
null
;
});
};
c3_chart_internal_fn
.
redraw
Bar
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Bar
=
function
(
durationForExit
)
{
var
$$
=
this
,
barData
=
$$
.
barData
.
bind
(
$$
),
classBar
=
$$
.
classBar
.
bind
(
$$
),
...
...
@@ -40,12 +40,13 @@ c3_chart_internal_fn.redrawBar = function (durationForExit) {
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForBar
=
function
(
transitions
,
drawBar
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainBar
.
transition
()
.
attr
(
'd'
,
drawBar
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
1
));
c3_chart_internal_fn
.
redrawBar
=
function
(
drawBar
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainBar
.
transition
()
:
this
.
mainBar
)
.
attr
(
'd'
,
drawBar
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"opacity"
,
1
)
];
};
c3_chart_internal_fn
.
getBarW
=
function
(
axis
,
barTargetsNum
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
src/shape.line.js
View file @
6b11a1f7
...
...
@@ -39,7 +39,7 @@ c3_chart_internal_fn.updateTargetsForLine = function (targets) {
// MEMO: can not keep same color...
//mainLineUpdate.exit().remove();
};
c3_chart_internal_fn
.
redraw
Line
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Line
=
function
(
durationForExit
)
{
var
$$
=
this
;
$$
.
mainLine
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
lines
).
selectAll
(
'.'
+
CLASS
.
line
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
...
...
@@ -54,12 +54,13 @@ c3_chart_internal_fn.redrawLine = function (durationForExit) {
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForLine
=
function
(
transitions
,
drawLine
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainLine
.
transition
()
.
attr
(
"d"
,
drawLine
)
.
style
(
"stroke"
,
$$
.
color
)
.
style
(
"opacity"
,
1
));
c3_chart_internal_fn
.
redrawLine
=
function
(
drawLine
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainLine
.
transition
()
:
this
.
mainLine
)
.
attr
(
"d"
,
drawLine
)
.
style
(
"stroke"
,
this
.
color
)
.
style
(
"opacity"
,
1
)
];
};
c3_chart_internal_fn
.
generateDrawLine
=
function
(
lineIndices
,
isSub
)
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
@@ -199,7 +200,7 @@ c3_chart_internal_fn.lineWithRegions = function (d, x, y, _regions) {
};
c3_chart_internal_fn
.
redraw
Area
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Area
=
function
(
durationForExit
)
{
var
$$
=
this
,
d3
=
$$
.
d3
;
$$
.
mainArea
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
areas
).
selectAll
(
'.'
+
CLASS
.
area
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
...
...
@@ -213,12 +214,13 @@ c3_chart_internal_fn.redrawArea = function (durationForExit) {
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForArea
=
function
(
transitions
,
drawArea
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainArea
.
transition
()
.
attr
(
"d"
,
drawArea
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
$$
.
orgAreaOpacity
));
c3_chart_internal_fn
.
redrawArea
=
function
(
drawArea
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainArea
.
transition
()
:
this
.
mainArea
)
.
attr
(
"d"
,
drawArea
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"opacity"
,
this
.
orgAreaOpacity
)
];
};
c3_chart_internal_fn
.
generateDrawArea
=
function
(
areaIndices
,
isSub
)
{
var
$$
=
this
,
config
=
$$
.
config
,
area
=
$$
.
d3
.
svg
.
area
(),
...
...
@@ -282,7 +284,7 @@ c3_chart_internal_fn.generateGetAreaPoints = function (areaIndices, isSub) { //
};
c3_chart_internal_fn
.
redraw
Circle
=
function
()
{
c3_chart_internal_fn
.
update
Circle
=
function
()
{
var
$$
=
this
;
$$
.
mainCircle
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
circles
).
selectAll
(
'.'
+
CLASS
.
circle
)
.
data
(
$$
.
lineOrScatterData
.
bind
(
$$
));
...
...
@@ -294,16 +296,18 @@ c3_chart_internal_fn.redrawCircle = function () {
.
style
(
"opacity"
,
$$
.
initialOpacityForCircle
.
bind
(
$$
));
$$
.
mainCircle
.
exit
().
remove
();
};
c3_chart_internal_fn
.
addTransitionForCircle
=
function
(
transitions
,
cx
,
cy
)
{
var
$$
=
this
;
transitions
.
push
(
$$
.
mainCircle
.
transition
()
.
style
(
'opacity'
,
$$
.
opacityForCircle
.
bind
(
$$
))
.
style
(
"fill"
,
$$
.
color
)
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
));
transitions
.
push
(
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
selectedCircle
).
transition
()
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
));
c3_chart_internal_fn
.
redrawCircle
=
function
(
cx
,
cy
,
withTransition
)
{
var
selectedCircles
=
this
.
main
.
selectAll
(
'.'
+
CLASS
.
selectedCircle
);
return
[
(
withTransition
?
this
.
mainCircle
.
transition
()
:
this
.
mainCircle
)
.
style
(
'opacity'
,
this
.
opacityForCircle
.
bind
(
this
))
.
style
(
"fill"
,
this
.
color
)
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
),
(
withTransition
?
selectedCircles
.
transition
()
:
selectedCircles
)
.
attr
(
"cx"
,
cx
)
.
attr
(
"cy"
,
cy
)
];
};
c3_chart_internal_fn
.
circleX
=
function
(
d
)
{
return
d
.
x
||
d
.
x
===
0
?
this
.
x
(
d
.
x
)
:
null
;
...
...
src/subchart.js
View file @
6b11a1f7
...
...
@@ -80,15 +80,66 @@ c3_chart_internal_fn.updateTargetsForSubchart = function (targets) {
.
attr
(
"class"
,
classAreas
);
}
};
c3_chart_internal_fn
.
updateBarForSubchart
=
function
(
durationForExit
)
{
var
$$
=
this
;
$$
.
contextBar
=
$$
.
context
.
selectAll
(
'.'
+
CLASS
.
bars
).
selectAll
(
'.'
+
CLASS
.
bar
)
.
data
(
$$
.
barData
.
bind
(
$$
));
$$
.
contextBar
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
$$
.
classBar
.
bind
(
$$
))
.
style
(
"stroke"
,
'none'
)
.
style
(
"fill"
,
$$
.
color
);
$$
.
contextBar
.
style
(
"opacity"
,
$$
.
initialOpacity
.
bind
(
$$
));
$$
.
contextBar
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
redrawBarForSubchart
=
function
(
drawBarOnSub
,
withTransition
,
duration
)
{
(
withTransition
?
this
.
contextBar
.
transition
().
duration
(
duration
)
:
this
.
contextBar
)
.
attr
(
'd'
,
drawBarOnSub
)
.
style
(
'opacity'
,
1
);
};
c3_chart_internal_fn
.
updateLineForSubchart
=
function
(
durationForExit
)
{
var
$$
=
this
;
$$
.
contextLine
=
$$
.
context
.
selectAll
(
'.'
+
CLASS
.
lines
).
selectAll
(
'.'
+
CLASS
.
line
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
$$
.
contextLine
.
enter
().
append
(
'path'
)
.
attr
(
'class'
,
$$
.
classLine
.
bind
(
$$
))
.
style
(
'stroke'
,
$$
.
color
);
$$
.
contextLine
.
style
(
"opacity"
,
$$
.
initialOpacity
.
bind
(
$$
));
$$
.
contextLine
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
redrawLineForSubchart
=
function
(
drawLineOnSub
,
withTransition
,
duration
)
{
(
withTransition
?
this
.
contextLine
.
transition
().
duration
(
duration
)
:
this
.
contextLine
)
.
attr
(
"d"
,
drawLineOnSub
)
.
style
(
'opacity'
,
1
);
};
c3_chart_internal_fn
.
updateAreaForSubchart
=
function
(
durationForExit
)
{
var
$$
=
this
,
d3
=
$$
.
d3
;
$$
.
contextArea
=
$$
.
context
.
selectAll
(
'.'
+
CLASS
.
areas
).
selectAll
(
'.'
+
CLASS
.
area
)
.
data
(
$$
.
lineData
.
bind
(
$$
));
$$
.
contextArea
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
$$
.
classArea
.
bind
(
$$
))
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
function
()
{
$$
.
orgAreaOpacity
=
+
d3
.
select
(
this
).
style
(
'opacity'
);
return
0
;
});
$$
.
contextArea
.
style
(
"opacity"
,
0
);
$$
.
contextArea
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
redrawAreaForSubchart
=
function
(
drawAreaOnSub
,
withTransition
,
duration
)
{
(
withTransition
?
this
.
contextArea
.
transition
().
duration
(
duration
)
:
this
.
contextArea
)
.
attr
(
"d"
,
drawAreaOnSub
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"opacity"
,
this
.
orgAreaOpacity
);
};
c3_chart_internal_fn
.
redrawSubchart
=
function
(
withSubchart
,
transitions
,
duration
,
durationForExit
,
areaIndices
,
barIndices
,
lineIndices
)
{
var
$$
=
this
,
d3
=
$$
.
d3
,
context
=
$$
.
context
,
config
=
$$
.
config
,
contextLine
,
contextArea
,
contextBar
,
drawAreaOnSub
,
drawBarOnSub
,
drawLineOnSub
,
barData
=
$$
.
barData
.
bind
(
$$
),
lineData
=
$$
.
lineData
.
bind
(
$$
),
classBar
=
$$
.
classBar
.
bind
(
$$
),
classLine
=
$$
.
classLine
.
bind
(
$$
),
classArea
=
$$
.
classArea
.
bind
(
$$
),
initialOpacity
=
$$
.
initialOpacity
.
bind
(
$$
);
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
drawAreaOnSub
,
drawBarOnSub
,
drawLineOnSub
;
// subchart
if
(
config
.
subchart_show
)
{
...
...
@@ -107,51 +158,14 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat
drawAreaOnSub
=
$$
.
generateDrawArea
(
areaIndices
,
true
);
drawBarOnSub
=
$$
.
generateDrawBar
(
barIndices
,
true
);
drawLineOnSub
=
$$
.
generateDrawLine
(
lineIndices
,
true
);
// bars
contextBar
=
context
.
selectAll
(
'.'
+
CLASS
.
bars
).
selectAll
(
'.'
+
CLASS
.
bar
)
.
data
(
barData
);
contextBar
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
classBar
)
.
style
(
"stroke"
,
'none'
)
.
style
(
"fill"
,
$$
.
color
);
contextBar
.
style
(
"opacity"
,
initialOpacity
)
.
transition
().
duration
(
duration
)
.
attr
(
'd'
,
drawBarOnSub
)
.
style
(
'opacity'
,
1
);
contextBar
.
exit
().
transition
().
duration
(
duration
)
.
style
(
'opacity'
,
0
)
.
remove
();
// lines
contextLine
=
context
.
selectAll
(
'.'
+
CLASS
.
lines
).
selectAll
(
'.'
+
CLASS
.
line
)
.
data
(
lineData
);
contextLine
.
enter
().
append
(
'path'
)
.
attr
(
'class'
,
classLine
)
.
style
(
'stroke'
,
$$
.
color
);
contextLine
.
style
(
"opacity"
,
initialOpacity
)
.
transition
().
duration
(
duration
)
.
attr
(
"d"
,
drawLineOnSub
)
.
style
(
'opacity'
,
1
);
contextLine
.
exit
().
transition
().
duration
(
duration
)
.
style
(
'opacity'
,
0
)
.
remove
();
// area
contextArea
=
context
.
selectAll
(
'.'
+
CLASS
.
areas
).
selectAll
(
'.'
+
CLASS
.
area
)
.
data
(
lineData
);
contextArea
.
enter
().
append
(
'path'
)
.
attr
(
"class"
,
classArea
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
function
()
{
$$
.
orgAreaOpacity
=
+
d3
.
select
(
this
).
style
(
'opacity'
);
return
0
;
});
contextArea
.
style
(
"opacity"
,
0
)
.
transition
().
duration
(
duration
)
.
attr
(
"d"
,
drawAreaOnSub
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"opacity"
,
$$
.
orgAreaOpacity
);
contextArea
.
exit
().
transition
().
duration
(
durationForExit
)
.
style
(
'opacity'
,
0
)
.
remove
();
$$
.
updateBarForSubchart
(
duration
);
$$
.
updateLineForSubchart
(
duration
);
$$
.
updateAreaForSubchart
(
duration
);
$$
.
redrawBarForSubchart
(
drawBarOnSub
,
duration
,
duration
);
$$
.
redrawLineForSubchart
(
drawLineOnSub
,
duration
,
duration
);
$$
.
redrawAreaForSubchart
(
drawAreaOnSub
,
duration
,
duration
);
}
}
};
...
...
src/text.js
View file @
6b11a1f7
...
...
@@ -19,7 +19,7 @@ c3_chart_internal_fn.updateTargetsForText = function (targets) {
mainTextEnter
.
append
(
'g'
)
.
attr
(
'class'
,
classTexts
);
};
c3_chart_internal_fn
.
redraw
Text
=
function
(
durationForExit
)
{
c3_chart_internal_fn
.
update
Text
=
function
(
durationForExit
)
{
var
$$
=
this
,
config
=
$$
.
config
,
barOrLineData
=
$$
.
barOrLineData
.
bind
(
$$
),
classText
=
$$
.
classText
.
bind
(
$$
);
...
...
@@ -38,14 +38,14 @@ c3_chart_internal_fn.redrawText = function (durationForExit) {
.
style
(
'fill-opacity'
,
0
)
.
remove
();
};
c3_chart_internal_fn
.
addTransitionForText
=
function
(
transitions
,
xForText
,
yForText
,
forFlow
)
{
var
$$
=
this
,
opacityForText
=
forFlow
?
0
:
$$
.
opacityForText
.
bind
(
$$
);
transitions
.
push
(
$$
.
mainText
.
transition
(
)
.
attr
(
'x'
,
x
ForText
)
.
attr
(
'y'
,
yForText
)
.
style
(
"fill"
,
$$
.
color
)
.
style
(
"fill-opacity"
,
opacityForText
))
;
c3_chart_internal_fn
.
redrawText
=
function
(
xForText
,
yForText
,
forFlow
,
withTransition
)
{
return
[
(
withTransition
?
this
.
mainText
.
transition
()
:
this
.
mainText
)
.
attr
(
'x'
,
xForText
)
.
attr
(
'y'
,
y
ForText
)
.
style
(
"fill"
,
this
.
color
)
.
style
(
"fill-opacity"
,
forFlow
?
0
:
this
.
opacityForText
.
bind
(
this
)
)
]
;
};
c3_chart_internal_fn
.
getTextRect
=
function
(
text
,
cls
)
{
var
body
=
this
.
d3
.
select
(
'body'
).
classed
(
'c3'
,
true
),
...
...
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