<template>
    <div class="DPcomputer20Box">
        <!-- 各装点车铲比 -->
        <div class="intelligentSchScrView_rightView_title">各装点车铲比</div>
        <div class="intelligentSchScrView_rightView_content">
            <div id="carsProportionView"></div>
        </div>
    </div>
</template>

<script>
import { Tools, HttpReq, CAMap} from '@/assets/js/common.js';
import * as echarts from 'echarts';


export default {
    data(){
        return {
            DPcomputer20BoxTimer:null,
            //各装点车铲比Echarts
            carsProportionData:[],
        }
    },
    mounted(){
        this.loadData();
    },
    methods:{
        loadData(){
            //各装点车铲比Echarts
            HttpReq.truckDispatching.getLargeScreenchechanbi1({size:9999}).then((res) => {
                if(res.code == 200){
                    this.carsProportionData = res.data;
                    this.carsProportionEcharts();
                }
            })

            this.DPcomputer20BoxTimer = setInterval(() => {
                //各装点车铲比Echarts
                HttpReq.truckDispatching.getLargeScreenchechanbi1({size:9999}).then((res) => {
                    if(res.code == 200){
                        this.carsProportionData = res.data;
                        this.carsProportionEcharts();
                    }
                })
            },10000)

        },
        //各装点车铲比Echarts
        carsProportionEcharts(){
            echarts.init(document.getElementById('carsProportionView')).dispose();
            var myChart = echarts.init(document.getElementById('carsProportionView'));
            var option;

            const data = [this.carsProportionData];
            option = {
                grid: {
                    top:'13%',
                    left: '2%',
                    right: '13%',
                    bottom: '5%',
                    containLabel: true
                },
                xAxis: {
                    name: '铲车',
                    nameTextStyle: { fontSize: 14 },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            type: 'dashed'
                        }
                    },
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#A6F6F9',
                            fontSize:14,
                        },
                    },
                    axisLine: {
                        lineStyle: {
                            color: '#A6F6F9',
                            width: 1
                        }
                    },
                },
                yAxis: {
                    name: '卡车',
                    nameTextStyle: { fontSize: 14 },
                    splitLine: {
                        lineStyle: {
                            type: 'dashed'
                        }
                    },
                    scale: true,
                    axisLabel: {
                        show: true,
                        textStyle: {
                            color: '#A6F6F9',
                            fontSize:14,
                        }
                    },
                    axisLine: {
                        lineStyle: {
                            color: '#A6F6F9',
                            width: 0
                        }
                    },
                },
                series: [
                    {
                        data: data[0],
                        type: 'scatter',
                        symbolSize: 15,
                        emphasis: {
                            focus: 'series',
                            label: {
                                show: true,
                                formatter: function (param) {
                                    return param.data[2];
                                },
                                position: 'top',
                                fontSize:16,
                            }
                        },
                        itemStyle: {
                            color: '#4BF3F9',
                        }
                    }
                ]
            };
            option && myChart.setOption(option);
        },
    },
    beforeDestroy(){
        if(this.DPcomputer20BoxTimer) {
			clearInterval(this.DPcomputer20BoxTimer);
            this.DPcomputer20BoxTimer = null;
		}
    }
}
</script>

<style scoped>
*{
  margin: 0;
  padding: 0;
}
.DPcomputer20Box{
    width: 20vw;
    height: 32vh;
    background-color: rgba(32,42,67,0.95);
    padding: 5px 7px;
    box-sizing: border-box;
    overflow: hidden;
}
.DPcomputer20Box .intelligentSchScrView_rightView_title{
    margin-bottom: 5px;
    width: 100%;
    height: 3.5vh;
    background:no-repeat center center url('~@/assets/images/cutGraph/biaoti1.png');
	background-size:100% 100%;
    padding-left: 10px;
    box-sizing: border-box;
    font-size: 18px;
    line-height: 3.5vh;
    color: #FAFAFB;
    letter-spacing: 1px;
    text-shadow: 1px 1px 1px #92CBFF;
}
.DPcomputer20Box .intelligentSchScrView_rightView_content{
    width: 100%;
}
.DPcomputer20Box #carsProportionView{
    width: 19vw;
    height: 27.5vh;
}
</style>