mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-08-15 11:55:49 +08:00
add async demo
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1><a href="https://github.com/Justineo/vue-echarts">Vue-ECharts</a></h1>
|
<h1><a href="https://github.com/Justineo/vue-echarts">Vue-ECharts</a></h1>
|
||||||
<chart :options="polar"></chart>
|
<chart :options="polar"></chart>
|
||||||
|
<chart :options="bar" v-ref:bar></chart>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -26,19 +27,24 @@ h1 {
|
|||||||
|
|
||||||
body .echarts {
|
body .echarts {
|
||||||
height: 300px;
|
height: 300px;
|
||||||
margin: 0 auto;
|
margin: 0 auto 5em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
let asyncData = {
|
||||||
|
categories: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"],
|
||||||
|
data: [5, 20, 36, 10, 10, 20]
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: function () {
|
data: function () {
|
||||||
var data = [];
|
let data = []
|
||||||
|
|
||||||
for (var i = 0; i <= 360; i++) {
|
for (let i = 0; i <= 360; i++) {
|
||||||
var t = i / 180 * Math.PI;
|
let t = i / 180 * Math.PI
|
||||||
var r = Math.sin(2 * t) * Math.cos(2 * t);
|
let r = Math.sin(2 * t) * Math.cos(2 * t)
|
||||||
data.push([r, i]);
|
data.push([r, i])
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -75,12 +81,43 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
animationDuration: 2000
|
animationDuration: 2000
|
||||||
|
},
|
||||||
|
|
||||||
|
bar: {
|
||||||
|
title: {
|
||||||
|
text: '异步数据加载示例'
|
||||||
|
},
|
||||||
|
tooltip: {},
|
||||||
|
legend: {
|
||||||
|
data:['销量']
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
data: []
|
||||||
|
},
|
||||||
|
yAxis: {},
|
||||||
|
series: [{
|
||||||
|
name: '销量',
|
||||||
|
type: 'bar',
|
||||||
|
data: []
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
},
|
},
|
||||||
ready: function () {
|
ready: function () {
|
||||||
|
// simulating async data from server
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.bar.mergeOptions({
|
||||||
|
xAxis: {
|
||||||
|
data: asyncData.categories
|
||||||
|
},
|
||||||
|
series: [{
|
||||||
|
name: '销量',
|
||||||
|
data: asyncData.data
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}, 3000)
|
||||||
},
|
},
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user