All Apps and Add-ons

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


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>

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;
            console.log("element type:",element1.settings.get("type"));
0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud | Customer Survey!

If you use Splunk Observability Cloud, we invite you to share your valuable insights with us through a brief ...

Happy CX Day, Splunk Community!

Happy CX Day, Splunk Community! CX stands for Customer Experience, and today, October 3rd, is CX Day — a ...

.conf23 | Get Your Cybersecurity Defense Analyst Certification in Vegas

We’re excited to announce a new Splunk certification exam being released at .conf23! If you’re going to Las ...