https://blog.csdn.net/she_lover/article/details/51448967

https://blog.csdn.net/n_meng/article/details/78593743

以上博客写的很清楚,但是对应找属性和方法不是很好找,最近写项目用到echart正好记录以下。

一.npm安装echarts

npm install echarts --save

二.在mian.js里面导入echarts

import echart from 'echarts'
  //挂载echart
  Vue.prototype.$echarts = echart

三.使用echart(目前是父组件引用子组件,具体的参数配置和使用都在子组件里面编写)

1.自定义的子组件1html代码(barechart.vue)

 <template>
<div id="main1" style="height:300px;"></div>
</template>

2.自定义的子组件1内容(直接代码了,该加注释的都加了)

 mounted () {
this.$nextTick(function(){
this.drawbarechart();
})
},
 methods: {
drawbarechart() {
let _this = this;
this.charts = this.$echarts.init(document.getElementById('main1'))
this.charts.setOption({
title:{ //设置标题的样式
padding:[0,15],
text:_this.titletext,
// text:'标题1',
// x:'center',
textStyle:{
fontSize:14,
color:'#333',
}
},
tooltip:{ //设置悬浮框的样式
trigger:'axis',
confine:true,
axisPointer:{
type:'shadow'
}
},
grid:{ //设置canvas构造内容的边距
left:'4%',
right:'12%',
bottom:'3%',
containLabel:true
},
xAxis:{ //X轴参数配置
type:'category',
name:_this.xAxisname,
data:_this.xAxisdata,
// axisLine:{ // 坐标轴线
// show:true, // 默认显示,属性show控制显示与否
// lineStyle:{ // 属性lineStyle控制线条样式
// color:'#ddd'
// }
// },
// axisLabel:{
// show:true,
// textStyle:{
// color:'#333'
// }
// },
splitLine:{show:false}, // 分隔线
splitArea:{ // 分隔区域
show:true, // 默认不显示,属性show控制显示与否
areaStyle:{ // 属性areaStyle(详见areaStyle)控制区域样式
color:[
'rgba(100,100,100,0.03)',
'rgba(100,100,100,0)'
]
}
},
axisTick:{ //轴上的齿度是否显示
alignWithLabel:true,
show:false
}
},
yAxis:{ //X轴参数配置
type:'value',
name:_this.yAxisname, // splitLine:{show: false},//去除网格线 axisTick:{ //轴上的齿度是否显示
show:false
}
},
series:[ //柱形的参数配置
{
name:_this.seriesname,
type:'bar',
barWidth: '25',
data:_this.seriesdata, itemStyle:{
normal:{
barBorderRadius:[5, 5, 5, 5],
color:'rgb(72,118,254)',
label:{
show:true,
position:'top',
textStyle:{
color:'rgb(72,118,254)'
}
}
}
}
}
]
})
}
},

3.以下是自定义子组件2,折线图(lineechart.vue)

 <template>
<div id="main2" style="height:300px;background:#ffffff"></div>
</template>

4.自定义的子组件2内容(直接代码了,该加注释的都加了)

 mounted () {         this.$nextTick(function(){
this.drawlineechart();
}) },
methods: {
drawlineechart() {
let _this = this;
this.charts = this.$echarts.init(document.getElementById('main2'))
this.charts.setOption({
title:{
text:_this.titletext,
// text:'标题2',
padding:[5,15],
// x:'center',
textStyle:{
fontSize:14,
color:'#333'
}
},
tooltip:{
trigger:'axis',
},
grid:{
left:'2%',
right:'12%',
bottom:'3%',
containLabel:true
},
xAxis:{
type:'category',
name:_this.xAxisname,
splitLine:{show:false},
// boundaryGap:false,
data:_this.xAxisdata,
splitArea:{
show:true,
areaStyle:{
color:[
'rgba(100,100,100,0.03)',
'rgba(100,100,100,0)'
]
}
}, // axisLine:{ // 坐标轴线
// show:true, // 默认显示,属性show控制显示与否
// lineStyle:{ // 属性lineStyle控制线条样式
// color:'#111'
// }
// },
// axisLabel:{
// show:true,
// interval:0, //X轴字段全部显示出来,默认不显示完可以把该项去掉
// textStyle:{
// color:'#111'
// }
// },
splitLine:{show:false}, // 分隔线
// splitArea:{ // 分隔区域
// show:true, // 默认不显示,属性show控制显示与否
// areaStyle:{ // 属性areaStyle(详见areaStyle)控制区域样式
// color:[
// 'rgba(100,100,100,0.03)',
// 'rgba(100,100,100,0)'
// ]
// }
// },
axisTick:{
show:false
}
},
yAxis:{
type:'value',
name:_this.yAxisname, // axisLine:{ // 坐标轴线
// show:true, // 默认显示,属性show控制显示与否
// lineStyle:{ // 属性lineStyle控制线条样式
// color:'#666'
// }
// }, // splitLine:{show: false},//去除网格线 axisLabel:{
formatter:'{value}(%)'
},
axisTick:{
show:false
}
},
series:[
{
name:_this.seriesname,
type:'line', symbol:'circle', //折线图拐点 symbolSize:10,
showAllSymbol:true,
data:_this.seriesdata, itemStyle:{
normal:{
color:'rgb(72,118,254)',
label:{
show:true,
position:'top',
formatter:'{c}(%)', //在series加上单位
textStyle:{
color:'rgb(72,118,254)'
}
}
}
}
}, ]
})
}
},

