Skip to content

Commit 67bf694

Browse files
ksercsZedwag
andauthored
Chart: valueAxis should not restore visualRange on dataSource update (T1262610) (#28375)
Co-authored-by: Alexander Kozlovskiy <[email protected]>
1 parent ff53976 commit 67bf694

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

packages/devextreme/js/viz/axes/base_axis.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,10 +1171,15 @@ Axis.prototype = {
11711171

11721172
if(!this.isArgumentAxis) {
11731173
const viewport = this.getViewport();
1174-
if(!isDefined(viewport.startValue) &&
1175-
!isDefined(viewport.endValue) &&
1176-
!isDefined(viewport.length)) {
1177-
return RESET;
1174+
const isViewportNotDefined = !isDefined(viewport.startValue) && !isDefined(viewport.endValue) && !isDefined(viewport.length);
1175+
1176+
if(isViewportNotDefined) {
1177+
const visualRange = this.visualRange();
1178+
const isVisualRangeNotDefined = !isDefined(visualRange.startValue) && !isDefined(visualRange.endValue);
1179+
1180+
if(isVisualRangeNotDefined) {
1181+
return RESET;
1182+
}
11781183
}
11791184
}
11801185

packages/devextreme/testing/tests/DevExpress.viz.charts/chart.visualRangeUpdate.tests.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,7 +2881,8 @@ QUnit.test('AdjustOnZoom true - show adjusted value range for every argument ran
28812881
let [chart, onOptionChanged] = this.createChart({
28822882
adjustOnZoom: true,
28832883
dataSource,
2884-
argumentAxis: { visualRange: [2, 4] }
2884+
argumentAxis: { visualRange: [2, 4] },
2885+
valueAxis: { visualRangeUpdateMode: 'reset' },
28852886
});
28862887
onOptionChanged.resetHistory();
28872888

@@ -2955,7 +2956,8 @@ QUnit.test('AdjustOnZoom false - show full value range for every argument range
29552956
let [chart, onOptionChanged] = this.createChart({
29562957
adjustOnZoom: false,
29572958
dataSource,
2958-
argumentAxis: { visualRange: [2, 4] }
2959+
argumentAxis: { visualRange: [2, 4] },
2960+
valueAxis: { visualRangeUpdateMode: 'reset' },
29592961
});
29602962
onOptionChanged.resetHistory();
29612963

packages/devextreme/testing/tests/DevExpress.viz.charts/zoomAndPan.tests.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,8 +2599,7 @@ QUnit.test('Pinch zoom. Big chart rendering time on start and small time in the
25992599

26002600
QUnit.module('Misc', environment);
26012601

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

2631+
QUnit.test('value axis should not restore visual range on dataSource update (T1262610)', function(assert) {
2632+
const dataSource = [{ arg: 2000, val: 10, }, { arg: 2010, val: 20, }];
2633+
const chart = this.createChart({
2634+
dataSource,
2635+
legend: {
2636+
visible: false,
2637+
},
2638+
series: { type: 'bar' },
2639+
valueAxis: {
2640+
visualRangeUpdateMode: 'keep',
2641+
visualRange: {
2642+
startValue: 5,
2643+
endValue: 25,
2644+
}
2645+
},
2646+
zoomAndPan: {
2647+
valueAxis: 'both',
2648+
}
2649+
});
2650+
2651+
this.pointer.start({ x: 200, y: 250 }).wheel(10);
2652+
dataSource.push({ arg: 2020, val: 15 });
2653+
chart.option('dataSource', dataSource);
2654+
2655+
const visualRange = chart.getValueAxis().visualRange();
2656+
2657+
assert.strictEqual(Math.floor(visualRange.startValue), 6);
2658+
assert.strictEqual(Math.floor(visualRange.endValue), 24);
2659+
});
2660+
26322661
QUnit.test('Do nothing if no actions allowed', function(assert) {
26332662
const onZoomStart = sinon.spy();
26342663
const onZoomEnd = sinon.spy();

0 commit comments

Comments
 (0)