| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <template>
- <div class="unsafe-position-chart">
- <div class="chart-container" ref="positionChart"></div>
- <div class="position-info">
- <div class="info-text">X光机操作员: {{ chartsData.total }}</div>
- </div>
- </div>
- </template>
- <script>
- import * as echarts from 'echarts'
- export default {
- name: 'UnsafePositionChart',
- props: {
- chartsData: {
- type: Object,
- default: () => ({
- total: 279,
- positions: {
- labels: ['X光机', '开包台', '引导岗', '验证岗', '维序岗'],
- data: [279, 0, 0, 0, 0]
- }
- })
- }
- },
- data() {
- return {
- chart: null
- }
- },
- mounted() {
- this.$nextTick(() => {
- this.initChart()
- })
- },
- watch: {
- chartsData: {
- deep: true,
- handler() {
- this.$nextTick(() => {
- if (this.chart) this.chart.dispose()
- this.initChart()
- })
- }
- }
- },
- methods: {
- initChart() {
- if (!this.$refs.positionChart) return
- this.chart = echarts.init(this.$refs.positionChart)
- const option = {
- responsive: true,
- maintainAspectRatio: false,
- grid: {
- left: '15%',
- right: '5%',
- bottom: '15%',
- top: '10%'
- },
- xAxis: {
- type: 'category',
- data: this.chartsData.positions.labels,
- axisLine: {
- lineStyle: {
- color: 'rgba(255, 255, 255, 0.1)'
- }
- },
- axisLabel: {
- color: 'rgba(255, 255, 255, 0.5)',
- fontSize: 10,
- // rotate: 30
- }
- },
- yAxis: {
- type: 'value',
- axisLine: {
- show: false
- },
- axisTick: {
- show: false
- },
- splitLine: {
- lineStyle: {
- color: 'rgba(255, 255, 255, 0.05)'
- }
- },
- axisLabel: {
- color: 'rgba(255, 255, 255, 0.5)',
- fontSize: 10
- }
- },
- series: [{
- type: 'bar',
- data: this.chartsData.positions.data,
- itemStyle: {
- color: {
- type: 'linear',
- x: 0,
- y: 0,
- x2: 0,
- y2: 1,
- colorStops: [{
- offset: 0, color: '#F472B6'
- }, {
- offset: 1, color: '#DB2777'
- }]
- }
- },
- barWidth: '60%'
- }]
- }
- this.chart.setOption(option)
- }
- },
- beforeDestroy() {
- if (this.chart) this.chart.dispose()
- }
- }
- </script>
- <style lang="scss" scoped>
- .unsafe-position-chart {
- .chart-container {
- height: 240rpx;
- }
-
- .position-info {
- margin-top: 16rpx;
- text-align: center;
-
- .info-text {
- font-size: 24rpx;
- color: rgba(255, 255, 255, 0.5);
- }
- }
- }
- </style>
|