utils.js 19.8 KB
Newer Older
1
import moment from 'moment';
程恺文's avatar
程恺文 committed
2
import _, { isArray } from 'lodash';
3

4
/** 轴宽度, 用于计算多轴显示时, 轴线偏移和绘图区域尺寸 */
5
const axisWidth = 40;
陈龙's avatar
陈龙 committed
6
const COLOR = {
程恺文's avatar
程恺文 committed
7 8 9 10 11 12 13 14
  NORMAL: '#1685FF',
  UPER: '#fa8c16',
  UPUPER: '#FF0000',
  // LOWER: '#13c2c2',
  // LOWLOWER: '#2f54eb',
  LOWER: '#fa8c16',
  LOWLOWER: '#FF0000',
  AVG: '#00B8B1',
陈龙's avatar
陈龙 committed
15
};
16 17
/**
 * 图表系列名称格式化
18 19
 *
 * @param {any} data
20
 * @param {boolean} contrast 是否为同期对比
21 22
 * @param {any} contrastOption 同期对比周期配置, day|month
 * @returns
23
 */
24
const nameFormatter = (data, contrast, contrastOption, nameWithSensor) => {
程恺文's avatar
程恺文 committed
25 26 27 28 29 30 31
  const { equipmentName, sensorName, unit, dataModel, dateFrom, dateTo } = data;
  let name = nameWithSensor ? `${equipmentName}-${sensorName}` : equipmentName;
  if (contrast) {
    const time = dateFrom.slice(0, contrastOption === 'day' ? 10 : 7).replace(/-/g, '');
    name = `${name}-${time}`;
  }
  return name;
32 33 34 35
};

/**
 * 图表系列数据格式化
36 37
 *
 * @param {any} data
38
 * @param {boolean} contrast 是否为同期对比
39
 * @param {any} contrastOption 同期对比周期配置, day|month
40 41 42
 * @returns 图表系列数据, [[DateTime, value]]
 */
const dataAccessor = (data, contrast, contrastOption) => {
程恺文's avatar
程恺文 committed
43 44 45 46 47 48 49 50 51
  const { dataModel } = data;
  let _currentYear = moment().format('YYYY');
  const formatStr =
    contrastOption === 'day' ? `${_currentYear}-01-01 HH:mm:00` : `${_currentYear}-01-DD HH:mm:00`;
  return dataModel
    .filter((item) => item.sensorName !== '是否在线')
    .map((item) => {
      const time = contrast ? moment(item.pt).format(formatStr) : item.pt;
      return [moment(time).valueOf(), item.pv];
52
    });
53 54 55 56
};

/**
 * 面积图配置(目前默认曲线图)
57 58 59
 *
 * @param {any} data 数据项
 * @returns Null/areaStyle, 为null显示曲线图, 为areaStyle对象显示为面积图.
60 61
 */
const areaStyleFormatter = (data) => {
程恺文's avatar
程恺文 committed
62 63
  const { sensorName } = data;
  return sensorName && sensorName.indexOf('流量') > -1 ? {} : null;
64 65
};

66 67 68 69 70 71 72
/**
 * 数据项中指标值最小最大值
 *
 * @param {any} data 数据项
 * @returns
 */
const minMax = (data) => {
程恺文's avatar
程恺文 committed
73 74 75 76 77 78 79 80
  const { dataModel } = data;
  let min = Number.MAX_SAFE_INTEGER;
  let max = Number.MIN_SAFE_INTEGER;
  dataModel.forEach((item) => {
    min = Math.min(min, item.pv ?? 0);
    max = Math.max(max, item.pv ?? 0);
  });
  return [min, max];
81
};
82

83
const markLineItem = (name, value, color) => {
程恺文's avatar
程恺文 committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  return {
    name: name,
    yAxis: value,
    value: value,
    lineStyle: {
      color: color || '#000',
    },
    label: {
      position: 'insideEndTop',
      color: color || '#000',
      formatter: function () {
        return `${name}:${value}`;
      },
    },
  };
99 100 101
};

