瀏覽代碼

fe-31 ej2-react-charts 折线图实现

master
Chunxian Zhang 2 年之前
父節點
當前提交
2928ffd7dc
共有 1 個文件被更改,包括 30 次插入0 次删除
  1. +30
    -0
      lazy-timer-fe/src/components/Charts/LineChart.jsx

+ 30
- 0
lazy-timer-fe/src/components/Charts/LineChart.jsx 查看文件

@ -0,0 +1,30 @@
import React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, LineSeries, DateTime, Legend, Tooltip } from '@syncfusion/ej2-react-charts';
import { lineCustomSeries, LinePrimaryXAxis, LinePrimaryYAxis } from '../../data/dummy';
import { useStateContext } from '../../contexts/ContextProvider';
const LineChart = () => {
const { currentMode } = useStateContext();
return (
<ChartComponent
id="line-chart"
height="420px"
primaryXAxis={LinePrimaryXAxis}
primaryYAxis={LinePrimaryYAxis}
chartArea={{ border: { width: 0 } }}
tooltip={{ enable: true }}
background={currentMode === 'Dark' ? '#33373E' : '#fff'}
legendSettings={{ background: 'white' }}
>
<Inject services={[LineSeries, DateTime, Legend, Tooltip]} />
<SeriesCollectionDirective>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
{lineCustomSeries.map((item, index) => <SeriesDirective key={index} {...item} />)}
</SeriesCollectionDirective>
</ChartComponent>
);
};
export default LineChart;

Loading…
取消
儲存