Echarts基本使用
2020-06-07 04:30
288 查看
需要axios,echarts
<template> <div class='home'> <div id='myChart' :style="{width: '100%', height: '600px'}"></div> </div> </template> <script> export default { name: 'Home', components: {}, data () { return {} }, mounted () { this.go() }, methods: { go () { // 基于准备好的dom,初始化echarts实例 const myChart = this.$echarts.init(document.getElementById('myChart')) // 绘制图表 myChart.setOption({ title: {}, tooltip: {}, xAxis: { data: [] }, yAxis: {}, series: [{ name: '数量', type: 'bar', data: [] }] }) myChart.showLoading() this.$axios({ method: 'get', url: 'http://192.168.18.200:8080/data' }).then(res => { const { result } = res.data const x = [] const y = [] delete result.all for (const key in result) { x.push(key) y.push(result[key]) } myChart.hideLoading() myChart.setOption({ title: { text: '各大网站访问数量' }, tooltip: {}, xAxis: { name: '网站', data: [...x] }, yAxis: { name: '数量' }, series: [{ type: 'bar', data: [...y] }] }) }) } } } </script>
相关文章推荐
- echarts 基本使用
- echarts基本使用
- echarts(3.0)的基本使用(标签式导入)
- ECharts基本使用
- echarts基本使用
- 关于ECharts框架的基本使用
- 使用echarts的vue项目第一天,引用框架构建基本模板(适合没接触过的echarts的新手)
- echarts基本使用
- echarts基本使用 (包括在vue中使用echarts)
- 关于echarts的基本使用
- echarts 基本使用
- echarts 基本使用
- ECHARTS的基本使用:柱状图、折线图、饼图等
- Echarts柱状图与折线图的基本使用
- 在vue中添加Echarts图表的基本使用教程
- ECharts框架的基本使用
- echarts 基本使用
- echarts基本使用
- vue+echarts基本图形使用
- vue中使用echarts图表自适应的几种基本解决方案