ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๐Ÿ’ฌ ๊ตฌํ˜„ํ•˜๊ณ ์ž ํ•˜๋Š” ๊ธฐ๋Šฅ

1. ํŒŒ์ด์ฐจํŠธ ๊ฐ€์šด๋ฐ์— ์ด๋ฏธ์ง€ ์ถ”๊ฐ€ํ•˜๊ธฐ

2. ํŒŒ์ด์ฐจํŠธ ํด๋ฆญ ์‹œ url ์ด๋™ํ•˜๊ธฐ

 

๐Ÿ“Œ ํŒŒ์ด์ฐจํŠธ ๊ฐ€์šด๋ฐ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€ํ•˜๊ธฐ

series ์†์„ฑ ์•ˆ์˜ label ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฏธ์ง€๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

series: [
    {
        label: {
            position: 'center',
            // 1. ๋ณ€์ˆ˜ 'a' ์„ค์ •
            formatter: () => {
                return '{a|}'		
            },
            rich: {
            	// 'a' ๋ณ€์ˆ˜์— ๋“ค์–ด๊ฐˆ ์†์„ฑ ์„ค์ •
                a: {				
                    backgroundColor: {
                        image: require(`@common/DashBoard/Content/img/${this.chartId}.png`),
                    },
                    height: 35
                },
            }
        },
    }
]

 

๐Ÿ“Œ ํŒŒ์ด์ฐจํŠธ ํด๋ฆญ์‹œ ์ด๋ฒคํŠธ ์ถ”๊ฐ€ํ•˜๊ธฐ

์ฐจํŠธ๋ฅผ ์ดˆ๊ธฐํ™”ํ•œ ํ›„, click ์ด๋ฒคํŠธ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

    methods: {
        setChart(option) {
            let pieChart = echarts.init(document.getElementById(this.chartId));
            pieChart.setOption(option);

            pieChart.on('click', (params) => {
                switch(params.seriesName){
                    case 'MCP': 
                        window.parent.location.href = `${process.env.VUE_APP_ROUTE_TARGET}main/1`
                        break;
                    case 'IO Link Master': 
                        window.parent.location.href = `${process.env.VUE_APP_ROUTE_TARGET}main/2`
                        break;
                    case 'Robot': 
                        window.parent.location.href = `${process.env.VUE_APP_ROUTE_TARGET}main/3`
                        break;
                }
            });
        }
    },

 

๐Ÿ“Œ ์ „์ฒด ์ฝ”๋“œ

<template>
     <div :id="chartId" class="status-container__chart--chart"></div>
</template>

<script>
import * as echarts from "echarts";

export default {
	props: { 
        chartId: { type: String, default: '' },
        stateCountList: { type: Array, default: [] },
    },
    data() {
        return {
            cnt: [
                { value: 0, name: 'Normal' },
                { value: 0, name: 'Warning' },
                { value: 0, name: 'Alert' },
            ],
            total: 0
        }
    },  
    watch: {
        // props ๋ณ€๊ฒฝ ๊ฐ์ง€
        stateCountList() {
            console.log('--props',this.stateCountList)
            this.cnt = this.stateCountList
            this.total = this.cnt[0].value + this.cnt[1].value + this.cnt[2].value   // total ๊ฐ’ ๊ณ„์‚ฐ
            this.setChart(this.option) 
        }
    },
	computed: {
        option() {
            return {
                tooltip: {
                    show: false,
                    trigger: 'item'
                },
                legend: {
                    show: false,
                    top: '5%',
                    left: 'center',
                },
                series: [
                    {
                        name: this.chartId,
                        type: 'pie',
                        radius: ['50%', '80%'],
                        color: ['rgb(146,208,80)','rgb(255,192,0)','rgb(255,0,0)'],
                        avoidLabelOverlap: false,
                        label: {
                            position: 'center',
                            formatter: () => {
                                return '{a|}'
                            },
                            rich: {
                                a: {
                                    backgroundColor: {
                                        image: require(`@common/DashBoard/Content/img/${this.chartId}.png`),
                                        
                                    },
                                    height: 35
                                },
                            }
                        },
                        labelLine: {
                            show: false
                        },
                        data: this.cnt
                    }
                ]
            }
        }
    },
    methods: {
        setChart(option) {
            let pieChart = echarts.init(document.getElementById(this.chartId));
            pieChart.setOption(option);

            pieChart.on('click', (params) => {
                switch(params.seriesName){
                    case 'MCP': 
                        window.parent.location.href = `${process.env.VUE_APP_ROUTE_TARGET}main/E00000201`
                        break;
                    case 'IO Link Master': 
                        window.parent.location.href = `${process.env.VUE_APP_ROUTE_TARGET}main/E00000301`
                        break;
                    case 'Robot': 
                        window.parent.location.href = `${process.env.VUE_APP_ROUTE_TARGET}main/E00000401`
                        break;
                }
            });
        }
    },  
    mounted(){
    }
}

</script>

<style>

</style>
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2025/05   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
๊ธ€ ๋ณด๊ด€ํ•จ