Skip to Content

How to Swap Dimension in Stacked Column Chart under "Color"

Feb 18 at 10:41 AM


avatar image

Hi Experts.

Using the radio button I am swapping X Axis Dimensions from both graphs.

It’s working on the left graph. But it’s not working on the right graph (Stacked Column Chart)

Dimension in Stacked Column Chart is under Color as shown below in Pic 1. in my Case, " Region"

Using this code to delete X axis dimensions first and then moving radio button selected dimension into rows

var selectedValue = P1_RADIO.getSelectedValue();

DS1.getDimensions(Axis.ROWS).forEach(function(dimension, index) {




pic1.png (37.7 kB)
pic2.png (34.8 kB)
10 |10000 characters needed characters left characters exceeded

What do you mean exactly by the code not working for stacked chart ?

Can you post a screenshot of the initial view of data source for the stacked chart ?


when i was clicking the radio button for swapping, it was actually stacking both the dimensions on the same access.

But now its working. Instead of rows, i cleared the column dimensions and moved the selected dimension into the column.


* Please Login or Register to Answer, Follow or Comment.

2 Answers

René Hvidberg Feb 18 at 09:20 PM


Instead of remove the dimension and then adding the new one try

DS_1.swapDimensions(dimension1, dimension2)

the moveDimensionToRows(selectedValue,0) is not currently working as intended - should be corrected in week 11 (Lumira 2.1 SP01)

And when you use the foreach statement to find the dimension on the rows - there should only be one dimension in that row - put the other dimensions in the columns in the datasource (DS_1)



Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks René, For your response.

I someone got it working using the following code. i cleared the Columns and moved the dimension into Columns. Although the actual dimension is under " Color" in Stacked Column chart it still worked.

var selectedValue = P1_RADIO.getSelectedValue();

P1_CH1.getDimensions(Axis.ROWS).forEach(function(dimension, index) { P1_CH1.removeDimension(dimension); });


P1_CH2.getDimensions(Axis.COLUMNS).forEach(function(dimension, index) { P1_CH2.removeDimension(dimension); });


Masood Sadiq Feb 19 at 04:38 AM

P1_CH2.getDimensions(Axis.COLUMNS).forEach(function(dimension, index) { P1_CH2.removeDimension(dimension); }); P1_CH2.moveDimensionToColumns(selectedValue);

10 |10000 characters needed characters left characters exceeded