123456789101112131415161718192021222324252627282930313233343536373839 |
- import React from 'react';
- import './index.less';
- import echarts from 'echarts/lib/echarts';
- import ReactEchartsCore from 'echarts-for-react/lib/core';
- import 'echarts/lib/chart/line';
- import 'echarts/lib/component/tooltip';
- import 'echarts/lib/component/title';
- import 'echarts/lib/component/legend';
- function LineChart(props) {
- const { className = '', theme = 'shine', option = {}, data = [] } = props;
- let defaultOption = {
- series: [
- {
- data: [],
- type: 'line',
- smooth: true,
- },
- ],
- xAxis: {
- type: 'key',
- },
- yAxis: {
- type: 'value',
- },
- };
- if (data.length > 0) {
- defaultOption.series.data = data;
- } else {
- defaultOption = option;
- }
- return (
- <div className={`line-chart ${className}`}>
- <ReactEchartsCore echarts={echarts} option={defaultOption} notMerge lazyUpdate theme={theme} />
- </div>
- );
- }
- export default LineChart;
|