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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...