DemuMesDataV/src/components/pointChart/index.vue

70 lines
1.1 KiB
Vue
Raw Normal View History

2018-12-22 20:55:24 +08:00
<template>
<div class="point-chart">
<loading v-if="!data" />
<div class="canvas-container">
<canvas :ref="ref" />
</div>
</div>
</template>
<script>
import canvasMixin from '../../mixins/canvasMixin.js'
import colorsMixin from '../../mixins/colorsMixin.js'
2018-12-23 19:06:42 +08:00
import axisMixin from '../../mixins/axisMixin.js'
2018-12-22 20:55:24 +08:00
export default {
name: 'PointChart',
2018-12-23 19:06:42 +08:00
mixins: [canvasMixin, colorsMixin, axisMixin],
2018-12-22 20:55:24 +08:00
props: ['data', 'colors'],
data () {
return {
ref: `point-chart-${(new Date()).getTime()}`,
// axis base config
boundaryGap: true,
horizon: false,
mulValueAdd: true
}
},
methods: {
async init () {
const { initCanvas, initColors, initAxis } = this
await initCanvas()
initColors()
initAxis()
const { drawAxis } = this
drawAxis()
}
},
mounted () {
const { init } = this
init()
}
}
</script>
<style lang="less">
.point-chart {
position: relative;
display: flex;
.canvas-container {
flex: 1;
canvas {
width: 100%;
height: 100%;
}
}
}
</style>