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!

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