Dashboards & Visualizations

Change/Set color of Single Value Visualization text box based on a String Value

harish_ka
Communicator

I have a single value text box and i need to fill the box with any color irrespective of the count/range.
Lets say, i have below result
Prod Count


ABC 10
XYZ 2
PQR 22

Here i need my Single value text box colour as RED when Prod is ABC, BLUE when Prod is PQR...

I tried with rangemap like
eval product=case(prod=="ABC",0,prod=="XYZ",10)|rangemap field=product low=0-9 medium=10-19, but it gives black color...

i am using only these options,
colorBy - value
colorMode - block
underLabel - Prod- ABC
useColors - 1

0 Karma
1 Solution

niketn
Legend

@harish_ka, You would need to use three Single Value visualizations one for ABC, XYZ and PQR each. Since you want each of your single values to be colored based on the Prod value, you can code static colors using rangeColors for both min-0 and 0-max as

Red (0x6db7c6) for PQR

    <option name="colorMode">block</option>
    <option name="rangeColors">["0x6db7c6","0x6db7c6"]</option>
    <option name="rangeValues">[0]</option>
    <option name="underLabel">PQR</option>
    <option name="useColors">1</option>

Blue(0xd93f3c), for ABC

    <option name="colorMode">block</option>
    <option name="rangeColors">["0xd93f3c","0xd93f3c"]</option>
    <option name="rangeValues">[0]</option>
    <option name="underLabel">ABC</option>
    <option name="useColors">1</option>

and in this case Green(0x65a637) for XYZ

    <option name="colorMode">block</option>
    <option name="rangeColors">["0x65a637","0x65a637"]</option>
    <option name="rangeValues">[0]</option>
    <option name="underLabel">XYZ</option>
    <option name="useColors">1</option>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@harish_ka, You would need to use three Single Value visualizations one for ABC, XYZ and PQR each. Since you want each of your single values to be colored based on the Prod value, you can code static colors using rangeColors for both min-0 and 0-max as

Red (0x6db7c6) for PQR

    <option name="colorMode">block</option>
    <option name="rangeColors">["0x6db7c6","0x6db7c6"]</option>
    <option name="rangeValues">[0]</option>
    <option name="underLabel">PQR</option>
    <option name="useColors">1</option>

Blue(0xd93f3c), for ABC

    <option name="colorMode">block</option>
    <option name="rangeColors">["0xd93f3c","0xd93f3c"]</option>
    <option name="rangeValues">[0]</option>
    <option name="underLabel">ABC</option>
    <option name="useColors">1</option>

and in this case Green(0x65a637) for XYZ

    <option name="colorMode">block</option>
    <option name="rangeColors">["0x65a637","0x65a637"]</option>
    <option name="rangeValues">[0]</option>
    <option name="underLabel">XYZ</option>
    <option name="useColors">1</option>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

harish_ka
Communicator

@niketnilay Thanks for this answer, it worked 🙂

So what if i have only one 'Single Value text box' and need to change the color based on prod value .
If my search returns result of prod value as ABC then Blue,
If my search returns result of prod value as XYZ then Green...

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...