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
144ba072
Commit
144ba072
authored
Aug 30, 2014
by
Christian Kalmar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into tooltip-fix-single-data-point
Conflicts: c3.min.js
parents
a083af28
7ee85d69
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
107 additions
and
20 deletions
+107
-20
c3.js
c3.js
+30
-8
c3.min.js
c3.min.js
+0
-0
chart_area.html
htdocs/samples/chart_area.html
+41
-2
grid_x_lines.html
htdocs/samples/grid_x_lines.html
+6
-2
arc.js
src/arc.js
+3
-0
class.js
src/class.js
+1
-0
config.js
src/config.js
+3
-2
core.js
src/core.js
+6
-0
domain.js
src/domain.js
+7
-2
grid.js
src/grid.js
+9
-3
size.js
src/size.js
+1
-1
No files found.
c3.js
View file @
144ba072
...
...
@@ -224,6 +224,9 @@
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
'class'
,
CLASS
.
chart
);
// Grid lines
if
(
config
.
grid_lines_front
)
{
$$
.
initGridLines
();
}
// Cover whole with rects for events
$$
.
initEventRect
();
...
...
@@ -371,6 +374,9 @@
// for arc
$$
.
arcWidth
=
$$
.
width
-
(
$$
.
isLegendRight
?
legendWidth
+
10
:
0
);
$$
.
arcHeight
=
$$
.
height
-
(
$$
.
isLegendRight
?
0
:
10
);
if
(
$$
.
hasType
(
'gauge'
))
{
$$
.
arcHeight
+=
$$
.
height
-
$$
.
getGaugeLabelHeight
();
}
if
(
$$
.
updateRadius
)
{
$$
.
updateRadius
();
}
if
(
$$
.
isLegendRight
&&
hasArc
)
{
...
...
@@ -958,7 +964,7 @@
axis_y_label
:
{},
axis_y_tick_format
:
undefined
,
axis_y_tick_outer
:
true
,
axis_y_padding
:
undefined
,
axis_y_padding
:
{}
,
axis_y_ticks
:
10
,
axis_y2_show
:
false
,
axis_y2_max
:
undefined
,
...
...
@@ -967,7 +973,7 @@
axis_y2_label
:
{},
axis_y2_tick_format
:
undefined
,
axis_y2_tick_outer
:
true
,
axis_y2_padding
:
undefined
,
axis_y2_padding
:
{}
,
axis_y2_ticks
:
10
,
// grid
grid_x_show
:
false
,
...
...
@@ -979,6 +985,7 @@
grid_y_lines
:
[],
grid_y_ticks
:
10
,
grid_focus_show
:
true
,
grid_lines_front
:
true
,
// point - point of each data
point_show
:
true
,
point_r
:
2.5
,
...
...
@@ -1236,6 +1243,11 @@
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
;
}
...
...
@@ -1262,11 +1274,11 @@
padding_top
+=
lengths
[
1
];
padding_bottom
+=
lengths
[
0
];
}
if
(
axisId
===
'y'
&&
config
.
axis_y_padding
)
{
if
(
axisId
===
'y'
&&
notEmpty
(
config
.
axis_y_padding
)
)
{
padding_top
=
$$
.
getAxisPadding
(
config
.
axis_y_padding
,
'top'
,
padding
,
domainLength
);
padding_bottom
=
$$
.
getAxisPadding
(
config
.
axis_y_padding
,
'bottom'
,
padding
,
domainLength
);
}
if
(
axisId
===
'y2'
&&
config
.
axis_y2_padding
)
{
if
(
axisId
===
'y2'
&&
notEmpty
(
config
.
axis_y2_padding
)
)
{
padding_top
=
$$
.
getAxisPadding
(
config
.
axis_y2_padding
,
'top'
,
padding
,
domainLength
);
padding_bottom
=
$$
.
getAxisPadding
(
config
.
axis_y2_padding
,
'bottom'
,
padding
,
domainLength
);
}
...
...
@@ -2271,7 +2283,7 @@
c3_chart_internal_fn
.
getCurrentHeight
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
h
=
config
.
size_height
?
config
.
size_height
:
$$
.
getParentHeight
();
return
h
>
0
?
h
:
320
;
return
h
>
0
?
h
:
320
/
(
$$
.
hasType
(
'gauge'
)
?
2
:
1
)
;
};
c3_chart_internal_fn
.
getCurrentPaddingTop
=
function
()
{
var
config
=
this
.
config
;
...
...
@@ -3062,8 +3074,6 @@
if
(
config
.
grid_y_show
)
{
$$
.
grid
.
append
(
'g'
).
attr
(
'class'
,
CLASS
.
ygrids
);
}
$$
.
grid
.
append
(
'g'
).
attr
(
"class"
,
CLASS
.
xgridLines
);
$$
.
grid
.
append
(
'g'
).
attr
(
'class'
,
CLASS
.
ygridLines
);
if
(
config
.
grid_focus_show
)
{
$$
.
grid
.
append
(
'g'
)
.
attr
(
"class"
,
CLASS
.
xgridFocus
)
...
...
@@ -3071,9 +3081,17 @@
.
attr
(
'class'
,
CLASS
.
xgridFocus
);
}
$$
.
xgrid
=
d3
.
selectAll
([]);
if
(
!
config
.
grid_lines_front
)
{
$$
.
initGridLines
();
}
};
c3_chart_internal_fn
.
initGridLines
=
function
()
{
var
$$
=
this
,
d3
=
$$
.
d3
;
$$
.
gridLines
=
$$
.
main
.
append
(
'g'
)
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
'class'
,
CLASS
.
grid
+
' '
+
CLASS
.
gridLines
);
$$
.
gridLines
.
append
(
'g'
).
attr
(
"class"
,
CLASS
.
xgridLines
);
$$
.
gridLines
.
append
(
'g'
).
attr
(
'class'
,
CLASS
.
ygridLines
);
$$
.
xgridLines
=
d3
.
selectAll
([]);
};
c3_chart_internal_fn
.
updateXGrid
=
function
(
withoutUpdate
)
{
var
$$
=
this
,
config
=
$$
.
config
,
d3
=
$$
.
d3
,
xgridData
=
$$
.
generateGridData
(
config
.
grid_x_type
,
$$
.
x
),
...
...
@@ -4413,6 +4431,9 @@
.
text
(
config
.
gauge_label_show
?
config
.
gauge_max
:
''
);
}
};
c3_chart_internal_fn
.
getGaugeLabelHeight
=
function
()
{
return
this
.
config
.
gauge_label_show
?
20
:
0
;
};
c3_chart_internal_fn
.
initRegion
=
function
()
{
var
$$
=
this
;
...
...
@@ -5043,6 +5064,7 @@
texts
:
'c3-texts'
,
gaugeValue
:
'c3-gauge-value'
,
grid
:
'c3-grid'
,
gridLines
:
'c3-grid-lines'
,
xgrid
:
'c3-xgrid'
,
xgrids
:
'c3-xgrids'
,
xgridLine
:
'c3-xgrid-line'
,
...
...
c3.min.js
View file @
144ba072
This source diff could not be displayed because it is too large. You can
view the blob
instead.
htdocs/samples/chart_area.html
View file @
144ba072
...
...
@@ -3,9 +3,16 @@
<link
href=
"/css/c3.css"
rel=
"stylesheet"
type=
"text/css"
>
</head>
<body>
<h3>
Zerobased
</h3>
<div
id=
"chart1"
></div>
<h3>
Not zerobased because of axis.y.min
</h3>
<div
id=
"chart2"
></div>
<h3>
Zerobased
</h3>
<div
id=
"chart3"
></div>
<h3>
Not zerobased because of axis.y.min
</h3>
<div
id=
"chart4"
></div>
<h3>
+/- vaulues
</h3>
<div
id=
"chart5"
></div>
<script
src=
"http://d3js.org/d3.v3.min.js"
charset=
"utf-8"
></script>
<script
src=
"/js/c3.js"
></script>
...
...
@@ -26,6 +33,22 @@
bindto
:
'#chart2'
,
data
:
{
columns
:
[
[
'data1'
,
300
,
350
,
300
,
0
,
0
,
0
],
[
'data2'
,
130
,
100
,
140
,
200
,
150
,
50
]
],
type
:
'area'
},
axis
:
{
y
:
{
min
:
100
,
}
},
});
var
chart3
=
c3
.
generate
({
bindto
:
'#chart3'
,
data
:
{
columns
:
[
[
'data1'
,
-
300
,
-
350
,
-
300
,
0
,
0
,
0
],
[
'data2'
,
-
130
,
-
100
,
-
140
,
-
200
,
-
150
,
-
50
]
],
...
...
@@ -33,8 +56,24 @@
}
});
var
chart3
=
c3
.
generate
({
bindto
:
'#chart3'
,
var
chart4
=
c3
.
generate
({
bindto
:
'#chart4'
,
data
:
{
columns
:
[
[
'data1'
,
-
300
,
-
350
,
-
300
,
0
,
0
,
0
],
[
'data2'
,
-
130
,
-
100
,
-
140
,
-
200
,
-
150
,
-
50
]
],
type
:
'area'
},
axis
:
{
y
:
{
max
:
-
100
,
}
}
});
var
chart5
=
c3
.
generate
({
bindto
:
'#chart5'
,
data
:
{
columns
:
[
[
'data1'
,
-
300
,
350
,
-
300
,
0
,
0
,
0
],
...
...
htdocs/samples/grid_x_lines.html
View file @
144ba072
...
...
@@ -15,7 +15,8 @@
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
]
]
],
type
:
'bar'
},
grid
:
{
x
:
{
...
...
@@ -39,7 +40,7 @@
columns
:
[
[
'x'
,
'2013-01-01'
,
'2013-01-02'
,
'2013-01-03'
,
'2013-01-04'
,
'2013-01-05'
],
[
'sample'
,
30
,
200
,
100
,
400
,
150
]
]
]
,
},
axis
:
{
x
:
{
...
...
@@ -53,6 +54,9 @@
text
:
'2013/01/04'
,
class
:
'lineFor20130104'
}]
},
lines
:
{
front
:
false
}
}
});
...
...
src/arc.js
View file @
144ba072
...
...
@@ -360,3 +360,6 @@ c3_chart_internal_fn.initGauge = function () {
.
text
(
config
.
gauge_label_show
?
config
.
gauge_max
:
''
);
}
};
c3_chart_internal_fn
.
getGaugeLabelHeight
=
function
()
{
return
this
.
config
.
gauge_label_show
?
20
:
0
;
};
src/class.js
View file @
144ba072
...
...
@@ -44,6 +44,7 @@ var CLASS = c3_chart_internal_fn.CLASS = {
texts
:
'c3-texts'
,
gaugeValue
:
'c3-gauge-value'
,
grid
:
'c3-grid'
,
gridLines
:
'c3-grid-lines'
,
xgrid
:
'c3-xgrid'
,
xgrids
:
'c3-xgrids'
,
xgridLine
:
'c3-xgrid-line'
,
...
...
src/config.js
View file @
144ba072
...
...
@@ -100,7 +100,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
axis_y_label
:
{},
axis_y_tick_format
:
undefined
,
axis_y_tick_outer
:
true
,
axis_y_padding
:
undefined
,
axis_y_padding
:
{}
,
axis_y_ticks
:
10
,
axis_y2_show
:
false
,
axis_y2_max
:
undefined
,
...
...
@@ -109,7 +109,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
axis_y2_label
:
{},
axis_y2_tick_format
:
undefined
,
axis_y2_tick_outer
:
true
,
axis_y2_padding
:
undefined
,
axis_y2_padding
:
{}
,
axis_y2_ticks
:
10
,
// grid
grid_x_show
:
false
,
...
...
@@ -121,6 +121,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
grid_y_lines
:
[],
grid_y_ticks
:
10
,
grid_focus_show
:
true
,
grid_lines_front
:
true
,
// point - point of each data
point_show
:
true
,
point_r
:
2.5
,
...
...
src/core.js
View file @
144ba072
...
...
@@ -219,6 +219,9 @@ c3_chart_internal_fn.initWithData = function (data) {
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
'class'
,
CLASS
.
chart
);
// Grid lines
if
(
config
.
grid_lines_front
)
{
$$
.
initGridLines
();
}
// Cover whole with rects for events
$$
.
initEventRect
();
...
...
@@ -366,6 +369,9 @@ c3_chart_internal_fn.updateSizes = function () {
// for arc
$$
.
arcWidth
=
$$
.
width
-
(
$$
.
isLegendRight
?
legendWidth
+
10
:
0
);
$$
.
arcHeight
=
$$
.
height
-
(
$$
.
isLegendRight
?
0
:
10
);
if
(
$$
.
hasType
(
'gauge'
))
{
$$
.
arcHeight
+=
$$
.
height
-
$$
.
getGaugeLabelHeight
();
}
if
(
$$
.
updateRadius
)
{
$$
.
updateRadius
();
}
if
(
$$
.
isLegendRight
&&
hasArc
)
{
...
...
src/domain.js
View file @
144ba072
...
...
@@ -82,6 +82,11 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId) {
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
;
}
...
...
@@ -108,11 +113,11 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId) {
padding_top
+=
lengths
[
1
];
padding_bottom
+=
lengths
[
0
];
}
if
(
axisId
===
'y'
&&
config
.
axis_y_padding
)
{
if
(
axisId
===
'y'
&&
notEmpty
(
config
.
axis_y_padding
)
)
{
padding_top
=
$$
.
getAxisPadding
(
config
.
axis_y_padding
,
'top'
,
padding
,
domainLength
);
padding_bottom
=
$$
.
getAxisPadding
(
config
.
axis_y_padding
,
'bottom'
,
padding
,
domainLength
);
}
if
(
axisId
===
'y2'
&&
config
.
axis_y2_padding
)
{
if
(
axisId
===
'y2'
&&
notEmpty
(
config
.
axis_y2_padding
)
)
{
padding_top
=
$$
.
getAxisPadding
(
config
.
axis_y2_padding
,
'top'
,
padding
,
domainLength
);
padding_bottom
=
$$
.
getAxisPadding
(
config
.
axis_y2_padding
,
'bottom'
,
padding
,
domainLength
);
}
...
...
src/grid.js
View file @
144ba072
...
...
@@ -9,8 +9,6 @@ c3_chart_internal_fn.initGrid = function () {
if
(
config
.
grid_y_show
)
{
$$
.
grid
.
append
(
'g'
).
attr
(
'class'
,
CLASS
.
ygrids
);
}
$$
.
grid
.
append
(
'g'
).
attr
(
"class"
,
CLASS
.
xgridLines
);
$$
.
grid
.
append
(
'g'
).
attr
(
'class'
,
CLASS
.
ygridLines
);
if
(
config
.
grid_focus_show
)
{
$$
.
grid
.
append
(
'g'
)
.
attr
(
"class"
,
CLASS
.
xgridFocus
)
...
...
@@ -18,9 +16,17 @@ c3_chart_internal_fn.initGrid = function () {
.
attr
(
'class'
,
CLASS
.
xgridFocus
);
}
$$
.
xgrid
=
d3
.
selectAll
([]);
if
(
!
config
.
grid_lines_front
)
{
$$
.
initGridLines
();
}
};
c3_chart_internal_fn
.
initGridLines
=
function
()
{
var
$$
=
this
,
d3
=
$$
.
d3
;
$$
.
gridLines
=
$$
.
main
.
append
(
'g'
)
.
attr
(
"clip-path"
,
$$
.
clipPath
)
.
attr
(
'class'
,
CLASS
.
grid
+
' '
+
CLASS
.
gridLines
);
$$
.
gridLines
.
append
(
'g'
).
attr
(
"class"
,
CLASS
.
xgridLines
);
$$
.
gridLines
.
append
(
'g'
).
attr
(
'class'
,
CLASS
.
ygridLines
);
$$
.
xgridLines
=
d3
.
selectAll
([]);
};
c3_chart_internal_fn
.
updateXGrid
=
function
(
withoutUpdate
)
{
var
$$
=
this
,
config
=
$$
.
config
,
d3
=
$$
.
d3
,
xgridData
=
$$
.
generateGridData
(
config
.
grid_x_type
,
$$
.
x
),
...
...
src/size.js
View file @
144ba072
...
...
@@ -5,7 +5,7 @@ c3_chart_internal_fn.getCurrentWidth = function () {
c3_chart_internal_fn
.
getCurrentHeight
=
function
()
{
var
$$
=
this
,
config
=
$$
.
config
,
h
=
config
.
size_height
?
config
.
size_height
:
$$
.
getParentHeight
();
return
h
>
0
?
h
:
320
;
return
h
>
0
?
h
:
320
/
(
$$
.
hasType
(
'gauge'
)
?
2
:
1
)
;
};
c3_chart_internal_fn
.
getCurrentPaddingTop
=
function
()
{
var
config
=
this
.
config
;
...
...
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