Browse Source

Merge branch 'matuszewski-master'

pull/340/head
Masayuki Tanaka 11 years ago
parent
commit
bae6ab3f4f
  1. 8
      c3.js
  2. 6
      c3.min.js
  3. 6
      htdocs/index.html
  4. 9
      htdocs/samples/chart_bar.html

8
c3.js

@ -253,7 +253,8 @@
// bar // bar
var __bar_width = getConfig(['bar', 'width']), var __bar_width = getConfig(['bar', 'width']),
__bar_width_ratio = getConfig(['bar', 'width', 'ratio'], 0.6); __bar_width_ratio = getConfig(['bar', 'width', 'ratio'], 0.6),
__bar_zerobased = getConfig(['bar', 'zerobased'], true);
// pie // pie
var __pie_label_show = getConfig(['pie', 'label', 'show'], true), var __pie_label_show = getConfig(['pie', 'label', 'show'], true),
@ -1258,6 +1259,7 @@
domainLength, padding, padding_top, padding_bottom, domainLength, padding, padding_top, padding_bottom,
center = axisId === 'y2' ? __axis_y2_center : __axis_y_center, center = axisId === 'y2' ? __axis_y2_center : __axis_y_center,
yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative, yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative,
isZeroBased = (hasBarType(yTargets) && __bar_zerobased) || hasAreaType(yTargets),
showHorizontalDataLabel = hasDataLabel() && __axis_rotated, showHorizontalDataLabel = hasDataLabel() && __axis_rotated,
showVerticalDataLabel = hasDataLabel() && !__axis_rotated; showVerticalDataLabel = hasDataLabel() && !__axis_rotated;
if (yTargets.length === 0) { // use current domain if target of axisId is none if (yTargets.length === 0) { // use current domain if target of axisId is none
@ -1270,7 +1272,7 @@
isAllNegative = yDomainMin <= 0 && yDomainMax <= 0; isAllNegative = yDomainMin <= 0 && yDomainMax <= 0;
// Bar/Area chart should be 0-based if all positive|negative // Bar/Area chart should be 0-based if all positive|negative
if (hasBarType(yTargets) || hasAreaType(yTargets)) { if (isZeroBased) {
if (isAllPositive) { yDomainMin = 0; } if (isAllPositive) { yDomainMin = 0; }
if (isAllNegative) { yDomainMax = 0; } if (isAllNegative) { yDomainMax = 0; }
} }
@ -1304,7 +1306,7 @@
padding_bottom = getAxisPadding(__axis_y2_padding, 'bottom', padding, domainLength); padding_bottom = getAxisPadding(__axis_y2_padding, 'bottom', padding, domainLength);
} }
// Bar/Area chart should be 0-based if all positive|negative // Bar/Area chart should be 0-based if all positive|negative
if (hasBarType(yTargets) || hasAreaType(yTargets)) { if (isZeroBased) {
if (isAllPositive) { padding_bottom = yDomainMin; } if (isAllPositive) { padding_bottom = yDomainMin; }
if (isAllNegative) { padding_top = -yDomainMax; } if (isAllNegative) { padding_top = -yDomainMax; }
} }

6
c3.min.js vendored

File diff suppressed because one or more lines are too long

6
htdocs/index.html

@ -313,6 +313,12 @@
Change radius of data point Change radius of data point
</a> </a>
</div> </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> </div>
</div> </div>

9
htdocs/samples/chart_bar.html

@ -11,8 +11,10 @@
var chart = c3.generate({ var chart = c3.generate({
data: { data: {
columns: [ columns: [
['data1', 30, 200, 100, 400, 150, 250], ['data1', 1030, 1200, 1100, 1400, 1150, 1250],
['data2', 130, 100, 140, 200, 150, 50] ['data2', 2130, 2100, 2140, 2200, 2150, 1850]
// ['data1', 30, 200, 100, 400, 150, 250],
// ['data2', 130, 100, 140, 200, 150, 50]
], ],
type: 'bar', type: 'bar',
onclick: function (d, element) { console.log("onclick", d, element); }, onclick: function (d, element) { console.log("onclick", d, element); },
@ -27,7 +29,8 @@
bar: { bar: {
width: { width: {
ratio: 0.3 ratio: 0.3
} },
zerobased: false
} }
}); });
</script> </script>

Loading…
Cancel
Save