From c03e6f96d969a41a1465fb099ad7ea2a70ceff4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rund=20Martinsen?= Date: Mon, 13 Sep 2021 16:17:29 +0200 Subject: [PATCH] Added annotation support --- src/module.ts | 146 +++++++++++++++++++++++++------------------------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/src/module.ts b/src/module.ts index 7855446..9d5b5dd 100644 --- a/src/module.ts +++ b/src/module.ts @@ -8,76 +8,78 @@ import 'utils'; import { SimplePanel } from './SimplePanel'; import { PanelOptionCode } from './PanelOptionCode'; -export const plugin = new PanelPlugin(SimplePanel).setPanelOptions((builder) => { - return builder - .addCustomEditor({ - id: 'data', - path: 'data', - name: 'Data', - description: 'Data of the chart', - editor: PanelOptionCode, - category: ['Plotly'], - settings: { - language: 'json', - initValue: defaults.data, - }, - defaultValue: null, //defaults.data, - }) - .addCustomEditor({ - id: 'layout', - path: 'layout', - name: 'Layout', - description: 'Layout of the chart', - editor: PanelOptionCode, - category: ['Plotly'], - settings: { - language: 'json', - initValue: defaults.layout, - }, - defaultValue: null, //defaults.layout, - }) - .addCustomEditor({ - id: 'config', - path: 'config', - name: 'Configuration', - description: 'Configuration of the chart', - editor: PanelOptionCode, - category: ['Plotly'], - settings: { - language: 'json', - initValue: defaults.config, - }, - defaultValue: null, //defaults.config, - }) - .addCustomEditor({ - id: 'script', - path: 'script', - name: 'Script', - description: ` - Script executed whenever new data is available. +export const plugin = new PanelPlugin(SimplePanel) + .setDataSupport({ annotations: true }) + .setPanelOptions((builder) => { + return builder + .addCustomEditor({ + id: 'data', + path: 'data', + name: 'Data', + description: 'Data of the chart', + editor: PanelOptionCode, + category: ['Plotly'], + settings: { + language: 'json', + initValue: defaults.data, + }, + defaultValue: null, //defaults.data, + }) + .addCustomEditor({ + id: 'layout', + path: 'layout', + name: 'Layout', + description: 'Layout of the chart', + editor: PanelOptionCode, + category: ['Plotly'], + settings: { + language: 'json', + initValue: defaults.layout, + }, + defaultValue: null, //defaults.layout, + }) + .addCustomEditor({ + id: 'config', + path: 'config', + name: 'Configuration', + description: 'Configuration of the chart', + editor: PanelOptionCode, + category: ['Plotly'], + settings: { + language: 'json', + initValue: defaults.config, + }, + defaultValue: null, //defaults.config, + }) + .addCustomEditor({ + id: 'script', + path: 'script', + name: 'Script', + description: ` + Script executed whenever new data is available. - Must return an object with one or more of the following properties : data, layout, config - f(data, variables){...your code...} - `, - editor: PanelOptionCode, - category: ['Script'], - settings: { - language: 'javascript', - }, - defaultValue: defaults.script, - }) - .addCustomEditor({ - id: 'onclick', - path: 'onclick', - name: 'Click script', - description: ` - Script executed when chart is clicked. - f(data){...your code...}`, - editor: PanelOptionCode, - category: ['Click script'], - settings: { - language: 'javascript', - }, - defaultValue: defaults.onclick, - }); -}); + Must return an object with one or more of the following properties : data, layout, config + f(data, variables){...your code...} + `, + editor: PanelOptionCode, + category: ['Script'], + settings: { + language: 'javascript', + }, + defaultValue: defaults.script, + }) + .addCustomEditor({ + id: 'onclick', + path: 'onclick', + name: 'Click script', + description: ` + Script executed when chart is clicked. + f(data){...your code...}`, + editor: PanelOptionCode, + category: ['Click script'], + settings: { + language: 'javascript', + }, + defaultValue: defaults.onclick, + }); + });