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

<script>
require("echarts/lib/chart/bar");
export default {
    name:'poi-echart-bar',
    // props: {
    //     optionValue:"",
    // },
    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: [120, 200, 150, 80, 70, 110, 130],
                    type: 'bar'
                }]
            },
            // 初始化的bar
            barDom:{},
        }
    },
    methods:{
        XYdataInitEchart(xdata,ydata){
            this.optionDefault.xAxis.data = xdata;
            this.optionDefault.series[0].data = ydata;
            this.barDom.setOption && this.barDom.setOption(this.optionDefault);
        },
        initEchartDefault(option){
            if(!option){
                option = {};
            }
            let newOption = {...this.optionDefault,...option};
            this.barDom.setOption && this.barDom.setOption(newOption);
        },
    }, 
    mounted(){
        this.barDom = this.Chart.init(this.$refs.bar);
        this.initEchartDefault();
    },
}
</script>
<style scoped>
.poi-echart-bar,
.poi-echart-bar-wrap{
    width: 100%;
    height: 100%;
}
</style>

