Skip to content

Commit

Permalink
Chart: valueAxis should not restore visualRange on dataSource update …
Browse files Browse the repository at this point in the history
…(T1262610) (#28375)

Co-authored-by: Alexander Kozlovskiy <[email protected]>
  • Loading branch information
ksercs and Zedwag authored Nov 15, 2024
1 parent ff53976 commit 67bf694
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
13 changes: 9 additions & 4 deletions packages/devextreme/js/viz/axes/base_axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -1171,10 +1171,15 @@ Axis.prototype = {

if(!this.isArgumentAxis) {
const viewport = this.getViewport();
if(!isDefined(viewport.startValue) &&
!isDefined(viewport.endValue) &&
!isDefined(viewport.length)) {
return RESET;
const isViewportNotDefined = !isDefined(viewport.startValue) && !isDefined(viewport.endValue) && !isDefined(viewport.length);

if(isViewportNotDefined) {
const visualRange = this.visualRange();
const isVisualRangeNotDefined = !isDefined(visualRange.startValue) && !isDefined(visualRange.endValue);

if(isVisualRangeNotDefined) {
return RESET;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,8 @@ QUnit.test('AdjustOnZoom true - show adjusted value range for every argument ran
let [chart, onOptionChanged] = this.createChart({
adjustOnZoom: true,
dataSource,
argumentAxis: { visualRange: [2, 4] }
argumentAxis: { visualRange: [2, 4] },
valueAxis: { visualRangeUpdateMode: 'reset' },
});
onOptionChanged.resetHistory();

Expand Down Expand Up @@ -2955,7 +2956,8 @@ QUnit.test('AdjustOnZoom false - show full value range for every argument range
let [chart, onOptionChanged] = this.createChart({
adjustOnZoom: false,
dataSource,
argumentAxis: { visualRange: [2, 4] }
argumentAxis: { visualRange: [2, 4] },
valueAxis: { visualRangeUpdateMode: 'reset' },
});
onOptionChanged.resetHistory();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2599,8 +2599,7 @@ QUnit.test('Pinch zoom. Big chart rendering time on start and small time in the

QUnit.module('Misc', environment);

// T1049139
QUnit.test('visualRange updating after zoomming', function(assert) {
QUnit.test('argument axis should not restore visual range on dataSource update (T1049139)', function(assert) {
const dataSource = [{ arg: 1960, val: 10, }, { arg: 2020, val: 20, }];
const chart = this.createChart({
dataSource,
Expand Down Expand Up @@ -2629,6 +2628,36 @@ QUnit.test('visualRange updating after zoomming', function(assert) {
assert.strictEqual(Math.floor(visualRange.endValue), 2018);
});

QUnit.test('value axis should not restore visual range on dataSource update (T1262610)', function(assert) {
const dataSource = [{ arg: 2000, val: 10, }, { arg: 2010, val: 20, }];
const chart = this.createChart({
dataSource,
legend: {
visible: false,
},
series: { type: 'bar' },
valueAxis: {
visualRangeUpdateMode: 'keep',
visualRange: {
startValue: 5,
endValue: 25,
}
},
zoomAndPan: {
valueAxis: 'both',
}
});

this.pointer.start({ x: 200, y: 250 }).wheel(10);
dataSource.push({ arg: 2020, val: 15 });
chart.option('dataSource', dataSource);

const visualRange = chart.getValueAxis().visualRange();

assert.strictEqual(Math.floor(visualRange.startValue), 6);
assert.strictEqual(Math.floor(visualRange.endValue), 24);
});

QUnit.test('Do nothing if no actions allowed', function(assert) {
const onZoomStart = sinon.spy();
const onZoomEnd = sinon.spy();
Expand Down

0 comments on commit 67bf694

Please sign in to comment.