how can this kind of graph be dynamically assigned through ajax?
how can this kind of graph be dynamically assigned through ajax?
you can write option in computed, and variables in option can be written in method or watch. If you change the variables, eCharts will render again
.the following is a piece of my own code:
option: in computed
computed: {
option () {
return {
legend: {
show: true,
bottom: 'bottom',
data: this.typeStr
},
grid: { //
left: '4%',
right: '4%',
containLabel: true
},
tooltip: {
trigger: 'axis'
},
xAxis: {
data: this.localDateStrAxis,
type: 'category',
min: 'datamin',
boundaryGap: true, // x
axisLine: {
lineStyle: {
color: '-sharpf0f0f0'
}
},
axisTick: {
lineStyle: {
color: '-sharpf0f0f0'
}
},
axisLabel: {
color: '-sharp5b5d61'
}
},
yAxis: this.yAxis,
series: this.series
}
}
}
contents of watch:
watch: {
// eCharts
localValueAxis: {
handler: function (n, o) {
this.series = []
this.yAxis = []
for (let i = 0; i < n.length; iPP) {
this.series.push({
name: this.typeStr[i],
type: 'line',
data: n[i],
yAxisIndex: i,
areaStyle: { opacity: 0.3 }
})
this.yAxis.push({
name: this.typeStr[i],
type: 'value',
axisLine: {
show: false
},
axisLabel: {
color: '-sharp787a7d'
},
axisTick: {
show: false
},
splitNumber: 3,
splitLine: {
show: true
}
})
}
},
deep: true
}
}
Don't worry too much about the specific code in watch. The logic is: when the value of localValueAxis changes, I ask eCharts's yAxis, series, and so on to re-assign values, and vue will naturally re-render eCharts. I hope it can help the subject.
ajax dynamic assignment echarts (pie chart and bar chart)
I want to know how the shipment volume in the middle of the ring chart is set up on the landlord's chart. I still don't know how to do it after seeing api.
Previous: Regular: how to match content after 2 decimal places
Next: A JAVA interview question, I don't quite understand about int and Integer,String and StringBuffer,.
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...
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? ...
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 ...
< 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...