From 3ada7182f5f4b4a968e1fadc99932f18dac8a180 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 13 Mar 2023 15:51:46 -0700 Subject: [PATCH] Update viewers chart y axis to make more sense. Closes #2806 --- web/components/admin/Chart.tsx | 15 ++++++++++++++- web/pages/admin/viewer-info.tsx | 9 ++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/web/components/admin/Chart.tsx b/web/components/admin/Chart.tsx index ec7868bc8..dbdea0d50 100644 --- a/web/components/admin/Chart.tsx +++ b/web/components/admin/Chart.tsx @@ -11,6 +11,7 @@ import { Tooltip, Legend, LogarithmicScale, + ChartOptions, } from 'chart.js'; import { Line } from 'react-chartjs-2'; @@ -40,6 +41,8 @@ export type ChartProps = { yFlipped?: boolean; yLogarithmic?: boolean; dataCollections?: any[]; + minYValue?: number; + yStepSize?: number; }; function createGraphDataset(dataArray) { @@ -60,6 +63,8 @@ export const Chart: FC = ({ dataCollections, yFlipped, yLogarithmic, + minYValue, + yStepSize = 0, }) => { const renderData = []; @@ -94,6 +99,10 @@ export const Chart: FC = ({ y: { type: yLogarithmic ? ('logarithmic' as const) : ('linear' as const), reverse: yFlipped, + min: minYValue, + ticks: { + stepSize: yStepSize, + }, title: { display: true, text: unit, @@ -104,7 +113,11 @@ export const Chart: FC = ({ return (
- + } + height="70vh" + />
); }; diff --git a/web/pages/admin/viewer-info.tsx b/web/pages/admin/viewer-info.tsx index 9724af168..77efbe4cb 100644 --- a/web/pages/admin/viewer-info.tsx +++ b/web/pages/admin/viewer-info.tsx @@ -151,7 +151,14 @@ export default function ViewersOverTime() { {viewerInfo.length > 0 && ( - + )}