you will not report an error when you just enter this page, but you will only report an error if you reduce the size of the page.
has successfully introduced jquery
you will not report an error when you just enter this page, but you will only report an error if you reduce the size of the page.
has successfully introduced jquery
the current this is pointing incorrectly. The current this points to the inside of the monitor. You should use the outside pointer after let _ this=this;.
this points to
for reference only
<template>
<div :class="className" :style="{height:height,width:width}"></div>
</template>
<script>
import echarts from "echarts";
import { debounce } from "@/utils";
export default {
props: {
className: {
type: String,
default: "chart"
},
width: {
type: String,
default: "100%"
},
height: {
type: String,
default: "280px"
},
//
legendData: {
type: Array
},
//
series: {
type: Array
},
//
title: {
type: String,
default: ""
}
},
data() {
return {
chart: null
};
},
watch: {
//
title(val) {
this.reDraw();
},
//
series(val) {
this.reDraw();
},
//
legendData(val) {
this.reDraw();
}
},
mounted() {
this.initChart();
this.__resizeHanlder = debounce(() => {
if (this.chart) {
this.chart.resize();
}
}, 100);
window.addEventListener("resize", this.__resizeHanlder);
},
beforeDestroy() {
if (!this.chart) {
return;
}
window.removeEventListener("resize", this.__resizeHanlder);
this.chart.dispose();
this.chart = null;
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, "macarons");
this.chart.setOption({
title: {
text: this.title,
left: "center",
bottom: 0,
textStyle: {
color: "black",
fontSize: 14
}
},
labelLine: {
normal: {
smooth: 0.2,
length: 0,
length2: 0
}
},
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
left: "center",
bottom: 40,
textStyle: {
color: "-sharp999",
fontSize: 12
},
data: this.legendData
},
calculable: true,
series: this.series
});
},
//
reDraw() {
if (!this.chart) {
return;
}
window.removeEventListener("resize", this.__resizeHanlder);
this.chart.dispose();
this.chart = null;
this.initChart();
}
}
};
</script>
<style lang="scss" scoped>
</style>
export function debounce(func, wait, immediate) {
let timeout, args, context, timestamp, result
const later = function () {
//
const last = +new Date() - timestamp
// lastwait
if (last < wait && last > 0) {
timeout = setTimeout(later, wait - last)
} else {
timeout = null
// immediate===true
if (!immediate) {
result = func.apply(context, args)
if (!timeout) context = args = null
}
}
}
callback function uses arrow function,
window.addEventListen("resize", () => {
this.chart.resize();
})
just can t show it. Thank you very much for your advice. ...
The problem with is that when the data is not obtained asynchronously, its color can be displayed normally. Part of the code and effect are as follows: setOptions({ expectedData, actualData } = {}) { this.chart.setOption({ tooltip: { ...
The echarts bar chart can be displayed in vue, so what should I do now to add a click event to each column to pass the data to the new page? how to introduce echarts config files? ...
simplify the official website demo, and as a result, the map only shows the South China Sea islands and each point. official website Demo the Vue code is as follows: drawMap () { let data = [ {name: , value: 9}, {name: , valu...
echart version: 3.8.5 problem: use the echart plug-in echarts-liquidfill to report an error in the vue component. I also reported an error in import in the same way as https: codeshelper.com q 10.. ...
cannot be rendered using echarts in vue <template> <div id="app" class="login_area"> <div id="myChart" class="echarts">< div> < div> < template> <script> expor...
insert an echarts china-map, into a floating div with a width of 50%. Please tell me how to make it adaptive. < div id= "myChart " style= "float: left;width: 50%; " > < div > mounted () { this.drawLine(); }, methods: { dr...
how vue-echarts-v3 initializes the map, gets the map object and generates a click event, knows which province the user clicks on, and finally completes the drill down. Because all the examples found on the Internet are from echart, no vue-echarts-v3, has...
the data of echarts is obtained through the background interface. I called the interface in created and initialized the chart in mounted. The result of the fan chart came out, but the legend legend on the right did not come out. The data I printed in mo...
index.js introduces echart echart the console mistakenly reported that graphic is not defined. May I ask what went wrong ? ...
I am a chart project developed by vue scaffolding, and now I need to change the position separately because the label and Abscissa of the column chart overlap. ask the boss for an answer. as shown in the figure, the first two histograms are normal...
how can this kind of graph be dynamically assigned through ajax? ...
optionmounted when I click the button to get the data in methods, how can I assign a value to data in legend and series? Can only put the option code in the ajax request? ...
< div: id= "id " > < div > < template > < script > import echarts from echarts export default { data () { return { charts: } }, props:["id","opinion","opinionData"],...
problem description A novice asks for advice. Echarts is used as a line chart in Vue. The data is transmitted from the background Ajax, but the data is not displayed at all. How is this going on? the environmental background of the problems and what...
because every chart is the same, you want to use v-for to loop the echart chart Code of the loop <el-col :span="6" v-for="(item,index) of items" :key="item.id"> <div class="body"> <d...
specific requirements are as follows: (data space-time in option when mounting, and filling in during initialization) : : echarts " " " " , :<section id="myChart">< section> ...
when Vue uses Echarts, the map does not show. Could you tell me how to quote bmap? ? <template> <div id="HotSpot">< div> < template> <script> export default { name: HotSpot , data(){ ...
A simple line chart is used in the project, I intend to implement it in echars. After the introduction, the project size has reached more than 3m. In order to reduce the project size, I intend to load the line chart on demand import echarts from &q...
problem description the environmental background of the problems and what methods you have tried < template > < div: class= "className ": id= "id ": style= "{height:height,width:width} " > < div > < template > < script > import echarts f...