export const alarmMarkLine = (dataItem, index, dataSource, schemes) => {
程恺文's avatar
程恺文 committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
  // 只有一个数据曲线时显示markline
  if (!dataItem || !schemes || dataSource.length !== 1) return {};
  const { deviceType, stationCode, sensorName, decimalPoint } = dataItem;
  const curSchemes = schemes.filter(
    (item) =>
      item.deviceCode === stationCode &&
      item.sensorName === sensorName &&
      item.valueType === '直接取值',
  );
  const data = [];
  curSchemes.forEach((scheme) => {
    const { hLimit, hhLimit, lLimit, llLimit } = scheme;
    lLimit !== null && lLimit !== void 0 && data.push(markLineItem('低限', lLimit, '#fa8c16'));
    hLimit !== null && hLimit !== void 0 && data.push(markLineItem('高限', hLimit, '#fa8c16'));
    llLimit !== null && llLimit !== void 0 && data.push(markLineItem('低低限', llLimit, '#FF0000'));
    hhLimit !== null && hhLimit !== void 0 && data.push(markLineItem('高高限', hhLimit, '#FF0000'));
  });
  data.push({
    name: '平均线',
    type: 'average',
    lineStyle: {
      color: '#00b8b1',
      type: 'solid',
    },
    label: {
      position: 'insideEndTop',
      color: '#00b8b1',
      formatter: function (param) {
        return `平均值:${param.value}`;
      },
    },
  });
  return {
    symbol: ['none', 'none'],
    data,
  };
138 139
};

140
export const minMaxMarkPoint = (dataItem, index, dataSource) => {
程恺文's avatar
程恺文 committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
  // 只有一个数据曲线时显示markline
  if (!dataItem || dataSource.length !== 1) return {};
  const data = [];
  data.push({ type: 'min', name: '最小: ' });
  data.push({ type: 'max', name: '最大: ' });
  return {
    symbolSize: 1,
    symbolOffset: [0, '50%'],
    label: {
      formatter: '{b|{b} }{c|{c}}',
      backgroundColor:
        window.globalConfig &&
        window.globalConfig &&
        window.globalConfig.variableTheme?.primaryColor
          ? window.globalConfig.variableTheme.primaryColor
          : '#0087F7',
      borderColor: '#ccc',
      borderWidth: 1,
      borderRadius: 4,
      padding: [2, 10],
      lineHeight: 22,
      position: 'top',
      distance: 10,
      rich: {
        b: {
          color: '#fff',
张瑶's avatar
张瑶 committed
167
        },
程恺文's avatar
程恺文 committed
168 169 170 171 172 173 174 175 176
        c: {
          color: '#fff',
          fontSize: 16,
          fontWeight: 700,
        },
      },
    },
    data,
  };
177 178
};

179 180 181 182 183 184
/**
 * 坐标轴添加网格线配置
 *
 * @param {any} axis
 */
export const decorateAxisGridLine = (axis, showGrid) => {
程恺文's avatar
程恺文 committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
  if (!axis) return;
  axis.minorTick = {
    lineStyle: {
      color: '#e2e2e2',
    },
    ...(axis.minorTick || {}),
    show: showGrid,
    splitNumber: 2,
  };
  axis.minorSplitLine = {
    lineStyle: {
      color: '#e2e2e2',
      type: 'dashed',
    },
    ...(axis.minorSplitLine || {}),
    show: showGrid,
  };
  axis.splitLine = {
    ...(axis.splitLine || {}),
    show: showGrid,
  };
206 207
};

张瑶's avatar
张瑶 committed
208 209 210 211 212 213
/**
 * 坐标轴添加离线区间
 *
 * @param {any} dataItem
 */
