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
056c402d
Commit
056c402d
authored
Jun 09, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bar.zerobased and add sample
parent
758ee70e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
9 deletions
+15
-9
c3.js
c3.js
+3
-6
c3.min.js
c3.min.js
+0
-0
index.html
htdocs/index.html
+6
-0
chart_bar.html
htdocs/samples/chart_bar.html
+6
-3
No files found.
c3.js
View file @
056c402d
...
...
@@ -1259,6 +1259,7 @@
domainLength
,
padding
,
padding_top
,
padding_bottom
,
center
=
axisId
===
'y2'
?
__axis_y2_center
:
__axis_y_center
,
yDomainAbs
,
lengths
,
diff
,
ratio
,
isAllPositive
,
isAllNegative
,
isZeroBased
=
(
hasBarType
(
yTargets
)
&&
__bar_zerobased
)
||
hasAreaType
(
yTargets
),
showHorizontalDataLabel
=
hasDataLabel
()
&&
__axis_rotated
,
showVerticalDataLabel
=
hasDataLabel
()
&&
!
__axis_rotated
;
if
(
yTargets
.
length
===
0
)
{
// use current domain if target of axisId is none
...
...
@@ -1271,7 +1272,7 @@
isAllNegative
=
yDomainMin
<=
0
&&
yDomainMax
<=
0
;
// Bar/Area chart should be 0-based if all positive|negative
if
(
(
hasBarType
(
yTargets
)
&&
isBarZerobased
())
||
hasAreaType
(
yTargets
)
)
{
if
(
isZeroBased
)
{
if
(
isAllPositive
)
{
yDomainMin
=
0
;
}
if
(
isAllNegative
)
{
yDomainMax
=
0
;
}
}
...
...
@@ -1305,7 +1306,7 @@
padding_bottom
=
getAxisPadding
(
__axis_y2_padding
,
'bottom'
,
padding
,
domainLength
);
}
// Bar/Area chart should be 0-based if all positive|negative
if
(
(
hasBarType
(
yTargets
)
&&
isBarZerobased
())
||
hasAreaType
(
yTargets
)
)
{
if
(
isZeroBased
)
{
if
(
isAllPositive
)
{
padding_bottom
=
yDomainMin
;
}
if
(
isAllNegative
)
{
padding_top
=
-
yDomainMax
;
}
}
...
...
@@ -2237,10 +2238,6 @@
var
id
=
(
typeof
d
===
'string'
)
?
d
:
d
.
id
;
return
__data_types
[
id
]
===
'bar'
;
}
function
isBarZerobased
()
{
return
__bar_zerobased
;
}
function
isScatterType
(
d
)
{
var
id
=
(
typeof
d
===
'string'
)
?
d
:
d
.
id
;
return
__data_types
[
id
]
===
'scatter'
;
...
...
c3.min.js
View file @
056c402d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
htdocs/index.html
View file @
056c402d
...
...
@@ -313,6 +313,12 @@
Change radius of data point
</a>
</div>
<div
class=
"col-md-4"
>
<h3>
Bar
</h3>
<a
href=
"./samples/bar_zerobased.html"
>
Disable zero-based y domain
</a>
</div>
</div>
</div>
</div>
...
...
htdocs/samples/chart_bar.html
View file @
056c402d
...
...
@@ -11,8 +11,10 @@
var
chart
=
c3
.
generate
({
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
130
,
100
,
140
,
200
,
150
,
50
]
[
'data1'
,
1030
,
1200
,
1100
,
1400
,
1150
,
1250
],
[
'data2'
,
2130
,
2100
,
2140
,
2200
,
2150
,
1850
]
// ['data1', 30, 200, 100, 400, 150, 250],
// ['data2', 130, 100, 140, 200, 150, 50]
],
type
:
'bar'
,
onclick
:
function
(
d
,
element
)
{
console
.
log
(
"onclick"
,
d
,
element
);
},
...
...
@@ -27,7 +29,8 @@
bar
:
{
width
:
{
ratio
:
0.3
}
},
zerobased
:
false
}
});
</script>
...
...
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