现在要做一个自定义的树图,echarts3引入方便,但是没有树图,遂想引echarts2进入vue工程中,请教一下大家,有什么办法吗?
现在要做一个自定义的树图,echarts3引入方便,但是没有树图,遂想引echarts2进入vue工程中,请教一下大家,有什么办法吗?
webpack中使用echarts
最近刚做的一个柱状图组件:
<template>
<div :id="'chart_'+id" :style="{'width':width,'height':height}" v-loading="isLoading">
</div>
</template>
<script>
// 引入 ECharts 主模块
var echarts = require('echarts/lib/echarts');
// 引入柱状图
require('echarts/lib/chart/bar');
// 引入提示框和标题组件
require('echarts/lib/component/tooltip');
require('echarts/lib/component/title');
var generateGUID = require('../utility.js').generateGUID
export default {
name: 'chartBar',
props: {
chartData: {
type: Array,
require: true,
default: []
},
isLoading: {
type: Boolean,
default: false
},
width: {
type: String,
default: '830px'
},
height: {
type: String,
default: '250px'
}
},
data() {
return {
id: generateGUID(),
myChart: null
}
},
methods: {
setChart() {
// 绘制图表
this.myChart.setOption({
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '16px',
right: '29px',
bottom: '43px',
top: '24px',
containLabel: true
},
xAxis: [{
type: 'category',
data: [
"0-1", "1-2", "2-3", "3-4", "4-5", "5-6",
"6-7", "7-8", "8-9", "9-10", "10-11", "11-12",
"12-13", "13-14", "14-15", "15-16", "16-17", "17-18",
"18-19", "19-20", "20-21", "21-22", "22-23", "23-24"
],
axisTick: {
interval: 0,
alignWithLabel: true
},
axisLabel: {
interval: 0,
rotate: -45,
fontSize: 10,
color: '#475568'
}
}],
yAxis: [
{
type: 'value',
splitLine: {
lineStyle: {
color: '#EFF2F7'
}
},
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
fontSize: 12,
color: '#475568'
}
}
],
series: [{
name: '在线次数',
type: 'bar',
data: this.chartData,
barWidth: '60%',
itemStyle: {
normal: {
color: '#6890D4'
},
emphasis: {
color: '#FF6633'
}
}
}]
});
}
},
watch: {
'chartData': function () {
this.setChart()
}
},
mounted() {
// 基于准备好的dom,初始化echarts实例
this.myChart = echarts.init(document.getElementById('chart_' + this.id))
}
}
</script>
<style scoped>
#chart {
width: 830px;
height: 250px;
}
</style>
5 回答4.9k 阅读✓ 已解决
4 回答3.2k 阅读✓ 已解决
2 回答4.8k 阅读✓ 已解决
4 回答4.4k 阅读✓ 已解决
4 回答1.9k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
https://github.com/Justineo/v...