Dashboards & Visualizations

Bar Chart with colors

Rgk_Trail
Explorer

Hi,

I am trying to assign colors to the bars in my chart.  I have 3 distinct values under variable "Change Type" and I am using charting.fieldColors but for some reason all the bars in the chart appear with default blue color. 

Am I doing something wrong here ? 

<panel>
<chart>
<title>Change Type Analysis</title>
<search base="Base">
<query>
|stats count by "Change Type"|sort -count </query>
</search>
<option name="charting.axisTitleX.text">Change Type</option>
<option name="charting.axisTitleY.text">Number of Changes</option>
<option name="charting.chart">bar</option>
<option name="charting.chart.showDataLabels">all</option>
<option name="charting.chart.stackMode">stacked</option>
<option name="charting.drilldown">all</option>
<option name="charting.fieldColors">{"Standard":0x9BE8AB,"Emergency":0xE87D6F,"Normal":0x5A4575}</option>
<option name="charting.layout.splitSeries">0</option>
<option name="charting.legend.labelStyle.overflowMode">ellipsisEnd</option>
<option name="height">200</option>
<option name="refresh.display">progressbar</option>
</chart>
</panel>

 

- Rohan

Labels (1)
0 Karma

Rgk_Trail
Explorer

Thanks a lot ! it worked. I am also trying to sort the bar charts by the count but looks like it was working before but it doesnt work with eval statements in stats command.  

Can you suggest a way to sort the bars by the count ? 

|stats count(eval(CHG_Type="Normal")) as Normal
count(eval(CHG_Type="Standard")) as Standard
count(eval(CHG_Type="Emergency")) as Emergency by CHG_Type|sort - count
</query>
</search>
<option name="charting.axisTitleX.text">Change Type</option>
<option name="charting.axisTitleY.text">Number of Changes</option>
<option name="charting.chart">bar</option>
<option name="charting.chart.showDataLabels">all</option>
<option name="charting.chart.stackMode">stacked</option>
<option name="charting.drilldown">all</option>
<option name="charting.fieldColors">{"Standard":#5DADE2,"Emergency":#85C1E9,"Normal":#3498DB}</option>

0 Karma

renjith_nair
Legend

fieldColors are set based on the field name not the values.

Please see below example.

https://docs.splunk.com/Documentation/SplunkCloud/8.1.2008/Viz/BuildandeditdashboardswithSimplifiedX...

Run anywhere example

<dashboard>
  <label>Chart Colors</label>
  <row>
    <panel>
      <chart>
        <title>Field colors example</title>
        <search>
          <query>
        index = _internal log_level=* | stats
        count(eval(log_level="ERROR")) as ERROR
        count(eval(log_level="WARN")) as WARN
        count(eval(log_level="INFO")) as INFO
        by sourcetype
      </query>
          <earliest>-2h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="charting.axisY.scale">log</option>
        <option name="charting.chart">column</option>
        <option name="charting.fieldColors">{"ERROR": 0xFF0000, "WARN": 0xFF9900, "INFO":0x009900, "NULL":0xC4C4C0}</option>
        <option name="charting.legend.placement">right</option>
      </chart>
    </panel>
  </row>
</dashboard>
---
What goes around comes around. If it helps, hit it with Karma 🙂
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...