方法一:全局引入echarts

步骤:

1、全局安装 echarts依赖。        cnpm install echarts -- save

2、引入echarts模块,在Vue项目的main.js中引入echarts模块,即是写入如下代码:

import echarts from 'echarts'
Vue.prototype.$echarts = echarts

3、在需要的组件,如index.vue中

<template>
<div class="echart-box" id="E_zkcl" style="width: 380px;
height:330px"></div>
</template>
<script>
export default {
data(){
return(){
}
},
methods: {
drawLine(){
let myChart1 = this.$echarts.init(document.getElementById('E_zkcl')) }
myChart1.setOption({
color:['#4ED8DA'],
title : {
text: '每月检修统计',
x:,
y:,
textStyle:{
fontSize: ,
fontWeight: 'bolder',
color: '#333'
}
},
tooltip : {
trigger: 'axis'
},
grid:{
borderWidth:,
x:'10%',
y:'20%',
x2:'5%',
y2:'15%',
},
calculable : true,
xAxis : [
{
type : 'category',
axisLine:{
show:false,
},
splitLine:{
show:false, //不显示分割线
},
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
}
],
yAxis : [
{
type : 'value',
axisLine:{
show:false,
}
}
],
series : [
{
name:'数量',
type:'bar',
data:[, , , , , , , , , , , ],
}
]
});

//根据窗口的大小变动图表 --- 重点
window.onresize = function(){
    myChart.resize();
    //myChart1.resize();    //若有多个图表变动,可多写


}

},

         mounted(){
this.drawLine();
} }
</script>

方法二:按需引入

vue中添加echarts的更多相关文章

  1. vue中添加Echarts图表的使用,Echarts的学习笔记

    项目中需要使用一些折线图.柱状图.饼状图等等,之前使用过heightCharts(关于heightCharts请看我的另一篇 http://www.cnblogs.com/jasonwang2y60/ ...

  2. 在vue中使用echarts图表

    在vue中使用echarts图表   转载请注明出处:https://www.cnblogs.com/wenjunwei/p/9815290.html 安装vue依赖 使用npm npm instal ...

  3. vue中使用echarts的两种方法

    在vue中使用echarts有两种方法一.第一种方法1.通过npm获取echarts npm install echarts --save 2.在vue项目中引入echarts 在 main.js 中 ...

  4. 在vue中调用echarts中的地图散点图~

    首先!当然是在vue中引入echarts! 命令行  npm install echarts --save 在main.js文件中里引入        import echarts from 'ech ...

  5. Vue中使用ECharts画散点图加均值线与阴影区域

    [本文出自天外归云的博客园] 需求 1. Vue中使用ECharts画散点图 2. 在图中加入加均值线 3. 在图中标注出阴影区域 实现 实现这个需求,要明确两点: 1. 知道如何在vue中使用ech ...

  6. vue中添加util公共方法&&ES6之import、export

    vue中添加util公共方法&&ES6之import.export https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Re ...

  7. 记录下vue 中引用echarts 出现 "TypeError: Cannot read property 'getAttribute' of undefined"问题

    今天做项目,用echarts展示数据 ,自己测试 先测试 了下.写的代码html: <div ref="myChart" style="height:300px;w ...

  8. vue中使用echarts(vue+vue-cli+axios+jsonp+echarts)

    一.安装echarts: cnpm i echarts -D 二.在vue-cli的main.js文件中引用echarts: import charts from 'echarts' Vue.prot ...

  9. VUE中集成echarts时 getAttribute of null错误

    错误 错误场景一: 错误提示: 在运行Vue项目时出现了上述错误,出现该错误的原因是Echarts的图形容器还未生成就对其进行了初始化所造成的,代码如下: // 基于准备好的dom,初始化echart ...

随机推荐

  1. Data Base mysql批量操作

    mysql  批量操作 批量操作数据是利用 CommandBuilder  和 DataAdapter.Update() 方法 对数据库进行批量更新 说解: DataAdapter中有四个重要对象:S ...

  2. Linux性能指标解释+Oracle性能指标解释

    Linux性能指标解释 类别 计数器名称 计数器描述 业界同行认可的资源阀值 memory Free(KB) 可用物理内存数 swap-in/out =0 Swap(KB) 已使用的虚拟内存数.在Li ...

  3. JS随机数生成算法

    ------------------------------------------ 知乎上边淘到的知识,又学到了~ http://www.zhihu.com/question/22818104 -- ...

  4. Python Flask-web表单

    Flask-WTF扩展可以把处理web表单的过程变成一种愉悦的体验. 一.跨站请求伪造保护 默认情况下,Flask-WTF能够保护所有表单免受跨站请求伪造的攻击.恶意网站把请求发送到被攻击者已登录的网 ...

  5. jq表单验证

    <body> <form method="post" action=""> <div class="int"& ...

  6. uwsgi01---uwsgi文件

    1. 安装 pip install uwsgi //测试uWSGI是否安装成功 在终端中输入以下命令查看uwsgi的版本:uwsgi --version 2.简单运行 运行uwsgi:uwsgi -- ...

  7. linux上传与下载

    首先必须安装xshell这个工具 使用xshell来操作服务非常方便,传文件也比较方便.就是使用rz,sz首先,服务器要安装了rz,szyum install lrzsz当然你的本地windows主机 ...

  8. 8. sql 片段

    sql 片段: <sql id="columnBase"> `id`, `title`, `author_id` as authorId, `state`, `feat ...

  9. 使用windows服务修改CPU型号(重启依然有效)

    此项目基于.net framework 4.0 效果如下: 服务运行前: 服务运行后: 思路大概是这样: 通过修改注册表可以修改CPU型号,把服务设置成本地服务,并且开机自动启动,来实现开机自动修改处 ...

  10. python 根据 数据库创建java 文件

    #coding=utf-8 import pymysql import os import re # 包全路径 packagepath=r'E:\idea工程\dc-exam\dc-exam\src\ ...