Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
c3-closed
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charts
c3-closed
Commits
7ee85d69
Commit
7ee85d69
authored
Aug 30, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cancel zerobased if axis.y.min/max specified - #454
parent
9d1b32a7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
10 deletions
+59
-10
c3.js
c3.js
+9
-4
c3.min.js
c3.min.js
+0
-0
chart_area.html
htdocs/samples/chart_area.html
+41
-2
config.js
src/config.js
+2
-2
domain.js
src/domain.js
+7
-2
No files found.
c3.js
View file @
7ee85d69
...
...
@@ -964,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
,
...
...
@@ -973,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
,
...
...
@@ -1243,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
;
}
...
...
@@ -1269,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
);
}
...
...
c3.min.js
View file @
7ee85d69
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 @
7ee85d69
...
...
@@ -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,17 +33,49 @@
bindto
:
'#chart2'
,
data
:
{
columns
:
[
[
'data1'
,
-
300
,
-
350
,
-
300
,
0
,
0
,
0
],
[
'data2'
,
-
130
,
-
100
,
-
140
,
-
200
,
-
150
,
-
50
]
[
'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
]
],
type
:
'area'
}
});
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
],
[
'data2'
,
-
130
,
-
100
,
140
,
-
200
,
150
,
-
50
]
],
...
...
src/config.js
View file @
7ee85d69
...
...
@@ -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
,
...
...
src/domain.js
View file @
7ee85d69
...
...
@@ -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
);
}
...
...
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