以上,关于echart各种常用的参数,就是这次的主要内容。

稍微更新一下:目前需求有跟着屏幕大小自动去刷新echart宽高,试了多种方式,最终解决了单个页面多个echart图自适应宽高问题:

 window.addEventListener('resize', ()=> {
this.charts.resize();
})

加在setOption后面即可。

window.addEventListener('resize', ()=> {
this.charts.resize();
})

echart 参数 vue配置 图文展示的更多相关文章

  1. HighCharts选项和参数详细配置查询表

    概述:作为一款出色的交互图表制作工具,HighCharts有着全面的选项.参数等配置信息.为了帮助大家进一步掌握HighCharts,今天我们为大家整理了HighCharts的所有配置信息和说明,将其 ...

  2. SDK?JDK?JDK 下载、安装、配置图文教程

    什么是软件开发工具包(SDK)   开发一个软件,需要经过编辑.编译.调试.运行几个过程. 编辑:使用编程语言编写程序代码的过程. 编译:如上一节所讲,就是将编写的程序进行翻译. 调试:程序不可能一次 ...

  3. tomcat是什么?Tomcat 下载、安装、配置图文教程

    你用浏览器上网的所有操作,所有请求发送给服务器(tomcat),服务器通过请求,找相应的逻辑处理程序(jsp或servelet或java类,就是有关java语言的所有可以处理逻辑的代码,其中包括访问后 ...

  4. Highcharts常用的最核心的参数选项配置详细说明

    Highcharts提供大量的选项配置参数,您可以轻松定制符合用户要求的图表,目前官网只提供英文版的开发配置说明文档,而中文版的文档网上甚少,且零散不全.这里,我把Highcharts常用的最核心的参 ...

  5. win7下IIS的安装和配置 图文教程

    转自   http://www.jb51.net/article/29787.htm 最近工作需要IIS,自己的电脑又是Windows7系统,找了下安装的方法,已经安装成功.在博客里记录一下,给需要的 ...

  6. Cocos2d-x win7 + vs2010 配置图文详解

    Cocos2d-x win7 + vs2010 配置图文详解 下载最新版的cocos2d-x.打开浏览器,输入cocos2d-x.org,然后选择Download,本教程写作时最新版本为cocos2d ...

  7. Python安装、配置图文详解(转载)

    Python安装.配置图文详解 目录: 一. Python简介 二. 安装python 1. 在windows下安装 2. 在Linux下安装 三. 在windows下配置python集成开发环境(I ...

  8. 【和我一起学python吧】Python安装、配置图文详解

     Python安装.配置图文详解 目录: 一. Python简介 二. 安装python 1. 在windows下安装 2. 在Linux下安装 三. 在windows下配置python集成开发环境( ...

  9. struts文件上传拦截器中参数的配置(maximumSize,allowedTypes ,allowedExtensions)问题

    <interceptor-ref name="fileUpload"> <param name="allowedTypes">image ...

随机推荐

  1. BNUOJ 9870 Contestants Division

    Contestants Division Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALiv ...

  2. BNUOJ 7697 Information Disturbing

    Information Disturbing Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on HDU. ...

  3. HDU 2647 逆向拓扑排序

    令每一个员工都有一个自己的等级level[i] , 员工等级越高,那么工资越高,为了使发的钱尽可能少,所以每一级只增加一单位的钱 输入a b表示a等级高于b,那么我们反向添加边,令b—>a那么i ...

  4. Thinkphp5.0 的视图view的循环标签

    Thinkphp5.0 的视图view的循环标签 volist标签: <!-- 使用volist --> <!-- name是传递过来的要循环变量名 --> <!-- k ...

  5. 自定义View实现跟随手指的小球

    package com.pingyijinren.test; import android.content.Context; import android.graphics.Canvas; impor ...

  6. 无法打开物理文件 "X.mdf"。操作系统错误 5:"5(拒绝访问。)"。 (Microsoft SQL Server,错误: 5120)解决

    环境 SQLServer 2008 R2 问题 附加数据库出现“无法打开物理文件 "X.mdf".操作系统错误 5:"5(拒绝访问.)". (Microsoft ...

  7. tomcat会自动解压webapps目录下的war包

    如图,把war包放到tomcat的webapps目录,会被自动解压

  8. oracle导入命令,记录一下 数据库日志太大,清理日志文件

    oracle导入命令,记录一下 工作中用到了,这个命令,记录一下,前提要安装imp.exe imp PECARD_HN/PECARD_HN@127.0.0.1:1521/orcl file=E:\wo ...

  9. ZOJ3659 Conquer a New Region 并查集

    Conquer a New Region Time Limit: 5 Seconds      Memory Limit: 32768 KB The wheel of the history roll ...

  10. exception log

    except Exception as e: l = [str(i) for i in [dbid, f_mp3, e]] log_s = '||'.join(l) logging.exception ...