Getting Data In

How to set single value chart with static color?

mottig
Path Finder

Hello

I am trying to set a static color to my single value (the value is string) visualization.

I tried it with CSS, add ID to single markup and it didn't work.

I also tried to set these options:

<option name="colorMode">block</option>
<option name="colorBy">value</option>
<option name="useColors">0</option>
<option name="rangeColors">["0x0000ff"]</option>

 

and it didnt work as well.

Labels (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

This is a working example of showing string values in different colours. It shows two ways of colouring SV panels with string data

<dashboard>
  <label>colour_box</label>
  <row>
    <panel depends="$hide_css$">
      <html>
        <style>
          #verdict rect {
            fill: $verdict_background$ !important;
          }
          #verdict text {
            fill: $verdict_foreground$ !important;
          }
        </style>
      </html>
    </panel>
    <panel>
      <single id="verdict">
        <title>Verdict - use CSS to style box</title>
        <search>
          <query>| makeresults
          | eval verdict=mvindex(split("Pass,Fail",","), random() % 2)
          </query>
          <done>
            <eval token="verdict_background">if($result.verdict$="Pass", "green", "red")</eval>
            <set token="verdict_foreground">black</set>
          </done>
        </search>
        <option name="colorMode">block</option>
        <option name="drilldown">none</option>
        <option name="height">60</option>
        <option name="rangeColors">["0x53a051","0xdc4e41"]</option>
        <option name="rangeValues">[0]</option>
        <option name="useColors">1</option>
      </single>
    </panel>
    <panel>
      <single>
        <title>Verdict 2 - define range based on pass/fail verdict</title>
        <search>
          <query>| makeresults
          | eval verdict=mvindex(split("Pass,Fail",","), random() % 2)
          | eval range=if(verdict=="Pass", "low", "severe")
          | table verdict range
          </query>
        </search>
        <option name="colorMode">block</option>
        <option name="drilldown">none</option>
        <option name="height">60</option>
        <option name="field">verdict</option>
      </single>
    </panel>
  </row>
</dashboard>

mottig
Path Finder

Thank you it is now working!

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Please mark the answer as a solution, if it works for you so it's useful for others.

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 ...