Not able to load data from datasource while using apache echarts

while trying some graph from apache echarts I wanted to take the query data to the charts but I wasn’t able to pass that data
I got the error this

even though my code looks correct enough


const pieData = data.series.map((s) => {
const models =
s.fields.find((f) => f.name === “Model”).values.buffer ||
s.fields.find((f) => f.name === “Model”).values;
const values =
s.fields.find((f) => f.name === “Value”).values.buffer ||
s.fields.find((f) => f.name === “Value”).values;

return values.map((d, i) => {
return { name: models[i], value: d };
});
})[0];


and even I try to find in some videos they told that dataframe json will be a json
but mine is an array

please someone help me out with this

Removed the duplicates
Now can you please help with the answer

For starters before using data.series in your code do the following

console.log(data) and check output in your web browser console tab. What do you see there

this is what i got

now try console.log(context) there has been breaking changes in a lot of the volkov lab plugins

see for an example here

https://echarts.volkovlabs.io/d/0b5-q7K4k/pie?orgId=1&editPanel=4&showCategory=Visual%20Editor

as you can see below screen shot, the new version allows you to specify the value data point and the metric data point

yes yes ThankYou So much It worked.
Thank You very much.
Although I have one more question this context.editor.dataset.source thing worked on monaco editor within paenel
but it didn’t gave out anything when I did console.log(context) instead shown error

so is there any way that if some point I want to check what data is being passed through it or what type. so I can just console it.

1 Like

we cant see your whole code remotely so not sure where you have it. This is really more basic javascript than grafana

1 Like