Cleanup and bar graphs for snow
This commit is contained in:
@@ -24,7 +24,7 @@ export const CityChart: Component<{
|
||||
const values = data.map(item => item[1]);
|
||||
|
||||
onMount(() => {
|
||||
const ctx = getCanvas()!.getContext('2d')!;
|
||||
const ctx = getCanvas()!.getContext("2d")!;
|
||||
chart = createCustomChart(
|
||||
ctx,
|
||||
false,
|
||||
|
||||
@@ -19,7 +19,12 @@ function isDateNumber(value: unknown): value is [string, number | null][] {
|
||||
if (!Array.isArray(value)) return false;
|
||||
for (let i = 0; i < value.length; 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
Title,
|
||||
} from "chart.js";
|
||||
|
||||
// Register the controllers, elements, scales, and plugins we'll be using
|
||||
// Register chart elements which will be used
|
||||
Chart.register(
|
||||
BarElement,
|
||||
BarController,
|
||||
@@ -22,9 +22,7 @@ Chart.register(
|
||||
CategoryScale,
|
||||
);
|
||||
|
||||
// Chart.defaults.backgroundColor = "#FF0000";
|
||||
|
||||
const barChartData = ["precipitation", "sunDuration"];
|
||||
const barChartData = ["precipitation", "sunDuration", "snowAvg"];
|
||||
|
||||
export function createCustomChart(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
|
||||
Reference in New Issue
Block a user