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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...