export const offlineArea = (dataItem) => {
程恺文's avatar
程恺文 committed
214 215 216 217 218 219 220 221 222 223 224
  if (!dataItem) return {};
  const { dataModel } = dataItem;
  let datas = new Array();
  let offlineData = [];
  let hasOffline = false;
  dataModel.forEach((item, index) => {
    if (!item.pv && !hasOffline) {
      offlineData = [
        {
          name: '离线',
          xAxis: new Date(item.pt),
张瑶's avatar
张瑶 committed
225
        },
程恺文's avatar
程恺文 committed
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
      ];
      hasOffline = true;
    } else if (item.pv && hasOffline) {
      offlineData.push({
        xAxis: new Date(item.pt),
      });
      datas.push(offlineData);
      offlineData = [];
      hasOffline = false;
    }
  });
  return {
    itemStyle: {
      color: '#eee',
    },
    data: datas,
  };
张瑶's avatar
张瑶 committed
243 244
};

245 246
/**
 * 图表配置项生成
247 248 249 250 251 252 253
 *
 * @param {any} dataSource 数据源
 * @param {any} cusOption 自定义属性
 * @param {any} contrast 是否为同期对比
 * @param {any} contrastOption 同期对比周期配置, day|month
 * @param {any} smooth Ture/false, 曲线/折线
 * @param {any} config 额外配置信息
254 255
 */
