1、首先在项目中安装Echarts 

npm install echarts -g --save    //安装

2、在项目中引入Echarts(在main.js中引入)

import echarts from 'echarts'  //引入Echarts,

Vue.prototype.$echarts = echarts  //定义为全局变量

3、使用并绘制简单表格(承载画布的div必须要定义大小width、height)

<template>
<!--
ref="myechart"定义该div也就是画布的名字,在this.$echarts.init(this.$refs.myechart) 图表初始化的时候使用
this.$refs.myechart 也可以替换为 document.getElementById('main') 或者 document.getElementByClassName('echart-box')
-->
<div class="HelloWorld echart-box" ref="myechart" id="main"></div>
</template>
<script> export default {
name:'HelloWorld',
data(){
return{
// 定义图表,各种参数
option:{
backgroundColor:"lightblue",
title:{
backgroundColor:"lightyellow",
show:true,
text:"测试练习",
textStyle:{
fontSize:,
fontWeight:,
color:'red',
},
subtext:'测试小标题',
subtextStyle:{
color:'green',
fontSize:,
fontWeight:
}
},
xAxis:{
type:"category",
data:["星期一","星期二","星期三","星期四","星期五","星期六","星期日",]
},
yAxis:{
type:"value",
},
series:[
{
data:[,,,,,,],
type:"line"
},
{
data:[,,,,,,],
type:"line"
}
]
}
}
},
mounted:function(){
console.log(this.$echarts)
let myechart = this.$echarts.init(this.$refs.myechart) //初始化一个echarts
myechart.setOption(this.option) //setOption 用this.option中的数据开始作图 } }
</script> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: ;
}
li {
display: inline-block;
margin: 10px;
}
a {
color: #42b983;
}
.HelloWorld{ //注意画布必须定义大小
width: 1000px;
height:600px;
background: #cce6f0;
margin: auto;
}
</style>

在vue中使用的Echarts的步骤的更多相关文章

  1. vue中如何使用echarts

    在vue中使用echarts主要是注意如何与vue生命周期相结合,从而做到数据驱动视图刷新 主要是以下几步: echarts的option配置项放在在data(){}或者computed(){}中 在 ...

  2. 关于vue中如何配置echarts以及使用方法

    ECharts,一个使用 JavaScript 实现的开源可视化库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(IE8/9/10/11,Chrome,Firefox,Safari等) ...

  3. vue中如何使用echarts,使用axios获取数据

    1==>首先准备一个容器 <div id="echartContainer" style="width:400px; height:400px"&g ...

  4. vue中动态设置echarts画布大小

    document.getElementById('news-shopPagechart').style.height = this.heightpx2+'px'; //heightpx2定义在data ...

  5. vue中,基于echarts 地图实现一个人才回流的大数据展示效果

    0.引入echarts组件,和中国地图js import eCharts from 'echarts' import 'echarts/map/js/china.js'// 引入中国地图 1. 设置地 ...

  6. vue中添加echarts

    方法一:全局引入echarts 步骤: 1.全局安装 echarts依赖.        cnpm install echarts -- save 2.引入echarts模块,在Vue项目的main. ...

  7. Vue中echarts的基本用法

    前言:同大多数的前端框架一样,先读官网的使用方法.学会基本使用后,在实例中找到自己想要demo.拿过来改一改,一个echarts图表就形成,毕竟人家做就是为了方便使用. 我是在vue中下面直接使用的e ...

  8. vue中引入babel步骤

    vue中引入babel步骤 vue项目中普遍使用es6语法,但有时我们的项目需要兼容低版本浏览器,这时就需要引入babel插件,将es6转成es5. 1.安装babel-polyfill插件 npm ...

  9. 在vue中使用echarts图表

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

随机推荐

  1. The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online J Press the Button

    BaoBao and DreamGrid are playing a game using a strange button. This button is attached to an LED li ...

  2. Xcode 下“ did not have any applicable content ”分析及解决

    问题的产生 a.新建项目时选的iPhone b.为了做成图片启动,按照惯例去掉了LaunchStoryboard的引用,建了个LaunchImage的资源,属性里随便勾了一个,找了张匹配的图拖了过去 ...

  3. set 集合————两个数组的交集

    class Solution { public: vector<int> intersection(vector<int>& nums1, vector<int& ...

  4. 利用cookie判断文件下载完成

    在网页下载文件时,该文件又是通过后台代码生成的,比如报表之类的.当需要生成文件过大时会耗费很多时间,而文件生成好传到页面的时候也没有事件可以监听它,像微软官网,谷歌,百度等下载方式都是通过提示五秒过后 ...

  5. JS - 浅拷贝与深拷贝的理解以及简单实现方法

    前几天撸项目代码时, 由一个技术点间接牵扯出了这东西. 所以就来总结一下. 深拷贝 拷贝对象每个层级的属性. 作用的对象是 js中引用类型的对象,基本类型没有涉及. 本质上将引用类型的对象在堆上重新开 ...

  6. WePy--使用zanUI组件

    因为Wepy 中不能直接引入zanUI组件, 好在还有百度, 参考链接 https://github.com/brucx/wepy-zanui-demo (感谢); 我的做法是将 源码下了下来, 源码 ...

  7. 如何使用JAVA请求HTTP

    package com.st.test; import java.io.BufferedReader; import java.io.IOException; import java.io.Input ...

  8. [WPF] 圆形等待效果

    原文:[WPF] 圆形等待效果 自己做着玩儿的,留着以后用,效果类似下面的 GIF 动画. <Grid Width="35" Height="35"> ...

  9. VUE:路由

    VUE:路由 一.说明 1)官方提供的用来实现SPA的vue插件 2)github:https://github.com/vuejs/vue-router 3)中文文档:http://router.v ...

  10. PatentTips - Increasing turbo mode residency of a processor

    BACKGROUND Many modern operating systems (OS's) use the Advanced Configuration and Power Interface ( ...