Skip to content

Commit

Permalink
Update ECharts function
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-vl committed Mar 25, 2024
1 parent 8c409ed commit a5c26b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
13 changes: 8 additions & 5 deletions src/constants/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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 });
Expand All @@ -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)',
},
Expand Down Expand Up @@ -84,6 +84,9 @@ return {
series,
};`;

/**
* ECharts Initial Visual Function
*/
const VISUAL_EDITOR_CODE = `console.log(context);
return {
dataset: context.editor.dataset,
Expand Down

0 comments on commit a5c26b9

Please sign in to comment.