Skip to main content

ECharts Function

setOption(options) is the main function from the Apache ECharts library. You need to call this function to build any chart with Apache ECharts Panel.

This function has the only required options parameter that you can use to specify the chart configuration in the JSON format.

Apache ECharts Panel uses the Apache ECharts library and specified parameters to generate charts.
Apache ECharts Panel uses the Apache ECharts library and specified parameters to generate charts.

Options

You need to specify the options parameter in the Monaco Code editor in the right part of the screen where the Apache ECharts panel resides.

Apache ECharts Panel provides the code editor to specify ECharts functions.
Apache ECharts Panel provides the code editor to specify ECharts functions.

In the Function text area, you can specify the function for chart generation. This function can take different parameters from Grafana. You can find the full list of parameters in the following table.

The options parameter is the only parameter that is passed from this function to the setOption() function. In the screenshot above, see the return statement that specifies the look of the chart.

Parameters

ParameterDescription
dataObject containing a time range, series, and request information.
echartsECharts library.
echartsInstanceInstance of the ECharts library. See the example in the screenshot above.
ecStatA statistical and data mining tool for Apache ECharts.
eventBusPublish and subscribe to application events.
locationServiceWorks with browser location and history.
notifyError(['Header', 'Error Message'])Display error notifications.
notifySuccess(['Header', 'Message'])Display success notifications.
replaceVariablesFunction to interpolate variables.
themeTheme object.

To inspect the used parameters, use the browser's developer console.

console.error(
data,
theme,
echartsInstance,
echarts,
replaceVariables,
locationService
);

Notifications

You can display success and error notifications when handling specific events.

notifySuccess(["Update", "Values updated successfully."]);
notifyError(["Update", `An error occurred while updating values.`]);