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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...