Dashboards & Visualizations

Pie chart vs Label colors

bharathkumarnec
Contributor

Hi All,

Is there a way that we can have same colors as pie chart to the labels separately written to represent?

Regards,
BK

0 Karma
1 Solution

niketn
Legend

@bharathkumarnec, Label Text for Pie Chart can be colored using CSS Style Override.

alt text

In the following run anywhere example I have used charting.seriesColors to apply color to Pie Chart Slices and also series sequence to the corresponding label text. Text Color override would also be possible, however, I feel jQuery will be required for that. Please see if seriesColors suits your needs or not.

Following is the run anywhere dashboard code for screenshot attached.

<dashboard>
  <label>Pie Chart Color Label Based on Slice</label>
  <init>
    <set token="tokGreen">0x65a637</set>
    <set token="tokBlue">0x6db7c6</set>
    <set token="tokYellow">0xf7bc38</set>
    <set token="tokOrange">0xf58f39</set>
    <set token="tokRed">0xd93f3c</set>
  </init>
  <row>
    <panel>
      <html depends="$alwaysHideCSSStyle$">
        <style>
          #myPieChart g.highcharts-data-label-color-0 text{
            fill:#65a637 !important;
          }
          #myPieChart g.highcharts-data-label-color-1 text{
            fill:#6db7c6 !important;
          }
          #myPieChart g.highcharts-data-label-color-2 text{
            fill:#f7bc38 !important;
          }
          #myPieChart g.highcharts-data-label-color-3 text{
            fill:#f58f39 !important;
          }
          #myPieChart g.highcharts-data-label-color-4 text{
            fill:#d93f3c !important;
          }
        </style>
      </html>
      <chart id="myPieChart">
        <search>
          <query>index=_internal sourcetype=splunkd log_level!="INFO" component!="Conf*"
|  top 5 component</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">pie</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">none</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">ellipsisEnd</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>
        <option name="charting.seriesColors">["$tokGreen$","$tokBlue$","$tokYellow$","$tokOrange$","$tokRed$"]</option>
      </chart>
    </panel>
  </row>
</dashboard>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@bharathkumarnec, Label Text for Pie Chart can be colored using CSS Style Override.

alt text

In the following run anywhere example I have used charting.seriesColors to apply color to Pie Chart Slices and also series sequence to the corresponding label text. Text Color override would also be possible, however, I feel jQuery will be required for that. Please see if seriesColors suits your needs or not.

Following is the run anywhere dashboard code for screenshot attached.

<dashboard>
  <label>Pie Chart Color Label Based on Slice</label>
  <init>
    <set token="tokGreen">0x65a637</set>
    <set token="tokBlue">0x6db7c6</set>
    <set token="tokYellow">0xf7bc38</set>
    <set token="tokOrange">0xf58f39</set>
    <set token="tokRed">0xd93f3c</set>
  </init>
  <row>
    <panel>
      <html depends="$alwaysHideCSSStyle$">
        <style>
          #myPieChart g.highcharts-data-label-color-0 text{
            fill:#65a637 !important;
          }
          #myPieChart g.highcharts-data-label-color-1 text{
            fill:#6db7c6 !important;
          }
          #myPieChart g.highcharts-data-label-color-2 text{
            fill:#f7bc38 !important;
          }
          #myPieChart g.highcharts-data-label-color-3 text{
            fill:#f58f39 !important;
          }
          #myPieChart g.highcharts-data-label-color-4 text{
            fill:#d93f3c !important;
          }
        </style>
      </html>
      <chart id="myPieChart">
        <search>
          <query>index=_internal sourcetype=splunkd log_level!="INFO" component!="Conf*"
|  top 5 component</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">pie</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">none</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">ellipsisEnd</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>
        <option name="charting.seriesColors">["$tokGreen$","$tokBlue$","$tokYellow$","$tokOrange$","$tokRed$"]</option>
      </chart>
    </panel>
  </row>
</dashboard>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...