diff --git a/web/pages/components/chart.tsx b/web/pages/components/chart.tsx
index 67dcd0380..080e722a4 100644
--- a/web/pages/components/chart.tsx
+++ b/web/pages/components/chart.tsx
@@ -1,5 +1,7 @@
import { LineChart, XAxis, YAxis, Line, Tooltip, Legend } from "recharts";
import { timeFormat } from "d3-time-format";
+import useWindowSize from '../../utils/hook-windowresize';
+import styles from '../../styles/styles.module.css';
interface ToolTipProps {
active?: boolean,
@@ -10,20 +12,18 @@ interface ToolTipProps {
const defaultProps = {
active: false,
payload: Object,
- unit: "",
+ unit: '',
};
interface TimedValue {
time: Date;
- value: Number;
+ value: number;
}
interface ChartProps {
- // eslint-disable-next-line react/require-default-props
data?: TimedValue[],
color: string,
unit: string,
- // eslint-disable-next-line react/require-default-props
dataCollections?: any[],
}
@@ -47,61 +47,67 @@ export default function Chart({ data, color, unit, dataCollections }: ChartProps
if (!data && !dataCollections) {
return null;
}
+
+ const windowSize = useWindowSize();
+ const chartWidth = windowSize.width * .68;
+ const chartHeight = chartWidth * .333;
const timeFormatter = (tick: string) => {
return timeFormat("%I:%M")(new Date(tick));
};
- let ticks
+ let ticks = [];
if (dataCollections.length > 0) {
- ticks = dataCollections[0].data?.map(function (collection) {
+ ticks = dataCollections[0].data?.map((collection) => {
return collection?.time;
})
} else if (data?.length > 0){
- ticks = data?.map(function (item) {
+ ticks = data?.map(item => {
return item?.time;
});
}
return (
-
-
-
- } />
-
-
- {dataCollections?.map((s) => (
-
+
+
+
+ } />
+
+
- ))}
-
+ {dataCollections?.map((s) => (
+
+ ))}
+
+
);
}
diff --git a/web/pages/components/main-layout.tsx b/web/pages/components/main-layout.tsx
index 400007718..b8bf3e31d 100644
--- a/web/pages/components/main-layout.tsx
+++ b/web/pages/components/main-layout.tsx
@@ -13,7 +13,7 @@ import {
MinusSquareFilled,
} from '@ant-design/icons';
import classNames from 'classnames';
-import {parseSecondsToDurationString} from '../../utils/format'
+import { parseSecondsToDurationString } from '../../utils/format'
import OwncastLogo from './logo';
import { BroadcastStatusContext } from '../../utils/broadcast-status-context';
@@ -24,7 +24,7 @@ export default function MainLayout(props) {
const { children } = props;
const context = useContext(BroadcastStatusContext);
- const { broadcastActive } = context || {};
+ const { broadcastActive, broadcaster } = context || {};
const router = useRouter();
const { route } = router || {};
@@ -33,7 +33,7 @@ export default function MainLayout(props) {
const { SubMenu } = Menu;
const streamDurationString = broadcastActive ?
- parseSecondsToDurationString(differenceInSeconds(new Date(), new Date(context.broadcaster.time))) : ""
+ parseSecondsToDurationString(differenceInSeconds(new Date(), new Date(broadcaster.time))) : ""
const statusIcon = broadcastActive ?
: ;
@@ -56,7 +56,7 @@ export default function MainLayout(props) {
>