|
|
|
@ -22,6 +22,7 @@ interface TimedValue { |
|
|
|
|
|
|
|
|
|
|
|
interface ChartProps { |
|
|
|
interface ChartProps { |
|
|
|
data?: TimedValue[], |
|
|
|
data?: TimedValue[], |
|
|
|
|
|
|
|
title?: string, |
|
|
|
color: string, |
|
|
|
color: string, |
|
|
|
unit: string, |
|
|
|
unit: string, |
|
|
|
dataCollections?: any[], |
|
|
|
dataCollections?: any[], |
|
|
|
@ -43,7 +44,7 @@ function CustomizedTooltip(props: ToolTipProps) { |
|
|
|
} |
|
|
|
} |
|
|
|
CustomizedTooltip.defaultProps = defaultProps; |
|
|
|
CustomizedTooltip.defaultProps = defaultProps; |
|
|
|
|
|
|
|
|
|
|
|
export default function Chart({ data, color, unit, dataCollections }: ChartProps) { |
|
|
|
export default function Chart({ data, title, color, unit, dataCollections }: ChartProps) { |
|
|
|
if (!data && !dataCollections) { |
|
|
|
if (!data && !dataCollections) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -67,6 +68,18 @@ export default function Chart({ data, color, unit, dataCollections }: ChartProps |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const line = data ? ( |
|
|
|
|
|
|
|
<Line |
|
|
|
|
|
|
|
type="natural" |
|
|
|
|
|
|
|
dataKey="value" |
|
|
|
|
|
|
|
stroke={color} |
|
|
|
|
|
|
|
dot={null} |
|
|
|
|
|
|
|
strokeWidth={3} |
|
|
|
|
|
|
|
legendType="square" |
|
|
|
|
|
|
|
name={title} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : null; |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className={styles.lineChartContainer}> |
|
|
|
<div className={styles.lineChartContainer}> |
|
|
|
<LineChart width={chartWidth} height={chartHeight} data={data}> |
|
|
|
<LineChart width={chartWidth} height={chartHeight} data={data}> |
|
|
|
@ -87,23 +100,18 @@ export default function Chart({ data, color, unit, dataCollections }: ChartProps |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Tooltip content={<CustomizedTooltip unit={unit} />} /> |
|
|
|
<Tooltip content={<CustomizedTooltip unit={unit} />} /> |
|
|
|
<Legend /> |
|
|
|
<Legend /> |
|
|
|
<Line |
|
|
|
{line} |
|
|
|
type="monotone" |
|
|
|
|
|
|
|
dataKey="value" |
|
|
|
|
|
|
|
stroke={color} |
|
|
|
|
|
|
|
dot={null} |
|
|
|
|
|
|
|
strokeWidth={3} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
{dataCollections?.map((s) => ( |
|
|
|
{dataCollections?.map((s) => ( |
|
|
|
<Line |
|
|
|
<Line |
|
|
|
dataKey="value" |
|
|
|
dataKey="value" |
|
|
|
data={s.data} |
|
|
|
data={s.data} |
|
|
|
name={s.name} |
|
|
|
name={s.name} |
|
|
|
key={s.name} |
|
|
|
key={s.name} |
|
|
|
type="monotone" |
|
|
|
type="natural" |
|
|
|
stroke={s.color} |
|
|
|
stroke={s.color} |
|
|
|
dot={null} |
|
|
|
dot={null} |
|
|
|
strokeWidth={3} |
|
|
|
strokeWidth={3} |
|
|
|
|
|
|
|
legendType="square" |
|
|
|
/> |
|
|
|
/> |
|
|
|
))} |
|
|
|
))} |
|
|
|
</LineChart> |
|
|
|
</LineChart> |
|
|
|
|