From dbd9f910f4fe6bca4788dec75c27730407b03ebb Mon Sep 17 00:00:00 2001 From: James Reed Date: Tue, 8 Oct 2024 16:41:33 -0700 Subject: [PATCH] mm --- .../pages/api/functions/renderChart.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/functional_chat/pages/api/functions/renderChart.ts b/apps/functional_chat/pages/api/functions/renderChart.ts index f06db13..b8dd987 100644 --- a/apps/functional_chat/pages/api/functions/renderChart.ts +++ b/apps/functional_chat/pages/api/functions/renderChart.ts @@ -1,5 +1,6 @@ import type { NextApiRequest, NextApiResponse } from 'next'; +// biome-ignore lint/complexity/noStaticOnlyClass: class Api { static async spec(req: NextApiRequest, res: NextApiResponse) { res.json({ @@ -31,8 +32,8 @@ class Api { properties: { label: { type: 'string' }, data: { type: 'array', items: { type: 'number' } }, - backgroundColor: { - type: 'array', + backgroundColor: { + type: 'array', items: { type: 'string' }, description: 'Array of colors for each data point' }, @@ -110,13 +111,19 @@ class Api { ]; // Apply default styles if not provided - jsonObj.data.datasets = jsonObj.data.datasets.map((dataset: any, index: number) => ({ + // biome-ignore lint/suspicious/noExplicitAny: + jsonObj.data.datasets = jsonObj.data.datasets.map((dataset: any, index: number) => ({ backgroundColor: defaultColors?.[index % defaultColors.length] || 'defaultColor', // Added optional chaining and fallback borderColor: defaultColors?.[index % defaultColors.length]?.replace('0.8', '1') || 'defaultBorderColor', // Added optional chaining and fallback borderWidth: 1, ...dataset })); + console.log('dataset'); + console.log(dataset); + console.log('jsonObj'); + console.log(jsonObj); + // Add default options if not provided jsonObj.options = { responsive: true,