const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth, config) => {
程恺文's avatar
程恺文 committed
256 257 258 259 260 261 262 263 264 265 266 267
  const needUnit = _.get(config, 'needUnit', false);
  const curveCenter = _.get(config, 'curveCenter', false);
  const nameWithSensor = _.get(config, 'nameWithSensor', true);
  const showGridLine = _.get(config, 'showGridLine', true);
  const showMarkLine = _.get(config, 'showMarkLine', false);
  const showPoint = _.get(config, 'showPoint', false);
  const deviceAlarmSchemes = _.get(config, 'deviceAlarmSchemes', []);
  const chartType = _.get(config, 'chartType', null);
  // const justLine = _.get(config, 'justLine', false);
  const showBoxOption = _.get(config, 'showBoxOption', false);
  // 自定义属性
  const restOption = _.pick(cusOption, ['title', 'legend']);
268

程恺文's avatar
程恺文 committed
269 270 271 272 273
  // 一种指标一个y轴
  const yAxisMap = new Map();
  dataSource.forEach((item, index) => {
    const { sensorName, unit } = item;
    const key = sensorName;
274

程恺文's avatar
程恺文 committed
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
    if (!yAxisMap.has(key)) {
      const i = yAxisMap.size;
      const axis = {
        type: 'value',
        name: needUnit ? unit : null,
        position: i % 2 === 0 ? 'left' : 'right',
        offset: Math.floor(i / 2) * axisWidth,
        axisLabel: {
          formatter: (value) => (value > 100000 ? `${value / 1000}k` : value),
        },
        axisLine: {
          show: true,
        },
        nameTextStyle: {
          align: i % 2 === 0 ? 'right' : 'left',
        },
        minorTick: {
          lineStyle: {
            color: '#e2e2e2',
          },
        },
        minorSplitLine: {
          lineStyle: {
            color: '#e2e2e2',
            type: 'dashed',
          },
        },
      };
      yAxisMap.set(key, axis);
    }
305

程恺文's avatar
程恺文 committed
306 307 308 309 310 311 312
    // 曲线居中
    if (curveCenter && item.dataModel && item.dataModel.length > 0) {
      const [min, max] = minMax(item);
      const axis = yAxisMap.get(key);
      axis.min = axis.min === void 0 ? min : Math.min(min, axis.min);
      axis.max = axis.max === void 0 ? max : Math.max(max, axis.max);
    }
313

程恺文's avatar
程恺文 committed
314 315 316 317 318
    // 网格显示
    const axis = yAxisMap.get(key);
    decorateAxisGridLine(axis, showGridLine);
  });
  const yAxis = yAxisMap.size > 0 ? [...yAxisMap.values()] : { type: 'value' };
319

程恺文's avatar
程恺文 committed
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
  // 根据y轴个数调整边距
  const leftNum = Math.ceil(yAxisMap.size / 2);
  const rightNum = Math.floor(yAxisMap.size / 2);
  const grid = {
    top: needUnit ? 80 : 60,
    left: 10 + leftNum * axisWidth,
    right: rightNum === 0 ? 20 : rightNum * axisWidth,
    bottom: 60,
  };
  const headTemplate = (param) => {
    if (!param) return '';
    const { name, axisValueLabel, axisType, axisValue } = param;
    const timeFormat = 'YYYY-MM-DD HH:mm:ss';
    const text =
      axisType === 'xAxis.time' ? moment(axisValue).format(timeFormat) : name || axisValueLabel;
    return `<div style="border-bottom: 1px solid #F0F0F0; color: #808080; margin-bottom: 5px; padding-bottom: 5px;">${text}</div>`;
  };
  const seriesTemplate = (param, unit) => {
    if (!param) return '';
    console.log(param);
    const { value, encode } = param;
    // const val = value[encode.y[0]];
    const _unit = unit || 'Mpa';
    const color = '#008CFF';
    if (!isArray(value))
      return ` <div style="display: flex; align-items: center;">
陈龙's avatar
陈龙 committed
346
            <span>${param.seriesName}</span><span style="display:inline-block;">:</span>
347
            <span style="color:${color};margin: 0 5px 0 auto;">${value?.toFixed(3) ?? '-'}</span>
陈龙's avatar
陈龙 committed
348 349
            <span style="font-size: 12px;">${_unit}</span>
        </div>`;
程恺文's avatar
程恺文 committed
350 351
    return param.componentSubType !== 'candlestick'
      ? `<div style="display: flex; align-items: center;">
陈龙's avatar
陈龙 committed
352 353 354
              <span>${param.seriesName}</span><span style="display:inline-block;">:</span>
              <span style="color: ${COLOR.AVG};margin: 0 5px 0 auto;">${value[1] ?? '-'}</span>
              <span style="font-size: 12px;">${_unit}</span>
程恺文's avatar
程恺文 committed
355 356
            </div>`
      : `
陈龙's avatar
陈龙 committed
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
            <div style="display: flex; align-items: center;">
              <span>首值</span><span style="display:inline-block;">:</span>
              <span style="color: ${COLOR.AVG};margin: 0 5px 0 auto;">${value[1] ?? '-'}</span>
              <span style="font-size: 12px;">${_unit}</span>
            </div>
            <div style="display: flex; align-items: center;">
              <span>尾值</span><span style="display:inline-block;">:</span>
              <span style="color: ${COLOR.AVG};margin: 0 5px 0 auto;">${value[2] ?? '-'}</span>
              <span style="font-size: 12px;">${_unit}</span>
            </div>
            <div style="display: flex; align-items: center;">
              <span>最小值</span><span style="display:inline-block;">:</span>
              <span style="color: ${COLOR.AVG};margin: 0 5px 0 auto;">${value[3] ?? '-'}</span>
              <span style="font-size: 12px;">${_unit}</span>
            </div>
            <div style="display: flex; align-items: center;">
              <span>最大值</span><span style="display:inline-block;">:</span>
              <span style="color: ${COLOR.AVG};margin: 0 5px 0 auto;">${value[4] ?? '-'}</span>
              <span style="font-size: 12px;">${_unit}</span>
            </div>
          `;
程恺文's avatar
程恺文 committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
  };
  const tooltipAccessor = (unit) => {
    return {
      formatter: function (params, ticket, callback) {
        let tooltipHeader = '';
        let tooltipContent = '';
        if (isArray(params)) {
          tooltipHeader = headTemplate(params[0]);
          params.forEach((param) => {
            tooltipContent += seriesTemplate(param, unit);
          });
        } else {
          tooltipHeader = headTemplate(params);
          tooltipContent += seriesTemplate(params, unit);
        }
        return `
陈龙's avatar
陈龙 committed
394 395 396 397 398
      <div>
        ${tooltipHeader}
        <div>${tooltipContent}</div>
      </div>
    `;
程恺文's avatar
程恺文 committed
399
      },
陈龙's avatar
陈龙 committed
400
    };
程恺文's avatar
程恺文 committed
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
  };
  // 根据"指标名称"分类yAxis
  const yAxisInterator = (() => {
    const map = new Map();
    let current = -1;
    const get = (name) => (map.has(name) ? map.get(name) : map.set(name, ++current).get(name));
    return { get };
  })();
  let _offlineData = [];
  let series = dataSource
    .filter((item) => {
      if (item.sensorName === '是否在线') {
        _offlineData.push(item);
      }
      return item.sensorName !== '是否在线';
    })
    .map((item, index) => {
      const { sensorName, unit } = item;
      const name = nameFormatter(item, contrast, contrastOption, nameWithSensor);
      const data = dataAccessor(item, contrast, contrastOption);
      const type = 'line';
      const areaStyle = areaStyleFormatter(item);
      const yAxisIndex = yAxisInterator.get(sensorName);
      const markLine = showMarkLine
        ? alarmMarkLine(item, index, dataSource, deviceAlarmSchemes)
        : {};
      const markPoint = showPoint ? minMaxMarkPoint(item, index, dataSource) : {};
      let markArea = null;
      // 需求变更:设备离线改用“是否在线”的数据,离线的状态标记的数据用该部分的数据。 2023年4月25日09:36:55
      let _offlineAreasData = _offlineData
        .map((item) => {
          let _item = { ...item };
          _item.dataModel = item.dataModel.map((d) => {
            let _d = { ...d };
            _d.pv = 0;
            return _d;
          });
          return _item;
        })
        .find((offline) => offline.stationCode === item.stationCode);
      let offlineAreas = offlineArea(_offlineAreasData);
      if (offlineAreas.data?.length) {
        restOption.markArea = null;
        markArea = offlineAreas;
      }
      return {
        notMerge: true,
        name,
        type,
        data,
        areaStyle,
        yAxisIndex,
        smooth,
        unit,
        markLine,
        markPoint,
        markArea,
      };
459
    });
程恺文's avatar
程恺文 committed
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
  // 由于series更新后,没有的数据曲线仍然停留在图表区上,导致图表可视区范围有问题
  const min = Math.min(
    ...series.map((item) => item.data?.[0]?.[0]).filter((item) => item !== undefined),
  );
  const max = Math.max(
    ...series
      .map((item) => item.data?.[item.data.length - 1]?.[0])
      .filter((item) => item !== undefined),
  );
  let xAxis = { type: 'time', min, max };
  decorateAxisGridLine(xAxis, showGridLine);
  const tooltipTimeFormat = !contrast
    ? 'YYYY-MM-DD HH:mm:ss'
    : contrastOption === 'day'
    ? 'HH:mm'
    : 'DD HH:mm';
  let tooltip = {
    timeFormat: tooltipTimeFormat,
    // trigger: 'axis',
    // axisPointer: {
    //   type: 'cross'
    // }
  };
  // 增加箱线图的逻辑,单曲线才存在
  if (chartType && showBoxOption) {
    if (chartType === 'boxChart') {
      const otherData =
        dataSource?.[0]?.dataModel.map((item) => {
          const { firstPV, lastPV, maxPV, minPV, pt } = item;
          return [moment(pt).valueOf(), firstPV, lastPV, minPV, maxPV];
        }) || []; //当存在othersData的时候,只是单曲线
      // xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))};
      xAxis = { type: 'time' };
      decorateAxisGridLine(xAxis, showGridLine);
      let unit = '';
      series = series.map((item) => {
        if (item.unit) unit = item.unit;
        let _item = { ...item, symbol: 'none' };
        /*                _item.data = _item?.data?.map(d => {
陈龙's avatar
陈龙 committed
499 500
                                    return d[1] || null
                                }) || [];*/
程恺文's avatar
程恺文 committed
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
        return _item;
      });
      series.push({
        type: 'candlestick',
        name: '箱线图',
        symbol: 'none',
        data: otherData,
        itemStyle: {
          color: '#FFA200',
          color0: '#44CD00',
          borderColor: '#FFA200',
          borderColor0: '#44CD00',
        },
      });
      tooltip = tooltipAccessor(unit);
    } else {
      let _maxData = [];
      let _minData = [];
      let _currentYear = moment().format('YYYY');
      const formatStr =
        contrastOption === 'day'
          ? `${_currentYear}-01-01 HH:mm:00`
          : `${_currentYear}-01-DD HH:mm:00`; // 用来做同期对比,把日期拉到同一区间
      let _maxValues = [];
      dataSource?.[0]?.dataModel.forEach((item) => {
        const { firstPV, lastPV, maxPV, minPV, pt } = item;
        _maxValues.push(maxPV);
        let time = contrast ? moment(pt).format(formatStr) : pt;
        _maxData.push([moment(time).valueOf(), (maxPV - minPV).toFixed(2)]);
        _minData.push([moment(time).valueOf(), minPV]);
      }); //当存在othersData的时候,只是单曲线
      // xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))};
      xAxis = { type: 'time' };
      decorateAxisGridLine(xAxis, showGridLine);
      let _unit = '';
      series = series.map((item) => {
        _unit = item.unit;
        let _item = { ...item, symbol: 'none' };
        /*                _item.data = _item?.data?.map(d => {
陈龙's avatar
陈龙 committed
540 541
                                    return d[1] || null
                                }) || [];*/
程恺文's avatar
程恺文 committed
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
        return _item;
      });
      console.log(series);
      [[..._minData], [..._maxData]].forEach((item, index) => {
        series.push({
          name: index === 0 ? '最小值' : '最大值',
          type: 'line',
          data: item,
          lineStyle: {
            opacity: 0,
          },
          ...(index !== 0
            ? {
                areaStyle: {
                  color: series?.[0]?.itemStyle?.color ?? '#65a0d1',
                  opacity: 0.2,
                },
              }
            : {}),
          stack: 'confidence-band',
          symbol: 'none',
        });
      });
      tooltip = {
        formatter: (e) => {
          return `<div>
陈龙's avatar
陈龙 committed
568 569 570
                    ${headTemplate(e[0])}
                    <div>
                        <div style="display: flex; align-items: center;">
程恺文's avatar
程恺文 committed
571 572 573 574 575 576
                              <span>${
                                e[0].seriesName
                              }</span><span style="display:inline-block;">:</span>
                              <span style="color: ${COLOR.NORMAL};margin: 0 5px 0 auto;">${
            e[0]?.value?.[1] ?? '-'
          }</span>
陈龙's avatar
陈龙 committed
577 578 579 580
                              <span style="font-size: 12px;">${_unit}</span>
                            </div>
                            <div style="display: flex; align-items: center;">
                              <span>最小值</span><span style="display:inline-block;">:</span>
程恺文's avatar
程恺文 committed
581 582 583
                              <span style="color: ${COLOR.AVG};margin: 0 5px 0 auto;">${
            e[1]?.value?.[1] ?? '-'
          }</span>
陈龙's avatar
陈龙 committed
584 585 586 587
                              <span style="font-size: 12px;">${_unit}</span>
                            </div>
                            <div style="display: flex; align-items: center;">
                              <span>最大值</span><span style="display:inline-block;">:</span>
程恺文's avatar
程恺文 committed
588 589 590
                              <span style="color: ${COLOR.AVG};margin: 0 5px 0 auto;">${
            _maxValues[e[2].dataIndex] ?? '-'
          }</span>
陈龙's avatar
陈龙 committed
591 592 593
                              <span style="font-size: 12px;">${_unit}</span>
                            </div>
                        </div>
程恺文's avatar
程恺文 committed
594
                    </div>`;
陈龙's avatar
陈龙 committed
595
        },
程恺文's avatar
程恺文 committed
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
      };
    }
  }
  restOption.dataZoom = [
    {
      show: true,
      bottom: 10,
      start: 0,
      end: 100,
      height: 28,
      type: 'inside',
      zoomOnMouseWheel: true,
    },
    {
      show: true,
      bottom: 10,
      start: 0,
      end: 100,
      height: 28,
      type: 'slider',
      zoomOnMouseWheel: true,
    },
  ];
  xAxis.minInterval = 3600 * 1 * 1000;
  return {
    yAxis,
    grid,
    xAxis,
    series,
    tooltip,
    ...restOption,
  };
628 629 630
};

export default optionGenerator;