Alpine with Echarts #1953
-
|
I cannot determine the error. But it does not allow the correct functioning of the echarts graph. When you interact with the legend it gives an error. However when using vanilla js it works fine. Here are other examples: Alpine-with-echarts-1 Any ideas I appreciate. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
|
You could change it to something like this: init() {
window.echart = echarts.init(this.$el);
window.echart.setOption(this.option);
} |
Beta Was this translation helpful? Give feedback.
-
|
You can also define a variable outside the reactive part (so it's still encapsulated in your component and it won't conflict if you have multiple graphs on the same page) import * as echarts from "echarts";
import Alpine from "alpinejs";
window.Alpine = Alpine;
Alpine.data("echart", () => {
let echart;
{
option: {
...
},
init() {
echart = echarts.init(this.$el);
echart.setOption(this.option);
}
}
);
Alpine.start(); |
Beta Was this translation helpful? Give feedback.


You could change it to something like this: