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
5c0c8ecc
Commit
5c0c8ecc
authored
Feb 02, 2015
by
kiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dist files.
parent
c47da0db
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
194 additions
and
162 deletions
+194
-162
api.axis.js
src/api.axis.js
+2
-2
axis.js
src/axis.js
+127
-121
core.js
src/core.js
+37
-11
domain.js
src/domain.js
+9
-9
format.js
src/format.js
+1
-1
scale.js
src/scale.js
+10
-10
size.js
src/size.js
+6
-6
tooltip.js
src/tooltip.js
+2
-2
No files found.
src/api.axis.js
View file @
5c0c8ecc
...
@@ -3,9 +3,9 @@ c3_chart_fn.axis.labels = function (labels) {
...
@@ -3,9 +3,9 @@ c3_chart_fn.axis.labels = function (labels) {
var
$$
=
this
.
internal
;
var
$$
=
this
.
internal
;
if
(
arguments
.
length
)
{
if
(
arguments
.
length
)
{
Object
.
keys
(
labels
).
forEach
(
function
(
axisId
)
{
Object
.
keys
(
labels
).
forEach
(
function
(
axisId
)
{
$$
.
setAxis
LabelText
(
axisId
,
labels
[
axisId
]);
$$
.
axis
.
set
LabelText
(
axisId
,
labels
[
axisId
]);
});
});
$$
.
updateAxis
Labels
();
$$
.
axis
.
update
Labels
();
}
}
// TODO: return some values?
// TODO: return some values?
};
};
...
...
src/axis.js
View file @
5c0c8ecc
c3_chart_internal_fn
.
initAxis
=
function
()
{
function
Axis
(
owner
)
{
var
$$
=
this
,
config
=
$$
.
config
,
main
=
$$
.
main
;
API
.
call
(
this
,
owner
);
}
inherit
(
API
,
Axis
);
Axis
.
prototype
.
init
=
function
init
()
{
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
main
=
$$
.
main
;
$$
.
axes
.
x
=
main
.
append
(
"g"
)
$$
.
axes
.
x
=
main
.
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisX
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisX
)
.
attr
(
"clip-path"
,
$$
.
clipPathForXAxis
)
.
attr
(
"clip-path"
,
$$
.
clipPathForXAxis
)
...
@@ -8,7 +15,7 @@ c3_chart_internal_fn.initAxis = function () {
...
@@ -8,7 +15,7 @@ c3_chart_internal_fn.initAxis = function () {
$$
.
axes
.
x
.
append
(
"text"
)
$$
.
axes
.
x
.
append
(
"text"
)
.
attr
(
"class"
,
CLASS
.
axisXLabel
)
.
attr
(
"class"
,
CLASS
.
axisXLabel
)
.
attr
(
"transform"
,
config
.
axis_rotated
?
"rotate(-90)"
:
""
)
.
attr
(
"transform"
,
config
.
axis_rotated
?
"rotate(-90)"
:
""
)
.
style
(
"text-anchor"
,
$$
.
textAnchorForXAxisLabel
.
bind
(
$$
));
.
style
(
"text-anchor"
,
this
.
textAnchorForXAxisLabel
.
bind
(
this
));
$$
.
axes
.
y
=
main
.
append
(
"g"
)
$$
.
axes
.
y
=
main
.
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisY
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisY
)
...
@@ -18,7 +25,7 @@ c3_chart_internal_fn.initAxis = function () {
...
@@ -18,7 +25,7 @@ c3_chart_internal_fn.initAxis = function () {
$$
.
axes
.
y
.
append
(
"text"
)
$$
.
axes
.
y
.
append
(
"text"
)
.
attr
(
"class"
,
CLASS
.
axisYLabel
)
.
attr
(
"class"
,
CLASS
.
axisYLabel
)
.
attr
(
"transform"
,
config
.
axis_rotated
?
""
:
"rotate(-90)"
)
.
attr
(
"transform"
,
config
.
axis_rotated
?
""
:
"rotate(-90)"
)
.
style
(
"text-anchor"
,
$$
.
textAnchorForYAxisLabel
.
bind
(
$$
));
.
style
(
"text-anchor"
,
this
.
textAnchorForYAxisLabel
.
bind
(
this
));
$$
.
axes
.
y2
=
main
.
append
(
"g"
)
$$
.
axes
.
y2
=
main
.
append
(
"g"
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisY2
)
.
attr
(
"class"
,
CLASS
.
axis
+
' '
+
CLASS
.
axisY2
)
...
@@ -28,10 +35,10 @@ c3_chart_internal_fn.initAxis = function () {
...
@@ -28,10 +35,10 @@ c3_chart_internal_fn.initAxis = function () {
$$
.
axes
.
y2
.
append
(
"text"
)
$$
.
axes
.
y2
.
append
(
"text"
)
.
attr
(
"class"
,
CLASS
.
axisY2Label
)
.
attr
(
"class"
,
CLASS
.
axisY2Label
)
.
attr
(
"transform"
,
config
.
axis_rotated
?
""
:
"rotate(-90)"
)
.
attr
(
"transform"
,
config
.
axis_rotated
?
""
:
"rotate(-90)"
)
.
style
(
"text-anchor"
,
$$
.
textAnchorForY2AxisLabel
.
bind
(
$$
));
.
style
(
"text-anchor"
,
this
.
textAnchorForY2AxisLabel
.
bind
(
this
));
};
};
c3_chart_internal_fn
.
getXAxis
=
function
(
scale
,
orient
,
tickFormat
,
tickValues
,
withOuterTick
,
withoutTransition
)
{
Axis
.
prototype
.
getXAxis
=
function
getXAxis
(
scale
,
orient
,
tickFormat
,
tickValues
,
withOuterTick
,
withoutTransition
)
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
axisParams
=
{
axisParams
=
{
isCategory
:
$$
.
isCategorized
(),
isCategory
:
$$
.
isCategorized
(),
withOuterTick
:
withOuterTick
,
withOuterTick
:
withOuterTick
,
...
@@ -64,10 +71,10 @@ c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues,
...
@@ -64,10 +71,10 @@ c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues,
return
axis
;
return
axis
;
};
};
c3_chart_internal_fn
.
updateXAxisTickValues
=
function
(
targets
,
axis
)
{
Axis
.
prototype
.
updateXAxisTickValues
=
function
updateXAxisTickValues
(
targets
,
axis
)
{
var
$$
=
this
,
config
=
$$
.
config
,
tickValues
;
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
tickValues
;
if
(
config
.
axis_x_tick_fit
||
config
.
axis_x_tick_count
)
{
if
(
config
.
axis_x_tick_fit
||
config
.
axis_x_tick_count
)
{
tickValues
=
$$
.
generateTickValues
(
$$
.
mapTargetsToUniqueXs
(
targets
),
config
.
axis_x_tick_count
,
$$
.
isTimeSeries
());
tickValues
=
this
.
generateTickValues
(
$$
.
mapTargetsToUniqueXs
(
targets
),
config
.
axis_x_tick_count
,
$$
.
isTimeSeries
());
}
}
if
(
axis
)
{
if
(
axis
)
{
axis
.
tickValues
(
tickValues
);
axis
.
tickValues
(
tickValues
);
...
@@ -77,22 +84,25 @@ c3_chart_internal_fn.updateXAxisTickValues = function (targets, axis) {
...
@@ -77,22 +84,25 @@ c3_chart_internal_fn.updateXAxisTickValues = function (targets, axis) {
}
}
return
tickValues
;
return
tickValues
;
};
};
c3_chart_internal_fn
.
getYAxis
=
function
(
scale
,
orient
,
tickFormat
,
tickValues
,
withOuterTick
)
{
Axis
.
prototype
.
getYAxis
=
function
getYAxis
(
scale
,
orient
,
tickFormat
,
tickValues
,
withOuterTick
)
{
var
axisParams
=
{
withOuterTick
:
withOuterTick
},
var
axisParams
=
{
withOuterTick
:
withOuterTick
},
axis
=
c3_axis
(
this
.
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
);
$$
=
this
.
owner
,
if
(
this
.
isTimeSeriesY
())
{
d3
=
$$
.
d3
,
axis
.
ticks
(
this
.
d3
.
time
[
this
.
config
.
axis_y_tick_time_value
],
this
.
config
.
axis_y_tick_time_interval
);
config
=
$$
.
config
,
axis
=
c3_axis
(
d3
,
axisParams
).
scale
(
scale
).
orient
(
orient
).
tickFormat
(
tickFormat
);
if
(
$$
.
isTimeSeriesY
())
{
axis
.
ticks
(
d3
.
time
[
config
.
axis_y_tick_time_value
],
config
.
axis_y_tick_time_interval
);
}
else
{
}
else
{
axis
.
tickValues
(
tickValues
);
axis
.
tickValues
(
tickValues
);
}
}
return
axis
;
return
axis
;
};
};
c3_chart_internal_fn
.
getAxisId
=
function
(
id
)
{
Axis
.
prototype
.
getId
=
function
getId
(
id
)
{
var
config
=
this
.
config
;
var
config
=
this
.
owner
.
config
;
return
id
in
config
.
data_axes
?
config
.
data_axes
[
id
]
:
'y'
;
return
id
in
config
.
data_axes
?
config
.
data_axes
[
id
]
:
'y'
;
};
};
c3_chart_internal_fn
.
getXAxisTickFormat
=
function
()
{
Axis
.
prototype
.
getXAxisTickFormat
=
function
getXAxisTickFormat
()
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
format
=
$$
.
isTimeSeries
()
?
$$
.
defaultAxisTimeFormat
:
$$
.
isCategorized
()
?
$$
.
categoryName
:
function
(
v
)
{
return
v
<
0
?
v
.
toFixed
(
0
)
:
v
;
};
format
=
$$
.
isTimeSeries
()
?
$$
.
defaultAxisTimeFormat
:
$$
.
isCategorized
()
?
$$
.
categoryName
:
function
(
v
)
{
return
v
<
0
?
v
.
toFixed
(
0
)
:
v
;
};
if
(
config
.
axis_x_tick_format
)
{
if
(
config
.
axis_x_tick_format
)
{
if
(
isFunction
(
config
.
axis_x_tick_format
))
{
if
(
isFunction
(
config
.
axis_x_tick_format
))
{
...
@@ -105,20 +115,20 @@ c3_chart_internal_fn.getXAxisTickFormat = function () {
...
@@ -105,20 +115,20 @@ c3_chart_internal_fn.getXAxisTickFormat = function () {
}
}
return
isFunction
(
format
)
?
function
(
v
)
{
return
format
.
call
(
$$
,
v
);
}
:
format
;
return
isFunction
(
format
)
?
function
(
v
)
{
return
format
.
call
(
$$
,
v
);
}
:
format
;
};
};
c3_chart_internal_fn
.
getAxisTickValues
=
function
(
tickValues
,
axis
)
{
Axis
.
prototype
.
getTickValues
=
function
getTickValues
(
tickValues
,
axis
)
{
return
tickValues
?
tickValues
:
axis
?
axis
.
tickValues
()
:
undefined
;
return
tickValues
?
tickValues
:
axis
?
axis
.
tickValues
()
:
undefined
;
};
};
c3_chart_internal_fn
.
getXAxisTickValues
=
function
()
{
Axis
.
prototype
.
getXAxisTickValues
=
function
getXAxisTickValues
()
{
return
this
.
get
AxisTickValues
(
this
.
config
.
axis_x_tick_values
,
this
.
xAxis
);
return
this
.
get
TickValues
(
this
.
owner
.
config
.
axis_x_tick_values
,
this
.
owner
.
xAxis
);
};
};
c3_chart_internal_fn
.
getYAxisTickValues
=
function
()
{
Axis
.
prototype
.
getYAxisTickValues
=
function
getYAxisTickValues
()
{
return
this
.
get
AxisTickValues
(
this
.
config
.
axis_y_tick_values
,
this
.
yAxis
);
return
this
.
get
TickValues
(
this
.
owner
.
config
.
axis_y_tick_values
,
this
.
owner
.
yAxis
);
};
};
c3_chart_internal_fn
.
getY2AxisTickValues
=
function
()
{
Axis
.
prototype
.
getY2AxisTickValues
=
function
getY2AxisTickValues
()
{
return
this
.
get
AxisTickValues
(
this
.
config
.
axis_y2_tick_values
,
this
.
y2Axis
);
return
this
.
get
TickValues
(
this
.
owner
.
config
.
axis_y2_tick_values
,
this
.
owner
.
y2Axis
);
};
};
c3_chart_internal_fn
.
getAxisLabelOptionByAxisId
=
function
(
axisId
)
{
Axis
.
prototype
.
getLabelOptionByAxisId
=
function
getLabelOptionByAxisId
(
axisId
)
{
var
$$
=
this
,
config
=
$$
.
config
,
option
;
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
option
;
if
(
axisId
===
'y'
)
{
if
(
axisId
===
'y'
)
{
option
=
config
.
axis_y_label
;
option
=
config
.
axis_y_label
;
}
else
if
(
axisId
===
'y2'
)
{
}
else
if
(
axisId
===
'y2'
)
{
...
@@ -128,13 +138,13 @@ c3_chart_internal_fn.getAxisLabelOptionByAxisId = function (axisId) {
...
@@ -128,13 +138,13 @@ c3_chart_internal_fn.getAxisLabelOptionByAxisId = function (axisId) {
}
}
return
option
;
return
option
;
};
};
c3_chart_internal_fn
.
getAxisLabelText
=
function
(
axisId
)
{
Axis
.
prototype
.
getLabelText
=
function
getLabelText
(
axisId
)
{
var
option
=
this
.
get
Axis
LabelOptionByAxisId
(
axisId
);
var
option
=
this
.
getLabelOptionByAxisId
(
axisId
);
return
isString
(
option
)
?
option
:
option
?
option
.
text
:
null
;
return
isString
(
option
)
?
option
:
option
?
option
.
text
:
null
;
};
};
c3_chart_internal_fn
.
setAxisLabelText
=
function
(
axisId
,
text
)
{
Axis
.
prototype
.
setLabelText
=
function
setLabelText
(
axisId
,
text
)
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
option
=
$$
.
getAxis
LabelOptionByAxisId
(
axisId
);
option
=
this
.
get
LabelOptionByAxisId
(
axisId
);
if
(
isString
(
option
))
{
if
(
isString
(
option
))
{
if
(
axisId
===
'y'
)
{
if
(
axisId
===
'y'
)
{
config
.
axis_y_label
=
text
;
config
.
axis_y_label
=
text
;
...
@@ -147,8 +157,8 @@ c3_chart_internal_fn.setAxisLabelText = function (axisId, text) {
...
@@ -147,8 +157,8 @@ c3_chart_internal_fn.setAxisLabelText = function (axisId, text) {
option
.
text
=
text
;
option
.
text
=
text
;
}
}
};
};
c3_chart_internal_fn
.
getAxisLabelPosition
=
function
(
axisId
,
defaultPosition
)
{
Axis
.
prototype
.
getLabelPosition
=
function
getLabelPosition
(
axisId
,
defaultPosition
)
{
var
option
=
this
.
get
Axis
LabelOptionByAxisId
(
axisId
),
var
option
=
this
.
getLabelOptionByAxisId
(
axisId
),
position
=
(
option
&&
typeof
option
===
'object'
&&
option
.
position
)
?
option
.
position
:
defaultPosition
;
position
=
(
option
&&
typeof
option
===
'object'
&&
option
.
position
)
?
option
.
position
:
defaultPosition
;
return
{
return
{
isInner
:
position
.
indexOf
(
'inner'
)
>=
0
,
isInner
:
position
.
indexOf
(
'inner'
)
>=
0
,
...
@@ -161,114 +171,113 @@ c3_chart_internal_fn.getAxisLabelPosition = function (axisId, defaultPosition) {
...
@@ -161,114 +171,113 @@ c3_chart_internal_fn.getAxisLabelPosition = function (axisId, defaultPosition) {
isBottom
:
position
.
indexOf
(
'bottom'
)
>=
0
isBottom
:
position
.
indexOf
(
'bottom'
)
>=
0
};
};
};
};
c3_chart_internal_fn
.
getXAxisLabelPosition
=
function
()
{
Axis
.
prototype
.
getXAxisLabelPosition
=
function
getXAxisLabelPosition
()
{
return
this
.
get
AxisLabelPosition
(
'x'
,
this
.
config
.
axis_rotated
?
'inner-top'
:
'inner-right'
);
return
this
.
get
LabelPosition
(
'x'
,
this
.
owner
.
config
.
axis_rotated
?
'inner-top'
:
'inner-right'
);
};
};
c3_chart_internal_fn
.
getYAxisLabelPosition
=
function
()
{
Axis
.
prototype
.
getYAxisLabelPosition
=
function
getYAxisLabelPosition
()
{
return
this
.
get
AxisLabelPosition
(
'y'
,
this
.
config
.
axis_rotated
?
'inner-right'
:
'inner-top'
);
return
this
.
get
LabelPosition
(
'y'
,
this
.
owner
.
config
.
axis_rotated
?
'inner-right'
:
'inner-top'
);
};
};
c3_chart_internal_fn
.
getY2AxisLabelPosition
=
function
()
{
Axis
.
prototype
.
getY2AxisLabelPosition
=
function
getY2AxisLabelPosition
()
{
return
this
.
get
AxisLabelPosition
(
'y2'
,
this
.
config
.
axis_rotated
?
'inner-right'
:
'inner-top'
);
return
this
.
get
LabelPosition
(
'y2'
,
this
.
owner
.
config
.
axis_rotated
?
'inner-right'
:
'inner-top'
);
};
};
c3_chart_internal_fn
.
getAxisLabelPositionById
=
function
(
id
)
{
Axis
.
prototype
.
getLabelPositionById
=
function
getLabelPositionById
(
id
)
{
return
id
===
'y2'
?
this
.
getY2AxisLabelPosition
()
:
id
===
'y'
?
this
.
getYAxisLabelPosition
()
:
this
.
getXAxisLabelPosition
();
return
id
===
'y2'
?
this
.
getY2AxisLabelPosition
()
:
id
===
'y'
?
this
.
getYAxisLabelPosition
()
:
this
.
getXAxisLabelPosition
();
};
};
c3_chart_internal_fn
.
textForXAxisLabel
=
function
()
{
Axis
.
prototype
.
textForXAxisLabel
=
function
textForXAxisLabel
()
{
return
this
.
get
Axis
LabelText
(
'x'
);
return
this
.
getLabelText
(
'x'
);
};
};
c3_chart_internal_fn
.
textForYAxisLabel
=
function
()
{
Axis
.
prototype
.
textForYAxisLabel
=
function
textForYAxisLabel
()
{
return
this
.
get
Axis
LabelText
(
'y'
);
return
this
.
getLabelText
(
'y'
);
};
};
c3_chart_internal_fn
.
textForY2AxisLabel
=
function
()
{
Axis
.
prototype
.
textForY2AxisLabel
=
function
textForY2AxisLabel
()
{
return
this
.
get
Axis
LabelText
(
'y2'
);
return
this
.
getLabelText
(
'y2'
);
};
};
c3_chart_internal_fn
.
xForAxisLabel
=
function
(
forHorizontal
,
position
)
{
Axis
.
prototype
.
xForAxisLabel
=
function
xForAxisLabel
(
forHorizontal
,
position
)
{
var
$$
=
this
;
var
$$
=
this
.
owner
;
if
(
forHorizontal
)
{
if
(
forHorizontal
)
{
return
position
.
isLeft
?
0
:
position
.
isCenter
?
$$
.
width
/
2
:
$$
.
width
;
return
position
.
isLeft
?
0
:
position
.
isCenter
?
$$
.
width
/
2
:
$$
.
width
;
}
else
{
}
else
{
return
position
.
isBottom
?
-
$$
.
height
:
position
.
isMiddle
?
-
$$
.
height
/
2
:
0
;
return
position
.
isBottom
?
-
$$
.
height
:
position
.
isMiddle
?
-
$$
.
height
/
2
:
0
;
}
}
};
};
c3_chart_internal_fn
.
dxForAxisLabel
=
function
(
forHorizontal
,
position
)
{
Axis
.
prototype
.
dxForAxisLabel
=
function
dxForAxisLabel
(
forHorizontal
,
position
)
{
if
(
forHorizontal
)
{
if
(
forHorizontal
)
{
return
position
.
isLeft
?
"0.5em"
:
position
.
isRight
?
"-0.5em"
:
"0"
;
return
position
.
isLeft
?
"0.5em"
:
position
.
isRight
?
"-0.5em"
:
"0"
;
}
else
{
}
else
{
return
position
.
isTop
?
"-0.5em"
:
position
.
isBottom
?
"0.5em"
:
"0"
;
return
position
.
isTop
?
"-0.5em"
:
position
.
isBottom
?
"0.5em"
:
"0"
;
}
}
};
};
c3_chart_internal_fn
.
textAnchorForAxisLabel
=
function
(
forHorizontal
,
position
)
{
Axis
.
prototype
.
textAnchorForAxisLabel
=
function
textAnchorForAxisLabel
(
forHorizontal
,
position
)
{
if
(
forHorizontal
)
{
if
(
forHorizontal
)
{
return
position
.
isLeft
?
'start'
:
position
.
isCenter
?
'middle'
:
'end'
;
return
position
.
isLeft
?
'start'
:
position
.
isCenter
?
'middle'
:
'end'
;
}
else
{
}
else
{
return
position
.
isBottom
?
'start'
:
position
.
isMiddle
?
'middle'
:
'end'
;
return
position
.
isBottom
?
'start'
:
position
.
isMiddle
?
'middle'
:
'end'
;
}
}
};
};
c3_chart_internal_fn
.
xForXAxisLabel
=
function
()
{
Axis
.
prototype
.
xForXAxisLabel
=
function
xForXAxisLabel
()
{
return
this
.
xForAxisLabel
(
!
this
.
config
.
axis_rotated
,
this
.
getXAxisLabelPosition
());
return
this
.
xForAxisLabel
(
!
this
.
owner
.
config
.
axis_rotated
,
this
.
getXAxisLabelPosition
());
};
};
c3_chart_internal_fn
.
xForYAxisLabel
=
function
()
{
Axis
.
prototype
.
xForYAxisLabel
=
function
xForYAxisLabel
()
{
return
this
.
xForAxisLabel
(
this
.
config
.
axis_rotated
,
this
.
getYAxisLabelPosition
());
return
this
.
xForAxisLabel
(
this
.
owner
.
config
.
axis_rotated
,
this
.
getYAxisLabelPosition
());
};
};
c3_chart_internal_fn
.
xForY2AxisLabel
=
function
()
{
Axis
.
prototype
.
xForY2AxisLabel
=
function
xForY2AxisLabel
()
{
return
this
.
xForAxisLabel
(
this
.
config
.
axis_rotated
,
this
.
getY2AxisLabelPosition
());
return
this
.
xForAxisLabel
(
this
.
owner
.
config
.
axis_rotated
,
this
.
getY2AxisLabelPosition
());
};
};
c3_chart_internal_fn
.
dxForXAxisLabel
=
function
()
{
Axis
.
prototype
.
dxForXAxisLabel
=
function
dxForXAxisLabel
()
{
return
this
.
dxForAxisLabel
(
!
this
.
config
.
axis_rotated
,
this
.
getXAxisLabelPosition
());
return
this
.
dxForAxisLabel
(
!
this
.
owner
.
config
.
axis_rotated
,
this
.
getXAxisLabelPosition
());
};
};
c3_chart_internal_fn
.
dxForYAxisLabel
=
function
()
{
Axis
.
prototype
.
dxForYAxisLabel
=
function
dxForYAxisLabel
()
{
return
this
.
dxForAxisLabel
(
this
.
config
.
axis_rotated
,
this
.
getYAxisLabelPosition
());
return
this
.
dxForAxisLabel
(
this
.
owner
.
config
.
axis_rotated
,
this
.
getYAxisLabelPosition
());
};
};
c3_chart_internal_fn
.
dxForY2AxisLabel
=
function
()
{
Axis
.
prototype
.
dxForY2AxisLabel
=
function
dxForY2AxisLabel
()
{
return
this
.
dxForAxisLabel
(
this
.
config
.
axis_rotated
,
this
.
getY2AxisLabelPosition
());
return
this
.
dxForAxisLabel
(
this
.
owner
.
config
.
axis_rotated
,
this
.
getY2AxisLabelPosition
());
};
};
c3_chart_internal_fn
.
dyForXAxisLabel
=
function
()
{
Axis
.
prototype
.
dyForXAxisLabel
=
function
dyForXAxisLabel
()
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
position
=
$$
.
getXAxisLabelPosition
();
position
=
this
.
getXAxisLabelPosition
();
if
(
config
.
axis_rotated
)
{
if
(
config
.
axis_rotated
)
{
return
position
.
isInner
?
"1.2em"
:
-
25
-
$$
.
getMaxTickWidth
(
'x'
);
return
position
.
isInner
?
"1.2em"
:
-
25
-
this
.
getMaxTickWidth
(
'x'
);
}
else
{
}
else
{
return
position
.
isInner
?
"-0.5em"
:
config
.
axis_x_height
?
config
.
axis_x_height
-
10
:
"3em"
;
return
position
.
isInner
?
"-0.5em"
:
config
.
axis_x_height
?
config
.
axis_x_height
-
10
:
"3em"
;
}
}
};
};
c3_chart_internal_fn
.
dyForYAxisLabel
=
function
()
{
Axis
.
prototype
.
dyForYAxisLabel
=
function
dyForYAxisLabel
()
{
var
$$
=
this
,
var
$$
=
this
.
owner
,
position
=
$$
.
getYAxisLabelPosition
();
position
=
this
.
getYAxisLabelPosition
();
if
(
$$
.
config
.
axis_rotated
)
{
if
(
$$
.
config
.
axis_rotated
)
{
return
position
.
isInner
?
"-0.5em"
:
"3em"
;
return
position
.
isInner
?
"-0.5em"
:
"3em"
;
}
else
{
}
else
{
return
position
.
isInner
?
"1.2em"
:
-
10
-
(
$$
.
config
.
axis_y_inner
?
0
:
(
$$
.
getMaxTickWidth
(
'y'
)
+
10
));
return
position
.
isInner
?
"1.2em"
:
-
10
-
(
$$
.
config
.
axis_y_inner
?
0
:
(
this
.
getMaxTickWidth
(
'y'
)
+
10
));
}
}
};
};
c3_chart_internal_fn
.
dyForY2AxisLabel
=
function
()
{
Axis
.
prototype
.
dyForY2AxisLabel
=
function
dyForY2AxisLabel
()
{
var
$$
=
this
,
var
$$
=
this
.
owner
,
position
=
$$
.
getY2AxisLabelPosition
();
position
=
this
.
getY2AxisLabelPosition
();
if
(
$$
.
config
.
axis_rotated
)
{
if
(
$$
.
config
.
axis_rotated
)
{
return
position
.
isInner
?
"1.2em"
:
"-2.2em"
;
return
position
.
isInner
?
"1.2em"
:
"-2.2em"
;
}
else
{
}
else
{
return
position
.
isInner
?
"-0.5em"
:
15
+
(
$$
.
config
.
axis_y2_inner
?
0
:
(
this
.
getMaxTickWidth
(
'y2'
)
+
15
));
return
position
.
isInner
?
"-0.5em"
:
15
+
(
$$
.
config
.
axis_y2_inner
?
0
:
(
this
.
getMaxTickWidth
(
'y2'
)
+
15
));
}
}
};
};
c3_chart_internal_fn
.
textAnchorForXAxisLabel
=
function
()
{
Axis
.
prototype
.
textAnchorForXAxisLabel
=
function
textAnchorForXAxisLabel
()
{
var
$$
=
this
;
var
$$
=
this
.
owner
;
return
$$
.
textAnchorForAxisLabel
(
!
$$
.
config
.
axis_rotated
,
$$
.
getXAxisLabelPosition
());
return
this
.
textAnchorForAxisLabel
(
!
$$
.
config
.
axis_rotated
,
this
.
getXAxisLabelPosition
());
};
};
c3_chart_internal_fn
.
textAnchorForYAxisLabel
=
function
()
{
Axis
.
prototype
.
textAnchorForYAxisLabel
=
function
textAnchorForYAxisLabel
()
{
var
$$
=
this
;
var
$$
=
this
.
owner
;
return
$$
.
textAnchorForAxisLabel
(
$$
.
config
.
axis_rotated
,
$$
.
getYAxisLabelPosition
());
return
this
.
textAnchorForAxisLabel
(
$$
.
config
.
axis_rotated
,
this
.
getYAxisLabelPosition
());
};
};
c3_chart_internal_fn
.
textAnchorForY2AxisLabel
=
function
()
{
Axis
.
prototype
.
textAnchorForY2AxisLabel
=
function
textAnchorForY2AxisLabel
()
{
var
$$
=
this
;
var
$$
=
this
.
owner
;
return
$$
.
textAnchorForAxisLabel
(
$$
.
config
.
axis_rotated
,
$$
.
getY2AxisLabelPosition
());
return
this
.
textAnchorForAxisLabel
(
$$
.
config
.
axis_rotated
,
this
.
getY2AxisLabelPosition
());
};
};
Axis
.
prototype
.
xForRotatedTickText
=
function
xForRotatedTickText
(
r
)
{
c3_chart_internal_fn
.
xForRotatedTickText
=
function
(
r
)
{
return
8
*
Math
.
sin
(
Math
.
PI
*
(
r
/
180
));
return
8
*
Math
.
sin
(
Math
.
PI
*
(
r
/
180
));
};
};
c3_chart_internal_fn
.
yForRotatedTickText
=
function
(
r
)
{
Axis
.
prototype
.
yForRotatedTickText
=
function
yForRotatedTickText
(
r
)
{
return
11.5
-
2.5
*
(
r
/
15
)
*
(
r
>
0
?
1
:
-
1
);
return
11.5
-
2.5
*
(
r
/
15
)
*
(
r
>
0
?
1
:
-
1
);
};
};
c3_chart_internal_fn
.
rotateTickText
=
function
(
axis
,
transition
,
rotate
)
{
Axis
.
prototype
.
rotateTickText
=
function
rotateTickText
(
axis
,
transition
,
rotate
)
{
axis
.
selectAll
(
'.tick text'
)
axis
.
selectAll
(
'.tick text'
)
.
style
(
"text-anchor"
,
rotate
>
0
?
"start"
:
"end"
);
.
style
(
"text-anchor"
,
rotate
>
0
?
"start"
:
"end"
);
transition
.
selectAll
(
'.tick text'
)
transition
.
selectAll
(
'.tick text'
)
...
@@ -277,9 +286,8 @@ c3_chart_internal_fn.rotateTickText = function (axis, transition, rotate) {
...
@@ -277,9 +286,8 @@ c3_chart_internal_fn.rotateTickText = function (axis, transition, rotate) {
.
selectAll
(
'tspan'
)
.
selectAll
(
'tspan'
)
.
attr
(
'dx'
,
this
.
xForRotatedTickText
(
rotate
));
.
attr
(
'dx'
,
this
.
xForRotatedTickText
(
rotate
));
};
};
Axis
.
prototype
.
getMaxTickWidth
=
function
getMaxTickWidth
(
id
,
withoutRecompute
)
{
c3_chart_internal_fn
.
getMaxTickWidth
=
function
(
id
,
withoutRecompute
)
{
var
$$
=
this
.
owner
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
maxWidth
=
0
,
targetsToShow
,
scale
,
axis
,
body
,
svg
;
maxWidth
=
0
,
targetsToShow
,
scale
,
axis
,
body
,
svg
;
if
(
withoutRecompute
&&
$$
.
currentMaxTickWidths
[
id
])
{
if
(
withoutRecompute
&&
$$
.
currentMaxTickWidths
[
id
])
{
return
$$
.
currentMaxTickWidths
[
id
];
return
$$
.
currentMaxTickWidths
[
id
];
...
@@ -288,16 +296,16 @@ c3_chart_internal_fn.getMaxTickWidth = function (id, withoutRecompute) {
...
@@ -288,16 +296,16 @@ c3_chart_internal_fn.getMaxTickWidth = function (id, withoutRecompute) {
targetsToShow
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
);
targetsToShow
=
$$
.
filterTargetsToShow
(
$$
.
data
.
targets
);
if
(
id
===
'y'
)
{
if
(
id
===
'y'
)
{
scale
=
$$
.
y
.
copy
().
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y'
));
scale
=
$$
.
y
.
copy
().
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y'
));
axis
=
$$
.
getYAxis
(
scale
,
$$
.
yOrient
,
config
.
axis_y_tick_format
,
$$
.
yAxisTickValues
);
axis
=
this
.
getYAxis
(
scale
,
$$
.
yOrient
,
config
.
axis_y_tick_format
,
$$
.
yAxisTickValues
);
}
else
if
(
id
===
'y2'
)
{
}
else
if
(
id
===
'y2'
)
{
scale
=
$$
.
y2
.
copy
().
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y2'
));
scale
=
$$
.
y2
.
copy
().
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y2'
));
axis
=
$$
.
getYAxis
(
scale
,
$$
.
y2Orient
,
config
.
axis_y2_tick_format
,
$$
.
y2AxisTickValues
);
axis
=
this
.
getYAxis
(
scale
,
$$
.
y2Orient
,
config
.
axis_y2_tick_format
,
$$
.
y2AxisTickValues
);
}
else
{
}
else
{
scale
=
$$
.
x
.
copy
().
domain
(
$$
.
getXDomain
(
targetsToShow
));
scale
=
$$
.
x
.
copy
().
domain
(
$$
.
getXDomain
(
targetsToShow
));
axis
=
$$
.
getXAxis
(
scale
,
$$
.
xOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
);
axis
=
this
.
getXAxis
(
scale
,
$$
.
xOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
);
$$
.
updateXAxisTickValues
(
targetsToShow
,
axis
);
this
.
updateXAxisTickValues
(
targetsToShow
,
axis
);
}
}
body
=
this
.
d3
.
select
(
'body'
).
classed
(
'c3'
,
true
);
body
=
$$
.
d3
.
select
(
'body'
).
classed
(
'c3'
,
true
);
svg
=
body
.
append
(
'svg'
).
style
(
'visibility'
,
'hidden'
);
svg
=
body
.
append
(
'svg'
).
style
(
'visibility'
,
'hidden'
);
svg
.
append
(
'g'
).
call
(
axis
).
each
(
function
()
{
svg
.
append
(
'g'
).
call
(
axis
).
each
(
function
()
{
$$
.
d3
.
select
(
this
).
selectAll
(
'text tspan'
).
each
(
function
()
{
$$
.
d3
.
select
(
this
).
selectAll
(
'text tspan'
).
each
(
function
()
{
...
@@ -314,30 +322,28 @@ c3_chart_internal_fn.getMaxTickWidth = function (id, withoutRecompute) {
...
@@ -314,30 +322,28 @@ c3_chart_internal_fn.getMaxTickWidth = function (id, withoutRecompute) {
$$
.
currentMaxTickWidths
[
id
]
=
maxWidth
<=
0
?
$$
.
currentMaxTickWidths
[
id
]
:
maxWidth
;
$$
.
currentMaxTickWidths
[
id
]
=
maxWidth
<=
0
?
$$
.
currentMaxTickWidths
[
id
]
:
maxWidth
;
return
$$
.
currentMaxTickWidths
[
id
];
return
$$
.
currentMaxTickWidths
[
id
];
};
};
Axis
.
prototype
.
updateLabels
=
function
updateLabels
(
withTransition
)
{
c3_chart_internal_fn
.
updateAxisLabels
=
function
(
withTransition
)
{
var
$$
=
this
.
owner
;
var
$$
=
this
;
var
axisXLabel
=
$$
.
main
.
select
(
'.'
+
CLASS
.
axisX
+
' .'
+
CLASS
.
axisXLabel
),
var
axisXLabel
=
$$
.
main
.
select
(
'.'
+
CLASS
.
axisX
+
' .'
+
CLASS
.
axisXLabel
),
axisYLabel
=
$$
.
main
.
select
(
'.'
+
CLASS
.
axisY
+
' .'
+
CLASS
.
axisYLabel
),
axisYLabel
=
$$
.
main
.
select
(
'.'
+
CLASS
.
axisY
+
' .'
+
CLASS
.
axisYLabel
),
axisY2Label
=
$$
.
main
.
select
(
'.'
+
CLASS
.
axisY2
+
' .'
+
CLASS
.
axisY2Label
);
axisY2Label
=
$$
.
main
.
select
(
'.'
+
CLASS
.
axisY2
+
' .'
+
CLASS
.
axisY2Label
);
(
withTransition
?
axisXLabel
.
transition
()
:
axisXLabel
)
(
withTransition
?
axisXLabel
.
transition
()
:
axisXLabel
)
.
attr
(
"x"
,
$$
.
xForXAxisLabel
.
bind
(
$$
))
.
attr
(
"x"
,
this
.
xForXAxisLabel
.
bind
(
this
))
.
attr
(
"dx"
,
$$
.
dxForXAxisLabel
.
bind
(
$$
))
.
attr
(
"dx"
,
this
.
dxForXAxisLabel
.
bind
(
this
))
.
attr
(
"dy"
,
$$
.
dyForXAxisLabel
.
bind
(
$$
))
.
attr
(
"dy"
,
this
.
dyForXAxisLabel
.
bind
(
this
))
.
text
(
$$
.
textForXAxisLabel
.
bind
(
$$
));
.
text
(
this
.
textForXAxisLabel
.
bind
(
this
));
(
withTransition
?
axisYLabel
.
transition
()
:
axisYLabel
)
(
withTransition
?
axisYLabel
.
transition
()
:
axisYLabel
)
.
attr
(
"x"
,
$$
.
xForYAxisLabel
.
bind
(
$$
))
.
attr
(
"x"
,
this
.
xForYAxisLabel
.
bind
(
this
))
.
attr
(
"dx"
,
$$
.
dxForYAxisLabel
.
bind
(
$$
))
.
attr
(
"dx"
,
this
.
dxForYAxisLabel
.
bind
(
this
))
.
attr
(
"dy"
,
$$
.
dyForYAxisLabel
.
bind
(
$$
))
.
attr
(
"dy"
,
this
.
dyForYAxisLabel
.
bind
(
this
))
.
text
(
$$
.
textForYAxisLabel
.
bind
(
$$
));
.
text
(
this
.
textForYAxisLabel
.
bind
(
this
));
(
withTransition
?
axisY2Label
.
transition
()
:
axisY2Label
)
(
withTransition
?
axisY2Label
.
transition
()
:
axisY2Label
)
.
attr
(
"x"
,
$$
.
xForY2AxisLabel
.
bind
(
$$
))
.
attr
(
"x"
,
this
.
xForY2AxisLabel
.
bind
(
this
))
.
attr
(
"dx"
,
$$
.
dxForY2AxisLabel
.
bind
(
$$
))
.
attr
(
"dx"
,
this
.
dxForY2AxisLabel
.
bind
(
this
))
.
attr
(
"dy"
,
$$
.
dyForY2AxisLabel
.
bind
(
$$
))
.
attr
(
"dy"
,
this
.
dyForY2AxisLabel
.
bind
(
this
))
.
text
(
$$
.
textForY2AxisLabel
.
bind
(
$$
));
.
text
(
this
.
textForY2AxisLabel
.
bind
(
this
));
};
};
Axis
.
prototype
.
getPadding
=
function
getPadding
(
padding
,
key
,
defaultValue
,
domainLength
)
{
c3_chart_internal_fn
.
getAxisPadding
=
function
(
padding
,
key
,
defaultValue
,
domainLength
)
{
if
(
!
isValue
(
padding
[
key
]))
{
if
(
!
isValue
(
padding
[
key
]))
{
return
defaultValue
;
return
defaultValue
;
}
}
...
@@ -347,12 +353,12 @@ c3_chart_internal_fn.getAxisPadding = function (padding, key, defaultValue, doma
...
@@ -347,12 +353,12 @@ c3_chart_internal_fn.getAxisPadding = function (padding, key, defaultValue, doma
// assume padding is pixels if unit is not specified
// assume padding is pixels if unit is not specified
return
this
.
convertPixelsToAxisPadding
(
padding
[
key
],
domainLength
);
return
this
.
convertPixelsToAxisPadding
(
padding
[
key
],
domainLength
);
};
};
c3_chart_internal_fn
.
convertPixelsToAxisPadding
=
function
(
pixels
,
domainLength
)
{
Axis
.
prototype
.
convertPixelsToAxisPadding
=
function
convertPixelsToAxisPadding
(
pixels
,
domainLength
)
{
var
length
=
this
.
config
.
axis_rotated
?
this
.
width
:
this
.
height
;
var
$$
=
this
.
owner
,
length
=
$$
.
config
.
axis_rotated
?
$$
.
width
:
$$
.
height
;
return
domainLength
*
(
pixels
/
length
);
return
domainLength
*
(
pixels
/
length
);
};
};
Axis
.
prototype
.
generateTickValues
=
function
generateTickValues
(
values
,
tickCount
,
forTimeSeries
)
{
c3_chart_internal_fn
.
generateTickValues
=
function
(
values
,
tickCount
,
forTimeSeries
)
{
var
tickValues
=
values
,
targetCount
,
start
,
end
,
count
,
interval
,
i
,
tickValue
;
var
tickValues
=
values
,
targetCount
,
start
,
end
,
count
,
interval
,
i
,
tickValue
;
if
(
tickCount
)
{
if
(
tickCount
)
{
targetCount
=
isFunction
(
tickCount
)
?
tickCount
()
:
tickCount
;
targetCount
=
isFunction
(
tickCount
)
?
tickCount
()
:
tickCount
;
...
@@ -378,8 +384,8 @@ c3_chart_internal_fn.generateTickValues = function (values, tickCount, forTimeSe
...
@@ -378,8 +384,8 @@ c3_chart_internal_fn.generateTickValues = function (values, tickCount, forTimeSe
if
(
!
forTimeSeries
)
{
tickValues
=
tickValues
.
sort
(
function
(
a
,
b
)
{
return
a
-
b
;
});
}
if
(
!
forTimeSeries
)
{
tickValues
=
tickValues
.
sort
(
function
(
a
,
b
)
{
return
a
-
b
;
});
}
return
tickValues
;
return
tickValues
;
};
};
c3_chart_internal_fn
.
generateAxisTransitions
=
function
(
duration
)
{
Axis
.
prototype
.
generateTransitions
=
function
generateTransitions
(
duration
)
{
var
$$
=
this
,
axes
=
$$
.
axes
;
var
$$
=
this
.
owner
,
axes
=
$$
.
axes
;
return
{
return
{
axisX
:
duration
?
axes
.
x
.
transition
().
duration
(
duration
)
:
axes
.
x
,
axisX
:
duration
?
axes
.
x
.
transition
().
duration
(
duration
)
:
axes
.
x
,
axisY
:
duration
?
axes
.
y
.
transition
().
duration
(
duration
)
:
axes
.
y
,
axisY
:
duration
?
axes
.
y
.
transition
().
duration
(
duration
)
:
axes
.
y
,
...
@@ -387,8 +393,8 @@ c3_chart_internal_fn.generateAxisTransitions = function (duration) {
...
@@ -387,8 +393,8 @@ c3_chart_internal_fn.generateAxisTransitions = function (duration) {
axisSubX
:
duration
?
axes
.
subx
.
transition
().
duration
(
duration
)
:
axes
.
subx
axisSubX
:
duration
?
axes
.
subx
.
transition
().
duration
(
duration
)
:
axes
.
subx
};
};
};
};
c3_chart_internal_fn
.
redrawAxis
=
function
(
transitions
,
isHidden
)
{
Axis
.
prototype
.
redraw
=
function
redraw
(
transitions
,
isHidden
)
{
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
.
owner
,
config
=
$$
.
config
;
$$
.
axes
.
x
.
style
(
"opacity"
,
isHidden
?
0
:
1
);
$$
.
axes
.
x
.
style
(
"opacity"
,
isHidden
?
0
:
1
);
$$
.
axes
.
y
.
style
(
"opacity"
,
isHidden
?
0
:
1
);
$$
.
axes
.
y
.
style
(
"opacity"
,
isHidden
?
0
:
1
);
$$
.
axes
.
y2
.
style
(
"opacity"
,
isHidden
?
0
:
1
);
$$
.
axes
.
y2
.
style
(
"opacity"
,
isHidden
?
0
:
1
);
...
@@ -399,7 +405,7 @@ c3_chart_internal_fn.redrawAxis = function (transitions, isHidden) {
...
@@ -399,7 +405,7 @@ c3_chart_internal_fn.redrawAxis = function (transitions, isHidden) {
transitions
.
axisSubX
.
call
(
$$
.
subXAxis
);
transitions
.
axisSubX
.
call
(
$$
.
subXAxis
);
// rotate tick text if needed
// rotate tick text if needed
if
(
!
config
.
axis_rotated
&&
config
.
axis_x_tick_rotate
)
{
if
(
!
config
.
axis_rotated
&&
config
.
axis_x_tick_rotate
)
{
$$
.
rotateTickText
(
$$
.
axes
.
x
,
transitions
.
axisX
,
config
.
axis_x_tick_rotate
);
this
.
rotateTickText
(
$$
.
axes
.
x
,
transitions
.
axisX
,
config
.
axis_x_tick_rotate
);
$$
.
rotateTickText
(
$$
.
axes
.
subx
,
transitions
.
axisSubX
,
config
.
axis_x_tick_rotate
);
this
.
rotateTickText
(
$$
.
axes
.
subx
,
transitions
.
axisSubX
,
config
.
axis_x_tick_rotate
);
}
}
};
};
src/core.js
View file @
5c0c8ecc
var
c3
=
{
version
:
"0.4.9"
};
var
c3
=
{
version
:
"0.4.9"
};
var
c3_chart_fn
,
c3_chart_internal_fn
;
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
{
var
f
=
function
f
()
{};
f
.
prototype
=
base
.
prototype
;
derived
.
prototype
=
new
f
();
}
derived
.
prototype
.
constructor
=
derived
;
return
derived
;
}
function
Chart
(
config
)
{
function
Chart
(
config
)
{
var
$$
=
this
.
internal
=
new
ChartInternal
(
this
);
var
$$
=
this
.
internal
=
new
ChartInternal
(
this
);
...
@@ -35,12 +56,15 @@ c3.generate = function (config) {
...
@@ -35,12 +56,15 @@ c3.generate = function (config) {
c3
.
chart
=
{
c3
.
chart
=
{
fn
:
Chart
.
prototype
,
fn
:
Chart
.
prototype
,
internal
:
{
internal
:
{
fn
:
ChartInternal
.
prototype
fn
:
ChartInternal
.
prototype
,
axis
:
{
fn
:
Axis
.
prototype
}
}
}
};
};
c3_chart_fn
=
c3
.
chart
.
fn
;
c3_chart_fn
=
c3
.
chart
.
fn
;
c3_chart_internal_fn
=
c3
.
chart
.
internal
.
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
()
{
c3_chart_internal_fn
.
init
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
;
var
$$
=
this
,
config
=
$$
.
config
;
...
@@ -149,6 +173,8 @@ c3_chart_internal_fn.initWithData = function (data) {
...
@@ -149,6 +173,8 @@ c3_chart_internal_fn.initWithData = function (data) {
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
var
$$
=
this
,
d3
=
$$
.
d3
,
config
=
$$
.
config
;
var
defs
,
main
,
binding
=
true
;
var
defs
,
main
,
binding
=
true
;
$$
.
axis
=
new
Axis
(
$$
);
if
(
$$
.
initPie
)
{
$$
.
initPie
();
}
if
(
$$
.
initPie
)
{
$$
.
initPie
();
}
if
(
$$
.
initBrush
)
{
$$
.
initBrush
();
}
if
(
$$
.
initBrush
)
{
$$
.
initBrush
();
}
if
(
$$
.
initZoom
)
{
$$
.
initZoom
();
}
if
(
$$
.
initZoom
)
{
$$
.
initZoom
();
}
...
@@ -266,7 +292,7 @@ c3_chart_internal_fn.initWithData = function (data) {
...
@@ -266,7 +292,7 @@ c3_chart_internal_fn.initWithData = function (data) {
if
(
config
.
axis_x_extent
)
{
$$
.
brush
.
extent
(
$$
.
getDefaultExtent
());
}
if
(
config
.
axis_x_extent
)
{
$$
.
brush
.
extent
(
$$
.
getDefaultExtent
());
}
// Add Axis
// Add Axis
$$
.
initAxis
();
$$
.
axis
.
init
();
// Set targets
// Set targets
$$
.
updateTargets
(
$$
.
data
.
targets
);
$$
.
updateTargets
(
$$
.
data
.
targets
);
...
@@ -456,7 +482,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
...
@@ -456,7 +482,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
durationForExit
=
withTransitionForExit
?
duration
:
0
;
durationForExit
=
withTransitionForExit
?
duration
:
0
;
durationForAxis
=
withTransitionForAxis
?
duration
:
0
;
durationForAxis
=
withTransitionForAxis
?
duration
:
0
;
transitions
=
transitions
||
$$
.
generateAxis
Transitions
(
durationForAxis
);
transitions
=
transitions
||
$$
.
axis
.
generate
Transitions
(
durationForAxis
);
// update legend and transform each g
// update legend and transform each g
if
(
withLegend
&&
config
.
legend_show
)
{
if
(
withLegend
&&
config
.
legend_show
)
{
...
@@ -475,7 +501,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
...
@@ -475,7 +501,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
if
(
targetsToShow
.
length
)
{
if
(
targetsToShow
.
length
)
{
$$
.
updateXDomain
(
targetsToShow
,
withUpdateXDomain
,
withUpdateOrgXDomain
,
withTrimXDomain
);
$$
.
updateXDomain
(
targetsToShow
,
withUpdateXDomain
,
withUpdateOrgXDomain
,
withTrimXDomain
);
if
(
!
config
.
axis_x_tick_values
)
{
if
(
!
config
.
axis_x_tick_values
)
{
tickValues
=
$$
.
updateXAxisTickValues
(
targetsToShow
);
tickValues
=
$$
.
axis
.
updateXAxisTickValues
(
targetsToShow
);
}
}
}
else
{
}
else
{
$$
.
xAxis
.
tickValues
([]);
$$
.
xAxis
.
tickValues
([]);
...
@@ -490,17 +516,17 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
...
@@ -490,17 +516,17 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
$$
.
y2
.
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y2'
,
xDomainForZoom
));
$$
.
y2
.
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y2'
,
xDomainForZoom
));
if
(
!
config
.
axis_y_tick_values
&&
config
.
axis_y_tick_count
)
{
if
(
!
config
.
axis_y_tick_values
&&
config
.
axis_y_tick_count
)
{
$$
.
yAxis
.
tickValues
(
$$
.
generateTickValues
(
$$
.
y
.
domain
(),
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
)
{
if
(
!
config
.
axis_y2_tick_values
&&
config
.
axis_y2_tick_count
)
{
$$
.
y2Axis
.
tickValues
(
$$
.
generateTickValues
(
$$
.
y2
.
domain
(),
config
.
axis_y2_tick_count
));
$$
.
y2Axis
.
tickValues
(
$$
.
axis
.
generateTickValues
(
$$
.
y2
.
domain
(),
config
.
axis_y2_tick_count
));
}
}
// axes
// axes
$$
.
redrawAxis
(
transitions
,
hideAxis
);
$$
.
axis
.
redraw
(
transitions
,
hideAxis
);
// Update axis label
// Update axis label
$$
.
updateAxis
Labels
(
withTransition
);
$$
.
axis
.
update
Labels
(
withTransition
);
// show/hide if manual culling needed
// show/hide if manual culling needed
if
((
withUpdateXDomain
||
withUpdateXAxis
)
&&
targetsToShow
.
length
)
{
if
((
withUpdateXDomain
||
withUpdateXAxis
)
&&
targetsToShow
.
length
)
{
...
@@ -681,7 +707,7 @@ c3_chart_internal_fn.updateAndRedraw = function (options) {
...
@@ -681,7 +707,7 @@ c3_chart_internal_fn.updateAndRedraw = function (options) {
$$
.
updateSizes
();
$$
.
updateSizes
();
// MEMO: called in updateLegend in redraw if withLegend
// MEMO: called in updateLegend in redraw if withLegend
if
(
!
(
options
.
withLegend
&&
config
.
legend_show
))
{
if
(
!
(
options
.
withLegend
&&
config
.
legend_show
))
{
transitions
=
$$
.
generateAxis
Transitions
(
options
.
withTransitionForAxis
?
config
.
transition_duration
:
0
);
transitions
=
$$
.
axis
.
generate
Transitions
(
options
.
withTransitionForAxis
?
config
.
transition_duration
:
0
);
// Update scales
// Update scales
$$
.
updateScales
();
$$
.
updateScales
();
$$
.
updateSvgSize
();
$$
.
updateSvgSize
();
...
...
src/domain.js
View file @
5c0c8ecc
...
@@ -20,7 +20,7 @@ c3_chart_internal_fn.getYDomainMin = function (targets) {
...
@@ -20,7 +20,7 @@ c3_chart_internal_fn.getYDomainMin = function (targets) {
id
=
idsInGroup
[
k
];
id
=
idsInGroup
[
k
];
if
(
!
ys
[
id
])
{
continue
;
}
if
(
!
ys
[
id
])
{
continue
;
}
ys
[
id
].
forEach
(
function
(
v
,
i
)
{
ys
[
id
].
forEach
(
function
(
v
,
i
)
{
if
(
$$
.
getAxisId
(
id
)
===
$$
.
getAxis
Id
(
baseId
)
&&
ys
[
baseId
]
&&
!
(
hasNegativeValue
&&
+
v
>
0
))
{
if
(
$$
.
axis
.
getId
(
id
)
===
$$
.
axis
.
get
Id
(
baseId
)
&&
ys
[
baseId
]
&&
!
(
hasNegativeValue
&&
+
v
>
0
))
{
ys
[
baseId
][
i
]
+=
+
v
;
ys
[
baseId
][
i
]
+=
+
v
;
}
}
});
});
...
@@ -51,7 +51,7 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
...
@@ -51,7 +51,7 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
id
=
idsInGroup
[
k
];
id
=
idsInGroup
[
k
];
if
(
!
ys
[
id
])
{
continue
;
}
if
(
!
ys
[
id
])
{
continue
;
}
ys
[
id
].
forEach
(
function
(
v
,
i
)
{
ys
[
id
].
forEach
(
function
(
v
,
i
)
{
if
(
$$
.
getAxisId
(
id
)
===
$$
.
getAxis
Id
(
baseId
)
&&
ys
[
baseId
]
&&
!
(
hasPositiveValue
&&
+
v
<
0
))
{
if
(
$$
.
axis
.
getId
(
id
)
===
$$
.
axis
.
get
Id
(
baseId
)
&&
ys
[
baseId
]
&&
!
(
hasPositiveValue
&&
+
v
<
0
))
{
ys
[
baseId
][
i
]
+=
+
v
;
ys
[
baseId
][
i
]
+=
+
v
;
}
}
});
});
...
@@ -62,7 +62,7 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
...
@@ -62,7 +62,7 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
};
};
c3_chart_internal_fn
.
getYDomain
=
function
(
targets
,
axisId
,
xDomain
)
{
c3_chart_internal_fn
.
getYDomain
=
function
(
targets
,
axisId
,
xDomain
)
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
targetsByAxisId
=
targets
.
filter
(
function
(
t
)
{
return
$$
.
getAxis
Id
(
t
.
id
)
===
axisId
;
}),
targetsByAxisId
=
targets
.
filter
(
function
(
t
)
{
return
$$
.
axis
.
get
Id
(
t
.
id
)
===
axisId
;
}),
yTargets
=
xDomain
?
$$
.
filterByXDomain
(
targetsByAxisId
,
xDomain
)
:
targetsByAxisId
,
yTargets
=
xDomain
?
$$
.
filterByXDomain
(
targetsByAxisId
,
xDomain
)
:
targetsByAxisId
,
yMin
=
axisId
===
'y2'
?
config
.
axis_y2_min
:
config
.
axis_y_min
,
yMin
=
axisId
===
'y2'
?
config
.
axis_y2_min
:
config
.
axis_y_min
,
yMax
=
axisId
===
'y2'
?
config
.
axis_y2_max
:
config
.
axis_y_max
,
yMax
=
axisId
===
'y2'
?
config
.
axis_y2_max
:
config
.
axis_y_max
,
...
@@ -123,16 +123,16 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) {
...
@@ -123,16 +123,16 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) {
padding_bottom
+=
domainLength
*
(
ratio
[
0
]
/
(
1
-
ratio
[
0
]
-
ratio
[
1
]));
padding_bottom
+=
domainLength
*
(
ratio
[
0
]
/
(
1
-
ratio
[
0
]
-
ratio
[
1
]));
}
else
if
(
showVerticalDataLabel
)
{
}
else
if
(
showVerticalDataLabel
)
{
lengths
=
$$
.
getDataLabelLength
(
yDomainMin
,
yDomainMax
,
'height'
);
lengths
=
$$
.
getDataLabelLength
(
yDomainMin
,
yDomainMax
,
'height'
);
padding_top
+=
th
is
.
convertPixelsToAxisPadding
(
lengths
[
1
],
domainLength
);
padding_top
+=
$$
.
ax
is
.
convertPixelsToAxisPadding
(
lengths
[
1
],
domainLength
);
padding_bottom
+=
th
is
.
convertPixelsToAxisPadding
(
lengths
[
0
],
domainLength
);
padding_bottom
+=
$$
.
ax
is
.
convertPixelsToAxisPadding
(
lengths
[
0
],
domainLength
);
}
}
if
(
axisId
===
'y'
&&
notEmpty
(
config
.
axis_y_padding
))
{
if
(
axisId
===
'y'
&&
notEmpty
(
config
.
axis_y_padding
))
{
padding_top
=
$$
.
getAxis
Padding
(
config
.
axis_y_padding
,
'top'
,
padding_top
,
domainLength
);
padding_top
=
$$
.
axis
.
get
Padding
(
config
.
axis_y_padding
,
'top'
,
padding_top
,
domainLength
);
padding_bottom
=
$$
.
getAxis
Padding
(
config
.
axis_y_padding
,
'bottom'
,
padding_bottom
,
domainLength
);
padding_bottom
=
$$
.
axis
.
get
Padding
(
config
.
axis_y_padding
,
'bottom'
,
padding_bottom
,
domainLength
);
}
}
if
(
axisId
===
'y2'
&&
notEmpty
(
config
.
axis_y2_padding
))
{
if
(
axisId
===
'y2'
&&
notEmpty
(
config
.
axis_y2_padding
))
{
padding_top
=
$$
.
getAxis
Padding
(
config
.
axis_y2_padding
,
'top'
,
padding_top
,
domainLength
);
padding_top
=
$$
.
axis
.
get
Padding
(
config
.
axis_y2_padding
,
'top'
,
padding_top
,
domainLength
);
padding_bottom
=
$$
.
getAxis
Padding
(
config
.
axis_y2_padding
,
'bottom'
,
padding_bottom
,
domainLength
);
padding_bottom
=
$$
.
axis
.
get
Padding
(
config
.
axis_y2_padding
,
'bottom'
,
padding_bottom
,
domainLength
);
}
}
// Bar/Area chart should be 0-based if all positive|negative
// Bar/Area chart should be 0-based if all positive|negative
if
(
isZeroBased
)
{
if
(
isZeroBased
)
{
...
...
src/format.js
View file @
5c0c8ecc
...
@@ -3,7 +3,7 @@ c3_chart_internal_fn.getYFormat = function (forArc) {
...
@@ -3,7 +3,7 @@ c3_chart_internal_fn.getYFormat = function (forArc) {
formatForY
=
forArc
&&
!
$$
.
hasType
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
yFormat
,
formatForY
=
forArc
&&
!
$$
.
hasType
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
yFormat
,
formatForY2
=
forArc
&&
!
$$
.
hasType
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
y2Format
;
formatForY2
=
forArc
&&
!
$$
.
hasType
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
y2Format
;
return
function
(
v
,
ratio
,
id
)
{
return
function
(
v
,
ratio
,
id
)
{
var
format
=
$$
.
getAxis
Id
(
id
)
===
'y2'
?
formatForY2
:
formatForY
;
var
format
=
$$
.
axis
.
get
Id
(
id
)
===
'y2'
?
formatForY2
:
formatForY
;
return
format
.
call
(
$$
,
v
,
ratio
);
return
format
.
call
(
$$
,
v
,
ratio
);
};
};
};
};
...
...
src/scale.js
View file @
5c0c8ecc
...
@@ -44,10 +44,10 @@ c3_chart_internal_fn.getY = function (min, max, domain) {
...
@@ -44,10 +44,10 @@ c3_chart_internal_fn.getY = function (min, max, domain) {
return
scale
;
return
scale
;
};
};
c3_chart_internal_fn
.
getYScale
=
function
(
id
)
{
c3_chart_internal_fn
.
getYScale
=
function
(
id
)
{
return
this
.
getAxis
Id
(
id
)
===
'y2'
?
this
.
y2
:
this
.
y
;
return
this
.
axis
.
get
Id
(
id
)
===
'y2'
?
this
.
y2
:
this
.
y
;
};
};
c3_chart_internal_fn
.
getSubYScale
=
function
(
id
)
{
c3_chart_internal_fn
.
getSubYScale
=
function
(
id
)
{
return
this
.
getAxis
Id
(
id
)
===
'y2'
?
this
.
subY2
:
this
.
subY
;
return
this
.
axis
.
get
Id
(
id
)
===
'y2'
?
this
.
subY2
:
this
.
subY
;
};
};
c3_chart_internal_fn
.
updateScales
=
function
()
{
c3_chart_internal_fn
.
updateScales
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
var
$$
=
this
,
config
=
$$
.
config
,
...
@@ -69,15 +69,15 @@ c3_chart_internal_fn.updateScales = function () {
...
@@ -69,15 +69,15 @@ c3_chart_internal_fn.updateScales = function () {
$$
.
subY
=
$$
.
getY
(
$$
.
subYMin
,
$$
.
subYMax
,
forInit
?
config
.
axis_y_default
:
$$
.
subY
.
domain
());
$$
.
subY
=
$$
.
getY
(
$$
.
subYMin
,
$$
.
subYMax
,
forInit
?
config
.
axis_y_default
:
$$
.
subY
.
domain
());
$$
.
subY2
=
$$
.
getY
(
$$
.
subYMin
,
$$
.
subYMax
,
forInit
?
config
.
axis_y2_default
:
$$
.
subY2
.
domain
());
$$
.
subY2
=
$$
.
getY
(
$$
.
subYMin
,
$$
.
subYMax
,
forInit
?
config
.
axis_y2_default
:
$$
.
subY2
.
domain
());
// update axes
// update axes
$$
.
xAxisTickFormat
=
$$
.
getXAxisTickFormat
();
$$
.
xAxisTickFormat
=
$$
.
axis
.
getXAxisTickFormat
();
$$
.
xAxisTickValues
=
$$
.
getXAxisTickValues
();
$$
.
xAxisTickValues
=
$$
.
axis
.
getXAxisTickValues
();
$$
.
yAxisTickValues
=
$$
.
getYAxisTickValues
();
$$
.
yAxisTickValues
=
$$
.
axis
.
getYAxisTickValues
();
$$
.
y2AxisTickValues
=
$$
.
getY2AxisTickValues
();
$$
.
y2AxisTickValues
=
$$
.
axis
.
getY2AxisTickValues
();
$$
.
xAxis
=
$$
.
getXAxis
(
$$
.
x
,
$$
.
xOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
,
config
.
axis_x_tick_outer
);
$$
.
xAxis
=
$$
.
axis
.
getXAxis
(
$$
.
x
,
$$
.
xOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
,
config
.
axis_x_tick_outer
);
$$
.
subXAxis
=
$$
.
getXAxis
(
$$
.
subX
,
$$
.
subXOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
,
config
.
axis_x_tick_outer
);
$$
.
subXAxis
=
$$
.
axis
.
getXAxis
(
$$
.
subX
,
$$
.
subXOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
,
config
.
axis_x_tick_outer
);
$$
.
yAxis
=
$$
.
getYAxis
(
$$
.
y
,
$$
.
yOrient
,
config
.
axis_y_tick_format
,
$$
.
yAxisTickValues
,
config
.
axis_y_tick_outer
);
$$
.
yAxis
=
$$
.
axis
.
getYAxis
(
$$
.
y
,
$$
.
yOrient
,
config
.
axis_y_tick_format
,
$$
.
yAxisTickValues
,
config
.
axis_y_tick_outer
);
$$
.
y2Axis
=
$$
.
getYAxis
(
$$
.
y2
,
$$
.
y2Orient
,
config
.
axis_y2_tick_format
,
$$
.
y2AxisTickValues
,
config
.
axis_y2_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
// Set initialized scales to brush and zoom
if
(
!
forInit
)
{
if
(
!
forInit
)
{
...
...
src/size.js
View file @
5c0c8ecc
...
@@ -22,7 +22,7 @@ c3_chart_internal_fn.getCurrentPaddingLeft = function (withoutRecompute) {
...
@@ -22,7 +22,7 @@ c3_chart_internal_fn.getCurrentPaddingLeft = function (withoutRecompute) {
}
else
if
(
config
.
axis_rotated
)
{
}
else
if
(
config
.
axis_rotated
)
{
return
!
config
.
axis_x_show
?
1
:
Math
.
max
(
ceil10
(
$$
.
getAxisWidthByAxisId
(
'x'
,
withoutRecompute
)),
40
);
return
!
config
.
axis_x_show
?
1
:
Math
.
max
(
ceil10
(
$$
.
getAxisWidthByAxisId
(
'x'
,
withoutRecompute
)),
40
);
}
else
if
(
!
config
.
axis_y_show
||
config
.
axis_y_inner
)
{
// && !config.axis_rotated
}
else
if
(
!
config
.
axis_y_show
||
config
.
axis_y_inner
)
{
// && !config.axis_rotated
return
$$
.
getYAxisLabelPosition
().
isOuter
?
30
:
1
;
return
$$
.
axis
.
getYAxisLabelPosition
().
isOuter
?
30
:
1
;
}
else
{
}
else
{
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y'
,
withoutRecompute
));
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y'
,
withoutRecompute
));
}
}
...
@@ -35,7 +35,7 @@ c3_chart_internal_fn.getCurrentPaddingRight = function () {
...
@@ -35,7 +35,7 @@ c3_chart_internal_fn.getCurrentPaddingRight = function () {
}
else
if
(
config
.
axis_rotated
)
{
}
else
if
(
config
.
axis_rotated
)
{
return
defaultPadding
+
legendWidthOnRight
;
return
defaultPadding
+
legendWidthOnRight
;
}
else
if
(
!
config
.
axis_y2_show
||
config
.
axis_y2_inner
)
{
// && !config.axis_rotated
}
else
if
(
!
config
.
axis_y2_show
||
config
.
axis_y2_inner
)
{
// && !config.axis_rotated
return
2
+
legendWidthOnRight
+
(
$$
.
getY2AxisLabelPosition
().
isOuter
?
20
:
0
);
return
2
+
legendWidthOnRight
+
(
$$
.
axis
.
getY2AxisLabelPosition
().
isOuter
?
20
:
0
);
}
else
{
}
else
{
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y2'
))
+
legendWidthOnRight
;
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y2'
))
+
legendWidthOnRight
;
}
}
...
@@ -75,8 +75,8 @@ c3_chart_internal_fn.getSvgLeft = function (withoutRecompute) {
...
@@ -75,8 +75,8 @@ c3_chart_internal_fn.getSvgLeft = function (withoutRecompute) {
c3_chart_internal_fn
.
getAxisWidthByAxisId
=
function
(
id
,
withoutRecompute
)
{
c3_chart_internal_fn
.
getAxisWidthByAxisId
=
function
(
id
,
withoutRecompute
)
{
var
$$
=
this
,
position
=
$$
.
getAxis
LabelPositionById
(
id
);
var
$$
=
this
,
position
=
$$
.
axis
.
get
LabelPositionById
(
id
);
return
$$
.
getMaxTickWidth
(
id
,
withoutRecompute
)
+
(
position
.
isInner
?
20
:
40
);
return
$$
.
axis
.
getMaxTickWidth
(
id
,
withoutRecompute
)
+
(
position
.
isInner
?
20
:
40
);
};
};
c3_chart_internal_fn
.
getHorizontalAxisHeight
=
function
(
axisId
)
{
c3_chart_internal_fn
.
getHorizontalAxisHeight
=
function
(
axisId
)
{
var
$$
=
this
,
config
=
$$
.
config
,
h
=
30
;
var
$$
=
this
,
config
=
$$
.
config
,
h
=
30
;
...
@@ -86,9 +86,9 @@ c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) {
...
@@ -86,9 +86,9 @@ c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) {
if
(
axisId
===
'y2'
&&
!
config
.
axis_y2_show
)
{
return
$$
.
rotated_padding_top
;
}
if
(
axisId
===
'y2'
&&
!
config
.
axis_y2_show
)
{
return
$$
.
rotated_padding_top
;
}
// Calculate x axis height when tick rotated
// Calculate x axis height when tick rotated
if
(
axisId
===
'x'
&&
!
config
.
axis_rotated
&&
config
.
axis_x_tick_rotate
)
{
if
(
axisId
===
'x'
&&
!
config
.
axis_rotated
&&
config
.
axis_x_tick_rotate
)
{
h
=
$$
.
getMaxTickWidth
(
axisId
)
*
Math
.
cos
(
Math
.
PI
*
(
90
-
config
.
axis_x_tick_rotate
)
/
180
);
h
=
$$
.
axis
.
getMaxTickWidth
(
axisId
)
*
Math
.
cos
(
Math
.
PI
*
(
90
-
config
.
axis_x_tick_rotate
)
/
180
);
}
}
return
h
+
(
$$
.
getAxis
LabelPositionById
(
axisId
).
isInner
?
0
:
10
)
+
(
axisId
===
'y2'
?
-
10
:
0
);
return
h
+
(
$$
.
axis
.
get
LabelPositionById
(
axisId
).
isInner
?
0
:
10
)
+
(
axisId
===
'y2'
?
-
10
:
0
);
};
};
c3_chart_internal_fn
.
getEventRectWidth
=
function
()
{
c3_chart_internal_fn
.
getEventRectWidth
=
function
()
{
...
...
src/tooltip.js
View file @
5c0c8ecc
...
@@ -18,7 +18,7 @@ c3_chart_internal_fn.initTooltip = function () {
...
@@ -18,7 +18,7 @@ c3_chart_internal_fn.initTooltip = function () {
}
}
$$
.
tooltip
.
html
(
config
.
tooltip_contents
.
call
(
$$
,
$$
.
data
.
targets
.
map
(
function
(
d
)
{
$$
.
tooltip
.
html
(
config
.
tooltip_contents
.
call
(
$$
,
$$
.
data
.
targets
.
map
(
function
(
d
)
{
return
$$
.
addName
(
d
.
values
[
config
.
tooltip_init_x
]);
return
$$
.
addName
(
d
.
values
[
config
.
tooltip_init_x
]);
}),
$$
.
getXAxisTickFormat
(),
$$
.
getYFormat
(
$$
.
hasArcType
()),
$$
.
color
));
}),
$$
.
axis
.
getXAxisTickFormat
(),
$$
.
getYFormat
(
$$
.
hasArcType
()),
$$
.
color
));
$$
.
tooltip
.
style
(
"top"
,
config
.
tooltip_init_position
.
top
)
$$
.
tooltip
.
style
(
"top"
,
config
.
tooltip_init_position
.
top
)
.
style
(
"left"
,
config
.
tooltip_init_position
.
left
)
.
style
(
"left"
,
config
.
tooltip_init_position
.
left
)
.
style
(
"display"
,
"block"
);
.
style
(
"display"
,
"block"
);
...
@@ -95,7 +95,7 @@ c3_chart_internal_fn.showTooltip = function (selectedData, element) {
...
@@ -95,7 +95,7 @@ c3_chart_internal_fn.showTooltip = function (selectedData, element) {
if
(
dataToShow
.
length
===
0
||
!
config
.
tooltip_show
)
{
if
(
dataToShow
.
length
===
0
||
!
config
.
tooltip_show
)
{
return
;
return
;
}
}
$$
.
tooltip
.
html
(
config
.
tooltip_contents
.
call
(
$$
,
selectedData
,
$$
.
getXAxisTickFormat
(),
$$
.
getYFormat
(
forArc
),
$$
.
color
)).
style
(
"display"
,
"block"
);
$$
.
tooltip
.
html
(
config
.
tooltip_contents
.
call
(
$$
,
selectedData
,
$$
.
axis
.
getXAxisTickFormat
(),
$$
.
getYFormat
(
forArc
),
$$
.
color
)).
style
(
"display"
,
"block"
);
// Get tooltip dimensions
// Get tooltip dimensions
tWidth
=
$$
.
tooltip
.
property
(
'offsetWidth'
);
tWidth
=
$$
.
tooltip
.
property
(
'offsetWidth'
);
...
...
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