From 88bec4e8137785041bd9cb0e5936302188ec7dec Mon Sep 17 00:00:00 2001 From: Vitali Pinchuk Date: Fri, 9 Feb 2024 15:28:20 +0300 Subject: [PATCH] fix - added panel --- echarts.volkovlabs.io/home.json | 49 ++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/echarts.volkovlabs.io/home.json b/echarts.volkovlabs.io/home.json index 24afd3a..380311b 100644 --- a/echarts.volkovlabs.io/home.json +++ b/echarts.volkovlabs.io/home.json @@ -141,12 +141,12 @@ "format": "auto", "height": 600 }, - "editorMode": "code", + "editorMode": "visual", "gaode": { "key": "", "plugin": "AMap.Scale,AMap.ToolBar" }, - "getOption": "echartsInstance.on('click', (params) => {\n locationService.replace('/d/E9NLNnFVz/bar?orgId=1');\n});\n\nconst labelRight = {\n position: 'right'\n};\n\nreturn {\n grid: {\n bottom: \"3%\",\n containLabel: true,\n left: \"3%\",\n right: \"4%\",\n top: \"4%\",\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n type: 'shadow'\n }\n },\n xAxis: {\n type: 'value',\n position: 'top',\n splitLine: {\n lineStyle: {\n type: 'dashed'\n }\n }\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisLabel: { show: false },\n axisTick: { show: false },\n splitLine: { show: false },\n data: [\n 'ten',\n 'nine',\n 'eight',\n 'seven',\n 'six',\n 'five',\n 'four',\n 'three',\n 'two',\n 'one'\n ]\n },\n series: [\n {\n name: 'Cost',\n type: 'bar',\n stack: 'Total',\n label: {\n show: true,\n formatter: '{b}'\n },\n data: [\n { value: -0.07, label: labelRight },\n { value: -0.09, label: labelRight },\n 0.2,\n 0.44,\n { value: -0.23, label: labelRight },\n 0.08,\n { value: -0.17, label: labelRight },\n 0.47,\n { value: -0.36, label: labelRight },\n 0.18\n ]\n }\n ],\n graphic: [\n {\n type: 'group',\n rotation: Math.PI / 4,\n bounding: 'raw',\n right: 110,\n bottom: 110,\n z: 100,\n children: [\n {\n type: 'rect',\n left: 'center',\n top: 'center',\n z: 100,\n shape: {\n width: 400,\n height: 50\n },\n style: {\n fill: 'rgba(0,0,0,0.3)'\n }\n },\n {\n type: 'text',\n left: 'center',\n top: 'center',\n z: 100,\n style: {\n fill: '#fff',\n text: 'CLICK FOR MORE',\n font: 'bold 26px sans-serif'\n }\n }\n ]\n }]\n};", + "getOption": "echartsInstance.on('click', (params) => {\n locationService.replace('/d/E9NLNnFVz/bar?orgId=1');\n});\nlet values = data.series[0].fields.find(f => f.name === 'Value').values\nlet labels = data.series[0].fields.find(f => f.name === 'Label').values\n\nconst labelRight = {\n position: 'right'\n};\n\nreturn {\n grid: {\n bottom: \"3%\",\n containLabel: true,\n left: \"3%\",\n right: \"4%\",\n top: \"4%\",\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n type: 'shadow'\n }\n },\n xAxis: {\n type: 'value',\n position: 'top',\n splitLine: {\n lineStyle: {\n type: 'dashed'\n }\n }\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisLabel: { show: false },\n axisTick: { show: false },\n splitLine: { show: false },\n data: labels\n },\n series: [\n {\n name: 'Cost',\n type: 'bar',\n stack: 'Total',\n label: {\n show: true,\n formatter: '{b}'\n },\n data: values\n }\n ],\n graphic: [\n {\n type: 'group',\n rotation: Math.PI / 4,\n bounding: 'raw',\n right: 110,\n bottom: 110,\n z: 100,\n children: [\n {\n type: 'rect',\n left: 'center',\n top: 'center',\n z: 100,\n shape: {\n width: 400,\n height: 50\n },\n style: {\n fill: 'rgba(0,0,0,0.3)'\n }\n },\n {\n type: 'text',\n left: 'center',\n top: 'center',\n z: 100,\n style: {\n fill: '#fff',\n text: 'CLICK FOR MORE',\n font: 'bold 26px sans-serif'\n }\n }\n ]\n }]\n};", "google": { "callback": "gmapReady", "key": "" @@ -159,13 +159,54 @@ "name": "default" }, "visualEditor": { - "code": "console.log(context);\nreturn {\n dataset: context.editor.dataset,\n series: context.editor.series,\n xAxis: {\n type: 'time',\n },\n yAxis: {\n type: 'value',\n min: 'dataMin',\n },\n}\n", + "code": "const labelRight = {\n position: 'right'\n};\n\nreturn {\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n type: 'shadow'\n }\n },\n grid: {\n bottom: \"3%\",\n containLabel: true,\n left: \"3%\",\n right: \"4%\",\n top: \"4%\",\n },\n dataset: {\n source: context.editor.dataset.source\n },\n xAxis: {\n type: 'value',\n position: 'top',\n splitLine: {\n lineStyle: {\n type: 'dashed'\n }\n }\n },\n yAxis: {\n type: 'category',\n axisLine: { show: false },\n axisLabel: { show: false },\n axisTick: { show: false },\n splitLine: { show: false }\n },\n series: [\n {\n name: 'Cost',\n type: 'bar',\n stack: 'Total',\n label: {\n show: true,\n formatter: '{b}'\n },\n encode: {\n y: 'label',\n x: 'value'\n }\n }\n ],\n graphic: [\n {\n type: 'group',\n rotation: Math.PI / 4,\n bounding: 'raw',\n right: 110,\n bottom: 110,\n z: 100,\n children: [\n {\n type: 'rect',\n left: 'center',\n top: 'center',\n z: 100,\n shape: {\n width: 400,\n height: 50\n },\n style: {\n fill: 'rgba(0,0,0,0.3)'\n }\n },\n {\n type: 'text',\n left: 'center',\n top: 'center',\n z: 100,\n style: {\n fill: '#fff',\n text: 'CLICK FOR MORE',\n font: 'bold 26px sans-serif'\n }\n }\n ]\n }]\n};", "codeHeight": 600, - "dataset": [], + "dataset": [ + { + "name": "Value", + "source": "A" + }, + { + "name": "Label", + "source": "A" + } + ], "series": [] } }, "pluginVersion": "5.2.0", + "targets": [ + { + "datasource": { + "type": "marcusolsson-static-datasource", + "uid": "4ytGZmF4k" + }, + "frame": { + "fields": [ + { + "config": {}, + "name": "Value", + "type": "number", + "values": [0] + }, + { + "config": {}, + "name": "Label", + "type": "string", + "values": [""] + } + ], + "meta": { + "custom": { + "customCode": "const result = {\n ...frame,\n fields: frame.fields.map((field) => {\n if (field.name === 'Value') {\n return ({\n ...field,\n values: [-0.07, -0.09, 0.2, 0.44, -0.23, 0.08, -0.17, 0.47, -0.36, 0.18]\n })\n }\n return ({\n ...field,\n values: ['ten', 'nine', 'eight', 'seeven', 'six', 'five', 'four', 'three', 'two', 'one']\n })\n }\n )\n}\n\nreturn Promise.resolve(result);", + "valuesEditor": "custom" + } + }, + "name": "Bars" + }, + "refId": "A" + } + ], "title": "Bar", "type": "volkovlabs-echarts-panel" },