cancel
Showing results for 
Search instead for 
Did you mean: 

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

masood_sadiq4
Explorer
0 Kudos

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) {

DS1.removeDimension(dimension);

});

DS1.moveDimensionToRows(selectedValue);

arijit_das
Active Contributor
0 Kudos

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 ?

masood_sadiq4
Explorer
0 Kudos

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.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member234401
Active Participant

Hi

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)

Br

René

masood_sadiq4
Explorer
0 Kudos

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_CH1.moveDimensionToRows(selectedValue);

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

P1_CH2.moveDimensionToColumns(selectedValue);

Answers (1)

Answers (1)

masood_sadiq4
Explorer
0 Kudos

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