Mr.Zhang
2023-08-22 14e73128bfa02922fdcf9591ee6d5fd6b6f7a5c6
不良品饼图
已修改1个文件
170 ■■■■■ 文件已修改
screen_standard/src/views/process.vue 170 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen_standard/src/views/process.vue
@@ -141,6 +141,14 @@
  { date: '8/6', num: '10' },
  { date: '8/7', num: '20' },
])
let typeDistribution = reactive([
  { name: '外观不良', num: 15 },
  { name: '有毛刺', num: 12 },
  { name: '尺寸不良', num: 22 },
  { name: '有划痕', num: 5 },
  { name: '其他', num: 2 },
])
// start()
onBeforeUnmount(() => {
  clearTimeout(planTimer.value)
@@ -148,9 +156,10 @@
})
onMounted(() => {
  nextTick(() => {
    // start()
    // reportStart()
    start()
    reportStart()
    setDayChart()
    setTypeChart()
  })
})
@@ -241,7 +250,9 @@
    }
  }
}
/** */
/**
 * 七日折线图
 */
function setDayChart() {
  let dayChartDom = document.getElementById('day-distribution');
  let myChart = echarts.init(dayChartDom);
@@ -326,69 +337,94 @@
      textStyle: {
        color: '#fff'
      }
    },
    // xAxis: {
    //   type: 'category',
    //   boundaryGap: false,
    //   axisLabel: {
    //     textStyle: {
    //       color: '#fff'
    //     }
    //   },
    //   axisLine: {
    //     lineStyle: {
    //       color: '#fff'
    //     }
    //   }
    // },
    // yAxis: {
    //   type: 'value',
    //   boundaryGap: [0, '30%'],
    //   splitLine: {
    //     lineStyle: {
    //       width: 0.5,
    //       color: ['#fff']
    //     }
    //   },
    //   axisLabel: {
    //     textStyle: {
    //       color: '#fff'
    //     }
    //   }
    // },
    // visualMap: {
    //   type: 'piecewise',
    //   show: false,
    //   dimension: 0,
    //   seriesIndex: 0,
    // },
    // series: [
    //   {
    //     type: 'line',
    //     smooth: 0.6,
    //     symbol: 'none',
    //     lineStyle: {
    //       color: '#03D2B5',
    //       width: 1
    //     },
    //     areaStyle: {
    //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    //         {
    //           offset: 0,
    //           color: 'rgba(3, 210, 181, .9)',
    //         },
    //         {
    //           offset: 1,
    //           color: 'rgba(3, 210, 181, 0)',
    //         }
    //       ])
    //     },
    //     data: dateList
    //   }
    // ]
    }
  }
  option && myChart.setOption(option);
}
/**
 * 不良类型分布
 */
function setTypeChart() {
  let dayChartDom = document.getElementById('type-distribution');
  let myChart = echarts.init(dayChartDom);
  let legendData = []
  let seriesData = []
  typeDistribution.forEach(item => {
    legendData.push(item.name)
    seriesData.push({name:item.name, value:item.num})
  })
  let option = {
    // title: {
    //   text: '同名数量统计',
    //   subtext: '纯属虚构',
    //   left: 'center'
    // },
    // tooltip: {
    //   trigger: 'item',
    //   formatter: '{a} <br/>{b} : {c} ({d}%)'
    // },
    legend: {
      show: false,
      type: 'scroll',
      orient: 'vertical',
      right: 10,
      top: 20,
      bottom: 20,
      data: legendData
    },
    series: [
      {
        // name: '姓名',
        type: 'pie',
        radius: ['60%', '70%'],
        // avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 4,
          borderColor: 'rgba(52, 88, 159, 0.4)',
          borderWidth: 4
        },
        center: ['50%', '50%'],
        labelLine: {
          show: false
        },
        label: {
          formatter:'{dot| } {title|{b} {c}}\n\n{per|{d}%}',
          rich: {
            title: {
              color: '#fff'
            },
            per: {
              color: '#01D9FE'
            },
            dot: {
              backgroundColor: 'inherit',
              width: 8,
              height: 8,
              borderRadius: 4
            }
          }
        },
        // labelLayout: {
        //   hideOverlap: true
        // },
        endLabel: {
          show: true,
          distance: 5,
          color: "red"
        },
        data: seriesData,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 1)'
          }
        }
      }
    ]
  }
  option && myChart.setOption(option);
}
</script>
@@ -525,15 +561,18 @@
    .bad-diagram {
      height: 222px;
      background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%);
      .bad-content {
        display: flex;
        margin-top: 20px;
        #day-distribution {
          // padding: 20px;
          box-sizing: border-box;
          flex: 0.5;
          height: 190px;
        }
        #type-distribution {
          flex: 0.4;
        }
@@ -609,5 +648,4 @@
      }
    }
  }
}
</style>
}</style>