This commit is contained in:
Gabe Kangas
2022-03-16 17:54:34 -07:00
committed by GitHub
parent ae88a38acc
commit 1ce2ee398c
6 changed files with 377 additions and 3 deletions

View File

@@ -16,6 +16,8 @@ interface ChartProps {
title?: string;
color: string;
unit: string;
yFlipped?: boolean;
yLogarithmic?: boolean;
dataCollections?: any[];
}
@@ -29,7 +31,15 @@ function createGraphDataset(dataArray) {
return dataValues;
}
export default function Chart({ data, title, color, unit, dataCollections }: ChartProps) {
export default function Chart({
data,
title,
color,
unit,
dataCollections,
yFlipped,
yLogarithmic,
}: ChartProps) {
const renderData = [];
if (data && data.length > 0) {
@@ -45,9 +55,24 @@ export default function Chart({ data, title, color, unit, dataCollections }: Cha
name: collection.name,
data: createGraphDataset(collection.data),
color: collection.color,
dataset: collection.options,
});
});
// ChartJs.defaults.scales.linear.reverse = true;
const options = {
scales: {
y: { reverse: false, type: 'linear' },
x: {
type: 'time',
},
},
};
options.scales.y.reverse = yFlipped;
options.scales.y.type = yLogarithmic ? 'logarithmic' : 'linear';
return (
<div className="line-chart-container">
<LineChart
@@ -58,6 +83,7 @@ export default function Chart({ data, title, color, unit, dataCollections }: Cha
color={color}
data={renderData}
download={title}
library={options}
/>
</div>
);
@@ -67,4 +93,6 @@ Chart.defaultProps = {
dataCollections: [],
data: [],
title: '',
yFlipped: false,
yLogarithmic: false,
};

View File

@@ -206,6 +206,9 @@ export default function MainLayout(props) {
<Menu.Item key="hardware-info">
<Link href="/hardware-info">Hardware</Link>
</Menu.Item>
<Menu.Item key="stream-health">
<Link href="/stream-health">Stream Health</Link>
</Menu.Item>
<Menu.Item key="logs">
<Link href="/logs">Logs</Link>
</Menu.Item>

View File

@@ -9,6 +9,7 @@ interface StatisticItemProps {
title?: string;
value?: any;
prefix?: any;
suffix?: string;
color?: string;
progress?: boolean;
centered?: boolean;
@@ -18,13 +19,14 @@ const defaultProps = {
title: '',
value: 0,
prefix: null,
suffix: null,
color: '',
progress: false,
centered: false,
formatter: null,
};
function ProgressView({ title, value, prefix, color }: StatisticItemProps) {
function ProgressView({ title, value, prefix, suffix, color }: StatisticItemProps) {
const endColor = value > 90 ? 'red' : color;
const content = (
<div>
@@ -33,7 +35,10 @@ function ProgressView({ title, value, prefix, color }: StatisticItemProps) {
<Text type="secondary">{title}</Text>
</div>
<div>
<Text type="secondary">{value}%</Text>
<Text type="secondary">
{value}
{suffix || '%'}
</Text>
</div>
</div>
);