From f74beb7144cd13565fcc00aa09c22e82db0567ce Mon Sep 17 00:00:00 2001 From: Konstantinos Markopoulos Date: Tue, 21 Jan 2025 16:32:01 +0200 Subject: [PATCH] Remvoe unused functions --- packages/website/src/helpers/map.ts | 86 ----------------------------- 1 file changed, 86 deletions(-) diff --git a/packages/website/src/helpers/map.ts b/packages/website/src/helpers/map.ts index cbf5ed833..fa0a99d3f 100644 --- a/packages/website/src/helpers/map.ts +++ b/packages/website/src/helpers/map.ts @@ -209,89 +209,3 @@ export const useMarkerIcon = ( if (hasSpotter || hasHobo) return sensorIcon; return buoyIcon(iconUrl); }; - -// Create a donut chart with the given counts and colors -// Source: https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/ -export function createDonutChart(counts: number[], colors: string[]) { - const offsets: number[] = []; - - let total = 0; - counts.forEach((count) => { - // eslint-disable-next-line fp/no-mutating-methods - offsets.push(total); - // eslint-disable-next-line fp/no-mutation - total += count; - }); - const fontSize = - // eslint-disable-next-line no-nested-ternary - total >= 1000 ? 22 : total >= 100 ? 20 : total >= 10 ? 18 : 16; - // eslint-disable-next-line no-nested-ternary - const r = total >= 1000 ? 50 : total >= 100 ? 32 : total >= 10 ? 24 : 18; - const r0 = Math.round(r * 0.6); - const w = r * 2; - - const segments = counts.map((count, i) => - donutSegment( - offsets[i] / total, - (offsets[i] + count) / total, - r, - r0, - colors[i], - ), - ); - const html = ` - - ${segments.join('')} - - ${total.toLocaleString()} - `; - - return html; -} - -function donutSegment( - start: number, - end: number, - r: number, - r0: number, - color: string, -) { - // eslint-disable-next-line fp/no-mutation, no-param-reassign - if (end - start === 1) end -= 0.00001; - const a0 = 2 * Math.PI * (start - 0.25); - const a1 = 2 * Math.PI * (end - 0.25); - const x0 = Math.cos(a0); - const y0 = Math.sin(a0); - const x1 = Math.cos(a1); - const y1 = Math.sin(a1); - const largeArc = end - start > 0.5 ? 1 : 0; - - return [ - '`, - ].join(' '); -}