Vue中使用Echarts绘制柱状图
2018-08-07 11:29
399 查看
<template> <!-- 稽核日志界面 --> <div class="tile is-parent test "> <article class="tile is-child box"> <Card> <Row :gutter="16"> <Col span="12"> <div id="echartContainer" style="width:500px; height:300px " ></div> </Col> <Col span="12"> <div id="echartContainer2" style="width:500px; height:300px " ></div> </Col> </Row> </Card> <br/> <br/> <TableHead headName="稽核列表"></TableHead> <Table size="small" border :columns="columnsName" :data="dataList"></Table> <Row type="flex" justify="space-between"> <Col span="4"> </Col> <Col> </Col> </Row> </article> </div> </template> <script> import Vue from 'vue' import axios from 'axios' import TableHead from 'component/TableHead.vue' var echarts = require('echarts') export default { components: { TableHead }, mounted: function() { this.$Notice.config({ top: 150, duration: 3 }); this.query(); }, name: 'debug', data: function() { return { dataList:[], columnsName: [ { title: "序号", type: "index", fixed: 'left', width: 75, }, { title: "文件日期", key: 'fileDate', width: 130, }, { title: "入库文件数", key: 'filesCloud', width: 130 }, { title: "源文件数", key: 'filesBill', width: 130, }, { title: "入库条数", key: 'rowsCloud', width: 130, }, { title: "源文件总条数", key: 'rowsBill', width: 130, }, { title: "文件差值", key: 'fileDiff', width: 130, }, { title: "总行数差值", key: 'rowsDiff', width: 130, }, { title: "稽核时间", key: 'checkDate', width: 160, }, { title: "更新时间", key: 'updateDate', width: 160, }, ], } }, methods: { query: function() { let that = this that.loading=true; axios.get("CheckBillsController/queryCheckBills", { }) .then(function(res) { let charData =res.data.data; that.total = res.data.data.dataList.datasize; that.dataList=res.data.data.dataList; that.open(charData); }) .catch(function(err) { console.log(err) }) that.loading=false; }, open(charData) { let that=this //文件稽核 var myChartFile = echarts.init(document.getElementById('echartContainer')); //行数稽核 var myChartRows = echarts.init(document.getElementById('echartContainer2')); // 绘制文件稽核图表 myChartFile.setOption( { title: { text: "文件稽核" }, tooltip: { trigger: 'axis' }, axisPointer : { // 坐标轴指示器,坐标轴触发有效 type : 'shadow' // 默认为直线,可选为:'line' | 'shadow' }, //图形类目 legend: { data:['入库文件数','源文件数','源文件数差值'] }, //图形工具栏 toolbox: { show : true, feature : { magicType : {show: true, type: ['line', 'bar']}, } }, calculable : true, xAxis: { data: charData.time, axisLabel: { //设置x轴文字倾斜显示 interval:0, rotate:40 }, //设置x轴文字长度自动适应 grid: { left: '10%', bottom:'35%' } }, yAxis: { //坐标显示内容 axisLabel: { margin: 2, formatter: function (value, index) { if (value <= -10000000) { value = value / 100000000 + "亿"; } else if (value <= -10000 && value > -10000000) { value = value / 10000 + "万"; } else if (value >= 10000 && value < 10000000) { value = value / 10000 + "万"; } else if (value >= 10000000 && value < 100000000) { value = value / 10000000 + "千万"; } else if (value > 100000000 ) { value = value / 100000000 + "亿"; } return value; } } }, series: [ { name: '入库文件数', type: 'bar', data: charData.cloudFiles, //柱子颜色 itemStyle:{ normal: { color:'#4ad2ff' } }, }, { name: '源文件数', type: 'bar', data: charData.billFiles, itemStyle:{ normal: { color:'#9966ff' } }, }, { name: '源文件数差值', type: 'bar', data: charData.diffFiles, itemStyle: { normal: { color:'#434343' } }, } ] }); myChartRows.setOption( { title: { text: "总行数稽核" }, tooltip : { trigger: 'axis', }, axisPointer : { // 坐标轴指示器,坐标轴触发有效 type : 'shadow' // 默认为直线,可选为:'line' | 'shadow' }, legend: { data:['入库总行数','源文件总行数','总行数差值'] }, toolbox: { show : true, feature : { magicType : {show: true, type: ['line', 'bar']}, } }, calculable : true, xAxis: { data: charData.time, //设置x轴文字倾斜显示 axisLabel: { interval:0, rotate:40, }, //设置x轴文字长度自动适应 grid: { left: '10%', bottom:'35%' } }, yAxis: { type: 'value', // name: '营业额(元)', axisTick: { inside: true }, scale: true, axisLabel: { margin: 2, formatter: function (value, index) { if (value <= -10000000) { value = value / 100000000 + "亿"; } else if (value <= -10000 && value > -10000000) { value = value / 10000 + "万"; } else if (value >= 10000 && value < 10000000) { value = value / 10000 + "万"; } else if (value >= 10000000 && value < 100000000) { value = value / 10000000 + "千万"; } else if (value > 100000000 ) { value = value / 100000000 + "亿"; } return value; } } }, series: [ { name: '入库总行数', type: 'bar', data: charData.cloudRows, itemStyle:{ normal:{ color:'#19BE6B' } }, }, { name: '源文件总行数', type: 'bar', data: charData.billRows, itemStyle:{ normal:{ color:'#2D8CF0' } }, }, { name: '总行数差值', type: 'bar', data: charData.diffRows, itemStyle:{ normal:{ color:'#993300' } }, } ] } ); } } } </script>
效果图
相关文章推荐
- vue项目中使用Echarts 动态更改图表数据 , Vue 折线图、柱状图等图表动态刷新 ,
- 基于SpringMVC框架使用ECharts3.0实现折线图,柱状图,饼状图,的绘制(上篇)
- vue 中使用vue-echarts-v3编写chart柱状图,动态展示数据
- 基于SpringMVC框架使用ECharts3.0实现折线图,柱状图,饼状图,的绘制(上篇)
- 在Vue项目中使用Echarts(五): Echarts绘制地图
- 基于SpringMVC框架使用ECharts3.0实现折线图,柱状图,饼状图,的绘制(上篇)
- vue中使用echarts图表自适应的几种基本解决方案
- QT使用QCustomPlot 绘制柱状图
- 使用D3绘制图表(6)--竖直柱状图表
- 图形报表echarts的使用2--柱状图
- 使用ECharts绘制可视化图表
- vue.js如何将echarts封装为组件一键使用详解
- 使用jpgraph绘制柱状图
- 如何在vue中使用echarts
- 使用pandas中的DataFrame数据绘制柱状图的方法
- 使用DevExpress的WebChartControl控件绘制图表(柱状图、折线图、饼图)
- 使用Echarts绘制中国地图看这篇就够了(认真脸!)
- Echarts图标使用实例(柱状图与饼图)
- 详解Vue中使用Echarts的两种方式
- echarts3 使用总结(绘制各种图表,地图)