Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart: valueAxis should not restore visualRange on dataSource update (T1262610) #28369

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading