How to Change the Background Color of a Chart in Splunk
Hi guys !! Again we have come with a very interesting topic of Splunk. For visualizing the data in Splunk Dashboards we often use column charts , bar charts and pie charts etc. The background of every panel appears white by default.
Have you ever thought of changing the background color of the charts in Splunk ????
In this post we will show you how to change the background color of a chart in splunk. It is very easy to implement. We have created a sample dashboard called Background Color.
Here we have created a panel with a column chart . The query behind the panel is
index=_internal sourcetype=splunkd_ui_access | stats count by method,status
Below we have shown how to change the background color of a chart in Splunk. For that you have to edit the source code of your dashboard. You can see the Edit option on the top right corner of your dashboard. Click on Edit.
Now you can see the Source option on the top left corner of the page. Click on Source to edit the source code.
Now in the source code, you have to add options inside the chart tag.
<option name="charting.fieldColors">
{"status":#FF0000,"count":#00009C}</option>
<option name="charting.backgroundColor">#00FFFF</option>
<option name="charting.fontColor">#000000</option>
<option name="charting.foregroundColor">#000000</option>
By charting.fieldColors we have changed the color of the columns in the chart. Here status and count are two existing field name in the column chart. You can see How to Add Custom Colors in the Charts in Splunk for more details. We have used charting.backgroundColor to change the background color of the column chart. Also, you have to specify the hexadecimal code of the colors to change the background color of the chart. You can choose any hexadecimal color code as per your wish. We have used charting.fontColor to change the colors of the fonts and also used charting.foregroundColor to change the foreground color of the chart lines.
After adding the options in the source code click on Save to save the changes.
As you can see, we have created a cool dashboard with a custom background color in the column chart. You can also change the background color of a bar chart, pie chart etc. in the same way.
You can download the source code of this sample dashboard by clicking the below button.
Source Code
Hope this has helped you in achieving the below requirement without fail:
How to Change the Background Color of a Chart in Splunk
Happy Splunking !!
[…] After making changes into the source code click on Save to make the changes. Like this way you can change the background color of charts in XML dashboard as […]