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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
41 deletions
+67
-41
api.axis.js
src/api.axis.js
+2
-2
axis.js
src/axis.js
+0
-0
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) {
var
$$
=
this
.
internal
;
if
(
arguments
.
length
)
{
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?
};
...
...
src/axis.js
View file @
5c0c8ecc
This diff is collapsed.
Click to expand it.
src/core.js
View file @
5c0c8ecc
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
)
{
var
$$
=
this
.
internal
=
new
ChartInternal
(
this
);
...
...
@@ -35,12 +56,15 @@ c3.generate = function (config) {
c3
.
chart
=
{
fn
:
Chart
.
prototype
,
internal
:
{
fn
:
ChartInternal
.
prototype
fn
:
ChartInternal
.
prototype
,
axis
:
{
fn
:
Axis
.
prototype
}
}
};
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
;
...
...
@@ -149,6 +173,8 @@ 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
();
}
...
...
@@ -266,7 +292,7 @@ c3_chart_internal_fn.initWithData = function (data) {
if
(
config
.
axis_x_extent
)
{
$$
.
brush
.
extent
(
$$
.
getDefaultExtent
());
}
// Add Axis
$$
.
initAxis
();
$$
.
axis
.
init
();
// Set targets
$$
.
updateTargets
(
$$
.
data
.
targets
);
...
...
@@ -456,7 +482,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
durationForExit
=
withTransitionForExit
?
duration
:
0
;
durationForAxis
=
withTransitionForAxis
?
duration
:
0
;
transitions
=
transitions
||
$$
.
generateAxis
Transitions
(
durationForAxis
);
transitions
=
transitions
||
$$
.
axis
.
generate
Transitions
(
durationForAxis
);
// update legend and transform each g
if
(
withLegend
&&
config
.
legend_show
)
{
...
...
@@ -475,7 +501,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
if
(
targetsToShow
.
length
)
{
$$
.
updateXDomain
(
targetsToShow
,
withUpdateXDomain
,
withUpdateOrgXDomain
,
withTrimXDomain
);
if
(
!
config
.
axis_x_tick_values
)
{
tickValues
=
$$
.
updateXAxisTickValues
(
targetsToShow
);
tickValues
=
$$
.
axis
.
updateXAxisTickValues
(
targetsToShow
);
}
}
else
{
$$
.
xAxis
.
tickValues
([]);
...
...
@@ -490,17 +516,17 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
$$
.
y2
.
domain
(
$$
.
getYDomain
(
targetsToShow
,
'y2'
,
xDomainForZoom
));
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
)
{
$$
.
y2Axis
.
tickValues
(
$$
.
generateTickValues
(
$$
.
y2
.
domain
(),
config
.
axis_y2_tick_count
));
$$
.
y2Axis
.
tickValues
(
$$
.
axis
.
generateTickValues
(
$$
.
y2
.
domain
(),
config
.
axis_y2_tick_count
));
}
// axes
$$
.
redrawAxis
(
transitions
,
hideAxis
);
$$
.
axis
.
redraw
(
transitions
,
hideAxis
);
// Update axis label
$$
.
updateAxis
Labels
(
withTransition
);
$$
.
axis
.
update
Labels
(
withTransition
);
// show/hide if manual culling needed
if
((
withUpdateXDomain
||
withUpdateXAxis
)
&&
targetsToShow
.
length
)
{
...
...
@@ -681,7 +707,7 @@ c3_chart_internal_fn.updateAndRedraw = function (options) {
$$
.
updateSizes
();
// MEMO: called in updateLegend in redraw if withLegend
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
$$
.
updateScales
();
$$
.
updateSvgSize
();
...
...
src/domain.js
View file @
5c0c8ecc
...
...
@@ -20,7 +20,7 @@ c3_chart_internal_fn.getYDomainMin = function (targets) {
id
=
idsInGroup
[
k
];
if
(
!
ys
[
id
])
{
continue
;
}
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
;
}
});
...
...
@@ -51,7 +51,7 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
id
=
idsInGroup
[
k
];
if
(
!
ys
[
id
])
{
continue
;
}
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
;
}
});
...
...
@@ -62,7 +62,7 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
};
c3_chart_internal_fn
.
getYDomain
=
function
(
targets
,
axisId
,
xDomain
)
{
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
,
yMin
=
axisId
===
'y2'
?
config
.
axis_y2_min
:
config
.
axis_y_min
,
yMax
=
axisId
===
'y2'
?
config
.
axis_y2_max
:
config
.
axis_y_max
,
...
...
@@ -123,16 +123,16 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) {
padding_bottom
+=
domainLength
*
(
ratio
[
0
]
/
(
1
-
ratio
[
0
]
-
ratio
[
1
]));
}
else
if
(
showVerticalDataLabel
)
{
lengths
=
$$
.
getDataLabelLength
(
yDomainMin
,
yDomainMax
,
'height'
);
padding_top
+=
th
is
.
convertPixelsToAxisPadding
(
lengths
[
1
],
domainLength
);
padding_bottom
+=
th
is
.
convertPixelsToAxisPadding
(
lengths
[
0
],
domainLength
);
padding_top
+=
$$
.
ax
is
.
convertPixelsToAxisPadding
(
lengths
[
1
],
domainLength
);
padding_bottom
+=
$$
.
ax
is
.
convertPixelsToAxisPadding
(
lengths
[
0
],
domainLength
);
}
if
(
axisId
===
'y'
&&
notEmpty
(
config
.
axis_y_padding
))
{
padding_top
=
$$
.
getAxis
Padding
(
config
.
axis_y_padding
,
'top'
,
padding_top
,
domainLength
);
padding_bottom
=
$$
.
getAxis
Padding
(
config
.
axis_y_padding
,
'bottom'
,
padding_bottom
,
domainLength
);
padding_top
=
$$
.
axis
.
get
Padding
(
config
.
axis_y_padding
,
'top'
,
padding_top
,
domainLength
);
padding_bottom
=
$$
.
axis
.
get
Padding
(
config
.
axis_y_padding
,
'bottom'
,
padding_bottom
,
domainLength
);
}
if
(
axisId
===
'y2'
&&
notEmpty
(
config
.
axis_y2_padding
))
{
padding_top
=
$$
.
getAxis
Padding
(
config
.
axis_y2_padding
,
'top'
,
padding_top
,
domainLength
);
padding_bottom
=
$$
.
getAxis
Padding
(
config
.
axis_y2_padding
,
'bottom'
,
padding_bottom
,
domainLength
);
padding_top
=
$$
.
axis
.
get
Padding
(
config
.
axis_y2_padding
,
'top'
,
padding_top
,
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
if
(
isZeroBased
)
{
...
...
src/format.js
View file @
5c0c8ecc
...
...
@@ -3,7 +3,7 @@ c3_chart_internal_fn.getYFormat = function (forArc) {
formatForY
=
forArc
&&
!
$$
.
hasType
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
yFormat
,
formatForY2
=
forArc
&&
!
$$
.
hasType
(
'gauge'
)
?
$$
.
defaultArcValueFormat
:
$$
.
y2Format
;
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
);
};
};
...
...
src/scale.js
View file @
5c0c8ecc
...
...
@@ -44,10 +44,10 @@ c3_chart_internal_fn.getY = function (min, max, domain) {
return
scale
;
};
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
)
{
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
()
{
var
$$
=
this
,
config
=
$$
.
config
,
...
...
@@ -69,15 +69,15 @@ c3_chart_internal_fn.updateScales = function () {
$$
.
subY
=
$$
.
getY
(
$$
.
subYMin
,
$$
.
subYMax
,
forInit
?
config
.
axis_y_default
:
$$
.
subY
.
domain
());
$$
.
subY2
=
$$
.
getY
(
$$
.
subYMin
,
$$
.
subYMax
,
forInit
?
config
.
axis_y2_default
:
$$
.
subY2
.
domain
());
// update axes
$$
.
xAxisTickFormat
=
$$
.
getXAxisTickFormat
();
$$
.
xAxisTickValues
=
$$
.
getXAxisTickValues
();
$$
.
yAxisTickValues
=
$$
.
getYAxisTickValues
();
$$
.
y2AxisTickValues
=
$$
.
getY2AxisTickValues
();
$$
.
xAxisTickFormat
=
$$
.
axis
.
getXAxisTickFormat
();
$$
.
xAxisTickValues
=
$$
.
axis
.
getXAxisTickValues
();
$$
.
yAxisTickValues
=
$$
.
axis
.
getYAxisTickValues
();
$$
.
y2AxisTickValues
=
$$
.
axis
.
getY2AxisTickValues
();
$$
.
xAxis
=
$$
.
getXAxis
(
$$
.
x
,
$$
.
xOrient
,
$$
.
xAxisTickFormat
,
$$
.
xAxisTickValues
,
config
.
axis_x_tick_outer
);
$$
.
subXAxis
=
$$
.
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
);
$$
.
y2Axis
=
$$
.
getYAxis
(
$$
.
y2
,
$$
.
y2Orient
,
config
.
axis_y2_tick_format
,
$$
.
y2AxisTickValues
,
config
.
axis_y2_tick_outer
);
$$
.
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
)
{
...
...
src/size.js
View file @
5c0c8ecc
...
...
@@ -22,7 +22,7 @@ c3_chart_internal_fn.getCurrentPaddingLeft = function (withoutRecompute) {
}
else
if
(
config
.
axis_rotated
)
{
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
return
$$
.
getYAxisLabelPosition
().
isOuter
?
30
:
1
;
return
$$
.
axis
.
getYAxisLabelPosition
().
isOuter
?
30
:
1
;
}
else
{
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y'
,
withoutRecompute
));
}
...
...
@@ -35,7 +35,7 @@ c3_chart_internal_fn.getCurrentPaddingRight = function () {
}
else
if
(
config
.
axis_rotated
)
{
return
defaultPadding
+
legendWidthOnRight
;
}
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
{
return
ceil10
(
$$
.
getAxisWidthByAxisId
(
'y2'
))
+
legendWidthOnRight
;
}
...
...
@@ -75,8 +75,8 @@ c3_chart_internal_fn.getSvgLeft = function (withoutRecompute) {
c3_chart_internal_fn
.
getAxisWidthByAxisId
=
function
(
id
,
withoutRecompute
)
{
var
$$
=
this
,
position
=
$$
.
getAxis
LabelPositionById
(
id
);
return
$$
.
getMaxTickWidth
(
id
,
withoutRecompute
)
+
(
position
.
isInner
?
20
:
40
);
var
$$
=
this
,
position
=
$$
.
axis
.
get
LabelPositionById
(
id
);
return
$$
.
axis
.
getMaxTickWidth
(
id
,
withoutRecompute
)
+
(
position
.
isInner
?
20
:
40
);
};
c3_chart_internal_fn
.
getHorizontalAxisHeight
=
function
(
axisId
)
{
var
$$
=
this
,
config
=
$$
.
config
,
h
=
30
;
...
...
@@ -86,9 +86,9 @@ c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) {
if
(
axisId
===
'y2'
&&
!
config
.
axis_y2_show
)
{
return
$$
.
rotated_padding_top
;
}
// Calculate x axis height when tick rotated
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
()
{
...
...
src/tooltip.js
View file @
5c0c8ecc
...
...
@@ -18,7 +18,7 @@ c3_chart_internal_fn.initTooltip = function () {
}
$$
.
tooltip
.
html
(
config
.
tooltip_contents
.
call
(
$$
,
$$
.
data
.
targets
.
map
(
function
(
d
)
{
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
)
.
style
(
"left"
,
config
.
tooltip_init_position
.
left
)
.
style
(
"display"
,
"block"
);
...
...
@@ -95,7 +95,7 @@ c3_chart_internal_fn.showTooltip = function (selectedData, element) {
if
(
dataToShow
.
length
===
0
||
!
config
.
tooltip_show
)
{
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
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