All Apps and Add-ons

Splunk Machine Learning Toolkit: How can I change visualization type programmatically in HTML converted dashboard?

chanfoli
Builder

Hello, I have a dashboard using some of the Visualizations from the Machine Learning Toolkit that I converted to HTML in order to do some interaction with the app's KV store. I would like to programatically change the visualization type under certain conditions.

Here is the div containing the viz:

 <div class="panel-element-row">
    <div id="element1" class="dashboard-element viz" style="width: 100%">
        <div class="panel-body"></div>
    </div>
 </div>

Here is the viz element in the JS:

var element1 = new VisualizationElement({
    "id": "element1",
    "type": "Splunk_ML_Toolkit.OutliersViz",
    "drilldown": "none",
    "trellis.enabled": "0",
    "resizable": true,
    "trellis.size": "medium",
    "trellis.scales.shared": "1",
    "refresh.display": "progressbar",
    "managerid": "search1",
    "el": $('#element1')
}, {tokens: true, tokenNamespace: "submitted"}).render();

If I try to set the type setting on element1 as follows it appears to change its assignment if I then get the type, but the visualization stays as an OutliersViz. I have tried calling render() and some other methods but none actually make it re-render as the desired type:

        else if (form_countTMethod == "TSF") {
            methodString = tsfSearch;
            element1.settings.set("type","Splunk_ML_Toolkit.ForecastViz");
            console.log("element type:",element1.settings.get("type"));
            element1.render();
        }
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 ...