vue图表组件使用,组件文档echarts
2018-03-07 14:47
766 查看
vue图表组件使用,组件文档echartshttp://echarts.baidu.com/echarts2/doc/example.html
vue组件手动封装barChart.vue
<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>
vue页面引用组件,及调用方式:
this.$refs.onclick.initChart(monthdata,seriesVoList,yeardata);<template><div class="components-container" style='height:100vh'>
<div class='chart-container'><chart ref="onclick" height='100%' width='100%'></chart></div>
</div></template><script> import Chart from 'components/Charts/barChart'; export default { components: { Chart },
methods: {
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: '获取信息失败'});}});},}
</script><style scoped>.chart-container{position: relative;width: 100%;height: 90%;padding-bottom: 40px;}</style>
相关文章推荐
- 使用Vue开发动态刷新Echarts组件的教程详解
- 在vue中添加Echarts图表的基本使用教程
- Vue 爬坑之路(八)—— 使用 Echarts 创建图表
- vue中vue-schart(图表组件)的使用
- vue.js如何将echarts封装为组件一键使用详解
- QT5中使用Echarts图表组件
- 如何在vue脚手架里面使用echarts 组件显示中国地图---亲测
- 在vue中使用echarts图表
- 在vue中使用echarts图表实例代码详解
- Echarts图表库。饼图 pie 图表组件的使用。饼图组件API使用规则--DOME
- 详解windows下vue-cli及webpack 构建网站(三)使用组件
- 百度Echarts图表JS插件的使用
- vue项目优化之按需加载组件-使用webpack require.ensure
- asp.net使用echarts展示图表数据
- vue组件的使用
- 转:ECharts图表组件之简单关系图:如何轻松实现另类站点地图且扩展节点属性实现点击节点页面跳转
- vue项目中Echarts的使用
- 使用Flex图表组件