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!

Announcing Scheduled Export GA for Dashboard Studio

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

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...