Splunk Search
Highlighted

Unable to dynamically set "charting.data.count" in a splunkjs ChartView and have it re-render. What's wrong?

Path Finder

I am creating a Javascript app outside of Splunk, and trying to dynamically reset the number of points that get charted in a ChartView instance.
I have tried doing this in two different ways, but none of the two options produces a re-render, as expected:

1-

   mychart.settings.set("charting.data.count", <value>);
   mychart.render();

2-

 mychart.settings.set({ "charting.data.count": <value> });
 mychart.render();

(NOTE: the suggestion that it be " mychart.settings.set({"charting.data.count", <value>}); "  is actually syntactically incorrect, and  Javascript complaints about it immediately)

My event handler (attached to a dropdown view) is as follows:

 myDropDownView.on("change", function() {
        const numElement = parseInt( myDropDownView.val());
        console.log("Trying to set bar chart to display " + numElement + " data points...");
        mychart.settings.set("charting.data.count", numElement); // using alternative 1 and also 2
        mychart.render();

    });

NOTES:
1- I have also tried the above without converting the value retrieved from the drop down to a number (in other words, tried with a string and a number).
2- The event handler executes, since it logs as expected

Am I missing something, or this setting somehow differs from all the others and cannot be dynamically updated?

Further update on 3/3/20: I notice that the chart actually re-renders, but it completely ignores the changed setting (that is, it renders as it originally did before I updated the setting.) I am starting to believe this may be a Splunkjs bug... Could somebody from Splunk confirm?

0 Karma
Highlighted

Re: Unable to dynamically set "charting.data.count" in a splunkjs ChartView and have it re-render. What's wrong?

Legend

@pgoldweic you need to use mychart.settings.set like

  mychart.settings.set({"charting.data.count", <value>});

Following is link to one of the examples: https://dev.splunk.com/enterprise/docs/developapps/webframework/displaydataview/howtoaddviewsplunkjs...

0 Karma
Highlighted

Re: Unable to dynamically set "charting.data.count" in a splunkjs ChartView and have it re-render. What's wrong?

Path Finder

That is exactly what I had already tried, with no effect. Looks like my post had a typo, since I forgot the "set" part, but I used it correctly in my app though.

0 Karma
Highlighted

Re: Unable to dynamically set "charting.data.count" in a splunkjs ChartView and have it re-render. What's wrong?

Path Finder

@niketnilay, I have tried to use it with and without brackets (I noticed you added the brackets to your comments). Note that in the documentation you point to, there's a special section for Javascript/HTML and it does not use the brackets. Either way, the code produces no result at all. BTW, I have used this syntax correctly before (to change a 'managerid' setting within a chart), so I do not think it is a problem with the syntax I am using, which is why my question as to what else could be wrong. Thanks.

0 Karma
Highlighted

Re: Unable to dynamically set "charting.data.count" in a splunkjs ChartView and have it re-render. What's wrong?

Legend

Small brackets are required for setting property. Also curly braces are required for comma separated values as in JSON. So I think both are required. If it was withing Splunk I would have easily tested the JS but your app is outside JS. Which might be difficult for me to reproduce. That's why I converted answer to comment. Do you want me to show in Splunk through JS? Also which even do you want to change the setting on render or something else?

0 Karma
Highlighted

Re: Unable to dynamically set "charting.data.count" in a splunkjs ChartView and have it re-render. What's wrong?

Path Finder

I've just updated the question to include more information that should answer your questions. Thanks.

0 Karma
Speak Up for Splunk Careers!

We want to better understand the impact Splunk experience and expertise has has on individuals' careers, and help highlight the growing demand for Splunk skills.