2018-01-28 09:40:57 +08:00
|
|
|
<template>
|
2018-01-28 14:58:34 +08:00
|
|
|
<div ref="chart" style="height: 100%;"></div>
|
2018-01-28 09:40:57 +08:00
|
|
|
</template>
|
2018-01-28 14:58:34 +08:00
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import G2Mixin from './G2'
|
|
|
|
|
export default {
|
|
|
|
|
mixins: [
|
|
|
|
|
G2Mixin
|
|
|
|
|
],
|
2018-01-28 22:45:54 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
// 在组件 mounted 后立即初始化图表
|
|
|
|
|
mountedInit: false
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-01-28 14:58:34 +08:00
|
|
|
methods: {
|
2018-01-28 22:45:54 +08:00
|
|
|
// 初始化图表
|
2018-01-28 14:58:34 +08:00
|
|
|
initHandler () {
|
|
|
|
|
this.creatChart()
|
2018-01-28 22:45:54 +08:00
|
|
|
this.setChartTitle()
|
|
|
|
|
this.chart.source(this.data)
|
2018-01-28 14:58:34 +08:00
|
|
|
this.chart.scale('value', {
|
|
|
|
|
min: 0
|
|
|
|
|
})
|
|
|
|
|
this.chart.scale('year', {
|
|
|
|
|
range: [0, 1]
|
|
|
|
|
})
|
|
|
|
|
this.chart.tooltip({
|
|
|
|
|
crosshairs: {
|
|
|
|
|
type: 'line'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.chart.line().position('year*value')
|
|
|
|
|
this.chart.point().position('year*value').size(4).shape('circle').style({
|
|
|
|
|
stroke: '#fff',
|
|
|
|
|
lineWidth: 1
|
|
|
|
|
})
|
|
|
|
|
this.chart.render()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|