Skip to main content

ECharts Function

setOption(options) is the main Apache ECharts library function. This function is called to build any chart.

It has one mandatory parameter options which is a chart configuration in a JSON format.

setOptions Schema.
setOptions Schema.

Options

You specify the options in the Apache ECharts visualization panel in the Monaco Code editor located on the right-hand side.

setOptions Function.
setOptions Function.

This whole text area is a body of the function that you write for the execution. This function takes in many parameters from Grafana. See the complete list in the table below.

The only parameter that is passed from this function to the setOption() is options. See the return statement in the picture above.

Parameters

ParameterDescription
dataThe data object with a time range, series and request information.
echartsECharts library.
echartsInstanceInstance of the ECharts. See the example in the picture above.
ecStatA statistical and data mining tool for Apache ECharts.
eventBusThe eventBus to publish and subscribe to application events.
locationServiceThe locationService works with browser location and history.
notifyError(['Header', 'Error Message'])Display error notification.
notifySuccess(['Header', 'Message'])Display successful notification.
replaceVariablesThe replaceVariables() function to interpolate variables.
themeThe theme object.

To learn more about parameters, you can log them in the Browser Console.

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

Notifications

Success and Error notifications can be triggered on events handling.

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