All docs
V19.2
19.2
19.1
18.2
18.1
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
17.1
The page you are viewing does not exist in version 17.1. This link will take you to the root page.
16.2
The page you are viewing does not exist in version 16.2. This link will take you to the root page.

Get a Widget Instance

Use the following code to get a widget instance:

JavaScript
var chartInstance = $("#chartContainer").dxChart("instance");

If the widget is not yet instantiated, this code throws an E0009 exception that you can handle with a try...catch block:

JavaScript
try {
    var chartInstance = $("#chartContainer").dxChart("instance");
}
catch (err) {
    alert("Exception handled: " + err.message);
}

Instead of the exception, you can get a truthy or falsy value that can be used in conditional statements. To do this, call the widget class's static getInstance(element) method. This method returns undefined if the widget is not instantiated for the element:

JavaScript
var element = document.getElementById("chartContainer");
var chartInstance = DevExpress.viz.dxChart.getInstance(element);
if (chartInstance) {
    // Your code goes here
}
See Also