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]);
|
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,
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user