我是靠谱客的博主 跳跃猫咪,这篇文章主要介绍vue图表组件使用,组件文档echarts,现在分享给大家,希望可以做个参考。

复制代码
1
2

vue图表组件使用,组件文档echarts

复制代码
1
2
http://echarts.baidu.com/echarts2/doc/example.html
复制代码
1
vue组件手动封装barChart.vue
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template> <div :class="className" :id="id" :style="{height:height,width:width}"></div> </template> <script> import echarts from 'echarts'; require('echarts/theme/macarons') export default { props: { className: { type: String, default: 'chart' }, id: { type: String, default: 'chart' }, width: { type: String, default: '200px' }, height: { type: String, default: '200px' } }, data() { return { chart: null }; }, mounted() { /*this.initChart();*/ this.chart = null; }, methods: { initChart(monthdata, seriesVoList, yeardata) { this.chart = echarts.init(document.getElementById(this.id)); this.chart.setOption( {     title: {         text: '2010-2013年中国城镇居民家庭人均消费构成(元)',         subtext: '数据来自国家统计局',         sublink: 'http://data.stats.gov.cn/search/keywordlist2?keyword=%E5%9F%8E%E9%95%87%E5%B1%85%E6%B0%91%E6%B6%88%E8%B4%B9'     },     tooltip: {         trigger: 'axis',         backgroundColor: 'rgba(255,255,255,0.7)',         axisPointer: {             type: 'shadow'         },             },     legend: {         x: 'right',         data:['2010','2011','2012','2013']     },     toolbox: {         show: true,         orient: 'vertical',         y: 'center',         feature: {             mark: {show: true},             dataView: {show: true, readOnly: false},             restore: {show: true},             saveAsImage: {show: true}         }     },     calculable: true,     grid: {         y: 80,         y2: 40,         x2: 40     },     xAxis: [         {             type: 'category',             data: ['食品', '衣着', '居住', '家庭设备及用品', '医疗保健', '交通和通信', '文教娱乐服务', '其他']         }     ],     yAxis: [         {             type: 'value'         }     ],     series: [         {             name: '2010',             type: 'bar',             data: [4804.7,1444.3,1332.1,908,871.8,1983.7,1627.6,499.2]         },         {             name: '2011',             type: 'bar',             data: [5506.3,1674.7,1405,1023.2,969,2149.7,1851.7,581.3]         },         {             name: '2012',             type: 'bar',             data: [6040.9,1823.4,1484.3,1116.1,1063.7,2455.5,2033.5,657.1]         },         {             name: '2013',             type: 'bar',             data: [6311.9,1902,1745.1,1215.1,1118.3,2736.9,2294,699.4]         }     ]}) } } } </script>
复制代码
1
vue页面引用组件,及调用方式:
复制代码
1
this.$refs.onclick.initChart(monthdata,seriesVoList,yeardata);

复制代码
1
2
3
<template> <div class="components-container" style='height:100vh'>
复制代码
1
2
3
<div class='chart-container'> <chart ref="onclick" height='100%' width='100%'></chart> </div>
复制代码
1
</div>
</ template > < script > import Chart from 'components/Charts/barChart'; export default { components: { Chart },
复制代码
1
复制代码
1
methods: {
复制代码
1
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
getstoreStatistics() { this.dialogauditorFormVisible = true; this.statisticsQuery.productId = this.productobj.productId; this.statisticsQuery.collectinCode = this.productobj.downSuperiorCode; this.statisticsQuery.year = (new Date().toISOString().slice(0,4)); storeStatistics(this.statisticsQuery).then(response => { if (response.data != null && response.data.status == 0) { /*console.log(response);*/ let monthdata = response.data.data.monthdata; let seriesVoList = response.data.data.seriesVoList; let yeardata = response.data.data.yeardata; this.$refs.onclick.initChart(monthdata,seriesVoList,yeardata); } else { this.$message({ message: '获取信息失败' }); } }); },
}
复制代码
1
2
3
4
5
6
7
8
9
10
</script> <style scoped> .chart-container{ position: relative; width: 100%; height: 90%; padding-bottom: 40px; } </style>


最后

以上就是跳跃猫咪最近收集整理的关于vue图表组件使用,组件文档echarts的全部内容,更多相关vue图表组件使用内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部