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: Negative values are not displayed when multiple value axes are synchronized to zero ( T1193670 ) #26217

Merged
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
21 changes: 21 additions & 0 deletions js/viz/chart_components/multi_axes_synchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,28 @@ function updateMinorTicks(axesInfo) {
});
}

function allAxesValuesOnSameSideFromZero(axesInfo) {
let allPositive = true;
let allNegative = true;

axesInfo.forEach((axis) => {
if(axis.oldMinValue > 0 || axis.oldMaxValue > 0) {
allNegative = false;
}

if(axis.oldMinValue < 0 || axis.oldMaxValue < 0) {
allPositive = false;
}
});

return allPositive || allNegative;
}

function correctPaddings(axesInfo, paddings) {
if(!allAxesValuesOnSameSideFromZero(axesInfo)) {
return paddings;
}

return axesInfo.reduce((prev, info) => {
const inverted = info.inverted;
const { start, end } = info.axis.getCorrectedValuesToZero(info.minValue, info.maxValue);
Expand Down
54 changes: 54 additions & 0 deletions testing/tests/DevExpress.viz.charts/chart.integration.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,60 @@ QUnit.test('Chart with large scale break. No ticks in break', function(assert) {
}
});

QUnit.test('negative values should be displayed after multiple axes are synchronized to zero(T1193670)', function(assert) {
const chart = this.createChart({
commonSeriesSettings: {
argumentField: 'arg',
type: 'bar',
},
series: [{
type: 'bar',
valueField: 'val1',
}, {
type: 'spline',
valueField: 'val2',
axis: 'secondAxis',
}],
valueAxis: [{
synchronizedValue: 0,
name: 'firstAxis',
}, {
name: 'secondAxis',
position: 'right',
synchronizedValue: 0
}],
dataSource: [{
arg: 'a',
val1: 1,
val2: 1
}, {
arg: 'b',
val1: 2,
val2: 2
}, {
arg: 'c',
val1: 1,
val2: -1
}, {
arg: 'd',
val1: 3,
val2: 3
}, {
arg: 'e',
val1: 1,
val2: 1
}],
});

const firstAxis = chart.getValueAxis('firstAxis').visualRange();
const secondAxis = chart.getValueAxis('secondAxis').visualRange();

assert.strictEqual(firstAxis.startValue, -1.5);
assert.strictEqual(firstAxis.endValue, 3.5);
assert.strictEqual(secondAxis.startValue, -1.5);
assert.strictEqual(secondAxis.endValue, 3.5);
});

QUnit.test('Dispose unused axes (T1042940)', function(assert) {
this.$container.css({ width: '1000px', height: '600px' });

Expand Down