diff --git a/src/chart-types.ts b/src/chart-types.ts index bea4762..b212477 100644 --- a/src/chart-types.ts +++ b/src/chart-types.ts @@ -2,17 +2,26 @@ import { ChartType, ChartData, ChartDataset, ChartOptions, DefaultDataPoint } fr export type GeoChartType = ChartType; +/** + * Extends the ChartData used by Chart.js and represents the whole Data to be displayed in the Chart + */ export interface GeoChartData< TType extends GeoChartType = GeoChartType, TData = DefaultDataPoint, TLabel = string > extends ChartData { }; +/** + * Represents a Dataset to be shown in the Chart + */ export type GeoChartDataset< TType extends GeoChartType = GeoChartType, TData = DefaultDataPoint > = ChartDataset; +/** + * Extends the ChartOptions used by Chart.js with more 'GeoChart' options + */ export interface GeoChartOptions extends ChartOptions { geochart: { chart: GeoChartType; @@ -23,6 +32,9 @@ export interface GeoChartOptions extends ChartOptions { }; }; +/** + * Options for the Slider component + */ export type GeoChartOptionsSlider = { display: boolean; min: number; @@ -31,6 +43,9 @@ export type GeoChartOptionsSlider = { track: 'normal' | 'inverted' | false; }; +/** + * Options for the Slider Axis component + */ export type GeoChartOptionsAxis = { type: string; }; diff --git a/src/chart.tsx b/src/chart.tsx index 0cccbec..1c3f0d0 100644 --- a/src/chart.tsx +++ b/src/chart.tsx @@ -1,6 +1,5 @@ -// import { useEffect, useState } from 'react'; import { Box } from '@mui/material'; -import { Chart as ChartJS, ChartData, ChartOptions, DefaultDataPoint } from 'chart.js'; +import { ChartData, ChartOptions, DefaultDataPoint } from 'chart.js'; import { GeoChartOptions, GeoChartType, GeoChartData} from './chart-types'; import { ChartDoughnut } from './charts/chart-doughnut'; import { ChartBarsVertical } from './charts/chart-bars-vertical'; @@ -47,6 +46,10 @@ export function Chart(props: TypeChartChartProps): JSX.Element { } }; + /** + * Renders the Chart JSX.Element itself using Line as default + * @returns The Chart JSX.Element itself using Line as default + */ const renderChart = (): JSX.Element => { // Depending on the type of chart switch (options!.geochart.chart) { @@ -96,6 +99,10 @@ export function Chart(props: TypeChartChartProps): JSX.Element { } }; + /** + * Renders the X Chart Slider JSX.Element or an empty div + * @returns The X Chart Slider JSX.Element or an empty div + */ const renderXSlider = () : JSX.Element => { const { xSlider } = options!.geochart; if (xSlider?.display) { @@ -116,6 +123,10 @@ export function Chart(props: TypeChartChartProps): JSX.Element { return
; } + /** + * Renders the Y Chart Slider JSX.Element or an empty div + * @returns The Y Chart Slider JSX.Element or an empty div + */ const renderYSlider = (): JSX.Element => { const { ySlider } = options!.geochart; if (ySlider?.display) { @@ -136,6 +147,10 @@ export function Chart(props: TypeChartChartProps): JSX.Element { return
; }; + /** + * Renders the whole Chart container JSX.Element or an empty div + * @returns The whole Chart container JSX.Element or an empty div + */ const renderChartContainer = (): JSX.Element => { if (options && options.geochart && options.geochart.chart) { return ( @@ -147,7 +162,7 @@ export function Chart(props: TypeChartChartProps): JSX.Element {
); } - return
; + return
; } return renderChartContainer(); diff --git a/src/charts/chart-bars-vertical.tsx b/src/charts/chart-bars-vertical.tsx index 7379376..0c3534b 100644 --- a/src/charts/chart-bars-vertical.tsx +++ b/src/charts/chart-bars-vertical.tsx @@ -21,12 +21,5 @@ export function ChartBarsVertical(props: ChartProps<'bar', DefaultDataPoint<'bar ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend); - // useEffect(() => { - // console.log("ChartBarsVertical useEffect Hey") - // return () => { - // console.log("ChartBarsVertical useEffect Kill") - // }; - // }, []); - return ; } diff --git a/src/charts/chart-doughnut.tsx b/src/charts/chart-doughnut.tsx index bc0c413..2286b64 100644 --- a/src/charts/chart-doughnut.tsx +++ b/src/charts/chart-doughnut.tsx @@ -12,12 +12,5 @@ export function ChartDoughnut(props: ChartProps<'doughnut', DefaultDataPoint<'do ChartJS.register(ArcElement, Tooltip, Legend); - // useEffect(() => { - // console.log("ChartDoughnut useEffect Hey") - // return () => { - // console.log("ChartDoughnut useEffect Kill") - // }; - // }, []); - return ; } diff --git a/src/charts/chart-line.tsx b/src/charts/chart-line.tsx index b15fb6c..f9734b5 100644 --- a/src/charts/chart-line.tsx +++ b/src/charts/chart-line.tsx @@ -22,12 +22,5 @@ export function ChartLine(props: ChartProps<'line', DefaultDataPoint<'line'>>): ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend); - // useEffect(() => { - // console.log("ChartLine useEffect Hey") - // return () => { - // console.log("ChartLine useEffect Kill") - // }; - // }, []); - return ; } diff --git a/src/charts/chart-pie.tsx b/src/charts/chart-pie.tsx index 4c841d6..86113c1 100644 --- a/src/charts/chart-pie.tsx +++ b/src/charts/chart-pie.tsx @@ -12,12 +12,5 @@ export function ChartPie(props: ChartProps<'pie', DefaultDataPoint<'pie'>>): JSX ChartJS.register(ArcElement, Tooltip, Legend); - // useEffect(() => { - // console.log("ChartPie useEffect Hey") - // return () => { - // console.log("ChartPie useEffect Kill") - // }; - // }, []); - return ; }