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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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