Hi again folks,
We have no problem using the dynamic text panel with the Plotly
library, however after much effort, have been unable to make a working example with the Observable Plot
Library here: Observable Plot | The JavaScript library for exploratory data visualization
Has anyone achieved this? Then please let us have an example/solution.
Many thanks for any help!
E
The last attempt gave the error:
Plot is not defined
The following source was defined in scripts in the editor panel:
https://cdn.skypack.dev/@observablehq/plot@0.6
This js in the Javascript Editor:
const datas = [
{ x: 1, y: 5 },
{ x: 2, y: 7 },
{ x: 3, y: 3 },
{ x: 4, y: 8 },
{ x: 5, y: 6 }
];
const plot = Plot.plot({
marks: [
Plot.lineX(datas, { x: "x", y: "y", stroke: "steelblue" })
],
x: {
label: "X-axis"
},
y: {
label: "Y-axis"
},
width: 600,
height: 400
});
const plotDiv = document.getElementById("plot");
plotDiv.appendChild(plot);
Here is the full panel json:
{
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"fieldConfig": {
"defaults": {
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 12,
"w": 13,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"renderMode": "data",
"editors": [
"helpers",
"afterRender"
],
"externalStyles": [],
"externalScripts": [
{
"id": "bac9c920-66c8-450c-9492-3ad6e0365a06",
"url": "https://cdn.skypack.dev/@observablehq/plot@0.6"
}
],
"editor": {
"language": "html",
"format": "auto",
"height": 254
},
"wrap": true,
"content": "<!DOCTYPE html>\n<html>\n\n <h1>Observable Plot Example</h1>\n <div id=\"plot\"></div>\n\n</html>",
"defaultContent": "The query didn't return any results. Sorrry!",
"helpers": "const datas = [\n { x: 1, y: 5 },\n { x: 2, y: 7 },\n { x: 3, y: 3 },\n { x: 4, y: 8 },\n { x: 5, y: 6 }\n];\n\nconst plot = Plot.plot({\n marks: [\n Plot.lineX(datas, { x: \"x\", y: \"y\", stroke: \"steelblue\" })\n ],\n x: {\n label: \"X-axis\"\n },\n y: {\n label: \"Y-axis\"\n },\n width: 600,\n height: 400\n});\n\nconst plotDiv = document.getElementById(\"plot\");\nplotDiv.appendChild(plot);",
"afterRender": "const datas = [\n { x: 1, y: 5 },\n { x: 2, y: 7 },\n { x: 3, y: 3 },\n { x: 4, y: 8 },\n { x: 5, y: 6 }\n];\n\nconst plot = Plot.plot({\n marks: [\n Plot.lineX(datas, { x: \"x\", y: \"y\", stroke: \"steelblue\" })\n ],\n x: {\n label: \"X-axis\"\n },\n y: {\n label: \"Y-axis\"\n },\n width: 600,\n height: 400\n});\n\nconst plotDiv = document.getElementById(\"plot\");\nplotDiv.appendChild(plot);",
"styles": "",
"status": "A-series"
},
"pluginVersion": "4.5.0",
"targets": [
{
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"queryType": "randomWalk",
"refId": "A"
}
],
"title": "all in one Plot ATTEMPT",
"type": "marcusolsson-dynamictext-panel",
"description": ""
}