Cleanup and bar graphs for snow

This commit is contained in:
Guntis Smaukstelis
2023-08-03 22:54:02 +03:00
parent b887317c6b
commit 4c9af88859
3 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ export const CityChart: Component<{
const values = data.map(item => item[1]); const values = data.map(item => item[1]);
onMount(() => { onMount(() => {
const ctx = getCanvas()!.getContext('2d')!; const ctx = getCanvas()!.getContext("2d")!;
chart = createCustomChart( chart = createCustomChart(
ctx, ctx,
false, false,
+6 -1
View File
@@ -19,7 +19,12 @@ function isDateNumber(value: unknown): value is [string, number | null][] {
if (!Array.isArray(value)) return false; if (!Array.isArray(value)) return false;
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
let item = value[i]; let item = value[i];
if (!Array.isArray(item) || item.length !== 2 || typeof item[0] !== 'string' || (typeof item[1] !== 'number' && item[1] !== null)) { if (
!Array.isArray(item)
|| item.length !== 2
|| typeof item[0] !== "string"
|| (typeof item[1] !== "number" && item[1] !== null)
) {
return false; return false;
} }
} }
+2 -4
View File
@@ -10,7 +10,7 @@ import {
Title, Title,
} from "chart.js"; } from "chart.js";
// Register the controllers, elements, scales, and plugins we'll be using // Register chart elements which will be used
Chart.register( Chart.register(
BarElement, BarElement,
BarController, BarController,
@@ -22,9 +22,7 @@ Chart.register(
CategoryScale, CategoryScale,
); );
// Chart.defaults.backgroundColor = "#FF0000"; const barChartData = ["precipitation", "sunDuration", "snowAvg"];
const barChartData = ["precipitation", "sunDuration"];
export function createCustomChart( export function createCustomChart(
ctx: CanvasRenderingContext2D, ctx: CanvasRenderingContext2D,