<!--柱图组件模块-->
<template>
    <div class="poi-echart-line">
        <div ref="line" class="poi-echart-line-wrap"></div>
    </div>
</template>

<script>
require("echarts/lib/chart/line");
export default {
    name:'poi-echart-line',
    data(){
        return {
            Chart : require("echarts/lib/echarts"),
            fontSizeGet : 16,
            // 默认option
            optionDefault:{
                xAxis: {
                    type: 'category',
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: [820, 932, 901, 934, 1290, 1330, 1320],
                    type: 'line',
                    smooth: true
                }]
            },
            // 初始化的line
            lineDom:{},
        }
    },
    methods:{
        XYdataInitEchart(xdata,ydata){
            this.optionDefault.xAxis.data = xdata;
            this.optionDefault.series[0].data = ydata;
            this.lineDom.setOption && this.lineDom.setOption(this.optionDefault);
        },
        initEchartDefault(option){
            if(!option){
                option = {};
            }
            let newOption = {...this.optionDefault,...option};
            this.lineDom.setOption && this.lineDom.setOption(newOption);
        },
    }, 
    mounted(){
        this.lineDom = this.Chart.init(this.$refs.line);
        this.initEchartDefault();
    },
}
</script>
<style scoped>
.poi-echart-line,
.poi-echart-line-wrap{
    width: 100%;
    height: 100%;
}
</style>

