Basic.tsx 2.21 KB
Newer Older
涂茜's avatar
涂茜 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
import React from 'react';
import BasicChart from '../index';

const Demo = () => {
  return (
    <div>
      <h3>折线图</h3>
      <div style={{ height: '600px' }}>
        <BasicChart chartOptions={chartOptions1} />
      </div>
      <h3 style={{ marginTop: '40px' }}>曲线面积图</h3>
      <div style={{ height: '600px' }}>
        <BasicChart chartOptions={chartOptions2} />
      </div>
      <h3 style={{ marginTop: '40px' }}>带滚动条曲线图</h3>
      <div style={{ height: '600px' }}>
        <BasicChart chartOptions={chartOptions3} constructorType={'stockChart'} />
      </div>
    </div>
  );
};

export default Demo;

const chartOptions1 = {
  // ...
  series: [
    {
      name: '今日供水量',
      color: '#1884EC',
      data: [
        [1620720173000, 122],
        [1620720473000, 122],
        [1620720773000, 122],
        [1620721073000, 123],
        [1620721373000, 123],
        [1620721673000, 123],
        [1620721973000, 124],
        [1620722274000, 124],
        [1620722724000, 125],
        [1620723024000, 125],
        [1620723324000, 125],
      ],
    },
  ],
};

const chartOptions2 = {
  // ...
  series: [
    {
      type: 'areaspline',
      name: '出水瞬时流量',
      color: '#68cbd1',
      data: [
        [1620720173000, 1.85],
        [1620720473000, 8.22],
        [1620720773000, 2.83],
        [1620721073000, 2.62],
        [1620721373000, 2.05],
        [1620721673000, 8.7],
        [1620721973000, 2.38],
        [1620722274000, 3.31],
        [1620722724000, 2.36],
        [1620723024000, 2.98],
        [1620723324000, 2.58],
      ],
      marker: {
        enabled: false,
      },
    },
  ],
  plotOptions: {
    areaspline: {
      fillOpacity: 0.5,
    },
  },
};

const chartOptions3 = {
  // ...
  series: [
    {
      type: 'spline',
      name: '进水压力',
      color: '#1884EC',
      data: [
        [1620720173000, 0.08],
        [1620720473000, 0.09],
        [1620720773000, 0.09],
        [1620721073000, 0.09],
        [1620721373000, 0.09],
        [1620721673000, 0.08],
        [1620721973000, 0.09],
        [1620722274000, 0.09],
        [1620722724000, 0.09],
        [1620723024000, 0.08],
        [1620723324000, 0.08],
      ],
    },
  ],
};