From a5c26b9f1e0d5a48f7a5c2e269373a803b18a983 Mon Sep 17 00:00:00 2001 From: Mikhail Volkov Date: Sun, 24 Mar 2024 21:50:44 -0400 Subject: [PATCH] Update ECharts function --- CHANGELOG.md | 18 +++++++++++++++++- src/constants/default.ts | 13 ++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 540a6b5..005f2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,32 @@ # Change Log -## 6.0.0 (2024-03-22) +## 6.0.0 (2024-03-24) ### Breaking changes - Requires Grafana 10 and Grafana 11 +- Removed non-context code parameters. Please update parameters to use `context` in the Function. + +### Code parameters migration guide + +- data -> context.panel.data +- theme -> context.grafana.theme +- chart -> context.panel.chart +- echarts -> context.echarts +- ecStat -> context.ecStat +- replaceVariables -> context.grafana.replaceVariables +- eventBus -> context.grafana.eventBus +- locationService -> context.grafana.locationService +- notifySuccess -> context.grafana.notifySuccess +- notifyError -> context.grafana.notifyError ### Features / Enhancements - Updated name to Business Charts Panel (#268) - Added Apache Acknowledgment and update description (#268) - Updated to Grafana 10.4.1 (#270) +- Removed ArrayVector deprecated in Grafana 11 (#272) +- Updated Apache ECharts deprecation warnings (#272) ## 5.3.0 (2024-03-06) diff --git a/src/constants/default.ts b/src/constants/default.ts index 54b96b7..085245e 100644 --- a/src/constants/default.ts +++ b/src/constants/default.ts @@ -4,9 +4,9 @@ import { Format } from './editor'; import { Map } from './maps'; /** - * ECharts Example + * ECharts Initial Code Function */ -const GET_OPTION = `const series = data.series.map((s) => { +const GET_OPTION = `const series = context.panel.data.series.map((s) => { const sData = s.fields.find((f) => f.type === 'number').values.buffer || s.fields.find((f) => f.type === 'number').values; const sTime = s.fields.find((f) => f.type === 'time').values.buffer || s.fields.find((f) => f.type === 'time').values; @@ -27,7 +27,7 @@ const GET_OPTION = `const series = data.series.map((s) => { /** * Enable Data Zoom by default */ -setTimeout(() => echartsInstance.dispatchAction({ +setTimeout(() => context.panel.chart.dispatchAction({ type: 'takeGlobalCursor', key: 'dataZoomSelect', dataZoomSelectActive: true, @@ -36,7 +36,7 @@ setTimeout(() => echartsInstance.dispatchAction({ /** * Update Time Range on Zoom */ -echartsInstance.on('datazoom', function (params) { +context.panel.chart.on('datazoom', function (params) { const startValue = params.batch[0]?.startValue; const endValue = params.batch[0]?.endValue; locationService.partial({ from: startValue, to: endValue }); @@ -50,7 +50,7 @@ return { legend: { left: '0', bottom: '0', - data: data.series.map((s) => s.refId), + data: context.panel.data.series.map((s) => s.refId), textStyle: { color: 'rgba(128, 128, 128, .9)', }, @@ -84,6 +84,9 @@ return { series, };`; +/** + * ECharts Initial Visual Function + */ const VISUAL_EDITOR_CODE = `console.log(context); return { dataset: context.editor.dataset,