Customize legend titles. Hide empty graph lines. Update colors.
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -55,17 +55,17 @@ export default function HardwareInfo() {
|
|||||||
const series = [
|
const series = [
|
||||||
{
|
{
|
||||||
name: "CPU",
|
name: "CPU",
|
||||||
color: "#FF7700",
|
color: "#B63FFF",
|
||||||
data: hardwareStatus.cpu,
|
data: hardwareStatus.cpu,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Memory",
|
name: "Memory",
|
||||||
color: "#004777",
|
color: "#2087E2",
|
||||||
data: hardwareStatus.memory,
|
data: hardwareStatus.memory,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Disk",
|
name: "Disk",
|
||||||
color: "#A9E190",
|
color: "#FF7700",
|
||||||
data: hardwareStatus.disk,
|
data: hardwareStatus.disk,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -76,24 +76,24 @@ const series = [
|
|||||||
<h2>Hardware Info</h2>
|
<h2>Hardware Info</h2>
|
||||||
<Row gutter={[16, 16]}>
|
<Row gutter={[16, 16]}>
|
||||||
<StatisticItem
|
<StatisticItem
|
||||||
title="CPU"
|
title={series[0].name}
|
||||||
value={`${currentCPUUsage}`}
|
value={`${currentCPUUsage}`}
|
||||||
prefix={<LaptopOutlined style={{color: '#FF7700' }}/>}
|
prefix={<LaptopOutlined style={{color: series[0].color }}/>}
|
||||||
color="#FF7700"
|
color={series[0].color}
|
||||||
progress
|
progress
|
||||||
/>
|
/>
|
||||||
<StatisticItem
|
<StatisticItem
|
||||||
title="RAM"
|
title={series[1].name}
|
||||||
value={`${currentRamUsage}`}
|
value={`${currentRamUsage}`}
|
||||||
prefix={<BulbOutlined style={{color: '#004777' }} />}
|
prefix={<BulbOutlined style={{color: series[1].color }} />}
|
||||||
color="#004777"
|
color={series[1].color}
|
||||||
progress
|
progress
|
||||||
/>
|
/>
|
||||||
<StatisticItem
|
<StatisticItem
|
||||||
title="Disk"
|
title={series[2].name}
|
||||||
value={`${currentDiskUsage}`}
|
value={`${currentDiskUsage}`}
|
||||||
prefix={<SaveOutlined style={{color: '#A9E190' }} />}
|
prefix={<SaveOutlined style={{color: series[2].color }} />}
|
||||||
color="#A9E190"
|
color={series[2].color}
|
||||||
progress
|
progress
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export default function ViewersOverTime() {
|
|||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
<div className="chart-container">
|
<div className="chart-container">
|
||||||
<Chart data={viewerInfo} color="#ff84d8" unit="" />
|
<Chart title="Viewers" data={viewerInfo} color="#2087E2" unit="" />
|
||||||
</div>
|
</div>
|
||||||
<Table dataSource={clients} columns={columns} />;
|
<Table dataSource={clients} columns={columns} />;
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user