Archive

How to avoid overlapping of data label values in area chart?

Explorer

Hello,

The issue is Data Label values are overlapping in my area chart when these values are almost similar.

Anyone has a idea to avoid this or can we show only one area's label values when selected?

Thanks & Regards,
Chinmay.

Tags (1)
0 Karma

SplunkTrust
SplunkTrust

@Chinmai, you can hide the Data Label for particular series in the Legend using CSS Override. Following code will hide the data label for first series in Legend where your chart id is myChartHiddenSeries1DataLabels using CSS Class selector .highcharts-data-labels.highcharts-series-1

  <row depends="$alwaysHideCSSOverridePanel$">
    <panel>
      <html>
        <style>
          #myChartHiddenSeries1DataLabels .highcharts-data-labels.highcharts-series-1{
            visibility:hidden !important;
          }
        </style>
      </html>
    </panel>
  </row>

If you want it to be applied for second series you need to change CSS Class selector to .highcharts-data-labels.highcharts-series-2.

Please try out the following run anywhere example where first chart has id myChartNoCSSOverride and CSS override is not applied. Hence it has both Data Labels overlapping each other. The Second chart has id myChartHiddenSeries1DataLabels and Data Label for first Legend Series i.e. count1 is hidden.

alt text

Following is the Simple XML code for run anywhere Dashboard based on sample mock screenshot/data.

<dashboard>
  <label>Hide Data Label for particular Legend</label>
  <row depends="$alwaysHideCSSOverridePanel$">
    <panel>
      <html>
        <style>
          #myChartHiddenSeries1DataLabels .highcharts-data-labels.highcharts-series-1{
            visibility:hidden !important;
          }
        </style>
      </html>
    </panel>
  </row>
  <row>
    <panel>
      <chart id="myChartNoCSSOverride">
        <title>With CSS Override to Hide Data Label for Legend Series 1 i.e. count1</title>
        <search>
          <query>| makeresults 
| eval sno="pipeline",count1=42384739,count2=42380021
|  append 
    [| makeresults 
| eval sno="queue",count1=81357843,count2=81357112]
|  table sno count1 count2</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
        <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
        <option name="charting.axisTitleX.visibility">visible</option>
        <option name="charting.axisTitleY.visibility">visible</option>
        <option name="charting.axisTitleY2.visibility">visible</option>
        <option name="charting.axisX.abbreviation">none</option>
        <option name="charting.axisX.scale">linear</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.axisY2.abbreviation">none</option>
        <option name="charting.axisY2.enabled">0</option>
        <option name="charting.axisY2.scale">inherit</option>
        <option name="charting.chart">area</option>
        <option name="charting.chart.bubbleMaximumSize">50</option>
        <option name="charting.chart.bubbleMinimumSize">10</option>
        <option name="charting.chart.bubbleSizeBy">area</option>
        <option name="charting.chart.nullValueMode">gaps</option>
        <option name="charting.chart.showDataLabels">all</option>
        <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.chart.style">shiny</option>
        <option name="charting.drilldown">none</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.layout.splitSeries.allowIndependentYRanges">0</option>
        <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.legend.mode">standard</option>
        <option name="charting.legend.placement">right</option>
        <option name="charting.lineWidth">2</option>
        <option name="trellis.enabled">0</option>
        <option name="trellis.scales.shared">1</option>
        <option name="trellis.size">medium</option>
      </chart>
    </panel>
    <panel>
      <chart id="myChartHiddenSeries1DataLabels">
        <title>With CSS Override to Hide Data Label for Legend Series 1 i.e. count1</title>
        <search>
          <query>| makeresults 
| eval sno="pipeline",count1=42384739,count2=42380021
|  append 
    [| makeresults 
| eval sno="queue",count1=81357843,count2=81357112]
|  table sno count1 count2</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="charting.axisLabelsX.majorLabelStyle.overflowMode">ellipsisNone</option>
        <option name="charting.axisLabelsX.majorLabelStyle.rotation">0</option>
        <option name="charting.axisTitleX.visibility">visible</option>
        <option name="charting.axisTitleY.visibility">visible</option>
        <option name="charting.axisTitleY2.visibility">visible</option>
        <option name="charting.axisX.abbreviation">none</option>
        <option name="charting.axisX.scale">linear</option>
        <option name="charting.axisY.abbreviation">none</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.axisY2.abbreviation">none</option>
        <option name="charting.axisY2.enabled">0</option>
        <option name="charting.axisY2.scale">inherit</option>
        <option name="charting.chart">area</option>
        <option name="charting.chart.bubbleMaximumSize">50</option>
        <option name="charting.chart.bubbleMinimumSize">10</option>
        <option name="charting.chart.bubbleSizeBy">area</option>
        <option name="charting.chart.nullValueMode">gaps</option>
        <option name="charting.chart.showDataLabels">all</option>
        <option name="charting.chart.sliceCollapsingThreshold">0.01</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.chart.style">shiny</option>
        <option name="charting.drilldown">none</option>
        <option name="charting.layout.splitSeries">0</option>
        <option name="charting.layout.splitSeries.allowIndependentYRanges">0</option>
        <option name="charting.legend.labelStyle.overflowMode">ellipsisMiddle</option>
        <option name="charting.legend.mode">standard</option>
        <option name="charting.legend.placement">right</option>
        <option name="charting.lineWidth">2</option>
        <option name="trellis.enabled">0</option>
        <option name="trellis.scales.shared">1</option>
        <option name="trellis.size">medium</option>
      </chart>
    </panel>
  </row>
</dashboard>

Please try out and confirm!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

New Member

Thanks for the code, but i copy pasted exactly same thing, but it is not working for me. still data label values are overlapping.
Moreover, i do not want to permanently hide the Data Label for first Legend Series i.e. count1 or Data Label for second Legend Series i.e. count2.

What i want is when i move over my mouse pointer on legend count1 then data label values for count2 legend should go invisible and

and when i move over my mouse pointer on legend count2 then data label values for count1 legend should go invisible

0 Karma

SplunkTrust
SplunkTrust

@Chinmai have you ensured that your chart id is #myChartHiddenSeries1DataLabels i.e.

<panel>
       <chart id="myChartHiddenSeries1DataLabels">

Tooltip Text will still be based on hover.

For what you are asking seems to be a jQuery requirement as it involves change of default Legend hover behavior (might not work as well).

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

New Member

attached is the issue snap shot, please check

0 Karma

New Member

or is it possible to show data label values only for the selected particular legend and not for all?

Current values of charting.chart.showDataLabels is all, min/max and none. can we use any token to show only data label values for only selected legend and how?

0 Karma

SplunkTrust
SplunkTrust

@chinmayc469 would it be possible for you to add a snapshot of your issue and what is it that you need?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma