From 42b69cd93fb8a1301f258deedec71de7b1c820eb Mon Sep 17 00:00:00 2001 From: Nikki Gonzales <38495263+nikkithelegendarypokemonster@users.noreply.github.com> Date: Fri, 15 Mar 2024 20:34:46 +0800 Subject: [PATCH] PolarChart: Properly update property stackName when updating option in polarChart[stackbar] (T1215023) (#26925) --- .../js/viz/series/stacked_series.js | 5 +- .../DevExpress.viz.charts/polarChart.tests.js | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/packages/devextreme/js/viz/series/stacked_series.js b/packages/devextreme/js/viz/series/stacked_series.js index dc1655669bac..80b727ad0b28 100644 --- a/packages/devextreme/js/viz/series/stacked_series.js +++ b/packages/devextreme/js/viz/series/stacked_series.js @@ -161,7 +161,10 @@ chart['fullstackedsplinearea'] = _extend({}, areaSeries['splinearea'], baseStack _appendInGroup: chart['stackedarea']._appendInGroup }); -polar['stackedbar'] = _extend({}, _polar.bar, baseStackedSeries, {}); +polar['stackedbar'] = _extend({}, _polar.bar, baseStackedSeries, { _updateOptions: function(options) { + baseStackedSeries._updateOptions.call(this, options); + this._stackName = this._stackName + '_stack_' + (options.stack || 'default'); +} }); export { chart, diff --git a/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js index a72c60656055..bc3fb7b992ca 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.charts/polarChart.tests.js @@ -260,7 +260,57 @@ const environment = { return this.createPolarChart($.extend({}, { dataSource: [], series: {}, argumentAxis: { startAngle: 0 } }, options)); } }; +QUnit.module('create Polar Chart with default configurations'); +QUnit.test('test if polarChart correctly labels axis and stack with default if not setted', function(assert) { + const chart = new dxPolarChart('#chartContainer', { + series: [{ type: 'stackedbar' }] + }); + + const series = chart.getAllSeries(); + + assert.strictEqual(series.length, 1, 'count of series'); + + assert.strictEqual(series[0].getStackName(), 'axis_default_stack_default'); +}); + +QUnit.test('test if polarChart correctly labels axisName without stackName', function(assert) { + const chart = new dxPolarChart('#chartContainer', { + series: [{ axis: 'axisName', type: 'stackedbar' }] + }); + + const series = chart.getAllSeries(); + + assert.strictEqual(series.length, 1, 'count of series'); + + assert.strictEqual(series[0].getStackName(), 'axis_axisName_stack_default'); +}); + +QUnit.test('test if polarChart correctly labels axisName with stackName', function(assert) { + const chart = new dxPolarChart('#chartContainer', { + series: [{ axis: 'axisName', type: 'stackedbar', stack: 'stackName' }] + }); + + const series = chart.getAllSeries(); + + assert.strictEqual(series.length, 1, 'count of series'); + + assert.strictEqual(series[0].getStackName(), 'axis_axisName_stack_stackName'); +}); + +QUnit.test('Series of PolarChart should have correct stackName when stackName is set(T1215023)', function(assert) { + const chart = new dxPolarChart('#chartContainer', { + series: [{ type: 'stackedbar', stack: 'first' }, + { type: 'stackedbar', stack: 'second' }] + }); + + const series = chart.getAllSeries(); + + assert.strictEqual(series.length, 2, 'count of series'); + + assert.strictEqual(series[0].getStackName(), 'axis_default_stack_first'); + assert.strictEqual(series[1].getStackName(), 'axis_default_stack_second'); +}); QUnit.module('create Polar chart', environment); QUnit.test('create empty polar chart', function(assert) {