Dashboards & Visualizations

How do you set axis labels via JavaScript REST API?

swb03
Explorer

Hi,

I'm using the following to successfully display Splunk charts on my external website via the JavaScript SDK:

splunkjs.UI.ready(chartToken, function () {

var chart = new splunkjs.UI.Charting.Chart($(element), splunkjs.UI.Charting.ChartType.LINE, false);

chart.setData(results, {
"chart.stackMode": "default",
"legend.placement": "bottom",
});

console.log("Chart: ", chart);

chart.draw();

});

I'm having a really hard time figuring out how to change simple things like the X & Y axis labels, set the min & max scale, etc.

Does anyone have a code example doing some of those things?

Any help would be appreciated.

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Have you tried adding the relevant chart configuration options to your already existing configuration like so?

...
chart.setData(results, {
  "chart.stackMode": "default",
  "legend.placement": "bottom",
  "axisY.minimumNumber": foo,
  "axisY.maximumNumber": bar,
});
...

See http://docs.splunk.com/Documentation/Splunk/6.0.2/Viz/ChartConfigurationReference for reference.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

Have you tried adding the relevant chart configuration options to your already existing configuration like so?

...
chart.setData(results, {
  "chart.stackMode": "default",
  "legend.placement": "bottom",
  "axisY.minimumNumber": foo,
  "axisY.maximumNumber": bar,
});
...

See http://docs.splunk.com/Documentation/Splunk/6.0.2/Viz/ChartConfigurationReference for reference.

swb03
Explorer

Hi Martin,

I could swear I tried this yesterday to no avail, but I must have done something differently because you're suggestion worked.

Thank you for taking the time to respond.

-Sean

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