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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...