vue introduced echarts chart

1:npm install echarts --save
2:在main.js写:
echarts from Import 'echarts / lib / echarts'

// incorporated balloon assembly, header assembly, kit components.
Import 'echarts / lib / Component / ToolTip'
Import 'echarts / lib / Component / title'
Import 'echarts / lib / Component / Toolbox'
Vue.prototype $ echarts = echarts.

. 3: Image module incorporated required components needed
如在home里:

1)html、
<div id="pie" ref="pie_wrap"></div>
import 'echarts/lib/chart/pie'
Mounted () { 
// Initialization echarts example
the let myChart = echarts.init the this $ ($ refs.pie_wrap the this.).
// Charting
myChart.setOption (
{
Color: [ 'RGB (102,208,113)', 'RGB (223,223,223) '],
Series: [
{
name:' referrer ',
type:' PIE ',
RADIUS: ['95%', '100%'],
avoidLabelOverlap: to false,
label: {
Normal: {
Show: to true,
position: 'Center',
textStyle: {
the fontSize: '48',
fontWeight: 'Bold'
}
},
emphasis: {
show: true,
textStyle: {
fontSize: '30',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data: [
{value: 30, name: ''},
{value: 70, name: ''}
],
silent: true
}
]
}
)
}

2)
// 引入柱状图
import 'echarts/lib/chart/bar'
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main')); // 绘制图表 myChart.setOption({ title: { text: 'ECharts 入门示例' }, tooltip: {}, xAxis: { data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'] }, yAxis: {}, series: [{ name: '销量', type: 'bar', data: [5, 20, 36, 10, 10, 20] }] });
 

Guess you like

Origin www.cnblogs.com/luckyShuang/p/11242193.html