diff --git a/src/views/statistics/hunliao.vue b/src/views/statistics/hunliao.vue index ce2e7be9..4ace7d6f 100644 --- a/src/views/statistics/hunliao.vue +++ b/src/views/statistics/hunliao.vue @@ -20,7 +20,9 @@ -
+
+
+
@@ -100,13 +102,14 @@ export default { text: '', }, grid: { - top: '80px' + top: '150px' }, tooltip: { trigger: 'axis' }, legend: { - top: 30 + top: 30, + left: 10, }, xAxis: { type: 'category', @@ -170,7 +173,8 @@ export default { } setTimeout(() => { try { - myChart.setOption(option); + myChart.clear(); + myChart.setOption(option, true); } catch (error) { } }, 500) }, @@ -230,13 +234,13 @@ export default { }) let seriesData = []; for (let i = 0; i < dateLabels.length; i++) { - seriesData.push(new Array(nameList.length).fill(0)); + seriesData.push(new Array(modelList.length).fill(0)); } dataList.forEach(item => { let indexX = 0, indexY = 0; if (that.queryType == '月') { indexX = item.周 - that.firstWeekNum; - indexY = nameList.indexOf(item.物料名); + indexY = modelList.indexOf(item.型号); if(dateList.indexOf(item.周)>-1){}else{ dateList.push(item.周); let obj = {}; @@ -247,21 +251,29 @@ export default { } else { that.dateFilters = [1,2,3,4,5,6,7,8,9,10,11,12]; indexX = item.月 - 1; - indexY = nameList.indexOf(item.物料名); + indexY = modelList.indexOf(item.型号); } if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) { seriesData[indexX][indexY] += item.合格数; } }); - option.xAxis.data = nameList; + option.xAxis.data = modelList; for (let n = 0; n < seriesData.length; n++) { let obj = {}; obj.name = dateLabels[n]; obj.type = 'bar'; - obj.barWidth = '15px'; + obj.barWidth = '10px'; obj.data = seriesData[n]; option.series.push(obj) } + let chartDom = document.getElementById('bachart1'); + if (chartDom) { + let parentWidth = that.$refs.chartScroll ? that.$refs.chartScroll.clientWidth : chartDom.parentElement.clientWidth; + let needWidth = modelList.length * dateLabels.length * 15; + chartDom.style.width = Math.max(parentWidth, needWidth) + 'px'; + let inst = echarts.getInstanceByDom(chartDom); + if (inst) inst.resize(); + } that.setChart("bachart1", option); } else { option.xAxis.data = []; @@ -366,4 +378,8 @@ export default { right: 8px; z-index: 10; } +.chart-scroll { + width: 100%; + overflow-x: auto; +}