Dashboards & Visualizations

How to assign colors to slices of a pie chart on a dashboard when the number of slices vary?

waardd
Engager

I want to assign specific colors to pie-parts even when the number of pie-parts vary from 1 to 5 parts.
Error parts are not always in the pie, but must always be red.
Completed part is always in the pie and must always be green.

There are two kinds of errors that are not always in the pie chart, but as mentioned must always get the same color.

How can i make this work?

code example of 1 piechart in the dashboard:

 <panel>
      <title>Extern (DLL) Async</title>
      <chart>
        <title>G (BKR)</title>
        <search>
          <query>index = fake-index sourcetype = fake-sourcetype source = /something/application.log "*Check execution performance*" AND ";G;" | table SoortToets , UitkomstToets | stats count(SoortToets) by UitkomstToets</query>
          <earliest>-15m</earliest>
        </search>
<!--        <option name="charting.seriesColors">[0xD0FFA1,0xFFDD00,0x00C3FF,0xFFA1A1,0xFF0000]</option> -->
        <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.scale">linear</option>
        <option name="charting.axisY.scale">linear</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">all</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.placement">right</option>
      </chart>
    </panel>
1 Solution

hylam
Contributor

http://docs.splunk.com/Documentation/Splunk/6.3.1/Viz/Chartcustomization

  <option name="charting.legend.labels">[error,warn,info]</option>
  <option name="charting.seriesColors">[0xFF0000,0xFFFF00,0x00FF00]</option>

View solution in original post

hylam
Contributor

http://docs.splunk.com/Documentation/Splunk/6.3.1/Viz/Chartcustomization

  <option name="charting.legend.labels">[error,warn,info]</option>
  <option name="charting.seriesColors">[0xFF0000,0xFFFF00,0x00FF00]</option>

jotne
Builder

A better way to do this that will always works correctly: (tested in 9.0.5)

<option name="charting.fieldColors">{"error":#FF0000,"warn":FFFF00,"info":00FF00}</option>
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...