yjryu / pohang_tp star
Stormen123 01-23
240123 김성훈 차트 완료
@f16558ef443f9b6167fee09803545784d6f0dbe8
Global.js
--- Global.js
+++ Global.js
@@ -4,7 +4,7 @@
 const LOG_BASE_DIR = `${__dirname}/server/logs`;
 const SERVICE_STATUS = process.env.NODE_ENV;//development, production
 const PORT = 80;
-const API_SERVER_HOST = 'localhost:8080';
+const API_SERVER_HOST = 'localhost:9090';
 
 module.exports = {
     PROJECT_NAME,
client/views/components/LineChart.vue
--- client/views/components/LineChart.vue
+++ client/views/components/LineChart.vue
@@ -21,6 +21,7 @@
             default: null
             // required: true,
         },
+
     },
     data() {
         return {
@@ -28,28 +29,28 @@
         };
     },
     methods: {
-        createChart(data, keyMapping, xField) {
-            console.log(typeof(xField));
-            let mappedData = [];
-            let keys = Object.keys(data[0]);
+        createChart(data, xField) {
+            // console.log(typeof(xField));
+            // let mappedData = [];
+            // let keys = Object.keys(data[0]);
 
-            for (let dataIndex = 0; dataIndex < data.length; dataIndex++) {
-                let currentItem = data[dataIndex];
-                let mappedItem = {};
+            // for (let dataIndex = 0; dataIndex < data.length; dataIndex++) {
+            //     let currentItem = data[dataIndex];
+            //     let mappedItem = {};
 
-                for (let i = 0; i < keys.length; i++) {
-                    let key = keys[i];
-                    let koreanKey = keyMapping[key];
+            //     for (let i = 0; i < keys.length; i++) {
+            //         let key = keys[i];
+            //         let koreanKey = keyMapping[key];
 
-                    if (koreanKey) {
-                        mappedItem[koreanKey] = currentItem[key];
-                    }
-                }
+            //         if (koreanKey) {
+            //             mappedItem[koreanKey] = currentItem[key];
+            //         }
+            //     }
 
-                mappedData.push(mappedItem);
-            }
+            //     mappedData.push(mappedItem);
+            // }
 
-            console.log("mappedData - ",mappedData)
+            // console.log("mappedData - ",mappedData)
 
             let chartWarp = this.$refs["chartdiv"]; // 차트 상위 div ref 매칭
             chartWarp.innerHTML = ""; // 차트 상위 div 내용 초기화 (기존 차트 삭제)
@@ -101,7 +102,13 @@
                 location: 1
             })
 
-            xAxis.data.setAll(mappedData);
+            /* let lineData = [
+                { search_date: "2023-01-01", value1: 10, value2: 20, value3: 50 },
+                { search_date: "2023-01-02", value1: 15, value2: 25, value3: 50 },
+                { search_date: "2023-01-03", value1: 20, value2: 30, value3: 50 },
+            ] */
+
+            xAxis.data.setAll(data);
 
             let yAxis = chart.yAxes.push(
                 am5xy.ValueAxis.new(root, {
@@ -113,9 +120,9 @@
                 })
             );
 
-
             // Add series
-            Object.keys(mappedData[0]).forEach((key, index) => {
+            Object.keys(data[0]).forEach((key, index) => {
+                console.log('key', key)
                 if (key !== xField) {
                     let series = chart.series.push(am5xy.LineSeries.new(root, {
                         name: key,
@@ -128,40 +135,45 @@
                         })
                     }));
 
-
-
                     series.strokes.template.setAll({
                         strokeWidth: 2
                     });
 
                     series.get("tooltip").get("background").set("fillOpacity", 0.5);
-
-
-                    series.data.setAll(mappedData.map(item => ({
+                    
+                    /* console.log('!!!!!',data.map(item => ({
                         [xField]: item[xField],
                         [key]: item[key]
-                    })));
+                    }))); */
+                    console.log("data: ", key, xField, data);
 
-                   
-
+                    // series.data.setAll(data.map(item => ({
+                    //     [xField]: item[xField],
+                    //     [key]: item[key]
+                    // })));
+                    series.data.setAll(data);
+                    series.appear(1000);
                 }
             });
 
 
             // Make stuff animate on load
             // https://www.amcharts.com/docs/v5/concepts/animations/
-            chart.series.each((series) => {
+            /* chart.series.each((series) => {
                 series.appear(1000);
-            });
+            }); */
             chart.appear(1000, 100);
+
+            // for (let i = 1; i < data.length; i++) {
+            //         createSeries(valueDataList[i], valueDataList[i], options['seriesColorList'][i]);
+            // }
 
         }
 
     },
     watch: {
         'chartData': function (newData) {
-            console.log('newData - ', newData)
-            this.createChart(newData,this.keyMapping,this.xField);
+            this.createChart(newData ,this.xField);
         }
     },
     mounted() {
client/views/components/MultiBarChart.vue
--- client/views/components/MultiBarChart.vue
+++ client/views/components/MultiBarChart.vue
@@ -12,9 +12,17 @@
 export default {
     props: {
         setData: {
-            type: Object,
-            default: {},
-        }, color: {
+            type: Array,
+            default: [],
+        }, 
+        mapping: {
+            type: Array,
+            default: [],
+        },
+        columnX: {
+            type: String
+        },
+        color: {
             type: Array,
             default: [],
         },
@@ -25,7 +33,7 @@
         };
     },
     methods: {
-        chartCreate: function (data, color) {
+        chartCreate: function (data, mapping, columnX, colors) {
             let chartWarp = this.$refs["chartdiv"]; // 차트 상위 div ref 매칭
             chartWarp.innerHTML = ""; // 차트 상위 div 내용 초기화 (기존 차트 삭제)
             let div = document.createElement("div"); // 차트를 담을 빈 div 생성 (차트 하위 div)
@@ -68,18 +76,18 @@
                 minorGridEnabled: true
             });
 
-            xRenderer.labels.template.setAll({ text: "" });
-
             let xAxis = chart.xAxes.push(
                 am5xy.CategoryAxis.new(root, {
                     maxDeviation: 0,
-                    categoryField: "category",
+                    categoryField: columnX,
                     renderer: xRenderer,
                     tooltip: am5.Tooltip.new(root, {
-                        labelText: "{realName}"
+                        labelText: "{city}"
                     })
                 })
             );
+            
+            xAxis.data.setAll(data);
 
             // let yAxis = chart.yAxes.push(
             //     am5xy.ValueAxis.new(root, {
@@ -94,61 +102,76 @@
                     renderer: am5xy.AxisRendererY.new(root, { opposite: false })
                 })
             );
+            
+            const keyName = ['maximum', 'minimum']
+
+            for(let i = 0; i < keyName.length; i++) {
+                let key = keyName[i];
+                let koreanKey = mapping[key];
+                makeSeries(koreanKey, key, colors[i]);
+            }
 
             // Create series
             // https://www.amcharts.com/docs/v5/charts/xy-chart/series/
-            let series = chart.series.push(
-                am5xy.ColumnSeries.new(root, {
-                    name: "Series 1",
-                    xAxis: xAxis,
-                    yAxis: yAxis,
-                    valueYField: "value",
-                    sequencedInterpolation: true,
-                    categoryXField: "category",
-                    tooltip: am5.Tooltip.new(root, {
-                        labelText: "{provider} {realName}: {valueY}"
+            function makeSeries(name, fieldName, color) {
+                let series = chart.series.push(
+                    am5xy.ColumnSeries.new(root, {
+                        name: name,
+                        xAxis: xAxis,
+                        yAxis: yAxis,
+                        valueYField: fieldName,
+                        sequencedInterpolation: true,
+                        categoryXField: columnX,
+                        fill: color,
+                        tooltip: am5.Tooltip.new(root, {
+                            labelText: "{name} : {valueY}"
+                        })
                     })
-                })
-            );
+                );
 
-            series.columns.template.setAll({
-                fillOpacity: 0.9,
-                strokeOpacity: 0
-            });
+                series.columns.template.setAll({
+                    fillOpacity: 0.9,
+                    strokeOpacity: 0
+                });
 
 
-            series.columns.template.adapters.add("fill", function (fill, target) {
-                const dataIndex = series.dataItems.indexOf(target.dataItem);
+                /* series.columns.template.adapters.add("fill", function (fill, target) {
+                    const dataIndex = series.dataItems.indexOf(target.dataItem);
 
-                // Check if the data index is valid
-                if (dataIndex !== -1) {
-                    // Calculate the reverse index to apply colors from the end of the array
-                    const reverseIndex = series.dataItems.length - 1 - dataIndex;
+                    // Check if the data index is valid
+                    if (dataIndex !== -1) {
+                        // Calculate the reverse index to apply colors from the end of the array
+                        const reverseIndex = series.dataItems.length - 1 - dataIndex;
 
-                    // Use the provided colors array
-                    return color[reverseIndex % color.length];
-                } else {
-                    // If data index is invalid, use the default chart colors
-                    return chart.get("colors").getIndex(series.dataItems.indexOf(target.dataItem));
-                }
-            });
+                        // Use the provided colors array
+                        return color[reverseIndex % color.length];
+                    } else {
+                        // If data index is invalid, use the default chart colors
+                        return chart.get("colors").getIndex(series.dataItems.indexOf(target.dataItem));
+                    }
+                }); */
 
-            // series.columns.template.adapters.add("stroke", (stroke, target) => {
-            //     return chart.get("colors").getIndex(series.columns.indexOf(target));
-            // });
+                series.columns.template.adapters.add("stroke", (stroke, target) => {
+                return chart.get("colors").getIndex(series.columns.indexOf(target));
+                });
+
+                series.data.setAll(data);
+                series.appear(1000);
+            }
+            
 
             let lineSeries = chart.series.push(
                 am5xy.LineSeries.new(root, {
                     name: "평균",
                     xAxis: xAxis,
                     yAxis: yAxis,
-                    valueYField: "quantity",
+                    valueYField: "average",
                     sequencedInterpolation: true,
                     stroke: chart.get("colors").getIndex(13),
                     fill: chart.get("colors").getIndex(13),
-                    categoryXField: "category",
+                    categoryXField: "city",
                     tooltip: am5.Tooltip.new(root, {
-                        labelText: "{name}{valueY}"
+                        labelText: "평균 : {valueY}"
                     })
                 })
             );
@@ -182,93 +205,94 @@
                     }
                 });
             });
-
-            let chartData = [];
+            
+            lineSeries.data.setAll(data);
+            lineSeries.appear(1000);
+            // let chartData = [];
 
             // process data ant prepare it for the chart
-            for (var providerName in data) {
-                //첫번째 데이터 
-                let providerData = data[providerName];
+            // for (var providerName in data) {
+            //     //첫번째 데이터 
+            //     let providerData = data[providerName];
 
 
-                // add data of one provider to temp array
-                let tempArray = [];
-                let count = 0;
-                // add items
-                for (var itemName in providerData) {
-                    if (itemName != "quantity") {
-                        count++;
-                        // we generate unique category for each column (providerName + "_" + itemName) and store realName
-                        tempArray.push({
-                            name: itemName + count,
-                            category: providerName + "_" + itemName,
-                            realName: itemName,
-                            value: providerData[itemName],
-                            provider: providerName
-                        });
-                    }
-                }
-                // sort temp array
-                tempArray.sort(function (a, b) {
-                    if (a.value > b.value) {
-                        return 1;
-                    } else if (a.value < b.value) {
-                        return -1;
-                    } else {
-                        return 0;
-                    }
-                });
+            //     // add data of one provider to temp array
+            //     let tempArray = [];
+            //     let count = 0;
+            //     // add items
+            //     for (var itemName in providerData) {
+            //         if (itemName != "quantity") {
+            //             count++;
+            //             // we generate unique category for each column (providerName + "_" + itemName) and store realName
+            //             tempArray.push({
+            //                 name: itemName + count,
+            //                 category: providerName + "_" + itemName,
+            //                 realName: itemName,
+            //                 value: providerData[itemName],
+            //                 provider: providerName
+            //             });
+            //         }
+            //     }
+            //     // sort temp array
+            //     tempArray.sort(function (a, b) {
+            //         if (a.value > b.value) {
+            //             return 1;
+            //         } else if (a.value < b.value) {
+            //             return -1;
+            //         } else {
+            //             return 0;
+            //         }
+            //     });
+                
+            //     console.log("chart data: ", tempArray);
+            //     // add quantity and count to middle data item (line series uses it)
+            //     let lineSeriesDataIndex = Math.floor(count / 2);
+            //     tempArray[lineSeriesDataIndex].quantity = providerData.quantity;
+            //     tempArray[lineSeriesDataIndex].count = count;
+            //     // push to the final data
+            //     am5.array.each(tempArray, function (item) {
+            //         chartData.push(item);
+            //     });
 
-                // add quantity and count to middle data item (line series uses it)
-                let lineSeriesDataIndex = Math.floor(count / 2);
-                tempArray[lineSeriesDataIndex].quantity = providerData.quantity;
-                tempArray[lineSeriesDataIndex].count = count;
-                // push to the final data
-                am5.array.each(tempArray, function (item) {
-                    chartData.push(item);
-                });
+            //     // create range (the additional label at the bottom)
 
-                // create range (the additional label at the bottom)
+            //     let range = xAxis.makeDataItem({});
+            //     xAxis.createAxisRange(range);
 
-                let range = xAxis.makeDataItem({});
-                xAxis.createAxisRange(range);
+            //     range.set("category", tempArray[0].category);
+            //     range.set("endCategory", tempArray[tempArray.length - 1].category);
 
-                range.set("category", tempArray[0].category);
-                range.set("endCategory", tempArray[tempArray.length - 1].category);
+            //     let label = range.get("label");
 
-                let label = range.get("label");
+            //     label.setAll({
+            //         text: tempArray[0].provider,
+            //         dy: 0,
+            //         fontWeight: "bold",
+            //         tooltipText: tempArray[0].provider
+            //     });
 
-                label.setAll({
-                    text: tempArray[0].provider,
-                    dy: 0,
-                    fontWeight: "bold",
-                    tooltipText: tempArray[0].provider
-                });
+            //     // let tick = range.get("tick");
+            //     // tick.setAll({ visible: true, strokeOpacity: 1, length: 50, location: 0 });
 
-                // let tick = range.get("tick");
-                // tick.setAll({ visible: true, strokeOpacity: 1, length: 50, location: 0 });
+            //     let grid = range.get("grid");
+            //     grid.setAll({ strokeOpacity: 1 });
+            // }
 
-                let grid = range.get("grid");
-                grid.setAll({ strokeOpacity: 1 });
-            }
+            // // add range for the last grid
+            // let range = xAxis.makeDataItem({});
+            // xAxis.createAxisRange(range);
+            // range.set("category", chartData[chartData.length - 1].category);
+            // // let tick = range.get("tick");
+            // // tick.setAll({ visible: true, strokeOpacity: 1, length: 50, location: 1 });
 
-            // add range for the last grid
-            let range = xAxis.makeDataItem({});
-            xAxis.createAxisRange(range);
-            range.set("category", chartData[chartData.length - 1].category);
-            // let tick = range.get("tick");
-            // tick.setAll({ visible: true, strokeOpacity: 1, length: 50, location: 1 });
-
-            let grid = range.get("grid");
-            grid.setAll({ strokeOpacity: 1, location: 1 });
+            // let grid = range.get("grid");
+            // grid.setAll({ strokeOpacity: 1, location: 1 });
 
 
 
-            xAxis.data.setAll(chartData);
-            series.data.setAll(chartData);
-            lineSeries.data.setAll(chartData);
+            
 
-            console.log("::::",series.data._values)
+            // console.log("::::",series.data._values)
             let legend = chart.children.unshift(am5.Legend.new(root, {
                 x: am5.percent(100), // 범례 중심 위치 (50: 중앙)
                 centerX: am5.percent(80), // 범례 중심 위치 (50: 중앙)
@@ -281,13 +305,13 @@
 
             // Make stuff animate on load
             // https://www.amcharts.com/docs/v5/concepts/animations/
-            series.appear(1000);
+            
             chart.appear(1000, 100);
         }
     },
     watch: {
-        'setData': function (newData) {  
-            this.chartCreate(newData, this.color)
+        'setData': function (newData) { 
+            this.chartCreate(newData, this.mapping, this.columnX, this.color)
         }
     },
     computed: {
client/views/components/NetworkingChart.vue
--- client/views/components/NetworkingChart.vue
+++ client/views/components/NetworkingChart.vue
@@ -55,8 +55,8 @@
                 singleBranchOnly: false,
                 downDepth: 1,
                 initialDepth: 2,
-                valueField: "value",
-                categoryField: "name",
+                valueField: "average",
+                categoryField: "city",
                 childDataField: "children",
                 centerStrength: 0.5,
                 minRadius: 20,
@@ -113,7 +113,6 @@
     },
     watch: {
         'setData': function (newData) {
-            console.log('newData  -  ', newData)
             this.chartCreate(newData)
         }
     },
client/views/components/PeiChart.vue
--- client/views/components/PeiChart.vue
+++ client/views/components/PeiChart.vue
@@ -51,8 +51,8 @@
             // Create series
             // https://www.amcharts.com/docs/v5/charts/percent-charts/pie-chart/#Series
             let series = chart.series.push(am5percent.PieSeries.new(root, {
-                valueField: "value",
-                categoryField: "category"
+                valueField: "city_count",
+                categoryField: "city"
             }));
 
 
@@ -92,7 +92,6 @@
     },
     watch: {
         'setData': function (newData) {
-            console.log('newData  -  ', newData)
             this.chartCreate(newData)
         }
     },
client/views/components/VerticalBarChart.vue
--- client/views/components/VerticalBarChart.vue
+++ client/views/components/VerticalBarChart.vue
@@ -84,10 +84,9 @@
 
             let yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
                 maxDeviation: 0.3,
-                min: 0,
                 renderer: am5xy.AxisRendererY.new(root, {
                     strokeOpacity: 0.1,
-                    inversed: true
+                    inversed: false
                 })
             }));
 
client/views/pages/Main/Main.vue
--- client/views/pages/Main/Main.vue
+++ client/views/pages/Main/Main.vue
@@ -11,23 +11,23 @@
                 <div class="chart-title">
                     <div class="flex">
                         <p>월별 평균 길이 Z축 마모</p>
-                        <select name="" id="">
+                        <select name="" id="" v-model="month_tl_no" @change="monthChange()">
                             <option v-for="(tool, index) in tools" :key="index" :value="tool">{{ tool }}</option>
                         </select>
                     </div>
                 </div>
-                <VerticalBarChart :chartData="emptyData" xField="month" yField="value" />
+                <VerticalBarChart :chartData="monthData" xField="ormpm_month" yField="avg_ofs5" />
             </div>
             <div class="content-box">
                 <div class="chart-title">
                     <div class="flex">
                         <p>시간대별 평균 길이 Z축 마모</p>
-                        <select name="" id="">
+                        <select name="" id="" v-model="time_tl_no" @change="timeChange()">
                             <option v-for="(tool, index) in tools" :key="index" :value="tool">{{ tool }}</option>
                         </select>
                     </div>
                 </div>
-                <VerticalBarChart :chartData="emptyTimeData" :xField="'time'" :yField="'value'" :color="['#1c7ed6','#74c0fc','#1864ab']" />
+                <VerticalBarChart :chartData="timeData" :xField="'ormpm_hour'" :yField="'avg_ofs5'" :color="['#1c7ed6','#74c0fc','#1864ab']" />
             </div>
             <div class="content-box">
                 <div class="chart-title">
@@ -35,7 +35,7 @@
                         <p>가동시간에 따른 각 툴별(도구) 길이 Z축 마모</p>
                     </div>
                 </div>
-                <LineChart :chartData="emptyLineData" :keyMapping="lineDataKeyMapping" :xField="lineDataKeyMapping.date" />
+                <LineChart :chartData="toolZWearData" :xField="'search_date'" />
             </div>
             <div class="content-box">
                 <div class="chart-title">
@@ -43,7 +43,7 @@
                         <p>가동시간에 따른 각 툴별(도구) 길이 X축 형상마모</p>
                     </div>
                 </div>
-                <LineChart :chartData="emptyLineData" :keyMapping="lineDataKeyMapping" :xField="lineDataKeyMapping.date" />
+                <LineChart :chartData="toolXWearData" :xField="'search_date'" />
             </div>
         </div>
     </div>
@@ -52,44 +52,85 @@
 <script>
 import VerticalBarChart from '../../components/VerticalBarChart.vue';
 import LineChart from '../../components/LineChart.vue';
+import axios from 'axios';
 
 export default {
     data() {
         return {
-            tools: ["T1", "T2", "T3", "T4", "T5"],
+            tools: ["T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8"],
+            month_tl_no: "T4",
+            time_tl_no: "T4",
             // 월별 데이터
             emptyData: [],
-            monthToolData: [
-                { month: "2023.11", value: 300 }
-
-            ],
+            monthData: [],
             // 시간대별
-            emptyTimeData: [],
-            timeData: [
-                { time: "01", value: 300 },
-                { time: "02", value: 300 },
-                { time: "03", value: 300 },
-                { time: "04", value: 300 },
-                { time: "05", value: 300 },
-                { time: "06", value: 300 },
-                { time: "07", value: 300 },
-            ],
-            // z축 마모 라인 데이터,
-            lineDataKeyMapping: {
-                date: "날짜",
-                value1: "T1",
-                value2: "T2",
-                value3: "T3",
-            },
-            emptyLineData: [],
-            lineData: [
-                { date: "2023-01-01", value1: 10, value2: 20, value3: 50 },
-                { date: "2023-01-02", value1: 15, value2: 25, value3: 50 },
-                { date: "2023-01-03", value1: 20, value2: 30, value3: 50 },
-            ]
+            timeData: [],
+
+            toolZWearData: [],
+
+            toolXWearData: [],
         }
     },
     methods: {
+        timeZWear: function(){
+            const vm = this;
+            axios({
+                url: '/hwaSin/timeZWear.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+                data: {tl_no : vm.time_tl_no}
+            }).then(function(response) {
+                vm.timeData = response.data;
+            }).catch(function() {
+                alert("시간대별 평균 길이 Z축 마모 조회 오류, 관리자에게 문의 바랍니다.")
+            })
+        },
+
+        timeChange: function() {
+            this.timeZWear();
+        },
+
+        monthZWear: function(){
+            const vm = this;
+            axios({
+                url: '/hwaSin/monthZWear.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+                data: {tl_no : vm.month_tl_no}
+            }).then(function(response) {
+                vm.monthData = response.data;
+            }).catch(function() {
+                alert("월별 평균 길이 Z축 마모 조회 오류, 관리자에게 문의 바랍니다.")
+            })
+        },
+        
+        monthChange: function() {
+            this.monthZWear();
+        },
+
+        toolWear: function() {
+            const vm = this;
+
+            axios({
+                url: '/hwaSin/toolWear.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+            }).then(function(response) {
+                vm.toolZWearData = response.data.toolZWear;
+                vm.toolXWearData = response.data.toolXWear;
+            }).catch(function() {
+                alert("가동시간에 따른 각 툴별(도구) 길이 Z축 마모 조회 오류, 관리자에게 문의 바랍니다.")
+            })
+        },
+
+
+
         dataSet: function () {
             this.emptyData = this.monthToolData;
             this.emptyTimeData = this.timeData;
@@ -107,6 +148,9 @@
     },
     mounted() {
         this.dataSet();
+        this.timeZWear();
+        this.monthZWear();
+        this.toolWear();
     }
 }
 </script>
client/views/pages/transit/Transit.vue
--- client/views/pages/transit/Transit.vue
+++ client/views/pages/transit/Transit.vue
@@ -11,84 +11,29 @@
                 <div class="chart-title">
                     <div class="flex">
                         <p>각 시도별 평균, 최소, 최대 이동거리</p>
-                        <select name="" id="">
-                            <option v-for="(month, index) in months" :key="index" :value="month">{{ month }}</option>
+                        <select name="" id="" v-model="distanceMonth" @change="distanceMonthChange()">
+                            <option :value=null disabled>전체</option>
+                            <option v-for="(month, index) in months" :key="index" :value="month">{{ month }}월</option>
                         </select>
                     </div>
                 </div>
-                <MultiBarChart :setData="emptyData" :color="['#339af0','#e67700']" />
-                <table>
+                <MultiBarChart :setData="distanceList" :mapping="keyMapping" columnX="city" :color="['#e67700', '#339af0']" />
+                <table v-if="distanceList.length != 0">
                     <tr>
                         <th></th>
-                        <th>경기</th>
-                        <th>경남</th>
-                        <th>경북</th>
-                        <th>광주</th>
-                        <th>대구</th>
-                        <th>대전</th>
-                        <th>부산</th>
-                        <th>서울</th>
-                        <th>울산</th>
-                        <th>인천</th>
-                        <th>전남</th>
-                        <th>전북</th>
-                        <th>제주</th>
-                        <th>충남</th>
-                        <th>충북</th>
-                    </tr>
-                    <tr>
-                        <th class="min-title">최소</th>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                    </tr>
-                    <tr>
-                        <th class="avg-title">평균</th>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
+                        <th v-for="(item, index) in distanceList" :key="index">{{ item.city }}</th>
                     </tr>
                     <tr>
                         <th class="max-title">최대</th>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
+                        <td v-for="(item, index) in distanceList" :key="index">{{ item.maximum }}</td>
+                    </tr>
+                    <tr>
+                        <th class="avg-title">평균</th>
+                        <td v-for="(item, index) in distanceList" :key="index">{{ item.average }}</td>
+                    </tr>
+                    <tr>
+                        <th class="min-title">최소</th>
+                        <td v-for="(item, index) in distanceList" :key="index">{{ item.minimum }}</td>
                     </tr>
                 </table>
             </div>
@@ -96,84 +41,29 @@
                 <div class="chart-title">
                     <div class="flex">
                         <p>각 시도별 평균, 최소, 최대 소요시간</p>
-                        <select name="" id="">
-                            <option v-for="(month, index) in months" :key="index" :value="month">{{ month }}</option>
+                        <select name="" id="" v-model="timeMonth" @change="useTimeMonthChange()">
+                            <option :value=null disabled>전체</option>
+                            <option v-for="(month, index) in months" :key="index" :value="month">{{ month }}월</option>
                         </select>
                     </div>
                 </div>
-                <MultiBarChart :setData="emptyData" :color="['#339af0','#e67700']" />
-                <table>
+                <MultiBarChart :setData="useTimeList" :mapping="keyMapping" columnX="city" :color="['#e67700', '#339af0']" />
+                <table v-if="useTimeList.length != 0">
                     <tr>
                         <th></th>
-                        <th>경기</th>
-                        <th>경남</th>
-                        <th>경북</th>
-                        <th>광주</th>
-                        <th>대구</th>
-                        <th>대전</th>
-                        <th>부산</th>
-                        <th>서울</th>
-                        <th>울산</th>
-                        <th>인천</th>
-                        <th>전남</th>
-                        <th>전북</th>
-                        <th>제주</th>
-                        <th>충남</th>
-                        <th>충북</th>
-                    </tr>
-                    <tr>
-                        <th class="min-title">최소</th>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                    </tr>
-                    <tr>
-                        <th class="avg-title">평균</th>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
+                        <th v-for="(item, index) in useTimeList" :key="index">{{ item.city }}</th>
                     </tr>
                     <tr>
                         <th class="max-title">최대</th>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
-                        <td>0</td>
+                        <td v-for="(item, index) in useTimeList" :key="index">{{ item.maximum }}</td>
+                    </tr>
+                    <tr>
+                        <th class="avg-title">평균</th>
+                        <td v-for="(item, index) in useTimeList" :key="index">{{ item.average }}</td>
+                    </tr>
+                    <tr>
+                        <th class="min-title">최소</th>
+                        <td v-for="(item, index) in useTimeList" :key="index">{{ item.minimum }}</td>
                     </tr>
                 </table>
             </div>
@@ -183,7 +73,7 @@
                         <p>지역별 배송 건수</p>
                     </div>
                 </div>
-                <PieChart :setData="emptyPieData" />
+                <PieChart :setData="deliveriesCountList" />
             </div>
             <div class="content-box">
                 <div class="chart-title">
@@ -191,7 +81,7 @@
                         <p>지역별 평균 이동 시간</p>
                     </div>
                 </div>
-                <NetworkingChart :setData="emptyNetData"  />
+                <NetworkingChart :setData="travelTimeList" />
             </div>
         </div>
     </div>
@@ -199,134 +89,106 @@
 
 <script>
 
-import MultiBarChart from '../../components/MultiBarChart.vue'
-import PieChart from '../../components/PeiChart.vue'
-import NetworkingChart from '../../components/NetworkingChart.vue'
+import MultiBarChart from '../../components/MultiBarChart.vue';
+import PieChart from '../../components/PeiChart.vue';
+import NetworkingChart from '../../components/NetworkingChart.vue';
+import axios from 'axios';
 
 export default {
     data() {
         return {
-            months: ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
-            // 이동 거리 및 소요시간 더미 데이터
-            emptyData: {},
-            distanceData: {
-                경기: {
-                    min: 10,
-                    max: 35,
-                    quantity: 430
-                },
-                경남: {
-                    min: 15,
-                    max: 21,
-                    quantity: 210
-                },
-                경북: {
-                    min: 25,
-                    max: 11,
-                    quantity: 265
-                },
-                광주: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                대구: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                대전: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                부산: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                서울: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                울산: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                인천: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                전남: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                전북: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                제주: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                충남: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                },
-                충북: {
-                    min: 12,
-                    max: 15,
-                    quantity: 98
-                }
+            months: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
+
+            keyMapping : {
+                maximum: '최대',
+                minimum: '최소',
+                average: '평균'
             },
-            // 파이차트 데이터
-            emptyPieData: [],
-            pieData: [
-                { value: 10, category: "One" },
-                { value: 9, category: "Two" },
-                { value: 6, category: "Three" },
-                { value: 5, category: "Four" },
-                { value: 4, category: "Five" },
-                { value: 3, category: "Six" },
-                { value: 1, category: "Seven" }
-            ],
-            // 네트워크 데이터
-            emptyNetData: [],
-            netData: {
-                name: "경북영천시고경면삼포리",
-                children: [
-                    { name: "경기", value: 320 },
-                    { name: "경남", value: 160 },
-                    { name: "경북", value: 40 },
-                    { name: "광주", value: 350 },
-                    { name: "대구", value: 90 },
-                    { name: "대전", value: 250 },
-                    { name: "부산", value: 120 },
-                    { name: "서울", value: 360 },
-                    { name: "울산", value: 85 },
-                    { name: "인천", value: 370 },
-                    { name: "전남", value: 400 },
-                    { name: "전북", value: 300 },
-                    { name: "제주", value: 600 },
-                    { name: "충남", value: 280 },
-                    { name: "충북", value: 230 }
-                ]
-            }
+
+            distanceMonth: null,
+            timeMonth: null,
+
+            distanceList: [],
+            useTimeList: [],
+            deliveriesCountList: [],
+            travelTimeList: {},
         }
     },
     methods: {
-        dataSet: function () {
-            this.emptyData = this.distanceData;
-            this.emptyPieData = this.pieData;
-           this.emptyNetData=this.netData;
-        }
+        travelDistance: function(){
+            const vm = this;
+            axios({
+                url: '/meatKorea/travelDistance.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+                data: {distanceMonth : vm.distanceMonth}
+            }).then(function(response) {
+                vm.distanceList = response.data;
+                console.log('distanceList', vm.distanceList.length)
+            }).catch(function() {
+                alert("각 시도별 평균, 최소, 최대 이동거리 조회 오류, 관리자에게 문의 바랍니다.")
+            })
+        },
+        
+        distanceMonthChange: function() {
+            this.travelDistance();
+        },
+
+        useTime: function(){
+            const vm = this;
+            axios({
+                url: '/meatKorea/useTime.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+                data: {timeMonth : vm.timeMonth}
+            }).then(function(response) {
+
+                vm.useTimeList = response.data;
+            }).catch(function() {
+                alert("각 시도별 평균, 최소, 최대 소요시간 조회 오류, 관리자에게 문의 바랍니다.")
+            })
+        },
+
+        useTimeMonthChange: function() {
+            this.useTime();
+        },
+
+        deliveriesCount: function(){
+            const vm = this;
+            axios({
+                url: '/meatKorea/deliveriesCount.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+            }).then(function(response) {
+                vm.deliveriesCountList = response.data;
+            }).catch(function() {
+                alert("지역별 배송 건수 조회 오류, 관리자에게 문의 바랍니다.")
+            })
+        },
+
+        travelTime: function(){
+            const vm = this;
+            axios({
+                url: '/meatKorea/travelTime.json',
+                method: 'post',
+                hearder: {
+                    'Content-Type': "application/json; charset=UTF-8",
+                },
+            }).then(function(response) {
+                const travelTime = {};
+                travelTime.city = '경북영천시고경면삼포리';
+                travelTime.children = response.data;
+                vm.travelTimeList = travelTime;
+            }).catch(function() {
+                alert("지역별 평균 이동 시간 조회 오류, 관리자에게 문의 바랍니다.")
+            })
+        },
     },
     watch: {
 
@@ -338,7 +200,10 @@
         'NetworkingChart':NetworkingChart
     },
     mounted() {
-        this.dataSet();
+        this.travelDistance();
+        this.useTime();
+        this.deliveriesCount();
+        this.travelTime();
     }
 }
 </script>
Add a comment
List