king
2021-05-24 f267d04e0561a0a20d1f2a9f558a273558ece90d
src/tabviews/custom/components/chart/antv-dashboard/index.jsx
@@ -86,12 +86,7 @@
      _sync = false
    }
    if (_config.style) {
      _config.style = {..._config.style, minHeight: (config.plot.height || 400)}
    } else {
      _config.style = {minHeight: (config.plot.height || 400)}
    }
    _config.style.height = config.plot.height || 400
    this.setState({
      config: _config,
@@ -164,16 +159,7 @@
    if (!config.timer) return
    const _change = {
      '15s': 15000,
      '30s': 30000,
      '1min': 60000,
      '5min': 300000,
      '10min': 600000,
      '15min': 900000,
      '30min': 1800000,
      '1hour': 3600000
    }
    const _change = { '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 }
    let timer = _change[config.timer]
@@ -268,6 +254,14 @@
      })
    }
    let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
    if (requireFields.length > 0) {
      this.setState({
        loading: false
      })
      return
    }
    if (!hastimer) {
      this.setState({
        loading: true
@@ -304,27 +298,33 @@
  }
  /**
   * @description 饼图渲染
   * @description 仪表盘渲染
   */
  dashboardrender = () => {
    const { plot, chartId, data } = this.state
    let _data = fromJS(data).toJS()
    if (_data.value && _data.value > plot.maxValue) {
      _data.value = plot.maxValue
    }
    const chart = new Chart({
      container: chartId,
      autoFit: true,
      height: plot.height ? (plot.height - 80) : 320,
      padding: [0, 0, 0, 0],
    })
    chart.data([data]);
    chart.data([_data]);
    chart.scale('value', {
      min: 0,
      max: plot.maxValue,
      tickInterval: plot.tickInterval,
    });
    })
    chart.coordinate('polar', {
      startAngle: (-9 / 8) * Math.PI,
      endAngle: (1 / 8) * Math.PI,
      radius: 0.75,
    });
    })
    chart.axis('1', false);
    chart.axis('value', {
@@ -345,9 +345,9 @@
        }
      },
      grid: null,
    });
    chart.legend(false);
    chart.tooltip(false);
    })
    chart.legend(false)
    chart.tooltip(false)
    chart
      .point()
      .position('value*1')
@@ -371,7 +371,7 @@
        appear: {
          animation: 'fade-in'
        }
      });
      })
    // 绘制仪表盘背景
    chart.annotation().arc({
@@ -394,7 +394,7 @@
          lineWidth: 18,
          lineDash: null,
        },
      });
      })
    } else {
      let start = 0
      plot.colors.forEach(item => {
@@ -438,7 +438,7 @@
          textAlign: 'center',
        },
        offsetY: 15,
      });
      })
    }
    chart.render()