-
Notifications
You must be signed in to change notification settings - Fork 3
/
common-chart.tsx
91 lines (86 loc) · 2.44 KB
/
common-chart.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import dynamic from "next/dynamic";
import { useQueryFilters } from "@/charts/shared/chart-helpers";
import { ChartConfig, DataSource } from "@/configurator";
const ChartAreasVisualization = dynamic(
import("@/charts/area/chart-area").then(
(mod) => mod.ChartAreasVisualization,
() => null as never
)
);
const ChartColumnsVisualization = dynamic(
import("@/charts/column/chart-column").then(
(mod) => mod.ChartColumnsVisualization,
() => null as never
)
);
const ChartLinesVisualization = dynamic(
import("@/charts/line/chart-lines").then(
(mod) => mod.ChartLinesVisualization,
() => null as never
)
);
const ChartMapVisualization = dynamic(
import("@/charts/map/chart-map").then(
(mod) => mod.ChartMapVisualization,
() => null as never
)
);
const ChartPieVisualization = dynamic(
import("@/charts/pie/chart-pie").then(
(mod) => mod.ChartPieVisualization,
() => null as never
)
);
const ChartScatterplotVisualization = dynamic(
import("@/charts/scatterplot/chart-scatterplot").then(
(mod) => mod.ChartScatterplotVisualization,
() => null as never
)
);
const ChartTableVisualization = dynamic(
import("@/charts/table/chart-table").then(
(mod) => mod.ChartTableVisualization,
() => null as never
)
);
const GenericChart = ({
dataSet,
dataSource,
chartConfig,
published,
}: {
dataSet: string;
dataSource: DataSource;
chartConfig: ChartConfig;
published: boolean;
}) => {
const queryFilters = useQueryFilters({ chartConfig });
const props = {
dataSetIri: dataSet,
dataSource,
queryFilters,
published,
};
switch (chartConfig.chartType) {
case "column":
return <ChartColumnsVisualization {...props} chartConfig={chartConfig} />;
case "line":
return <ChartLinesVisualization {...props} chartConfig={chartConfig} />;
case "area":
return <ChartAreasVisualization {...props} chartConfig={chartConfig} />;
case "scatterplot":
return (
<ChartScatterplotVisualization {...props} chartConfig={chartConfig} />
);
case "pie":
return <ChartPieVisualization {...props} chartConfig={chartConfig} />;
case "table":
return <ChartTableVisualization {...props} chartConfig={chartConfig} />;
case "map":
return <ChartMapVisualization {...props} chartConfig={chartConfig} />;
default:
const _exhaustiveCheck: never = chartConfig;
return _exhaustiveCheck;
}
};
export default GenericChart;