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
18a39d58
Commit
18a39d58
authored
Jun 03, 2015
by
GermainBergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed build
Added c3.js & c3.min.js
parent
ce96ac07
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
423 additions
and
417 deletions
+423
-417
c3.js
c3.js
+421
-415
c3.min.js
c3.min.js
+0
-0
api.tooltip.js
src/api.tooltip.js
+2
-2
No files found.
c3.js
View file @
18a39d58
...
...
@@ -4,17 +4,17 @@
/*global define, module, exports, require */
var
c3
=
{
version
:
"0.4.10"
};
var
c3_chart_fn
,
c3_chart_internal_fn
,
c3_chart_internal_axis_fn
;
function
API
(
owner
)
{
this
.
owner
=
owner
;
}
function
inherit
(
base
,
derived
)
{
if
(
Object
.
create
)
{
derived
.
prototype
=
Object
.
create
(
base
.
prototype
);
}
else
{
...
...
@@ -22,17 +22,17 @@
f
.
prototype
=
base
.
prototype
;
derived
.
prototype
=
new
f
();
}
derived
.
prototype
.
constructor
=
derived
;
return
derived
;
}
function
Chart
(
config
)
{
var
$$
=
this
.
internal
=
new
ChartInternal
(
this
);
$$
.
loadConfig
(
config
);
$$
.
init
();
// bind "this" to nested API
(
function
bindThis
(
fn
,
target
,
argThis
)
{
Object
.
keys
(
fn
).
forEach
(
function
(
key
)
{
...
...
@@ -43,7 +43,7 @@
});
})(
c3_chart_fn
,
this
,
this
);
}
function
ChartInternal
(
api
)
{
var
$$
=
this
;
$$
.
d3
=
window
.
d3
?
window
.
d3
:
typeof
require
!==
'undefined'
?
require
(
"d3"
)
:
undefined
;
...
...
@@ -53,11 +53,11 @@
$$
.
cache
=
{};
$$
.
axes
=
{};
}
c3
.
generate
=
function
(
config
)
{
return
new
Chart
(
config
);
};
c3
.
chart
=
{
fn
:
Chart
.
prototype
,
internal
:
{
...
...
@@ -70,12 +70,12 @@
c3_chart_fn
=
c3
.
chart
.
fn
;
c3_chart_internal_fn
=
c3
.
chart
.
internal
.
fn
;
c3_chart_internal_axis_fn
=
c3
.
chart
.
internal
.
axis
.
fn
;
c3_chart_internal_fn
.
init
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
;
$$
.
initParams
();
if
(
config
.
data_url
)
{
$$
.
convertUrlToData
(
config
.
data_url
,
config
.
data_mimeType
,
config
.
data_keys
,
$$
.
initWithData
);
}
...
...
@@ -92,10 +92,10 @@
throw
Error
(
'url or json or rows or columns is required.'
);
}
};
c3_chart_internal_fn
.
initParams
=
function
()
{
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
// MEMO: clipId needs to be unique because it conflicts when multiple charts exist
$$
.
clipId
=
"c3-"
+
(
+
new
Date
())
+
'-clip'
,
$$
.
clipIdForXAxis
=
$$
.
clipId
+
'-xaxis'
,
...
...
@@ -107,17 +107,17 @@
$$
.
clipPathForYAxis
=
$$
.
getClipPath
(
$$
.
clipIdForYAxis
);
$$
.
clipPathForGrid
=
$$
.
getClipPath
(
$$
.
clipIdForGrid
),
$$
.
clipPathForSubchart
=
$$
.
getClipPath
(
$$
.
clipIdForSubchart
),
$$
.
dragStart
=
null
;
$$
.
dragging
=
false
;
$$
.
flowing
=
false
;
$$
.
cancelClick
=
false
;
$$
.
mouseover
=
false
;
$$
.
transiting
=
false
;
$$
.
color
=
$$
.
generateColor
();
$$
.
levelColor
=
$$
.
generateLevelColor
();
$$
.
dataTimeFormat
=
config
.
data_xLocaltime
?
d3
.
time
.
format
:
d3
.
time
.
format
.
utc
;
$$
.
axisTimeFormat
=
config
.
axis_x_localtime
?
d3
.
time
.
format
:
d3
.
time
.
format
.
utc
;
$$
.
defaultAxisTimeFormat
=
$$
.
axisTimeFormat
.
multi
([
...
...
@@ -130,17 +130,17 @@
[
"%-m/%-d"
,
function
(
d
)
{
return
d
.
getMonth
();
}],
[
"%Y/%-m/%-d"
,
function
()
{
return
true
;
}]
]);
$$
.
hiddenTargetIds
=
[];
$$
.
hiddenLegendIds
=
[];
$$
.
focusedTargetIds
=
[];
$$
.
defocusedTargetIds
=
[];
$$
.
xOrient
=
config
.
axis_rotated
?
"left"
:
"bottom"
;
$$
.
yOrient
=
config
.
axis_rotated
?
(
config
.
axis_y_inner
?
"top"
:
"bottom"
)
:
(
config
.
axis_y_inner
?
"right"
:
"left"
);
$$
.
y2Orient
=
config
.
axis_rotated
?
(
config
.
axis_y2_inner
?
"bottom"
:
"top"
)
:
(
config
.
axis_y2_inner
?
"left"
:
"right"
);
$$
.
subXOrient
=
config
.
axis_rotated
?
"left"
:
"bottom"
;
$$
.
isLegendRight
=
config
.
legend_position
===
'right'
;
$$
.
isLegendInset
=
config
.
legend_position
===
'inset'
;
$$
.
isLegendTop
=
config
.
legend_inset_anchor
===
'top-left'
||
config
.
legend_inset_anchor
===
'top-right'
;
...
...
@@ -148,24 +148,24 @@
$$
.
legendStep
=
0
;
$$
.
legendItemWidth
=
0
;
$$
.
legendItemHeight
=
0
;
$$
.
currentMaxTickWidths
=
{
x
:
0
,
y
:
0
,
y2
:
0
};
$$
.
rotated_padding_left
=
30
;
$$
.
rotated_padding_right
=
config
.
axis_rotated
&&
!
config
.
axis_x_show
?
0
:
30
;
$$
.
rotated_padding_top
=
5
;
$$
.
withoutFadeIn
=
{};
$$
.
intervalForObserveInserted
=
undefined
;
$$
.
axes
.
subx
=
d3
.
selectAll
([]);
// needs when excluding subchart.js
};
c3_chart_internal_fn
.
initChartElements
=
function
()
{
if
(
this
.
initBar
)
{
this
.
initBar
();
}
if
(
this
.
initLine
)
{
this
.
initLine
();
}
...
...
@@ -173,17 +173,17 @@
if
(
this
.
initGauge
)
{
this
.
initGauge
();
}
if
(
this
.
initText
)
{
this
.
initText
();
}
};
c3_chart_internal_fn
.
initWithData
=
function
(
data
)
{
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
var
defs
,
main
,
binding
=
true
;
$$
.
axis
=
new
Axis
(
$$
);
if
(
$$
.
initPie
)
{
$$
.
initPie
();
}
if
(
$$
.
initBrush
)
{
$$
.
initBrush
();
}
if
(
$$
.
initZoom
)
{
$$
.
initZoom
();
}
if
(
!
config
.
bindto
)
{
$$
.
selectChart
=
d3
.
selectAll
([]);
}
...
...
@@ -199,15 +199,15 @@
binding
=
false
;
}
$$
.
selectChart
.
html
(
""
).
classed
(
"c3"
,
true
);
// Init data as targets
$$
.
data
.
xs
=
{};
$$
.
data
.
targets
=
$$
.
convertDataToTargets
(
data
);
if
(
config
.
data_filter
)
{
$$
.
data
.
targets
=
$$
.
data
.
targets
.
filter
(
config
.
data_filter
);
}
// Set targets to hide if needed
if
(
config
.
data_hide
)
{
$$
.
addHiddenTargetIds
(
config
.
data_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
data_hide
);
...
...
@@ -215,16 +215,16 @@
if
(
config
.
legend_hide
)
{
$$
.
addHiddenLegendIds
(
config
.
legend_hide
===
true
?
$$
.
mapToIds
(
$$
.
data
.
targets
)
:
config
.
legend_hide
);
}
// when gauge, hide legend // TODO: fix
if
(
$$
.
hasType
(
'gauge'
))
{
config
.
legend_show
=
false
;
}
// Init sizes and scales
$$
.
updateSizes
();
$$
.
updateScales
();
// Set domains for each scale
$$
.
x
.
domain
(
d3
.
extent
(
$$
.
getXDomain
(
$$
.
data
.
targets
)));
$$
.
y
.
domain
(
$$
.
getYDomain
(
$$
.
data
.
targets
,
'y'
));
...
...
@@ -232,22 +232,22 @@
$$
.
subX
.
domain
(
$$
.
x
.
domain
());
$$
.
subY
.
domain
(
$$
.
y
.
domain
());
$$
.
subY2
.
domain
(
$$
.
y2
.
domain
());
// Save original x domain for zoom update
$$
.
orgXDomain
=
$$
.
x
.
domain
();
// Set initialized scales to brush and zoom
if
(
$$
.
brush
)
{
$$
.
brush
.
scale
(
$$
.
subX
);
}
if
(
config
.
zoom_enabled
)
{
$$
.
zoom
.
scale
(
$$
.
x
);
}
/*-- Basic Elements --*/
// Define svgs
$$
.
svg
=
$$
.
selectChart
.
append
(
"svg"
)
.
style
(
"overflow"
,
"hidden"
)
.
on
(
'mouseenter'
,
function
()
{
return
config
.
onmouseover
.
call
(
$$
);
})
.
on
(
'mouseleave'
,
function
()
{
return
config
.
onmouseout
.
call
(
$$
);
});
// Define defs
defs
=
$$
.
svg
.
append
(
"defs"
);
$$
.
clipChart
=
$$
.
appendClip
(
defs
,
$$
.
clipId
);
...
...
@@ -256,43 +256,43 @@
$$
.
clipGrid
=
$$
.
appendClip
(
defs
,
$$
.
clipIdForGrid
);
$$
.
clipSubchart
=
$$
.
appendClip
(
defs
,
$$
.
clipIdForSubchart
);
$$
.
updateSvgSize
();
// Define regions
main
=
$$
.
main
=
$$
.
svg
.
append
(
"g"
).
attr
(
"transform"
,
$$
.
getTranslate
(
'main'
));
if
(
$$
.
initSubchart
)
{
$$
.
initSubchart
();
}
if
(
$$
.
initTooltip
)
{
$$
.
initTooltip
();
}
if
(
$$
.
initLegend
)
{
$$
.
initLegend
();
}
if
(
$$
.
initTitle
)
{
$$
.
initTitle
();
}
/*-- Main Region --*/
// text when empty
main
.
append
(
"text"
)
.
attr
(
"class"
,
CLASS
.
text
+
' '
+
CLASS
.
empty
)
.
attr
(
"text-anchor"
,
"middle"
)
// horizontal centering of text at x position in all browsers.
.
attr
(
"dominant-baseline"
,
"middle"
);
// vertical centering of text at y position in all browsers, except IE.
// Regions
$$
.
initRegion
();
// Grids
$$
.
initGrid
();
// Define g for chart area
main
.
append
(
'g'
)
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
'class'
,
CLASS
.
chart
);
// Grid lines
if
(
config
.
grid_lines_front
)
{
$$
.
initGridLines
();
}
// Cover whole with rects for events
$$
.
initEventRect
();
// Define g for chart
$$
.
initChartElements
();
// if zoom privileged, insert rect to forefront
// TODO: is this needed?
main
.
insert
(
'rect'
,
config
.
zoom_privileged
?
null
:
'g.'
+
CLASS
.
regions
)
...
...
@@ -301,16 +301,16 @@
.
attr
(
'height'
,
$$
.
height
)
.
style
(
'opacity'
,
0
)
.
on
(
"dblclick.zoom"
,
null
);
// Set default extent if defined
if
(
config
.
axis_x_extent
)
{
$$
.
brush
.
extent
(
$$
.
getDefaultExtent
());
}
// Add Axis
$$
.
axis
.
init
();
// Set targets
$$
.
updateTargets
(
$$
.
data
.
targets
);
// Draw with targets
if
(
binding
)
{
$$
.
updateDimension
();
...
...
@@ -323,7 +323,7 @@
withTransitionForAxis
:
false
});
}
// Bind resize event
if
(
window
.
onresize
==
null
)
{
window
.
onresize
=
$$
.
generateResize
();
...
...
@@ -339,11 +339,11 @@
config
.
onresized
.
call
(
$$
);
});
}
// export element of the chart
$$
.
api
.
element
=
$$
.
selectChart
.
node
();
};
c3_chart_internal_fn
.
smoothLines
=
function
(
el
,
type
)
{
var
$$
=
this
;
if
(
type
===
'grid'
)
{
...
...
@@ -362,8 +362,8 @@
});
}
};
c3_chart_internal_fn
.
updateSizes
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
;
var
legendHeight
=
$$
.
legend
?
$$
.
getLegendHeight
()
:
0
,
...
...
@@ -372,10 +372,10 @@
hasArc
=
$$
.
hasArcType
(),
xAxisHeight
=
config
.
axis_rotated
||
hasArc
?
0
:
$$
.
getHorizontalAxisHeight
(
'x'
),
subchartHeight
=
config
.
subchart_show
&&
!
hasArc
?
(
config
.
subchart_size_height
+
xAxisHeight
)
:
0
;
$$
.
currentWidth
=
$$
.
getCurrentWidth
();
$$
.
currentHeight
=
$$
.
getCurrentHeight
();
// for main
$$
.
margin
=
config
.
axis_rotated
?
{
top
:
$$
.
getHorizontalAxisHeight
(
'y2'
)
+
$$
.
getCurrentPaddingTop
(),
...
...
@@ -388,7 +388,7 @@
bottom
:
xAxisHeight
+
subchartHeight
+
legendHeightForBottom
+
$$
.
getCurrentPaddingBottom
(),
left
:
hasArc
?
0
:
$$
.
getCurrentPaddingLeft
()
};
// for subchart
$$
.
margin2
=
config
.
axis_rotated
?
{
top
:
$$
.
margin
.
top
,
...
...
@@ -401,7 +401,7 @@
bottom
:
xAxisHeight
+
legendHeightForBottom
,
left
:
$$
.
margin
.
left
};
// for legend
$$
.
margin3
=
{
top
:
0
,
...
...
@@ -410,17 +410,17 @@
left
:
0
};
if
(
$$
.
updateSizeForLegend
)
{
$$
.
updateSizeForLegend
(
legendHeight
,
legendWidth
);
}
$$
.
width
=
$$
.
currentWidth
-
$$
.
margin
.
left
-
$$
.
margin
.
right
;
$$
.
height
=
$$
.
currentHeight
-
$$
.
margin
.
top
-
$$
.
margin
.
bottom
;
if
(
$$
.
width
<
0
)
{
$$
.
width
=
0
;
}
if
(
$$
.
height
<
0
)
{
$$
.
height
=
0
;
}
$$
.
width2
=
config
.
axis_rotated
?
$$
.
margin
.
left
-
$$
.
rotated_padding_left
-
$$
.
rotated_padding_right
:
$$
.
width
;
$$
.
height2
=
config
.
axis_rotated
?
$$
.
height
:
$$
.
currentHeight
-
$$
.
margin2
.
top
-
$$
.
margin2
.
bottom
;
if
(
$$
.
width2
<
0
)
{
$$
.
width2
=
0
;
}
if
(
$$
.
height2
<
0
)
{
$$
.
height2
=
0
;
}
// for arc
$$
.
arcWidth
=
$$
.
width
-
(
$$
.
isLegendRight
?
legendWidth
+
10
:
0
);
$$
.
arcHeight
=
$$
.
height
-
(
$$
.
isLegendRight
?
0
:
10
);
...
...
@@ -428,33 +428,33 @@
$$
.
arcHeight
+=
$$
.
height
-
$$
.
getGaugeLabelHeight
();
}
if
(
$$
.
updateRadius
)
{
$$
.
updateRadius
();
}
if
(
$$
.
isLegendRight
&&
hasArc
)
{
$$
.
margin3
.
left
=
$$
.
arcWidth
/
2
+
$$
.
radiusExpanded
*
1.1
;
}
};
c3_chart_internal_fn
.
updateTargets
=
function
(
targets
)
{
var
$$
=
this
;
/*-- Main --*/
//-- Text --//
$$
.
updateTargetsForText
(
targets
);
//-- Bar --//
$$
.
updateTargetsForBar
(
targets
);
//-- Line --//
$$
.
updateTargetsForLine
(
targets
);
//-- Arc --//
if
(
$$
.
hasArcType
()
&&
$$
.
updateTargetsForArc
)
{
$$
.
updateTargetsForArc
(
targets
);
}
/*-- Sub --*/
if
(
$$
.
updateTargetsForSubchart
)
{
$$
.
updateTargetsForSubchart
(
targets
);
}
// Fade-in each chart
$$
.
showTargets
();
};
...
...
@@ -464,7 +464,7 @@
.
transition
().
duration
(
$$
.
config
.
transition_duration
)
.
style
(
"opacity"
,
1
);
};
c3_chart_internal_fn
.
redraw
=
function
(
options
,
transitions
)
{
var
$$
=
this
,
main
=
$$
.
main
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
var
areaIndices
=
$$
.
getShapeIndices
(
$$
.
isAreaType
),
barIndices
=
$$
.
getShapeIndices
(
$$
.
isBarType
),
lineIndices
=
$$
.
getShapeIndices
(
$$
.
isLineType
);
...
...
@@ -477,7 +477,7 @@
var
waitForDraw
,
flow
;
var
targetsToShow
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
),
tickValues
,
i
,
intervalForCulling
,
xDomainForZoom
;
var
xv
=
$$
.
xv
.
bind
(
$$
),
cx
,
cy
;
options
=
options
||
{};
withY
=
getOption
(
options
,
"withY"
,
true
);
withSubchart
=
getOption
(
options
,
"withSubchart"
,
true
);
...
...
@@ -492,13 +492,13 @@
withDimension
=
getOption
(
options
,
"withDimension"
,
true
);
withTransitionForExit
=
getOption
(
options
,
"withTransitionForExit"
,
withTransition
);
withTransitionForAxis
=
getOption
(
options
,
"withTransitionForAxis"
,
withTransition
);
duration
=
withTransition
?
config
.
transition_duration
:
0
;
durationForExit
=
withTransitionForExit
?
duration
:
0
;
durationForAxis
=
withTransitionForAxis
?
duration
:
0
;
transitions
=
transitions
||
$$
.
axis
.
generateTransitions
(
durationForAxis
);
// update legend and transform each g
if
(
withLegend
&&
config
.
legend_show
)
{
$$
.
updateLegend
(
$$
.
mapToIds
(
$$
.
data
.
targets
),
options
,
transitions
);
...
...
@@ -507,12 +507,12 @@
// no need to update axis in it because they will be updated in redraw()
$$
.
updateDimension
(
true
);
}
// MEMO: needed for grids calculation
if
(
$$
.
isCategorized
()
&&
targetsToShow
.
length
===
0
)
{
$$
.
x
.
domain
([
0
,
$$
.
axes
.
x
.
selectAll
(
'.tick'
).
size
()]);
}
if
(
targetsToShow
.
length
)
{
$$
.
updateXDomain
(
targetsToShow
,
withUpdateXDomain
,
withUpdateOrgXDomain
,
withTrimXDomain
);
if
(
!
config
.
axis_x_tick_values
)
{
...
...
@@ -522,27 +522,27 @@
$$
.
xAxis
.
tickValues
([]);
$$
.
subXAxis
.
tickValues
([]);
}
if
(
config
.
zoom_rescale
&&
!
options
.
flow
)
{
xDomainForZoom
=
$$
.
x
.
orgDomain
();
}
$$
.
y
.
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y'
,
xDomainForZoom
));
$$
.
y2
.
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y2'
,
xDomainForZoom
));
if
(
!
config
.
axis_y_tick_values
&&
config
.
axis_y_tick_count
)
{
$$
.
yAxis
.
tickValues
(
$$
.
axis
.
generateTickValues
(
$$
.
y
.
domain
(),
config
.
axis_y_tick_count
));
}
if
(
!
config
.
axis_y2_tick_values
&&
config
.
axis_y2_tick_count
)
{
$$
.
y2Axis
.
tickValues
(
$$
.
axis
.
generateTickValues
(
$$
.
y2
.
domain
(),
config
.
axis_y2_tick_count
));
}
// axes
$$
.
axis
.
redraw
(
transitions
,
hideAxis
);
// Update axis label
$$
.
axis
.
updateLabels
(
withTransition
);
// show/hide if manual culling needed
if
((
withUpdateXDomain
||
withUpdateXAxis
)
&&
targetsToShow
.
length
)
{
if
(
config
.
axis_x_tick_culling
&&
tickValues
)
{
...
...
@@ -562,26 +562,26 @@
$$
.
svg
.
selectAll
(
'.'
+
CLASS
.
axisX
+
' .tick text'
).
style
(
'display'
,
'block'
);
}
}
// setup drawer - MEMO: these must be called after axis updated
drawArea
=
$$
.
generateDrawArea
?
$$
.
generateDrawArea
(
areaIndices
,
false
)
:
undefined
;
drawBar
=
$$
.
generateDrawBar
?
$$
.
generateDrawBar
(
barIndices
)
:
undefined
;
drawLine
=
$$
.
generateDrawLine
?
$$
.
generateDrawLine
(
lineIndices
,
false
)
:
undefined
;
xForText
=
$$
.
generateXYForText
(
areaIndices
,
barIndices
,
lineIndices
,
true
);
yForText
=
$$
.
generateXYForText
(
areaIndices
,
barIndices
,
lineIndices
,
false
);
// Update sub domain
if
(
withY
)
{
$$
.
subY
.
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y'
));
$$
.
subY2
.
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y2'
));
}
// tooltip
$$
.
tooltip
.
style
(
"display"
,
"none"
);
// xgrid focus
$$
.
updateXgridFocus
();
// Data empty label positioning and text.
main
.
select
(
"text."
+
CLASS
.
text
+
'.'
+
CLASS
.
empty
)
.
attr
(
"x"
,
$$
.
width
/
2
)
...
...
@@ -589,56 +589,56 @@
.
text
(
config
.
data_empty_label_text
)
.
transition
()
.
style
(
'opacity'
,
targetsToShow
.
length
?
0
:
1
);
// grid
$$
.
updateGrid
(
duration
);
// rect for regions
$$
.
updateRegion
(
duration
);
// bars
$$
.
updateBar
(
durationForExit
);
// lines, areas and cricles
$$
.
updateLine
(
durationForExit
);
$$
.
updateArea
(
durationForExit
);
$$
.
updateCircle
();
// text
if
(
$$
.
hasDataLabel
())
{
$$
.
updateText
(
durationForExit
);
}
// title
if
(
$$
.
redrawTitle
)
{
$$
.
redrawTitle
();
}
// arc
if
(
$$
.
redrawArc
)
{
$$
.
redrawArc
(
duration
,
durationForExit
,
withTransform
);
}
// subchart
if
(
$$
.
redrawSubchart
)
{
$$
.
redrawSubchart
(
withSubchart
,
transitions
,
duration
,
durationForExit
,
areaIndices
,
barIndices
,
lineIndices
);
}
// circles for select
main
.
selectAll
(
'.'
+
CLASS
.
selectedCircles
)
.
filter
(
$$
.
isBarType
.
bind
(
$$
))
.
selectAll
(
'circle'
)
.
remove
();
// event rects will redrawn when flow called
if
(
config
.
interaction_enabled
&&
!
options
.
flow
&&
withEventRect
)
{
$$
.
redrawEventRect
();
if
(
$$
.
updateZoom
)
{
$$
.
updateZoom
();
}
}
// update circleY based on updated parameters
$$
.
updateCircleY
();
// generate circle x/y functions depending on updated params
cx
=
(
$$
.
config
.
axis_rotated
?
$$
.
circleY
:
$$
.
circleX
).
bind
(
$$
);
cy
=
(
$$
.
config
.
axis_rotated
?
$$
.
circleX
:
$$
.
circleY
).
bind
(
$$
);
if
(
options
.
flow
)
{
flow
=
$$
.
generateFlow
({
targets
:
targetsToShow
,
...
...
@@ -654,12 +654,12 @@
yForText
:
yForText
});
}
if
((
duration
||
flow
)
&&
$$
.
isTabVisible
())
{
// Only use transition if tab visible. See #938.
// transition should be derived from one transition
d3
.
transition
().
duration
(
duration
).
each
(
function
()
{
var
transitionsToWait
=
[];
// redraw and gather transitions
[
$$
.
redrawBar
(
drawBar
,
true
),
...
...
@@ -674,7 +674,7 @@
transitionsToWait
.
push
(
transition
);
});
});
// Wait for end of transitions to call flow and onrendered callback
waitForDraw
=
$$
.
generateWait
();
transitionsToWait
.
forEach
(
function
(
t
)
{
...
...
@@ -702,13 +702,13 @@
config
.
onrendered
.
call
(
$$
);
}
}
// update fadein condition
$$
.
mapToIds
(
$$
.
data
.
targets
).
forEach
(
function
(
id
)
{
$$
.
withoutFadeIn
[
id
]
=
true
;
});
};
c3_chart_internal_fn
.
updateAndRedraw
=
function
(
options
)
{
var
$$
=
this
,
config
=
$$
.
config
,
transitions
;
options
=
options
||
{};
...
...
@@ -743,7 +743,7 @@
withTransitionForAxis
:
false
});
};
c3_chart_internal_fn
.
isTimeSeries
=
function
()
{
return
this
.
config
.
axis_x_type
===
'timeseries'
;
};
...
...
@@ -754,11 +754,11 @@
var
$$
=
this
,
config
=
$$
.
config
;
return
!
$$
.
isTimeSeries
()
&&
(
config
.
data_x
||
notEmpty
(
config
.
data_xs
));
};
c3_chart_internal_fn
.
isTimeSeriesY
=
function
()
{
return
this
.
config
.
axis_y_type
===
'timeseries'
;
};
c3_chart_internal_fn
.
getTranslate
=
function
(
target
)
{
var
$$
=
this
,
config
=
$$
.
config
,
x
,
y
;
if
(
target
===
'main'
)
{
...
...
@@ -822,7 +822,7 @@
c3_chart_internal_fn
.
subxx
=
function
(
d
)
{
return
d
?
this
.
subX
(
d
.
x
)
:
null
;
};
c3_chart_internal_fn
.
transformMain
=
function
(
withTransition
,
transitions
)
{
var
$$
=
this
,
xAxis
,
yAxis
,
y2Axis
;
...
...
@@ -856,7 +856,7 @@
if
(
$$
.
config
.
subchart_show
)
{
$$
.
transformContext
(
withTransition
,
transitions
);
}
if
(
$$
.
legend
)
{
$$
.
transformLegend
(
withTransition
);
}
};
c3_chart_internal_fn
.
updateSvgSize
=
function
()
{
var
$$
=
this
,
brush
=
$$
.
svg
.
select
(
".c3-brush .background"
);
...
...
@@ -883,8 +883,8 @@
// MEMO: parent div's height will be bigger than svg when <!DOCTYPE html>
$$
.
selectChart
.
style
(
'max-height'
,
$$
.
currentHeight
+
"px"
);
};
c3_chart_internal_fn
.
updateDimension
=
function
(
withoutAxis
)
{
var
$$
=
this
;
if
(
!
withoutAxis
)
{
...
...
@@ -901,7 +901,7 @@
$$
.
updateSvgSize
();
$$
.
transformAll
(
false
);
};
c3_chart_internal_fn
.
observeInserted
=
function
(
selection
)
{
var
$$
=
this
,
observer
;
if
(
typeof
MutationObserver
===
'undefined'
)
{
...
...
@@ -936,8 +936,8 @@
});
observer
.
observe
(
selection
.
node
(),
{
attributes
:
true
,
childList
:
true
,
characterData
:
true
});
};
c3_chart_internal_fn
.
generateResize
=
function
()
{
var
resizeFunctions
=
[];
function
callResizeFunctions
()
{
...
...
@@ -950,7 +950,7 @@
};
return
callResizeFunctions
;
};
c3_chart_internal_fn
.
endall
=
function
(
transition
,
callback
)
{
var
n
=
0
;
transition
...
...
@@ -986,7 +986,7 @@
};
return
f
;
};
c3_chart_internal_fn
.
parseDate
=
function
(
date
)
{
var
$$
=
this
,
parsedDate
;
if
(
date
instanceof
Date
)
{
...
...
@@ -1001,7 +1001,7 @@
}
return
parsedDate
;
};
c3_chart_internal_fn
.
isTabVisible
=
function
()
{
var
hidden
;
if
(
typeof
document
.
hidden
!==
"undefined"
)
{
// Opera 12.10 and Firefox 18 and later support
...
...
@@ -1013,7 +1013,7 @@
}
else
if
(
typeof
document
.
webkitHidden
!==
"undefined"
)
{
hidden
=
"webkitHidden"
;
}
return
document
[
hidden
]
?
false
:
true
;
};
...
...
@@ -1211,6 +1211,8 @@
tooltip_init_show
:
false
,
tooltip_init_x
:
0
,
tooltip_init_position
:
{
top
:
'0px'
,
left
:
'50px'
},
tooltip_onshow
:
function
()
{},
tooltip_onhide
:
function
()
{},
// title
title_text
:
undefined
,
title_padding
:
{
...
...
@@ -1332,12 +1334,12 @@
$$
.
xAxisTickValues
=
$$
.
axis
.
getXAxisTickValues
();
$$
.
yAxisTickValues
=
$$
.
axis
.
getYAxisTickValues
();
$$
.
y2AxisTickValues
=
$$
.
axis
.
getY2AxisTickValues
();
$$
.
xAxis
=
$$
.
axis
.
getXAxis
(
$$
.
x
,
$$
.
xOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
,
config
.
axis_x_tick_outer
);
$$
.
subXAxis
=
$$
.
axis
.
getXAxis
(
$$
.
subX
,
$$
.
subXOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
,
config
.
axis_x_tick_outer
);
$$
.
yAxis
=
$$
.
axis
.
getYAxis
(
$$
.
y
,
$$
.
yOrient
,
config
.
axis_y_tick_format
,
$$
.
yAxisTickValues
,
config
.
axis_y_tick_outer
);
$$
.
y2Axis
=
$$
.
axis
.
getYAxis
(
$$
.
y2
,
$$
.
y2Orient
,
config
.
axis_y2_tick_format
,
$$
.
y2AxisTickValues
,
config
.
axis_y2_tick_outer
);
// Set initialized scales to brush and zoom
if
(
!
forInit
)
{
if
(
$$
.
brush
)
{
$$
.
brush
.
scale
(
$$
.
subX
);
}
...
...
@@ -1424,11 +1426,11 @@
isInverted
=
axisId
===
'y2'
?
config
.
axis_y2_inverted
:
config
.
axis_y_inverted
,
showHorizontalDataLabel
=
$$
.
hasDataLabel
()
&&
config
.
axis_rotated
,
showVerticalDataLabel
=
$$
.
hasDataLabel
()
&&
!
config
.
axis_rotated
;
// MEMO: avoid inverting domain unexpectedly
yDomainMin
=
isValue
(
yMin
)
?
yMin
:
isValue
(
yMax
)
?
(
yDomainMin
<
yMax
?
yDomainMin
:
yMax
-
10
)
:
yDomainMin
;
yDomainMax
=
isValue
(
yMax
)
?
yMax
:
isValue
(
yMin
)
?
(
yMin
<
yDomainMax
?
yDomainMax
:
yMin
+
10
)
:
yDomainMax
;
if
(
yTargets
.
length
===
0
)
{
// use current domain if target of axisId is none
return
axisId
===
'y2'
?
$$
.
y2
.
domain
()
:
$$
.
y
.
domain
();
}
...
...
@@ -1443,21 +1445,21 @@
}
isAllPositive
=
yDomainMin
>=
0
&&
yDomainMax
>=
0
;
isAllNegative
=
yDomainMin
<=
0
&&
yDomainMax
<=
0
;
// Cancel zerobased if axis_*_min / axis_*_max specified
if
((
isValue
(
yMin
)
&&
isAllPositive
)
||
(
isValue
(
yMax
)
&&
isAllNegative
))
{
isZeroBased
=
false
;
}
// Bar/Area chart should be 0-based if all positive|negative
if
(
isZeroBased
)
{
if
(
isAllPositive
)
{
yDomainMin
=
0
;
}
if
(
isAllNegative
)
{
yDomainMax
=
0
;
}
}
domainLength
=
Math
.
abs
(
yDomainMax
-
yDomainMin
);
padding
=
padding_top
=
padding_bottom
=
domainLength
*
0.1
;
if
(
typeof
center
!==
'undefined'
)
{
yDomainAbs
=
Math
.
max
(
Math
.
abs
(
yDomainMin
),
Math
.
abs
(
yDomainMax
));
yDomainMax
=
center
+
yDomainAbs
;
...
...
@@ -1551,7 +1553,7 @@
};
c3_chart_internal_fn
.
updateXDomain
=
function
(
targets
,
withUpdateXDomain
,
withUpdateOrgXDomain
,
withTrim
,
domain
)
{
var
$$
=
this
,
config
=
$$
.
config
;
if
(
withUpdateOrgXDomain
)
{
$$
.
x
.
domain
(
domain
?
domain
:
$$
.
d3
.
extent
(
$$
.
getXDomain
(
targets
)));
$$
.
orgXDomain
=
$$
.
x
.
domain
();
...
...
@@ -1563,10 +1565,10 @@
$$
.
x
.
domain
(
domain
?
domain
:
(
!
$$
.
brush
||
$$
.
brush
.
empty
())
?
$$
.
orgXDomain
:
$$
.
brush
.
extent
());
if
(
config
.
zoom_enabled
)
{
$$
.
zoom
.
scale
(
$$
.
x
).
updateScaleExtent
();
}
}
// Trim domain when too big by zoom mousemove event
if
(
withTrim
)
{
$$
.
x
.
domain
(
$$
.
trimXDomain
(
$$
.
x
.
orgDomain
()));
}
return
$$
.
x
.
domain
();
};
c3_chart_internal_fn
.
trimXDomain
=
function
(
domain
)
{
...
...
@@ -1876,21 +1878,21 @@
}
return
sames
;
};
c3_chart_internal_fn
.
findClosestFromTargets
=
function
(
targets
,
pos
)
{
var
$$
=
this
,
candidates
;
// map to array of closest points of each target
candidates
=
targets
.
map
(
function
(
target
)
{
return
$$
.
findClosest
(
target
.
values
,
pos
);
});
// decide closest point and return
return
$$
.
findClosest
(
candidates
,
pos
);
};
c3_chart_internal_fn
.
findClosest
=
function
(
values
,
pos
)
{
var
$$
=
this
,
minDist
=
100
,
closest
;
// find mouseovering bar
values
.
filter
(
function
(
v
)
{
return
v
&&
$$
.
isBarType
(
v
.
id
);
}).
forEach
(
function
(
v
)
{
var
shape
=
$$
.
main
.
select
(
'.'
+
CLASS
.
bars
+
$$
.
getTargetSelectorSuffix
(
v
.
id
)
+
' .'
+
CLASS
.
bar
+
'-'
+
v
.
index
).
node
();
...
...
@@ -1898,7 +1900,7 @@
closest
=
v
;
}
});
// find closest point from non-bar
values
.
filter
(
function
(
v
)
{
return
v
&&
!
$$
.
isBarType
(
v
.
id
);
}).
forEach
(
function
(
v
)
{
var
d
=
$$
.
dist
(
v
,
pos
);
...
...
@@ -1907,7 +1909,7 @@
closest
=
v
;
}
});
return
closest
;
};
c3_chart_internal_fn
.
dist
=
function
(
data
,
pos
)
{
...
...
@@ -1920,15 +1922,15 @@
};
c3_chart_internal_fn
.
convertValuesToStep
=
function
(
values
)
{
var
converted
=
[].
concat
(
values
),
i
;
if
(
!
this
.
isCategorized
())
{
return
values
;
}
for
(
i
=
values
.
length
+
1
;
0
<
i
;
i
--
)
{
converted
[
i
]
=
converted
[
i
-
1
];
}
converted
[
0
]
=
{
x
:
converted
[
0
].
x
-
1
,
value
:
converted
[
0
].
value
,
...
...
@@ -1939,7 +1941,7 @@
value
:
converted
[
values
.
length
].
value
,
id
:
converted
[
values
.
length
].
id
};
return
converted
;
};
c3_chart_internal_fn
.
updateDataAttributes
=
function
(
name
,
attrs
)
{
...
...
@@ -2051,11 +2053,11 @@
ids
=
$$
.
d3
.
keys
(
data
[
0
]).
filter
(
$$
.
isNotX
,
$$
),
xs
=
$$
.
d3
.
keys
(
data
[
0
]).
filter
(
$$
.
isX
,
$$
),
targets
;
// save x for update data by load when custom x and c3.x API
ids
.
forEach
(
function
(
id
)
{
var
xKey
=
$$
.
getXKey
(
id
);
if
(
$$
.
isCustomX
()
||
$$
.
isTimeSeries
())
{
// if included in input data
if
(
xs
.
indexOf
(
xKey
)
>=
0
)
{
...
...
@@ -2078,15 +2080,15 @@
$$
.
data
.
xs
[
id
]
=
data
.
map
(
function
(
d
,
i
)
{
return
i
;
});
}
});
// check x is defined
ids
.
forEach
(
function
(
id
)
{
if
(
!
$$
.
data
.
xs
[
id
])
{
throw
new
Error
(
'x is not defined for id = "'
+
id
+
'".'
);
}
});
// convert to target
targets
=
ids
.
map
(
function
(
id
,
index
)
{
var
convertedId
=
config
.
data_idConverter
(
id
);
...
...
@@ -2108,7 +2110,7 @@
}).
filter
(
function
(
v
)
{
return
isDefined
(
v
.
x
);
})
};
});
// finish targets
targets
.
forEach
(
function
(
t
)
{
var
i
;
...
...
@@ -2130,17 +2132,17 @@
return
v1
-
v2
;
});
});
// set target types
if
(
config
.
data_type
)
{
$$
.
setTargetType
(
$$
.
mapToIds
(
targets
).
filter
(
function
(
id
)
{
return
!
(
id
in
config
.
data_types
);
}),
config
.
data_type
);
}
// cache as original id keyed
targets
.
forEach
(
function
(
d
)
{
$$
.
addCache
(
d
.
id_org
,
d
);
});
return
targets
;
};
...
...
@@ -2170,13 +2172,13 @@
});
$$
.
data
.
targets
=
$$
.
data
.
targets
.
concat
(
targets
);
// add remained
}
// Set targets
$$
.
updateTargets
(
$$
.
data
.
targets
);
// Redraw with new targets
$$
.
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
if
(
args
.
done
)
{
args
.
done
();
}
};
c3_chart_internal_fn
.
loadFromArgs
=
function
(
args
)
{
...
...
@@ -2248,19 +2250,19 @@
var
$$
=
this
,
config
=
$$
.
config
,
eventRectUpdate
,
maxDataCountTarget
,
isMultipleX
=
$$
.
isMultipleX
();
// rects for mouseover
var
eventRects
=
$$
.
main
.
select
(
'.'
+
CLASS
.
eventRects
)
.
style
(
'cursor'
,
config
.
zoom_enabled
?
config
.
axis_rotated
?
'ns-resize'
:
'ew-resize'
:
null
)
.
classed
(
CLASS
.
eventRectsMultiple
,
isMultipleX
)
.
classed
(
CLASS
.
eventRectsSingle
,
!
isMultipleX
);
// clear old rects
eventRects
.
selectAll
(
'.'
+
CLASS
.
eventRect
).
remove
();
// open as public variable
$$
.
eventRect
=
eventRects
.
selectAll
(
'.'
+
CLASS
.
eventRect
);
if
(
isMultipleX
)
{
eventRectUpdate
=
$$
.
eventRect
.
data
([
0
]);
// enter : only one rect will be added
...
...
@@ -2286,10 +2288,10 @@
c3_chart_internal_fn
.
updateEventRect
=
function
(
eventRectUpdate
)
{
var
$$
=
this
,
config
=
$$
.
config
,
x
,
y
,
w
,
h
,
rectW
,
rectX
;
// set update selection if null
eventRectUpdate
=
eventRectUpdate
||
$$
.
eventRect
.
data
(
function
(
d
)
{
return
d
;
});
if
(
$$
.
isMultipleX
())
{
// TODO: rotated not supported yet
x
=
0
;
...
...
@@ -2299,34 +2301,34 @@
}
else
{
if
((
$$
.
isCustomX
()
||
$$
.
isTimeSeries
())
&&
!
$$
.
isCategorized
())
{
// update index for x that is used by prevX and nextX
$$
.
updateXs
();
rectW
=
function
(
d
)
{
var
prevX
=
$$
.
getPrevX
(
d
.
index
),
nextX
=
$$
.
getNextX
(
d
.
index
);
// if there this is a single data point make the eventRect full width (or height)
if
(
prevX
===
null
&&
nextX
===
null
)
{
return
config
.
axis_rotated
?
$$
.
height
:
$$
.
width
;
}
if
(
prevX
===
null
)
{
prevX
=
$$
.
x
.
domain
()[
0
];
}
if
(
nextX
===
null
)
{
nextX
=
$$
.
x
.
domain
()[
1
];
}
return
Math
.
max
(
0
,
(
$$
.
x
(
nextX
)
-
$$
.
x
(
prevX
))
/
2
);
};
rectX
=
function
(
d
)
{
var
prevX
=
$$
.
getPrevX
(
d
.
index
),
nextX
=
$$
.
getNextX
(
d
.
index
),
thisX
=
$$
.
data
.
xs
[
d
.
id
][
d
.
index
];
// if there this is a single data point position the eventRect at 0
if
(
prevX
===
null
&&
nextX
===
null
)
{
return
0
;
}
if
(
prevX
===
null
)
{
prevX
=
$$
.
x
.
domain
()[
0
];
}
return
(
$$
.
x
(
thisX
)
+
$$
.
x
(
prevX
))
/
2
;
};
}
else
{
...
...
@@ -2340,7 +2342,7 @@
w
=
config
.
axis_rotated
?
$$
.
width
:
rectW
;
h
=
config
.
axis_rotated
?
rectW
:
$$
.
height
;
}
eventRectUpdate
.
attr
(
'class'
,
$$
.
classEvent
.
bind
(
$$
))
.
attr
(
"x"
,
x
)
...
...
@@ -2355,14 +2357,14 @@
.
style
(
"cursor"
,
config
.
data_selection_enabled
&&
config
.
data_selection_grouped
?
"pointer"
:
null
)
.
on
(
'mouseover'
,
function
(
d
)
{
var
index
=
d
.
index
;
if
(
$$
.
dragging
||
$$
.
flowing
)
{
return
;
}
// do nothing while dragging/flowing
if
(
$$
.
hasArcType
())
{
return
;
}
// Expand shapes for selection
if
(
config
.
point_focus_expand_enabled
)
{
$$
.
expandCircles
(
index
,
null
,
true
);
}
$$
.
expandBars
(
index
,
null
,
true
);
// Call event handler
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shape
+
'-'
+
index
).
each
(
function
(
d
)
{
config
.
data_onmouseover
.
call
(
$$
.
api
,
d
);
...
...
@@ -2385,28 +2387,28 @@
.
on
(
'mousemove'
,
function
(
d
)
{
var
selectedData
,
index
=
d
.
index
,
eventRect
=
$$
.
svg
.
select
(
'.'
+
CLASS
.
eventRect
+
'-'
+
index
);
if
(
$$
.
dragging
||
$$
.
flowing
)
{
return
;
}
// do nothing while dragging/flowing
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
$$
.
isStepType
(
d
)
&&
$$
.
config
.
line_step_type
===
'step-after'
&&
d3
.
mouse
(
this
)[
0
]
<
$$
.
x
(
$$
.
getXValue
(
d
.
id
,
index
)))
{
index
-=
1
;
}
// Show tooltip
selectedData
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
).
map
(
function
(
t
)
{
return
$$
.
addName
(
$$
.
getValueOnIndex
(
t
.
values
,
index
));
});
if
(
config
.
tooltip_grouped
)
{
$$
.
showTooltip
(
selectedData
,
this
);
$$
.
showXGridFocus
(
selectedData
);
}
if
(
config
.
tooltip_grouped
&&
(
!
config
.
data_selection_enabled
||
config
.
data_selection_grouped
))
{
return
;
}
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shape
+
'-'
+
index
)
.
each
(
function
()
{
d3
.
select
(
this
).
classed
(
CLASS
.
EXPANDED
,
true
);
...
...
@@ -2463,10 +2465,10 @@
)
:
function
()
{}
);
};
c3_chart_internal_fn
.
generateEventRectsForMultipleXs
=
function
(
eventRectEnter
)
{
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
function
mouseout
()
{
$$
.
svg
.
select
(
'.'
+
CLASS
.
eventRect
).
style
(
'cursor'
,
null
);
$$
.
hideXGridFocus
();
...
...
@@ -2474,7 +2476,7 @@
$$
.
unexpandCircles
();
$$
.
unexpandBars
();
}
eventRectEnter
.
append
(
'rect'
)
.
attr
(
'x'
,
0
)
.
attr
(
'y'
,
0
)
...
...
@@ -2489,44 +2491,44 @@
.
on
(
'mousemove'
,
function
()
{
var
targetsToShow
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
);
var
mouse
,
closest
,
sameXData
,
selectedData
;
if
(
$$
.
dragging
)
{
return
;
}
// do nothing when dragging
if
(
$$
.
hasArcType
(
targetsToShow
))
{
return
;
}
mouse
=
d3
.
mouse
(
this
);
closest
=
$$
.
findClosestFromTargets
(
targetsToShow
,
mouse
);
if
(
$$
.
mouseover
&&
(
!
closest
||
closest
.
id
!==
$$
.
mouseover
.
id
))
{
config
.
data_onmouseout
.
call
(
$$
.
api
,
$$
.
mouseover
);
$$
.
mouseover
=
undefined
;
}
if
(
!
closest
)
{
mouseout
();
return
;
}
if
(
$$
.
isScatterType
(
closest
)
||
!
config
.
tooltip_grouped
)
{
sameXData
=
[
closest
];
}
else
{
sameXData
=
$$
.
filterByX
(
targetsToShow
,
closest
.
x
);
}
// show tooltip when cursor is close to some point
selectedData
=
sameXData
.
map
(
function
(
d
)
{
return
$$
.
addName
(
d
);
});
$$
.
showTooltip
(
selectedData
,
this
);
// expand points
if
(
config
.
point_focus_expand_enabled
)
{
$$
.
expandCircles
(
closest
.
index
,
closest
.
id
,
true
);
}
$$
.
expandBars
(
closest
.
index
,
closest
.
id
,
true
);
// Show xgrid focus line
$$
.
showXGridFocus
(
selectedData
);
// Show cursor as pointer if point is close to mouse position
if
(
$$
.
isBarType
(
closest
.
id
)
||
$$
.
dist
(
closest
,
mouse
)
<
100
)
{
$$
.
svg
.
select
(
'.'
+
CLASS
.
eventRect
).
style
(
'cursor'
,
'pointer'
);
...
...
@@ -2539,14 +2541,14 @@
.
on
(
'click'
,
function
()
{
var
targetsToShow
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
);
var
mouse
,
closest
;
if
(
$$
.
hasArcType
(
targetsToShow
))
{
return
;
}
mouse
=
d3
.
mouse
(
this
);
closest
=
$$
.
findClosestFromTargets
(
targetsToShow
,
mouse
);
if
(
!
closest
)
{
return
;
}
// select if selection enabled
if
(
$$
.
isBarType
(
closest
.
id
)
||
$$
.
dist
(
closest
,
mouse
)
<
100
)
{
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shapes
+
$$
.
getTargetSelectorSuffix
(
closest
.
id
)).
selectAll
(
'.'
+
CLASS
.
shape
+
'-'
+
closest
.
index
).
each
(
function
()
{
...
...
@@ -2574,7 +2576,7 @@
x
=
box
.
left
+
(
mouse
?
mouse
[
0
]
:
0
),
y
=
box
.
top
+
(
mouse
?
mouse
[
1
]
:
0
),
event
=
document
.
createEvent
(
"MouseEvents"
);
event
.
initMouseEvent
(
type
,
true
,
true
,
window
,
0
,
x
,
y
,
x
,
y
,
false
,
false
,
false
,
false
,
0
,
null
);
eventRect
.
dispatchEvent
(
event
);
...
...
@@ -2627,7 +2629,7 @@
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y2'
))
+
legendWidthOnRight
;
}
};
c3_chart_internal_fn
.
getParentRectValue
=
function
(
key
)
{
var
parent
=
this
.
selectChart
.
node
(),
v
;
while
(
parent
&&
parent
.
tagName
!==
'BODY'
)
{
...
...
@@ -2654,8 +2656,8 @@
var
h
=
this
.
selectChart
.
style
(
'height'
);
return
h
.
indexOf
(
'px'
)
>
0
?
+
h
.
replace
(
'px'
,
''
)
:
0
;
};
c3_chart_internal_fn
.
getSvgLeft
=
function
(
withoutRecompute
)
{
var
$$
=
this
,
config
=
$$
.
config
,
hasLeftAxisRect
=
config
.
axis_rotated
||
(
!
config
.
axis_rotated
&&
!
config
.
axis_y_inner
),
...
...
@@ -2667,8 +2669,8 @@
svgLeft
=
svgRect
.
right
-
chartRect
.
left
-
(
hasArc
?
0
:
$$
.
getCurrentPaddingLeft
(
withoutRecompute
));
return
svgLeft
>
0
?
svgLeft
:
0
;
};
c3_chart_internal_fn
.
getAxisWidthByAxisId
=
function
(
id
,
withoutRecompute
)
{
var
$$
=
this
,
position
=
$$
.
axis
.
getLabelPositionById
(
id
);
return
$$
.
axis
.
getMaxTickWidth
(
id
,
withoutRecompute
)
+
(
position
.
isInner
?
20
:
40
);
...
...
@@ -2685,7 +2687,7 @@
}
return
h
+
(
$$
.
axis
.
getLabelPositionById
(
axisId
).
isInner
?
0
:
10
)
+
(
axisId
===
'y2'
?
-
10
:
0
);
};
c3_chart_internal_fn
.
getEventRectWidth
=
function
()
{
return
Math
.
max
(
0
,
this
.
xAxis
.
tickInterval
());
};
...
...
@@ -2755,8 +2757,8 @@
}
return
isWithin
;
};
c3_chart_internal_fn
.
getInterpolate
=
function
(
d
)
{
var
$$
=
this
;
return
$$
.
isSplineType
(
d
)
?
"cardinal"
:
$$
.
isStepType
(
d
)
?
$$
.
config
.
line_step_type
:
"linear"
;
...
...
@@ -2835,7 +2837,7 @@
yValue
=
function
(
d
,
i
)
{
return
config
.
data_groups
.
length
>
0
?
getPoints
(
d
,
i
)[
0
][
1
]
:
yScaleGetter
.
call
(
$$
,
d
.
id
)(
d
.
value
);
};
line
=
config
.
axis_rotated
?
line
.
x
(
yValue
).
y
(
xValue
)
:
line
.
x
(
xValue
).
y
(
yValue
);
if
(
!
config
.
line_connectNull
)
{
line
=
line
.
defined
(
function
(
d
)
{
return
d
.
value
!=
null
;
});
}
return
function
(
d
)
{
...
...
@@ -2882,8 +2884,8 @@
];
};
};
c3_chart_internal_fn
.
lineWithRegions
=
function
(
d
,
x
,
y
,
_regions
)
{
var
$$
=
this
,
config
=
$$
.
config
,
prev
=
-
1
,
i
,
j
,
...
...
@@ -2892,7 +2894,7 @@
xOffset
=
$$
.
isCategorized
()
?
0.5
:
0
,
xValue
,
yValue
,
regions
=
[];
function
isWithinRegions
(
x
,
regions
)
{
var
i
;
for
(
i
=
0
;
i
<
regions
.
length
;
i
++
)
{
...
...
@@ -2900,7 +2902,7 @@
}
return
false
;
}
// Check start/end of regions
if
(
isDefined
(
_regions
))
{
for
(
i
=
0
;
i
<
_regions
.
length
;
i
++
)
{
...
...
@@ -2917,11 +2919,11 @@
}
}
}
// Set scales
xValue
=
config
.
axis_rotated
?
function
(
d
)
{
return
y
(
d
.
value
);
}
:
function
(
d
)
{
return
x
(
d
.
x
);
};
yValue
=
config
.
axis_rotated
?
function
(
d
)
{
return
x
(
d
.
x
);
}
:
function
(
d
)
{
return
y
(
d
.
value
);
};
// Define svg generator function for region
function
generateM
(
points
)
{
return
'M'
+
points
[
0
][
0
]
+
' '
+
points
[
0
][
1
]
+
' '
+
points
[
1
][
0
]
+
' '
+
points
[
1
][
1
];
...
...
@@ -2950,10 +2952,10 @@
return
generateM
(
points
);
};
}
// Generate
for
(
i
=
0
;
i
<
d
.
length
;
i
++
)
{
// Draw as normal
if
(
isUndefined
(
regions
)
||
!
isWithinRegions
(
d
[
i
].
x
,
regions
))
{
s
+=
" "
+
xValue
(
d
[
i
])
+
" "
+
yValue
(
d
[
i
]);
...
...
@@ -2962,24 +2964,24 @@
else
{
xp
=
$$
.
getScale
(
d
[
i
-
1
].
x
+
xOffset
,
d
[
i
].
x
+
xOffset
,
$$
.
isTimeSeries
());
yp
=
$$
.
getScale
(
d
[
i
-
1
].
value
,
d
[
i
].
value
);
dx
=
x
(
d
[
i
].
x
)
-
x
(
d
[
i
-
1
].
x
);
dy
=
y
(
d
[
i
].
value
)
-
y
(
d
[
i
-
1
].
value
);
dd
=
Math
.
sqrt
(
Math
.
pow
(
dx
,
2
)
+
Math
.
pow
(
dy
,
2
));
diff
=
2
/
dd
;
diffx2
=
diff
*
2
;
for
(
j
=
diff
;
j
<=
1
;
j
+=
diffx2
)
{
s
+=
sWithRegion
(
d
[
i
-
1
],
d
[
i
],
j
,
diff
);
}
}
prev
=
d
[
i
].
x
;
}
return
s
;
};
c3_chart_internal_fn
.
updateArea
=
function
(
durationForExit
)
{
var
$$
=
this
,
d3
=
$$
.
d3
;
$$
.
mainArea
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
areas
).
selectAll
(
'.'
+
CLASS
.
area
)
...
...
@@ -3013,12 +3015,12 @@
value1
=
function
(
d
,
i
)
{
return
config
.
data_groups
.
length
>
0
?
getPoints
(
d
,
i
)[
1
][
1
]
:
yScaleGetter
.
call
(
$$
,
d
.
id
)(
d
.
value
);
};
area
=
config
.
axis_rotated
?
area
.
x0
(
value0
).
x1
(
value1
).
y
(
xValue
)
:
area
.
x
(
xValue
).
y0
(
value0
).
y1
(
value1
);
if
(
!
config
.
line_connectNull
)
{
area
=
area
.
defined
(
function
(
d
)
{
return
d
.
value
!==
null
;
});
}
return
function
(
d
)
{
var
values
=
config
.
line_connectNull
?
$$
.
filterRemoveNull
(
d
.
values
)
:
d
.
values
,
x0
=
0
,
y0
=
0
,
path
;
...
...
@@ -3062,8 +3064,8 @@
];
};
};
c3_chart_internal_fn
.
updateCircle
=
function
()
{
var
$$
=
this
;
$$
.
mainCircle
=
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
circles
).
selectAll
(
'.'
+
CLASS
.
circle
)
...
...
@@ -3170,7 +3172,7 @@
mainBarEnter
.
append
(
'g'
)
.
attr
(
"class"
,
classBars
)
.
style
(
"cursor"
,
function
(
d
)
{
return
config
.
data_selection_isselectable
(
d
)
?
"pointer"
:
null
;
});
};
c3_chart_internal_fn
.
updateBar
=
function
(
durationForExit
)
{
var
$$
=
this
,
...
...
@@ -3222,17 +3224,17 @@
return
function
(
d
,
i
)
{
// 4 points that make a bar
var
points
=
getPoints
(
d
,
i
);
// switch points if axis is rotated, not applicable for sub chart
var
indexX
=
config
.
axis_rotated
?
1
:
0
;
var
indexY
=
config
.
axis_rotated
?
0
:
1
;
var
path
=
'M '
+
points
[
0
][
indexX
]
+
','
+
points
[
0
][
indexY
]
+
' '
+
'L'
+
points
[
1
][
indexX
]
+
','
+
points
[
1
][
indexY
]
+
' '
+
'L'
+
points
[
2
][
indexX
]
+
','
+
points
[
2
][
indexY
]
+
' '
+
'L'
+
points
[
3
][
indexX
]
+
','
+
points
[
3
][
indexY
]
+
' '
+
'z'
;
return
path
;
};
};
...
...
@@ -3519,7 +3521,7 @@
var
$$
=
this
,
config
=
$$
.
config
,
d3
=
$$
.
d3
,
xgridData
=
$$
.
generateGridData
(
config
.
grid_x_type
,
$$
.
x
),
tickOffset
=
$$
.
isCategorized
()
?
$$
.
xAxis
.
tickOffset
()
:
0
;
$$
.
xgridAttr
=
config
.
axis_rotated
?
{
'x1'
:
0
,
'x2'
:
$$
.
width
,
...
...
@@ -3531,7 +3533,7 @@
'y1'
:
0
,
'y2'
:
$$
.
height
};
$$
.
xgrid
=
$$
.
main
.
select
(
'.'
+
CLASS
.
xgrids
).
selectAll
(
'.'
+
CLASS
.
xgrid
)
.
data
(
xgridData
);
$$
.
xgrid
.
enter
().
append
(
'line'
).
attr
(
"class"
,
CLASS
.
xgrid
);
...
...
@@ -3541,7 +3543,7 @@
}
$$
.
xgrid
.
exit
().
remove
();
};
c3_chart_internal_fn
.
updateYGrid
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
gridValues
=
$$
.
yAxis
.
tickValues
()
||
$$
.
y
.
ticks
(
config
.
grid_y_ticks
);
...
...
@@ -3556,7 +3558,7 @@
$$
.
ygrid
.
exit
().
remove
();
$$
.
smoothLines
(
$$
.
ygrid
,
'grid'
);
};
c3_chart_internal_fn
.
gridTextAnchor
=
function
(
d
)
{
return
d
.
position
?
d
.
position
:
"end"
;
};
...
...
@@ -3572,10 +3574,10 @@
c3_chart_internal_fn
.
updateGrid
=
function
(
duration
)
{
var
$$
=
this
,
main
=
$$
.
main
,
config
=
$$
.
config
,
xgridLine
,
ygridLine
,
yv
;
// hide if arc type
$$
.
grid
.
style
(
'visibility'
,
$$
.
hasArcType
()
?
'hidden'
:
'visible'
);
main
.
select
(
'line.'
+
CLASS
.
xgridFocus
).
style
(
"visibility"
,
"hidden"
);
if
(
config
.
grid_x_show
)
{
$$
.
updateXGrid
();
...
...
@@ -3599,7 +3601,7 @@
$$
.
xgridLines
.
exit
().
transition
().
duration
(
duration
)
.
style
(
"opacity"
,
0
)
.
remove
();
// Y-Grid
if
(
config
.
grid_y_show
)
{
$$
.
updateYGrid
();
...
...
@@ -3761,17 +3763,17 @@
text
,
i
,
title
,
value
,
name
,
bgcolor
;
for
(
i
=
0
;
i
<
d
.
length
;
i
++
)
{
if
(
!
(
d
[
i
]
&&
(
d
[
i
].
value
||
d
[
i
].
value
===
0
)))
{
continue
;
}
if
(
!
text
)
{
title
=
titleFormat
?
titleFormat
(
d
[
i
].
x
)
:
d
[
i
].
x
;
text
=
"<table class='"
+
CLASS
.
tooltip
+
"'>"
+
(
title
||
title
===
0
?
"<tr><th colspan='2'>"
+
title
+
"</th></tr>"
:
""
);
}
value
=
valueFormat
(
d
[
i
].
value
,
d
[
i
].
ratio
,
d
[
i
].
id
,
d
[
i
].
index
);
if
(
value
!==
undefined
)
{
name
=
nameFormat
(
d
[
i
].
name
,
d
[
i
].
ratio
,
d
[
i
].
id
,
d
[
i
].
index
);
bgcolor
=
$$
.
levelColor
?
$$
.
levelColor
(
d
[
i
].
value
)
:
color
(
d
[
i
].
id
);
text
+=
"<tr class='"
+
CLASS
.
tooltipName
+
"-"
+
d
[
i
].
id
+
"'>"
;
text
+=
"<td class='name'><span style='background-color:"
+
bgcolor
+
"'></span>"
+
name
+
"</td>"
;
text
+=
"<td class='value'>"
+
value
+
"</td>"
;
...
...
@@ -3802,7 +3804,7 @@
chartRight
=
svgLeft
+
$$
.
currentWidth
-
$$
.
getCurrentPaddingRight
();
tooltipTop
=
mouse
[
1
]
+
15
;
}
if
(
tooltipRight
>
chartRight
)
{
// 20 is needed for Firefox to keep tooletip width
tooltipLeft
-=
tooltipRight
-
chartRight
+
20
;
...
...
@@ -3826,11 +3828,11 @@
return
;
}
$$
.
tooltip
.
html
(
config
.
tooltip_contents
.
call
(
$$
,
selectedData
,
$$
.
axis
.
getXAxisTickFormat
(),
$$
.
getYFormat
(
forArc
),
$$
.
color
)).
style
(
"display"
,
"block"
);
// Get tooltip dimensions
tWidth
=
$$
.
tooltip
.
property
(
'offsetWidth'
);
tHeight
=
$$
.
tooltip
.
property
(
'offsetHeight'
);
position
=
positionFunction
.
call
(
this
,
dataToShow
,
tWidth
,
tHeight
,
element
);
// Set tooltip
$$
.
tooltip
...
...
@@ -3864,7 +3866,7 @@
top
:
$$
.
isLegendTop
?
$$
.
getCurrentPaddingTop
()
+
config
.
legend_inset_y
+
5.5
:
$$
.
currentHeight
-
legendHeight
-
$$
.
getCurrentPaddingBottom
()
-
config
.
legend_inset_y
,
left
:
$$
.
isLegendLeft
?
$$
.
getCurrentPaddingLeft
()
+
config
.
legend_inset_x
+
0.5
:
$$
.
currentWidth
-
legendWidth
-
$$
.
getCurrentPaddingRight
()
-
config
.
legend_inset_x
+
0.5
};
$$
.
margin3
=
{
top
:
$$
.
isLegendRight
?
0
:
$$
.
isLegendInset
?
insetLegendPosition
.
top
:
$$
.
currentHeight
-
legendHeight
,
right
:
NaN
,
...
...
@@ -3961,18 +3963,18 @@
var
l
,
totalLength
=
0
,
offsets
=
{},
widths
=
{},
heights
=
{},
margins
=
[
0
],
steps
=
{},
step
=
0
;
var
withTransition
,
withTransitionForTransform
;
var
texts
,
rects
,
tiles
,
background
;
options
=
options
||
{};
withTransition
=
getOption
(
options
,
"withTransition"
,
true
);
withTransitionForTransform
=
getOption
(
options
,
"withTransitionForTransform"
,
true
);
function
getTextBox
(
textElement
,
id
)
{
if
(
!
$$
.
legendItemTextBox
[
id
])
{
$$
.
legendItemTextBox
[
id
]
=
$$
.
getTextRect
(
textElement
.
textContent
,
CLASS
.
legendItem
);
}
return
$$
.
legendItemTextBox
[
id
];
}
function
updatePositions
(
textElement
,
id
,
index
)
{
var
reset
=
index
===
0
,
isLast
=
index
===
targetIds
.
length
-
1
,
box
=
getTextBox
(
textElement
,
id
),
...
...
@@ -3981,7 +3983,7 @@
itemLength
=
$$
.
isLegendRight
||
$$
.
isLegendInset
?
itemHeight
:
itemWidth
,
areaLength
=
$$
.
isLegendRight
||
$$
.
isLegendInset
?
$$
.
getLegendHeight
()
:
$$
.
getLegendWidth
(),
margin
,
maxLength
;
// MEMO: care about condifion of step, totalLength
function
updateValues
(
id
,
withoutStep
)
{
if
(
!
withoutStep
)
{
...
...
@@ -3997,26 +3999,26 @@
offsets
[
id
]
=
totalLength
;
totalLength
+=
itemLength
;
}
if
(
reset
)
{
totalLength
=
0
;
step
=
0
;
maxWidth
=
0
;
maxHeight
=
0
;
}
if
(
config
.
legend_show
&&
!
$$
.
isLegendToShow
(
id
))
{
widths
[
id
]
=
heights
[
id
]
=
steps
[
id
]
=
offsets
[
id
]
=
0
;
return
;
}
widths
[
id
]
=
itemWidth
;
heights
[
id
]
=
itemHeight
;
if
(
!
maxWidth
||
itemWidth
>=
maxWidth
)
{
maxWidth
=
itemWidth
;
}
if
(
!
maxHeight
||
itemHeight
>=
maxHeight
)
{
maxHeight
=
itemHeight
;
}
maxLength
=
$$
.
isLegendRight
||
$$
.
isLegendInset
?
maxHeight
:
maxWidth
;
if
(
config
.
legend_equally
)
{
Object
.
keys
(
widths
).
forEach
(
function
(
id
)
{
widths
[
id
]
=
maxWidth
;
});
Object
.
keys
(
heights
).
forEach
(
function
(
id
)
{
heights
[
id
]
=
maxHeight
;
});
...
...
@@ -4033,12 +4035,12 @@
updateValues
(
id
);
}
}
if
(
$$
.
isLegendInset
)
{
step
=
config
.
legend_inset_step
?
config
.
legend_inset_step
:
targetIds
.
length
;
$$
.
updateLegendStep
(
step
);
}
if
(
$$
.
isLegendRight
)
{
xForLegend
=
function
(
id
)
{
return
maxWidth
*
steps
[
id
];
};
yForLegend
=
function
(
id
)
{
return
margins
[
steps
[
id
]]
+
offsets
[
id
];
};
...
...
@@ -4053,7 +4055,7 @@
yForLegendText
=
function
(
id
,
i
)
{
return
yForLegend
(
id
,
i
)
+
9
;
};
xForLegendRect
=
function
(
id
,
i
)
{
return
xForLegend
(
id
,
i
);
};
yForLegendRect
=
function
(
id
,
i
)
{
return
yForLegend
(
id
,
i
)
-
5
;
};
// Define g for legend area
l
=
$$
.
legend
.
selectAll
(
'.'
+
CLASS
.
legendItem
)
.
data
(
targetIds
)
...
...
@@ -4109,7 +4111,7 @@
.
attr
(
'y'
,
$$
.
isLegendRight
||
$$
.
isLegendInset
?
-
200
:
yForLegend
)
.
attr
(
'width'
,
10
)
.
attr
(
'height'
,
10
);
// Set background for inset legend
background
=
$$
.
legend
.
select
(
'.'
+
CLASS
.
legendBackground
+
' rect'
);
if
(
$$
.
isLegendInset
&&
maxWidth
>
0
&&
background
.
size
()
===
0
)
{
...
...
@@ -4117,7 +4119,7 @@
.
attr
(
"class"
,
CLASS
.
legendBackground
)
.
append
(
'rect'
);
}
texts
=
$$
.
legend
.
selectAll
(
'text'
)
.
data
(
targetIds
)
.
text
(
function
(
id
)
{
return
isDefined
(
config
.
data_names
[
id
])
?
config
.
data_names
[
id
]
:
id
;
})
// MEMO: needed for update
...
...
@@ -4125,7 +4127,7 @@
(
withTransition
?
texts
.
transition
()
:
texts
)
.
attr
(
'x'
,
xForLegendText
)
.
attr
(
'y'
,
yForLegendText
);
rects
=
$$
.
legend
.
selectAll
(
'rect.'
+
CLASS
.
legendItemEvent
)
.
data
(
targetIds
);
(
withTransition
?
rects
.
transition
()
:
rects
)
...
...
@@ -4133,24 +4135,24 @@
.
attr
(
'height'
,
function
(
id
)
{
return
heights
[
id
];
})
.
attr
(
'x'
,
xForLegendRect
)
.
attr
(
'y'
,
yForLegendRect
);
tiles
=
$$
.
legend
.
selectAll
(
'rect.'
+
CLASS
.
legendItemTile
)
.
data
(
targetIds
);
(
withTransition
?
tiles
.
transition
()
:
tiles
)
.
style
(
'fill'
,
$$
.
color
)
.
attr
(
'x'
,
xForLegend
)
.
attr
(
'y'
,
yForLegend
);
if
(
background
)
{
(
withTransition
?
background
.
transition
()
:
background
)
.
attr
(
'height'
,
$$
.
getLegendHeight
()
-
12
)
.
attr
(
'width'
,
maxWidth
*
(
step
+
1
)
+
10
);
}
// toggle legend state
$$
.
legend
.
selectAll
(
'.'
+
CLASS
.
legendItem
)
.
classed
(
CLASS
.
legendItemHidden
,
function
(
id
)
{
return
!
$$
.
isTargetToShow
(
id
);
});
// Update all to reflect change of legend
$$
.
updateLegendItemWidth
(
maxWidth
);
$$
.
updateLegendItemHeight
(
maxHeight
);
...
...
@@ -4199,11 +4201,11 @@
function
Axis
(
owner
)
{
API
.
call
(
this
,
owner
);
}
inherit
(
API
,
Axis
);
Axis
.
prototype
.
init
=
function
init
()
{
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
main
=
$$
.
main
;
$$
.
axes
.
x
=
main
.
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisX
)
...
...
@@ -4223,7 +4225,7 @@
.
attr
(
"class"
,
CLASS
.
axisYLabel
)
.
attr
(
"transform"
,
config
.
axis_rotated
?
""
:
"rotate(-90)"
)
.
style
(
"text-anchor"
,
this
.
textAnchorForYAxisLabel
.
bind
(
this
));
$$
.
axes
.
y2
=
main
.
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisY2
)
// clip-path?
...
...
@@ -4245,11 +4247,11 @@
withoutTransition
:
withoutTransition
,
},
axis
=
c3_axis
(
$$
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
);
if
(
$$
.
isTimeSeries
()
&&
tickValues
)
{
tickValues
=
tickValues
.
map
(
function
(
v
)
{
return
$$
.
parseDate
(
v
);
});
}
// Set tick
axis
.
tickFormat
(
tickFormat
).
tickValues
(
tickValues
);
if
(
$$
.
isCategorized
())
{
...
...
@@ -4258,7 +4260,7 @@
config
.
axis_x_tick_culling
=
false
;
}
}
return
axis
;
};
Axis
.
prototype
.
updateXAxisTickValues
=
function
updateXAxisTickValues
(
targets
,
axis
)
{
...
...
@@ -4496,7 +4498,7 @@
$$
.
currentMaxTickWidths
[
id
]
=
maxWidth
<=
0
?
$$
.
currentMaxTickWidths
[
id
]
:
maxWidth
;
return
$$
.
currentMaxTickWidths
[
id
];
};
Axis
.
prototype
.
updateLabels
=
function
updateLabels
(
withTransition
)
{
var
$$
=
this
.
owner
;
var
axisXLabel
=
$$
.
main
.
select
(
'.'
+
CLASS
.
axisX
+
' .'
+
CLASS
.
axisXLabel
),
...
...
@@ -4648,7 +4650,7 @@
$$
.
pie
.
sort
(
null
);
}
};
c3_chart_internal_fn
.
updateRadius
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
w
=
config
.
gauge_width
||
config
.
donut_width
;
...
...
@@ -4657,14 +4659,14 @@
$$
.
innerRadiusRatio
=
w
?
(
$$
.
radius
-
w
)
/
$$
.
radius
:
0.6
;
$$
.
innerRadius
=
$$
.
hasType
(
'donut'
)
||
$$
.
hasType
(
'gauge'
)
?
$$
.
radius
*
$$
.
innerRadiusRatio
:
0
;
};
c3_chart_internal_fn
.
updateArc
=
function
()
{
var
$$
=
this
;
$$
.
svgArc
=
$$
.
getSvgArc
();
$$
.
svgArcExpanded
=
$$
.
getSvgArcExpanded
();
$$
.
svgArcExpandedSub
=
$$
.
getSvgArcExpanded
(
0.98
);
};
c3_chart_internal_fn
.
updateAngle
=
function
(
d
)
{
var
$$
=
this
,
config
=
$$
.
config
,
found
=
false
,
index
=
0
,
...
...
@@ -4691,7 +4693,7 @@
}
return
found
?
d
:
null
;
};
c3_chart_internal_fn
.
getSvgArc
=
function
()
{
var
$$
=
this
,
arc
=
$$
.
d3
.
svg
.
arc
().
outerRadius
(
$$
.
radius
).
innerRadius
(
$$
.
innerRadius
),
...
...
@@ -4705,7 +4707,7 @@
newArc
.
centroid
=
arc
.
centroid
;
return
newArc
;
};
c3_chart_internal_fn
.
getSvgArcExpanded
=
function
(
rate
)
{
var
$$
=
this
,
arc
=
$$
.
d3
.
svg
.
arc
().
outerRadius
(
$$
.
radiusExpanded
*
(
rate
?
rate
:
1
)).
innerRadius
(
$$
.
innerRadius
);
...
...
@@ -4714,12 +4716,12 @@
return
updated
?
arc
(
updated
)
:
"M 0 0"
;
};
};
c3_chart_internal_fn
.
getArc
=
function
(
d
,
withoutUpdate
,
force
)
{
return
force
||
this
.
isArcType
(
d
.
data
)
?
this
.
svgArc
(
d
,
withoutUpdate
)
:
"M 0 0"
;
};
c3_chart_internal_fn
.
transformForArcLabel
=
function
(
d
)
{
var
$$
=
this
,
updated
=
$$
.
updateAngle
(
d
),
c
,
x
,
y
,
h
,
ratio
,
translate
=
""
;
...
...
@@ -4734,13 +4736,13 @@
}
return
translate
;
};
c3_chart_internal_fn
.
getArcRatio
=
function
(
d
)
{
var
$$
=
this
,
whole
=
$$
.
hasType
(
'gauge'
)
?
Math
.
PI
:
(
Math
.
PI
*
2
);
return
d
?
(
d
.
endAngle
-
d
.
startAngle
)
/
whole
:
null
;
};
c3_chart_internal_fn
.
convertToArcData
=
function
(
d
)
{
return
this
.
addName
({
id
:
d
.
data
.
id
,
...
...
@@ -4749,7 +4751,7 @@
index
:
d
.
index
});
};
c3_chart_internal_fn
.
textForArcLabel
=
function
(
d
)
{
var
$$
=
this
,
updated
,
value
,
ratio
,
id
,
format
;
...
...
@@ -4762,10 +4764,10 @@
format
=
$$
.
getArcLabelFormat
();
return
format
?
format
(
value
,
ratio
,
id
)
:
$$
.
defaultArcValueFormat
(
value
,
ratio
);
};
c3_chart_internal_fn
.
expandArc
=
function
(
targetIds
)
{
var
$$
=
this
,
interval
;
// MEMO: avoid to cancel transition
if
(
$$
.
transiting
)
{
interval
=
window
.
setInterval
(
function
()
{
...
...
@@ -4778,9 +4780,9 @@
},
10
);
return
;
}
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
,
'.'
+
CLASS
.
chartArc
)).
each
(
function
(
d
)
{
if
(
!
$$
.
shouldExpand
(
d
.
data
.
id
))
{
return
;
}
$$
.
d3
.
select
(
this
).
selectAll
(
'path'
)
...
...
@@ -4795,26 +4797,26 @@
});
});
};
c3_chart_internal_fn
.
unexpandArc
=
function
(
targetIds
)
{
var
$$
=
this
;
if
(
$$
.
transiting
)
{
return
;
}
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
,
'.'
+
CLASS
.
chartArc
)).
selectAll
(
'path'
)
.
transition
().
duration
(
50
)
.
attr
(
"d"
,
$$
.
svgArc
);
$$
.
svg
.
selectAll
(
'.'
+
CLASS
.
arc
)
.
style
(
"opacity"
,
1
);
};
c3_chart_internal_fn
.
shouldExpand
=
function
(
id
)
{
var
$$
=
this
,
config
=
$$
.
config
;
return
(
$$
.
isDonutType
(
id
)
&&
config
.
donut_expand
)
||
(
$$
.
isGaugeType
(
id
)
&&
config
.
gauge_expand
)
||
(
$$
.
isPieType
(
id
)
&&
config
.
pie_expand
);
};
c3_chart_internal_fn
.
shouldShowArcLabel
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
shouldShow
=
true
;
if
(
$$
.
hasType
(
'donut'
))
{
...
...
@@ -4825,13 +4827,13 @@
// when gauge, always true
return
shouldShow
;
};
c3_chart_internal_fn
.
meetsArcLabelThreshold
=
function
(
ratio
)
{
var
$$
=
this
,
config
=
$$
.
config
,
threshold
=
$$
.
hasType
(
'donut'
)
?
config
.
donut_label_threshold
:
config
.
pie_label_threshold
;
return
ratio
>=
threshold
;
};
c3_chart_internal_fn
.
getArcLabelFormat
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
format
=
config
.
pie_label_format
;
...
...
@@ -4842,12 +4844,12 @@
}
return
format
;
};
c3_chart_internal_fn
.
getArcTitle
=
function
()
{
var
$$
=
this
;
return
$$
.
hasType
(
'donut'
)
?
$$
.
config
.
donut_title
:
""
;
};
c3_chart_internal_fn
.
updateTargetsForArc
=
function
(
targets
)
{
var
$$
=
this
,
main
=
$$
.
main
,
mainPieUpdate
,
mainPieEnter
,
...
...
@@ -4869,7 +4871,7 @@
// MEMO: can not keep same color..., but not bad to update color in redraw
//mainPieUpdate.exit().remove();
};
c3_chart_internal_fn
.
initArc
=
function
()
{
var
$$
=
this
;
$$
.
arcs
=
$$
.
main
.
select
(
'.'
+
CLASS
.
chart
).
append
(
"g"
)
...
...
@@ -4880,7 +4882,7 @@
.
style
(
"text-anchor"
,
"middle"
)
.
text
(
$$
.
getArcTitle
());
};
c3_chart_internal_fn
.
redrawArc
=
function
(
duration
,
durationForExit
,
withTransform
)
{
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
main
=
$$
.
main
,
mainArc
;
...
...
@@ -4987,7 +4989,7 @@
.
style
(
"opacity"
,
function
(
d
)
{
return
$$
.
isTargetToShow
(
d
.
data
.
id
)
&&
$$
.
isArcType
(
d
.
data
)
?
1
:
0
;
});
main
.
select
(
'.'
+
CLASS
.
chartArcsTitle
)
.
style
(
"opacity"
,
$$
.
hasType
(
'donut'
)
||
$$
.
hasType
(
'gauge'
)
?
1
:
0
);
if
(
$$
.
hasType
(
'gauge'
))
{
$$
.
arcs
.
select
(
'.'
+
CLASS
.
chartArcsBackground
)
.
attr
(
"d"
,
function
()
{
...
...
@@ -5042,10 +5044,10 @@
};
c3_chart_internal_fn
.
updateRegion
=
function
(
duration
)
{
var
$$
=
this
,
config
=
$$
.
config
;
// hide if arc type
$$
.
region
.
style
(
'visibility'
,
$$
.
hasArcType
()
?
'hidden'
:
'visible'
);
$$
.
mainRegion
=
$$
.
main
.
select
(
'.'
+
CLASS
.
regions
).
selectAll
(
'.'
+
CLASS
.
region
)
.
data
(
config
.
regions
);
$$
.
mainRegion
.
enter
().
append
(
'g'
)
...
...
@@ -5119,12 +5121,12 @@
c3_chart_internal_fn
.
drag
=
function
(
mouse
)
{
var
$$
=
this
,
config
=
$$
.
config
,
main
=
$$
.
main
,
d3
=
$$
.
d3
;
var
sx
,
sy
,
mx
,
my
,
minX
,
maxX
,
minY
,
maxY
;
if
(
$$
.
hasArcType
())
{
return
;
}
if
(
!
config
.
data_selection_enabled
)
{
return
;
}
// do nothing if not selectable
if
(
config
.
zoom_enabled
&&
!
$$
.
zoom
.
altDomain
)
{
return
;
}
// skip if zoomable because of conflict drag dehavior
if
(
!
config
.
data_selection_multiple
)
{
return
;
}
// skip when single selection because drag is used for multiple selection
sx
=
$$
.
dragStart
[
0
];
sy
=
$$
.
dragStart
[
1
];
mx
=
mouse
[
0
];
...
...
@@ -5133,7 +5135,7 @@
maxX
=
Math
.
max
(
sx
,
mx
);
minY
=
(
config
.
data_selection_grouped
)
?
$$
.
margin
.
top
:
Math
.
min
(
sy
,
my
);
maxY
=
(
config
.
data_selection_grouped
)
?
$$
.
height
:
Math
.
max
(
sy
,
my
);
main
.
select
(
'.'
+
CLASS
.
dragarea
)
.
attr
(
'x'
,
minX
)
.
attr
(
'y'
,
minY
)
...
...
@@ -5173,7 +5175,7 @@
}
});
};
c3_chart_internal_fn
.
dragstart
=
function
(
mouse
)
{
var
$$
=
this
,
config
=
$$
.
config
;
if
(
$$
.
hasArcType
())
{
return
;
}
...
...
@@ -5184,7 +5186,7 @@
.
style
(
'opacity'
,
0.1
);
$$
.
dragging
=
true
;
};
c3_chart_internal_fn
.
dragend
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
;
if
(
$$
.
hasArcType
())
{
return
;
}
...
...
@@ -5261,7 +5263,7 @@
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
shape
=
d3
.
select
(
that
),
isSelected
=
shape
.
classed
(
CLASS
.
SELECTED
),
toggle
=
$$
.
getToggle
(
that
,
d
).
bind
(
$$
);
if
(
config
.
data_selection_enabled
&&
config
.
data_selection_isselectable
(
d
))
{
if
(
!
config
.
data_selection_multiple
)
{
$$
.
main
.
selectAll
(
'.'
+
CLASS
.
shapes
+
(
config
.
data_selection_grouped
?
$$
.
getTargetSelectorSuffix
(
d
.
id
)
:
""
)).
selectAll
(
'.'
+
CLASS
.
shape
).
each
(
function
(
d
,
i
)
{
...
...
@@ -5288,28 +5290,28 @@
c3_chart_internal_fn
.
initSubchart
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
context
=
$$
.
context
=
$$
.
svg
.
append
(
"g"
).
attr
(
"transform"
,
$$
.
getTranslate
(
'context'
));
context
.
style
(
'visibility'
,
config
.
subchart_show
?
'visible'
:
'hidden'
);
// Define g for chart area
context
.
append
(
'g'
)
.
attr
(
"clip-path"
,
$$
.
clipPathForSubchart
)
.
attr
(
'class'
,
CLASS
.
chart
);
// Define g for bar chart area
context
.
select
(
'.'
+
CLASS
.
chart
).
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
chartBars
);
// Define g for line chart area
context
.
select
(
'.'
+
CLASS
.
chart
).
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
chartLines
);
// Add extent rect for Brush
context
.
append
(
"g"
)
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
"class"
,
CLASS
.
brush
)
.
call
(
$$
.
brush
);
// ATTENTION: This must be called AFTER chart added
// Add Axis
$$
.
axes
.
subx
=
context
.
append
(
"g"
)
...
...
@@ -5325,7 +5327,7 @@
classChartLine
=
$$
.
classChartLine
.
bind
(
$$
),
classLines
=
$$
.
classLines
.
bind
(
$$
),
classAreas
=
$$
.
classAreas
.
bind
(
$$
);
if
(
config
.
subchart_show
)
{
//-- Bar --//
contextBarUpdate
=
context
.
select
(
'.'
+
CLASS
.
chartBars
).
selectAll
(
'.'
+
CLASS
.
chartBar
)
...
...
@@ -5337,7 +5339,7 @@
// Bars for each data
contextBarEnter
.
append
(
'g'
)
.
attr
(
"class"
,
classBars
);
//-- Line --//
contextLineUpdate
=
context
.
select
(
'.'
+
CLASS
.
chartLines
).
selectAll
(
'.'
+
CLASS
.
chartLine
)
.
data
(
targets
)
...
...
@@ -5351,7 +5353,7 @@
// Area
contextLineEnter
.
append
(
"g"
)
.
attr
(
"class"
,
classAreas
);
//-- Brush --//
context
.
selectAll
(
'.'
+
CLASS
.
brush
+
' rect'
)
.
attr
(
config
.
axis_rotated
?
"width"
:
"height"
,
config
.
axis_rotated
?
$$
.
width2
:
$$
.
height2
);
...
...
@@ -5417,9 +5419,9 @@
c3_chart_internal_fn
.
redrawSubchart
=
function
(
withSubchart
,
transitions
,
duration
,
durationForExit
,
areaIndices
,
barIndices
,
lineIndices
)
{
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
drawAreaOnSub
,
drawBarOnSub
,
drawLineOnSub
;
$$
.
context
.
style
(
'visibility'
,
config
.
subchart_show
?
'visible'
:
'hidden'
);
// subchart
if
(
config
.
subchart_show
)
{
// reflect main chart to extent on subchart if zoomed
...
...
@@ -5428,7 +5430,7 @@
}
// update subchart elements if needed
if
(
withSubchart
)
{
// extent rect
if
(
!
$$
.
brush
.
empty
())
{
$$
.
brush
.
extent
(
$$
.
x
.
orgDomain
()).
update
();
...
...
@@ -5437,11 +5439,11 @@
drawAreaOnSub
=
$$
.
generateDrawArea
(
areaIndices
,
true
);
drawBarOnSub
=
$$
.
generateDrawBar
(
barIndices
,
true
);
drawLineOnSub
=
$$
.
generateDrawLine
(
lineIndices
,
true
);
$$
.
updateBarForSubchart
(
duration
);
$$
.
updateLineForSubchart
(
duration
);
$$
.
updateAreaForSubchart
(
duration
);
$$
.
redrawBarForSubchart
(
drawBarOnSub
,
duration
,
duration
);
$$
.
redrawLineForSubchart
(
drawLineOnSub
,
duration
,
duration
);
$$
.
redrawAreaForSubchart
(
drawAreaOnSub
,
duration
,
duration
);
...
...
@@ -5481,7 +5483,7 @@
c3_chart_internal_fn
.
initZoom
=
function
()
{
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
,
startEvent
;
$$
.
zoom
=
d3
.
behavior
.
zoom
()
.
on
(
"zoomstart"
,
function
()
{
startEvent
=
d3
.
event
.
sourceEvent
;
...
...
@@ -5555,10 +5557,10 @@
pattern
=
notEmpty
(
config
.
color_pattern
)
?
config
.
color_pattern
:
d3
.
scale
.
category10
().
range
(),
callback
=
config
.
data_color
,
ids
=
[];
return
function
(
d
)
{
var
id
=
d
.
id
||
(
d
.
data
&&
d
.
data
.
id
)
||
d
,
color
;
// if callback function is provided
if
(
colors
[
id
]
instanceof
Function
)
{
color
=
colors
[
id
](
d
);
...
...
@@ -5881,10 +5883,10 @@
c3_chart_fn
.
focus
=
function
(
targetIds
)
{
var
$$
=
this
.
internal
,
candidates
;
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
candidates
=
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
.
filter
(
$$
.
isTargetToShow
,
$$
))),
this
.
revert
();
this
.
defocus
();
candidates
.
classed
(
CLASS
.
focused
,
true
).
classed
(
CLASS
.
defocused
,
false
);
...
...
@@ -5892,37 +5894,37 @@
$$
.
expandArc
(
targetIds
);
}
$$
.
toggleFocusLegend
(
targetIds
,
true
);
$$
.
focusedTargetIds
=
targetIds
;
$$
.
defocusedTargetIds
=
$$
.
defocusedTargetIds
.
filter
(
function
(
id
)
{
return
targetIds
.
indexOf
(
id
)
<
0
;
});
};
c3_chart_fn
.
defocus
=
function
(
targetIds
)
{
var
$$
=
this
.
internal
,
candidates
;
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
candidates
=
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
.
filter
(
$$
.
isTargetToShow
,
$$
))),
candidates
.
classed
(
CLASS
.
focused
,
false
).
classed
(
CLASS
.
defocused
,
true
);
if
(
$$
.
hasArcType
())
{
$$
.
unexpandArc
(
targetIds
);
}
$$
.
toggleFocusLegend
(
targetIds
,
false
);
$$
.
focusedTargetIds
=
$$
.
focusedTargetIds
.
filter
(
function
(
id
)
{
return
targetIds
.
indexOf
(
id
)
<
0
;
});
$$
.
defocusedTargetIds
=
targetIds
;
};
c3_chart_fn
.
revert
=
function
(
targetIds
)
{
var
$$
=
this
.
internal
,
candidates
;
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
candidates
=
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
));
// should be for all targets
candidates
.
classed
(
CLASS
.
focused
,
false
).
classed
(
CLASS
.
defocused
,
false
);
if
(
$$
.
hasArcType
())
{
$$
.
unexpandArc
(
targetIds
);
...
...
@@ -5935,55 +5937,55 @@
})
.
classed
(
CLASS
.
legendItemFocused
,
false
);
}
$$
.
focusedTargetIds
=
[];
$$
.
defocusedTargetIds
=
[];
};
c3_chart_fn
.
show
=
function
(
targetIds
,
options
)
{
var
$$
=
this
.
internal
,
targets
;
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
options
=
options
||
{};
$$
.
removeHiddenTargetIds
(
targetIds
);
targets
=
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
));
targets
.
transition
()
.
style
(
'opacity'
,
1
,
'important'
)
.
call
(
$$
.
endall
,
function
()
{
targets
.
style
(
'opacity'
,
null
).
style
(
'opacity'
,
1
);
});
if
(
options
.
withLegend
)
{
$$
.
showLegend
(
targetIds
);
}
$$
.
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
};
c3_chart_fn
.
hide
=
function
(
targetIds
,
options
)
{
var
$$
=
this
.
internal
,
targets
;
targetIds
=
$$
.
mapToTargetIds
(
targetIds
);
options
=
options
||
{};
$$
.
addHiddenTargetIds
(
targetIds
);
targets
=
$$
.
svg
.
selectAll
(
$$
.
selectorTargets
(
targetIds
));
targets
.
transition
()
.
style
(
'opacity'
,
0
,
'important'
)
.
call
(
$$
.
endall
,
function
()
{
targets
.
style
(
'opacity'
,
null
).
style
(
'opacity'
,
0
);
});
if
(
options
.
withLegend
)
{
$$
.
hideLegend
(
targetIds
);
}
$$
.
redraw
({
withUpdateOrgXDomain
:
true
,
withUpdateXDomain
:
true
,
withLegend
:
true
});
};
c3_chart_fn
.
toggle
=
function
(
targetIds
,
options
)
{
var
that
=
this
,
$$
=
this
.
internal
;
$$
.
mapToTargetIds
(
targetIds
).
forEach
(
function
(
targetId
)
{
...
...
@@ -6057,7 +6059,7 @@
$$
.
loadFromArgs
(
args
);
}
};
c3_chart_fn
.
unload
=
function
(
args
)
{
var
$$
=
this
.
internal
;
args
=
args
||
{};
...
...
@@ -6076,7 +6078,7 @@
var
$$
=
this
.
internal
,
targets
,
data
,
notfoundIds
=
[],
orgDataCount
=
$$
.
getMaxDataCount
(),
dataCount
,
domain
,
baseTarget
,
baseValue
,
length
=
0
,
tail
=
0
,
diff
,
to
;
if
(
args
.
json
)
{
data
=
$$
.
convertJsonToData
(
args
.
json
,
args
.
keys
);
}
...
...
@@ -6090,19 +6092,19 @@
return
;
}
targets
=
$$
.
convertDataToTargets
(
data
,
true
);
// Update/Add data
$$
.
data
.
targets
.
forEach
(
function
(
t
)
{
var
found
=
false
,
i
,
j
;
for
(
i
=
0
;
i
<
targets
.
length
;
i
++
)
{
if
(
t
.
id
===
targets
[
i
].
id
)
{
found
=
true
;
if
(
t
.
values
[
t
.
values
.
length
-
1
])
{
tail
=
t
.
values
[
t
.
values
.
length
-
1
].
index
+
1
;
}
length
=
targets
[
i
].
values
.
length
;
for
(
j
=
0
;
j
<
length
;
j
++
)
{
targets
[
i
].
values
[
j
].
index
=
tail
+
j
;
if
(
!
$$
.
isTimeSeries
())
{
...
...
@@ -6110,14 +6112,14 @@
}
}
t
.
values
=
t
.
values
.
concat
(
targets
[
i
].
values
);
targets
.
splice
(
i
,
1
);
break
;
}
}
if
(
!
found
)
{
notfoundIds
.
push
(
t
.
id
);
}
});
// Append null for not found targets
$$
.
data
.
targets
.
forEach
(
function
(
t
)
{
var
i
,
j
;
...
...
@@ -6135,7 +6137,7 @@
}
}
});
// Generate null values for new target
if
(
$$
.
data
.
targets
.
length
)
{
targets
.
forEach
(
function
(
t
)
{
...
...
@@ -6158,12 +6160,12 @@
});
}
$$
.
data
.
targets
=
$$
.
data
.
targets
.
concat
(
targets
);
// add remained
// check data count because behavior needs to change when it's only one
dataCount
=
$$
.
getMaxDataCount
();
baseTarget
=
$$
.
data
.
targets
[
0
];
baseValue
=
baseTarget
.
values
[
0
];
// Update length to flow if needed
if
(
isDefined
(
args
.
to
))
{
length
=
0
;
...
...
@@ -6174,7 +6176,7 @@
}
else
if
(
isDefined
(
args
.
length
))
{
length
=
args
.
length
;
}
// If only one data, update the domain to flow from left edge of the chart
if
(
!
orgDataCount
)
{
if
(
$$
.
isTimeSeries
())
{
...
...
@@ -6195,10 +6197,10 @@
$$
.
updateXDomain
(
null
,
true
,
true
,
false
,
domain
);
}
}
// Set targets
$$
.
updateTargets
(
$$
.
data
.
targets
);
// Redraw with new targets
$$
.
redraw
({
flow
:
{
...
...
@@ -6214,10 +6216,10 @@
withUpdateXAxis
:
true
,
});
};
c3_chart_internal_fn
.
generateFlow
=
function
(
args
)
{
var
$$
=
this
,
config
=
$$
.
config
,
d3
=
$$
.
d3
;
return
function
()
{
var
targets
=
args
.
targets
,
flow
=
args
.
flow
,
...
...
@@ -6230,7 +6232,7 @@
xForText
=
args
.
xForText
,
yForText
=
args
.
yForText
,
duration
=
args
.
duration
;
var
translateX
,
scaleX
=
1
,
transform
,
flowIndex
=
flow
.
index
,
flowLength
=
flow
.
length
,
...
...
@@ -6240,7 +6242,7 @@
durationForFlow
=
flow
.
duration
||
duration
,
done
=
flow
.
done
||
function
()
{},
wait
=
$$
.
generateWait
();
var
xgrid
=
$$
.
xgrid
||
d3
.
selectAll
([]),
xgridLines
=
$$
.
xgridLines
||
d3
.
selectAll
([]),
mainRegion
=
$$
.
mainRegion
||
d3
.
selectAll
([]),
...
...
@@ -6249,20 +6251,20 @@
mainLine
=
$$
.
mainLine
||
d3
.
selectAll
([]),
mainArea
=
$$
.
mainArea
||
d3
.
selectAll
([]),
mainCircle
=
$$
.
mainCircle
||
d3
.
selectAll
([]);
// set flag
$$
.
flowing
=
true
;
// remove head data after rendered
$$
.
data
.
targets
.
forEach
(
function
(
d
)
{
d
.
values
.
splice
(
0
,
flowLength
);
});
// update x domain to generate axis elements for flow
domain
=
$$
.
updateXDomain
(
targets
,
true
,
true
);
// update elements related to x scale
if
(
$$
.
updateXGrid
)
{
$$
.
updateXGrid
(
true
);
}
// generate transform to flow
if
(
!
flow
.
orgDataCount
)
{
// if empty
if
(
$$
.
data
.
targets
[
0
].
values
.
length
!==
1
)
{
...
...
@@ -6287,11 +6289,11 @@
}
scaleX
=
(
diffDomain
(
orgDomain
)
/
diffDomain
(
domain
));
transform
=
'translate('
+
translateX
+
',0) scale('
+
scaleX
+
',1)'
;
// hide tooltip
$$
.
hideXGridFocus
();
$$
.
hideTooltip
();
d3
.
transition
().
ease
(
'linear'
).
duration
(
durationForFlow
).
each
(
function
()
{
wait
.
add
(
$$
.
axes
.
x
.
transition
().
call
(
$$
.
xAxis
));
wait
.
add
(
mainBar
.
transition
().
attr
(
'transform'
,
transform
));
...
...
@@ -6305,7 +6307,7 @@
})
.
call
(
wait
,
function
()
{
var
i
,
shapes
=
[],
texts
=
[],
eventRects
=
[];
// remove flowed elements
if
(
flowLength
)
{
for
(
i
=
0
;
i
<
flowLength
;
i
++
)
{
...
...
@@ -6318,7 +6320,7 @@
$$
.
svg
.
selectAll
(
'.'
+
CLASS
.
eventRects
).
selectAll
(
eventRects
).
remove
();
$$
.
svg
.
select
(
'.'
+
CLASS
.
xgrid
).
remove
();
}
// draw again for removing flowed elements and reverting attr
xgrid
.
attr
(
'transform'
,
null
)
...
...
@@ -6354,14 +6356,14 @@
mainRegion
.
select
(
'rect'
).
filter
(
$$
.
isRegionOnX
)
.
attr
(
"x"
,
$$
.
regionX
.
bind
(
$$
))
.
attr
(
"width"
,
$$
.
regionWidth
.
bind
(
$$
));
if
(
config
.
interaction_enabled
)
{
$$
.
redrawEventRect
();
}
// callback for end of flow
done
();
$$
.
flowing
=
false
;
});
};
...
...
@@ -6427,7 +6429,7 @@
options
=
[
'pie'
,
'donut'
].
indexOf
(
type
)
>=
0
?
{
withTransform
:
true
}
:
null
;
$$
.
transformTo
(
targetIds
,
type
,
options
);
};
c3_chart_internal_fn
.
transformTo
=
function
(
targetIds
,
type
,
optionsForRedraw
)
{
var
$$
=
this
,
withTransitionForAxis
=
!
$$
.
hasArcType
(),
...
...
@@ -6462,7 +6464,7 @@
var
$$
=
this
.
internal
;
$$
.
removeGridLines
(
params
,
true
);
};
c3_chart_fn
.
ygrids
=
function
(
grids
)
{
var
$$
=
this
.
internal
,
config
=
$$
.
config
;
if
(
!
grids
)
{
return
config
.
grid_y_lines
;
}
...
...
@@ -6496,16 +6498,16 @@
c3_chart_fn
.
regions
.
remove
=
function
(
options
)
{
var
$$
=
this
.
internal
,
config
=
$$
.
config
,
duration
,
classes
,
regions
;
options
=
options
||
{};
duration
=
$$
.
getOption
(
options
,
"duration"
,
config
.
transition_duration
);
classes
=
$$
.
getOption
(
options
,
"classes"
,
[
CLASS
.
region
]);
regions
=
$$
.
main
.
select
(
'.'
+
CLASS
.
regions
).
selectAll
(
classes
.
map
(
function
(
c
)
{
return
'.'
+
c
;
}));
(
duration
?
regions
.
transition
().
duration
(
duration
)
:
regions
)
.
style
(
'opacity'
,
0
)
.
remove
();
config
.
regions
=
config
.
regions
.
filter
(
function
(
region
)
{
var
found
=
false
;
if
(
!
region
[
'class'
])
{
...
...
@@ -6516,7 +6518,7 @@
});
return
!
found
;
});
return
config
.
regions
;
};
...
...
@@ -6666,25 +6668,25 @@
config
.
size_height
=
size
?
size
.
height
:
null
;
this
.
flush
();
};
c3_chart_fn
.
flush
=
function
()
{
var
$$
=
this
.
internal
;
$$
.
updateAndRedraw
({
withLegend
:
true
,
withTransition
:
false
,
withTransitionForTransform
:
false
});
};
c3_chart_fn
.
destroy
=
function
()
{
var
$$
=
this
.
internal
;
window
.
clearInterval
(
$$
.
intervalForObserveInserted
);
window
.
onresize
=
null
;
$$
.
selectChart
.
classed
(
'c3'
,
false
).
html
(
""
);
// MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen.
Object
.
keys
(
$$
).
forEach
(
function
(
key
)
{
$$
[
key
]
=
null
;
});
return
null
;
};
...
...
@@ -6718,10 +6720,14 @@
// emulate mouse events to show
$$
.
dispatchEvent
(
'mouseover'
,
index
,
mouse
);
$$
.
dispatchEvent
(
'mousemove'
,
index
,
mouse
);
this
.
config
.
tooltip_onshow
.
call
(
$$
,
args
.
data
);
};
c3_chart_fn
.
tooltip
.
hide
=
function
()
{
// TODO: get target data by checking the state of focus
this
.
internal
.
dispatchEvent
(
'mouseout'
,
0
);
this
.
config
.
tooltip_onhide
.
call
(
this
);
};
// Features:
...
...
@@ -6731,12 +6737,12 @@
var
tickTextCharSize
;
function
c3_axis
(
d3
,
params
)
{
var
scale
=
d3
.
scale
.
linear
(),
orient
=
"bottom"
,
innerTickSize
=
6
,
outerTickSize
,
tickPadding
=
3
,
tickValues
=
null
,
tickFormat
,
tickArguments
;
var
tickOffset
=
0
,
tickCulling
=
true
,
tickCentered
;
params
=
params
||
{};
outerTickSize
=
params
.
withOuterTick
?
6
:
0
;
function
axisX
(
selection
,
x
)
{
selection
.
attr
(
"transform"
,
function
(
d
)
{
return
"translate("
+
Math
.
ceil
(
x
(
d
)
+
tickOffset
)
+
", 0)"
;
...
...
@@ -6804,9 +6810,9 @@
function
axis
(
g
)
{
g
.
each
(
function
()
{
var
g
=
axis
.
g
=
d3
.
select
(
this
);
var
scale0
=
this
.
__chart__
||
scale
,
scale1
=
this
.
__chart__
=
copyScale
();
var
ticks
=
tickValues
?
tickValues
:
generateTicks
(
scale1
),
tick
=
g
.
selectAll
(
".tick"
).
data
(
ticks
,
scale1
),
tickEnter
=
tick
.
enter
().
insert
(
"g"
,
".domain"
).
attr
(
"class"
,
"tick"
).
style
(
"opacity"
,
1
e
-
6
),
...
...
@@ -6814,18 +6820,18 @@
tickExit
=
tick
.
exit
().
remove
(),
tickUpdate
=
transitionise
(
tick
).
style
(
"opacity"
,
1
),
tickTransform
,
tickX
,
tickY
;
var
range
=
scale
.
rangeExtent
?
scale
.
rangeExtent
()
:
scaleExtent
(
scale
.
range
()),
path
=
g
.
selectAll
(
".domain"
).
data
([
0
]),
pathUpdate
=
(
path
.
enter
().
append
(
"path"
).
attr
(
"class"
,
"domain"
),
transitionise
(
path
));
tickEnter
.
append
(
"line"
);
tickEnter
.
append
(
"text"
);
var
lineEnter
=
tickEnter
.
select
(
"line"
),
lineUpdate
=
tickUpdate
.
select
(
"line"
),
textEnter
=
tickEnter
.
select
(
"text"
),
textUpdate
=
tickUpdate
.
select
(
"text"
);
if
(
params
.
isCategory
)
{
tickOffset
=
Math
.
ceil
((
scale1
(
1
)
-
scale1
(
0
))
/
2
);
tickX
=
tickCentered
?
0
:
tickOffset
;
...
...
@@ -6833,24 +6839,24 @@
}
else
{
tickOffset
=
tickX
=
0
;
}
var
text
,
tspan
,
sizeFor1Char
=
getSizeFor1Char
(
g
.
select
(
'.tick'
)),
counts
=
[];
var
tickLength
=
Math
.
max
(
innerTickSize
,
0
)
+
tickPadding
,
isVertical
=
orient
===
'left'
||
orient
===
'right'
;
// this should be called only when category axis
function
splitTickText
(
d
,
maxWidth
)
{
var
tickText
=
textFormatted
(
d
),
subtext
,
spaceIndex
,
textWidth
,
splitted
=
[];
if
(
Object
.
prototype
.
toString
.
call
(
tickText
)
===
"[object Array]"
)
{
return
tickText
;
}
if
(
!
maxWidth
||
maxWidth
<=
0
)
{
maxWidth
=
isVertical
?
95
:
params
.
isCategory
?
(
Math
.
ceil
(
scale1
(
ticks
[
1
])
-
scale1
(
ticks
[
0
]))
-
12
)
:
110
;
}
function
split
(
splitted
,
text
)
{
spaceIndex
=
undefined
;
for
(
var
i
=
1
;
i
<
text
.
length
;
i
++
)
{
...
...
@@ -6869,10 +6875,10 @@
}
return
splitted
.
concat
(
text
);
}
return
split
(
splitted
,
tickText
+
""
);
}
function
tspanDy
(
d
,
i
)
{
var
dy
=
sizeFor1Char
.
h
;
if
(
i
===
0
)
{
...
...
@@ -6884,12 +6890,12 @@
}
return
dy
;
}
function
tickSize
(
d
)
{
var
tickPosition
=
scale
(
d
)
+
(
tickCentered
?
0
:
tickOffset
);
return
range
[
0
]
<
tickPosition
&&
tickPosition
<
range
[
1
]
?
innerTickSize
:
0
;
}
text
=
tick
.
select
(
"text"
);
tspan
=
text
.
selectAll
(
'tspan'
)
.
data
(
function
(
d
,
i
)
{
...
...
@@ -6902,9 +6908,9 @@
tspan
.
enter
().
append
(
'tspan'
);
tspan
.
exit
().
remove
();
tspan
.
text
(
function
(
d
)
{
return
d
.
splitted
;
});
var
rotate
=
params
.
tickTextRotate
;
function
textAnchorForText
(
rotate
)
{
if
(
!
rotate
)
{
return
'middle'
;
...
...
@@ -6929,7 +6935,7 @@
}
return
11.5
-
2.5
*
(
rotate
/
15
)
*
(
rotate
>
0
?
1
:
-
1
);
}
switch
(
orient
)
{
case
"bottom"
:
{
...
...
@@ -7067,7 +7073,7 @@
// PhantomJS doesn't have support for Function.prototype.bind, which has caused confusion. Use
// this polyfill to avoid the confusion.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill
if
(
!
Function
.
prototype
.
bind
)
{
Function
.
prototype
.
bind
=
function
(
oThis
)
{
if
(
typeof
this
!==
'function'
)
{
...
...
@@ -7075,17 +7081,17 @@
// internal IsCallable function
throw
new
TypeError
(
'Function.prototype.bind - what is trying to be bound is not callable'
);
}
var
aArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
),
fToBind
=
this
,
fNOP
=
function
()
{},
fBound
=
function
()
{
return
fToBind
.
apply
(
this
instanceof
fNOP
?
this
:
oThis
,
aArgs
.
concat
(
Array
.
prototype
.
slice
.
call
(
arguments
)));
};
fNOP
.
prototype
=
this
.
prototype
;
fBound
.
prototype
=
new
fNOP
();
return
fBound
;
};
}
...
...
c3.min.js
View file @
18a39d58
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/api.tooltip.js
View file @
18a39d58
...
...
@@ -29,11 +29,11 @@ c3_chart_fn.tooltip.show = function (args) {
$$
.
dispatchEvent
(
'mouseover'
,
index
,
mouse
);
$$
.
dispatchEvent
(
'mousemove'
,
index
,
mouse
);
config
.
tooltip_onshow
.
call
(
$$
,
dataToShow
);
this
.
config
.
tooltip_onshow
.
call
(
$$
,
args
.
data
);
};
c3_chart_fn
.
tooltip
.
hide
=
function
()
{
// TODO: get target data by checking the state of focus
this
.
internal
.
dispatchEvent
(
'mouseout'
,
0
);
config
.
tooltip_onhide
.
call
(
this
);
this
.
config
.
tooltip_onhide
.
call
(
this
);
};
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