Browse Source

Fix sub y extent when default extent set

pull/713/merge
Masayuki Tanaka 10 years ago
parent
commit
198d16f7ea
  1. 6
      c3.js
  2. 2
      c3.min.js
  3. 55
      spec/zoom-spec.js
  4. 6
      src/core.js

6
c3.js

@ -534,8 +534,10 @@
yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false);
// Update sub domain
$$.subY.domain($$.y.domain());
$$.subY2.domain($$.y2.domain());
if (withY) {
$$.subY.domain($$.getYDomain(targetsToShow, 'y'));
$$.subY2.domain($$.getYDomain(targetsToShow, 'y2'));
}
// tooltip
$$.tooltip.style("display", "none");

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

55
spec/zoom-spec.js

@ -0,0 +1,55 @@
var describe = window.describe,
expect = window.expect,
it = window.it,
beforeEach = window.beforeEach;
describe('c3 chart zoom', function () {
'use strict';
var chart, d3;
var args = {
data: {
columns: [
['data1', 30, 200, 100, 400, 3150, 250],
['data2', 50, 20, 10, 40, 15, 6025]
]
},
axis: {
x: {
extent: [1, 2]
}
},
zoom: {
enable: true
},
subchart: {
show: true
}
};
beforeEach(function (done) {
chart = window.initChart(chart, args, done);
d3 = chart.internal.d3;
});
describe('default extent', function () {
it('should have default extent', function () {
var yDomain = chart.internal.y.domain(),
subYDomain = chart.internal.subY.domain(),
brushExtent = chart.internal.brush.extent(),
expectedYDomain = [-9, 219],
expectedSubYDomain = [-591.5, 6626.5],
expectedBrushExtent = [1, 2];
expect(yDomain[0]).toBe(expectedYDomain[0]);
expect(yDomain[1]).toBe(expectedYDomain[1]);
expect(subYDomain[0]).toBe(expectedSubYDomain[0]);
expect(subYDomain[1]).toBe(expectedSubYDomain[1]);
expect(brushExtent[0]).toBe(expectedBrushExtent[0]);
expect(brushExtent[1]).toBe(expectedBrushExtent[1]);
});
});
});

6
src/core.js

@ -529,8 +529,10 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false);
// Update sub domain
$$.subY.domain($$.y.domain());
$$.subY2.domain($$.y2.domain());
if (withY) {
$$.subY.domain($$.getYDomain(targetsToShow, 'y'));
$$.subY2.domain($$.getYDomain(targetsToShow, 'y2'));
}
// tooltip
$$.tooltip.style("display", "none");

Loading…
Cancel
Save