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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...