Splunk Dev

assigning "seriesColors" attribute in Javascript SDK

kwchang_splunk
Splunk Employee
Splunk Employee

Dear,
I'm looking for Javascript SDK sample code of changing "seriesColors" attribute of a chart.
Thank you in advance.

1 Solution

ineeman
Splunk Employee
Splunk Employee

Using the chart sample that ships with the SDK, here is a small change to add seriesColors:

function(results, job, callback) { 
  splunkjs.UI.ready(chartToken, function() {
    chart.setData(results, {
      "chart.stackMode": "stacked",
      "seriesColors": "[0xff0000, 0x00ff00]"
    });
    chart.draw();
    callback(null, job);
  });
}

As you can see, we simply set the 'seriesColors' attribute. Note that it needs to be a string with an array in it, as this is what the charting library expects.

View solution in original post

0 Karma

ineeman
Splunk Employee
Splunk Employee

Using the chart sample that ships with the SDK, here is a small change to add seriesColors:

function(results, job, callback) { 
  splunkjs.UI.ready(chartToken, function() {
    chart.setData(results, {
      "chart.stackMode": "stacked",
      "seriesColors": "[0xff0000, 0x00ff00]"
    });
    chart.draw();
    callback(null, job);
  });
}

As you can see, we simply set the 'seriesColors' attribute. Note that it needs to be a string with an array in it, as this is what the charting library expects.

0 Karma

kwchang_splunk
Splunk Employee
Splunk Employee

Thank you so much!!

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...