Skip to Content

Getting duplicate legend values in Line Chart with 2 Y-Axes

Hi Pros,

I am getting duplicate legend values for every value i select in Listbox.

I have created two measures and based on a condition the values are getting stored in both measures. These values are generated against a dimension field and as per the condition if a value is generated in one measure then for other measure the value will be null. Now when i select a particular value from listbox i get a single axis against that but two legends. Please find attached the screenshot legend-issue.pngt for the same. I need to have single legend for the axis for which i am getting value. Thanks in advance.

Arpit

legend-issue.png (34.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 12, 2017 at 08:51 AM

    This is how I tried to replicate a similar scenario:

    I have created 2 css classes as below:

    .hideLegend1 .viz-legend-valueLabel g:nth-child(1){
       visibility:hidden;
    }
    
    .hideLegend2 .viz-legend-valueLabel g:nth-child(2){
       visibility:hidden;
    }

    Now, the on startup event of application, I used the script below. You have to use same script in the on selection event of the listbox as well.

    if(DS_1.getData("_GIiL54mPEee2VZjheZxFZQ", {}).formattedValue == ''){ // If the first measure is null
           INFOCHART_1.setCSSClass('hideLegend1');
    }else{ // If the second measure is null
           INFOCHART_1.setCSSClass('hideLegend2');
    }

    In initial view of the data source, I used Sum to calculate total of the measures so that the total is blank in case all values are null.

    Thus, if one measure provides all null values, the legend for the same is hidden in the infochart.

    Add comment
    10|10000 characters needed characters exceeded

    • I have tried with single measure but as per the requirement the values for some tags are very low and for some are very high so to make all the tag values visible and at some level we need dual axis, but i think due to legend getting duplicate we won't be able to achieve that. I think this is a limitation or some kind of bug in SAP Design Studio 1.6 SP3 base pack.

      Thanks

      Arpit