@geo2france/api-dashboard 1.18.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Charts/ChartComparison.d.ts +28 -0
- package/dist/components/Charts/ChartComparison.js +95 -0
- package/dist/components/Charts/Datatable.d.ts +14 -0
- package/dist/components/Charts/Datatable.js +22 -0
- package/dist/components/Charts/Pie.d.ts +2 -1
- package/dist/components/Charts/Statistics.d.ts +7 -16
- package/dist/components/Charts/Statistics.js +7 -13
- package/dist/components/Charts/YearSerie.d.ts +2 -1
- package/dist/components/Control/Select.d.ts +14 -2
- package/dist/components/Control/Select.js +3 -0
- package/dist/components/Dataset/Dataset.d.ts +15 -3
- package/dist/components/Dataset/Dataset.js +8 -6
- package/dist/components/Dataset/Filter.d.ts +0 -1
- package/dist/components/Dataset/hooks.d.ts +3 -1
- package/dist/components/Dataset/hooks.js +2 -20
- package/dist/components/Palette/Palette.js +1 -1
- package/dist/dsl/index.d.ts +3 -1
- package/dist/dsl/index.js +3 -1
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EChartsOption } from "echarts";
|
|
2
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
3
|
+
type labelType = "percent" | "value" | "category" | "none";
|
|
4
|
+
export interface ChartComparisonProps {
|
|
5
|
+
/** Identifiant du dataset */
|
|
6
|
+
dataset?: datasetInput;
|
|
7
|
+
/** Nom de la colonne qui contient les valeurs numériques */
|
|
8
|
+
valueKey: string;
|
|
9
|
+
/** Nom de la colonne qui contient les catégories */
|
|
10
|
+
nameKey: string;
|
|
11
|
+
/** Type de graphique */
|
|
12
|
+
chartType?: 'bar' | 'pie' | 'donut';
|
|
13
|
+
/** Unité à afficher */
|
|
14
|
+
unit?: string;
|
|
15
|
+
/** Titre du graphique */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Valeur à afficher en étiquette */
|
|
18
|
+
label?: labelType;
|
|
19
|
+
/** Couleur unique pour le graphique */
|
|
20
|
+
singleColor?: boolean;
|
|
21
|
+
/** Options suplémentaires passées à Echarts
|
|
22
|
+
* https://echarts.apache.org/en/option.html
|
|
23
|
+
*/
|
|
24
|
+
option?: EChartsOption;
|
|
25
|
+
}
|
|
26
|
+
/** Composant de visualisation destiné à comparer des catégories au sein d’un dataset. */
|
|
27
|
+
export declare const ChartComparison: React.FC<ChartComparisonProps>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useDataset } from "../Dataset/hooks";
|
|
3
|
+
import { ChartEcharts, useBlockConfig, usePalette, usePaletteLabels } from "../../dsl";
|
|
4
|
+
import { from, op } from "arquero";
|
|
5
|
+
import deepMerge from "../../utils/deepmerge";
|
|
6
|
+
/** Composant de visualisation destiné à comparer des catégories au sein d’un dataset. */
|
|
7
|
+
export const ChartComparison = ({ dataset: dataset_id, title, nameKey, valueKey, chartType = 'bar', unit, singleColor = false, label: label_in, option: custom_option = {} }) => {
|
|
8
|
+
const dataset = useDataset(dataset_id);
|
|
9
|
+
const data = dataset?.data;
|
|
10
|
+
useBlockConfig({
|
|
11
|
+
title: title,
|
|
12
|
+
dataExport: data
|
|
13
|
+
});
|
|
14
|
+
// Label par défaut selon le type de graphique
|
|
15
|
+
const label = label_in ?? ((chartType === 'pie' || chartType === 'donut') ? 'category' : 'none');
|
|
16
|
+
const chart_data1 = data && data.length > 0
|
|
17
|
+
? from(data.filter(e => e[valueKey]))
|
|
18
|
+
.groupby(nameKey)
|
|
19
|
+
.rollup({ value: op.sum(valueKey) })
|
|
20
|
+
.orderby('value')
|
|
21
|
+
.objects()
|
|
22
|
+
.map((d) => ([
|
|
23
|
+
d[nameKey], //0
|
|
24
|
+
d.value, //1
|
|
25
|
+
]))
|
|
26
|
+
: [];
|
|
27
|
+
const colors_libels = usePaletteLabels();
|
|
28
|
+
const colors_palette = usePalette({ nColors: chart_data1.length }) || ['#d4d4d4'];
|
|
29
|
+
// Total, utilisé pour les pourcentage
|
|
30
|
+
const total = chart_data1?.reduce((sum, item) => sum + item[1], 0);
|
|
31
|
+
const labelFormatter = (v) => {
|
|
32
|
+
if (!label || label == 'none')
|
|
33
|
+
return '';
|
|
34
|
+
const value = (chartType === 'pie' || chartType === 'donut') ?
|
|
35
|
+
v?.value
|
|
36
|
+
: v?.value?.[1];
|
|
37
|
+
const name = v?.name;
|
|
38
|
+
switch (label) {
|
|
39
|
+
case 'percent': {
|
|
40
|
+
return ((100 * value / total).toLocaleString(undefined, {
|
|
41
|
+
maximumFractionDigits: 0,
|
|
42
|
+
}) + ' %');
|
|
43
|
+
}
|
|
44
|
+
case 'value':
|
|
45
|
+
return `${value.toLocaleString(undefined, {
|
|
46
|
+
maximumFractionDigits: 0,
|
|
47
|
+
})} ${unit || ''}`;
|
|
48
|
+
case 'category':
|
|
49
|
+
return name;
|
|
50
|
+
default:
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const serie_common = {
|
|
55
|
+
itemStyle: {
|
|
56
|
+
color: (p) => singleColor ? colors_palette?.[0] :
|
|
57
|
+
colors_libels.find(c => c.label == p.data[0] || c.label == p.name)?.color || colors_palette?.[p.dataIndex]
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const serie = chartType == 'bar' ?
|
|
61
|
+
{
|
|
62
|
+
type: 'bar',
|
|
63
|
+
data: chart_data1?.map(r => [r[0], r[1]]),
|
|
64
|
+
label: {
|
|
65
|
+
show: label && label !== 'none',
|
|
66
|
+
position: 'right',
|
|
67
|
+
formatter: labelFormatter
|
|
68
|
+
},
|
|
69
|
+
encode: {
|
|
70
|
+
x: 1,
|
|
71
|
+
y: 0
|
|
72
|
+
},
|
|
73
|
+
...serie_common,
|
|
74
|
+
} :
|
|
75
|
+
{
|
|
76
|
+
type: 'pie',
|
|
77
|
+
radius: chartType == 'donut' ? ['40%', '75%'] : [0, '75%'],
|
|
78
|
+
data: chart_data1?.map(r => ({ name: r[0], value: r[1] })),
|
|
79
|
+
label: {
|
|
80
|
+
show: label && label !== 'none',
|
|
81
|
+
formatter: labelFormatter
|
|
82
|
+
},
|
|
83
|
+
...serie_common,
|
|
84
|
+
};
|
|
85
|
+
const option = {
|
|
86
|
+
tooltip: {
|
|
87
|
+
show: true,
|
|
88
|
+
valueFormatter: (v) => `${v?.toLocaleString(undefined, { maximumFractionDigits: 0 })} t`
|
|
89
|
+
},
|
|
90
|
+
yAxis: { show: chartType == 'bar', type: 'category' },
|
|
91
|
+
xAxis: { show: chartType == 'bar', type: 'value', axisLabel: { formatter: (v) => `${(v).toLocaleString()} ${unit}` } },
|
|
92
|
+
series: [serie],
|
|
93
|
+
};
|
|
94
|
+
return _jsx(ChartEcharts, { option: deepMerge(option, custom_option) });
|
|
95
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
2
|
+
export interface DataTableProps {
|
|
3
|
+
/** Jeu de données */
|
|
4
|
+
dataset: datasetInput;
|
|
5
|
+
/** Titre du composant */
|
|
6
|
+
title?: string;
|
|
7
|
+
/** Nombre d'éléments par page */
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
/** Style CSS du tableau */
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
/** Afficher un dataset sous forme de tableau
|
|
13
|
+
*/
|
|
14
|
+
export declare const DataTable: React.FC<DataTableProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Table } from "antd";
|
|
3
|
+
import { useDataset } from "../Dataset/hooks";
|
|
4
|
+
import { useBlockConfig } from "../DashboardPage/Block";
|
|
5
|
+
/** Afficher un dataset sous forme de tableau
|
|
6
|
+
*/
|
|
7
|
+
export const DataTable = ({ dataset: dataset_id, title, pageSize = 5, style }) => {
|
|
8
|
+
const dataset = useDataset(dataset_id); //Récupérer le jeu de données
|
|
9
|
+
const data = dataset?.data;
|
|
10
|
+
useBlockConfig({
|
|
11
|
+
title: title,
|
|
12
|
+
dataExport: data
|
|
13
|
+
});
|
|
14
|
+
const cols = Object.keys(data?.[0] || {})?.map((k) => ({
|
|
15
|
+
dataIndex: k,
|
|
16
|
+
title: k,
|
|
17
|
+
ellipsis: true,
|
|
18
|
+
key: k,
|
|
19
|
+
render: (v) => typeof v === 'number' ? isNaN(v) ? '' : v.toLocaleString() : v,
|
|
20
|
+
}));
|
|
21
|
+
return _jsx(Table, { columns: cols, style: style, className: "data-table", dataSource: Array.isArray(data) ? data?.map((r, idx) => ({ ...r, key: idx })) : [], pagination: { pageSize: pageSize } });
|
|
22
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
1
2
|
import { EChartsOption, LabelFormatterCallback } from "echarts";
|
|
2
3
|
import type { CallbackDataParams } from 'echarts/types/dist/shared';
|
|
3
4
|
export interface IChartPieProps {
|
|
4
5
|
/** Identifiant du dataset */
|
|
5
|
-
dataset?:
|
|
6
|
+
dataset?: datasetInput;
|
|
6
7
|
/** Nom de la colonne qui contient les valeurs numériques */
|
|
7
8
|
dataKey: string;
|
|
8
9
|
/** Nom de la colonne qui contient les catégories */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
2
3
|
import { SimpleRecord } from "../../types";
|
|
3
4
|
type comparwithType = "first" | "previous";
|
|
4
5
|
type aggregateType = "last" | "first" | "sum" | "lastNotNull" | "min" | "max" | "count" | "mean" | "countDistinct" | "countMissing";
|
|
@@ -13,8 +14,8 @@ interface ICallbackParams {
|
|
|
13
14
|
compareValue: number;
|
|
14
15
|
}
|
|
15
16
|
export interface StatisticsProps {
|
|
16
|
-
/** Identifiant du jeu de données */
|
|
17
|
-
dataset:
|
|
17
|
+
/** Identifiant du jeu de données ou tableau de valeurs */
|
|
18
|
+
dataset: datasetInput;
|
|
18
19
|
/** Nom de la colonne qui contient les valeurs */
|
|
19
20
|
dataKey: string;
|
|
20
21
|
/** Texte à afficher après l'évolution */
|
|
@@ -29,7 +30,7 @@ export interface StatisticsProps {
|
|
|
29
30
|
unit?: string;
|
|
30
31
|
/** Inverser les couleurs (rouge/vert) de l'évolution */
|
|
31
32
|
invertColor?: boolean;
|
|
32
|
-
/** Icône
|
|
33
|
+
/** Icône. Composant ou nom de l'icône sur https://icon-sets.iconify.design/ */
|
|
33
34
|
icon?: ReactElement | string;
|
|
34
35
|
/** Texte à afficher dans le tooltip d'aide */
|
|
35
36
|
help?: string;
|
|
@@ -37,7 +38,7 @@ export interface StatisticsProps {
|
|
|
37
38
|
compareWith?: comparwithType;
|
|
38
39
|
/** Texte d'annotation (remplace evolution si définie) */
|
|
39
40
|
annotation?: React.ReactNode | ((param: ICallbackParams) => React.ReactNode);
|
|
40
|
-
/** Fonction a appliquer avant rendu */
|
|
41
|
+
/** Fonction de formattager a appliquer avant rendu */
|
|
41
42
|
valueFormatter?: ((param: ICallbackParams) => string);
|
|
42
43
|
/** Méthode d'aggrégation */
|
|
43
44
|
aggregate?: aggregateType;
|
|
@@ -45,17 +46,7 @@ export interface StatisticsProps {
|
|
|
45
46
|
animation?: boolean;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
|
-
* Composant `Statistics` affichant une valeur
|
|
49
|
-
*
|
|
50
|
-
* Affiche :
|
|
51
|
-
* - La dernière valeur du dataset
|
|
52
|
-
* - Unité et picto
|
|
53
|
-
* - Évolution par rapport à la première ou l'avant-dernière valeur
|
|
54
|
-
* - Couleur selon évolution positive/négative
|
|
55
|
-
* - Tooltip d'aide si fourni
|
|
56
|
-
*
|
|
57
|
-
* @param {StatisticsProps} props - Propriétés du composant
|
|
58
|
-
* @returns {ReactElement} Carte statistique
|
|
49
|
+
* Composant `Statistics` affichant une valeur depuis un dataset.
|
|
59
50
|
*/
|
|
60
51
|
export declare const Statistics: React.FC<StatisticsProps>;
|
|
61
52
|
export interface StatisticsCollectionProps {
|
|
@@ -73,7 +64,7 @@ export interface StatisticsCollectionProps {
|
|
|
73
64
|
title?: string;
|
|
74
65
|
}
|
|
75
66
|
/**
|
|
76
|
-
* `StatisticsCollection` permet de regrouper plusieurs cartes
|
|
67
|
+
* `StatisticsCollection` permet de regrouper plusieurs cartes [`Statistics`](?path=/docs/dataviz-statistics--docs)
|
|
77
68
|
* dans un bloc
|
|
78
69
|
* ```
|
|
79
70
|
*/
|
|
@@ -10,19 +10,13 @@ import CountUp from "react-countup";
|
|
|
10
10
|
const { Text, Paragraph } = Typography;
|
|
11
11
|
// DEV : modele cf https://bootstrapbrain.com/component/bootstrap-statistics-card-example/
|
|
12
12
|
/**
|
|
13
|
-
* Composant `Statistics` affichant une valeur
|
|
14
|
-
*
|
|
15
|
-
* Affiche :
|
|
16
|
-
* - La dernière valeur du dataset
|
|
17
|
-
* - Unité et picto
|
|
18
|
-
* - Évolution par rapport à la première ou l'avant-dernière valeur
|
|
19
|
-
* - Couleur selon évolution positive/négative
|
|
20
|
-
* - Tooltip d'aide si fourni
|
|
21
|
-
*
|
|
22
|
-
* @param {StatisticsProps} props - Propriétés du composant
|
|
23
|
-
* @returns {ReactElement} Carte statistique
|
|
13
|
+
* Composant `Statistics` affichant une valeur depuis un dataset.
|
|
24
14
|
*/
|
|
25
|
-
export const Statistics = ({ dataset: dataset_id, dataKey, unit, evolutionSuffix,
|
|
15
|
+
export const Statistics = ({ dataset: dataset_id, dataKey, unit, evolutionSuffix, // A supprimer
|
|
16
|
+
title, icon: icon_input, color, invertColor = false, // A supprimer
|
|
17
|
+
help, compareWith, // A supprimer
|
|
18
|
+
relativeEvolution = false, // A supprimer
|
|
19
|
+
valueFormatter = (param) => (param.value.toLocaleString()), annotation, aggregate = "last", animation = false }) => {
|
|
26
20
|
const icon = typeof icon_input === "string" ? _jsx(Icon, { icon: icon_input }) : icon_input;
|
|
27
21
|
const dataset = useDataset(dataset_id);
|
|
28
22
|
const { row, value } = aggregator({ data: dataset?.data, dataKey, aggregate });
|
|
@@ -64,7 +58,7 @@ export const Statistics = ({ dataset: dataset_id, dataKey, unit, evolutionSuffix
|
|
|
64
58
|
};
|
|
65
59
|
;
|
|
66
60
|
/**
|
|
67
|
-
* `StatisticsCollection` permet de regrouper plusieurs cartes
|
|
61
|
+
* `StatisticsCollection` permet de regrouper plusieurs cartes [`Statistics`](?path=/docs/dataviz-statistics--docs)
|
|
68
62
|
* dans un bloc
|
|
69
63
|
* ```
|
|
70
64
|
*/
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Graphique standard pour afficher des données annuelles
|
|
3
3
|
*/
|
|
4
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
4
5
|
import { EChartsOption, SeriesOption } from "echarts";
|
|
5
6
|
export interface IYearSerieProps {
|
|
6
|
-
dataset:
|
|
7
|
+
dataset: datasetInput;
|
|
7
8
|
title?: string;
|
|
8
9
|
yearKey: string;
|
|
9
10
|
valueKey: string;
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import type { SelectProps } from 'antd';
|
|
2
2
|
type ExtendedSelectProps = Omit<SelectProps<any>, 'options'> & {
|
|
3
|
+
/** Nom technique du controle */
|
|
4
|
+
name?: string;
|
|
5
|
+
/** Nom à afficher */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Jeu de données contenant les choix (à la place de options) */
|
|
3
8
|
dataset?: string;
|
|
9
|
+
/** Choix possible */
|
|
4
10
|
options?: {
|
|
5
11
|
label: string;
|
|
6
12
|
value: string;
|
|
7
13
|
}[] | string[];
|
|
14
|
+
/** Valeur intiale sélectionnée */
|
|
8
15
|
initial_value?: string;
|
|
16
|
+
/** Colonne à utiliser pour le libellé (si dataset utilisé) */
|
|
9
17
|
labelField?: string;
|
|
18
|
+
/** Colonne à utiliser pour la valeur (si dataset utilisé) */
|
|
10
19
|
valueField?: string;
|
|
11
|
-
|
|
12
|
-
label?: string;
|
|
20
|
+
/** Affichage des flèches Suivant/Précédent */
|
|
13
21
|
arrows?: boolean;
|
|
22
|
+
/** Inverser le sens des flêches */
|
|
14
23
|
reverse?: boolean;
|
|
15
24
|
};
|
|
25
|
+
/** Composant de controle permettant de choisir une valeur parmis une liste de choix.
|
|
26
|
+
* Adapté pour les choix de territoires ou d'années
|
|
27
|
+
*/
|
|
16
28
|
export declare const Select: React.FC<ExtendedSelectProps>;
|
|
17
29
|
export {};
|
|
@@ -5,6 +5,9 @@ import NextPrevSelect from '../NextPrevSelect/NextPrevSelect';
|
|
|
5
5
|
import { list_to_options } from './Control';
|
|
6
6
|
// TODO : a fusionner avec NextPrevSelect pour n'avoir qu'un seul composant
|
|
7
7
|
// Actuellement, Select apporte seulement le fait de choisir les valeurs depuis un
|
|
8
|
+
/** Composant de controle permettant de choisir une valeur parmis une liste de choix.
|
|
9
|
+
* Adapté pour les choix de territoires ou d'années
|
|
10
|
+
*/
|
|
8
11
|
export const Select = ({ name, dataset: datasetSource, options: input_options = [], labelField = 'label', valueField = 'value', arrows = false, reverse = false, label, initial_value: initial_value_in, ...rest }) => {
|
|
9
12
|
const options = list_to_options(input_options);
|
|
10
13
|
const data = useDataset(datasetSource)?.data;
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { SimpleRecord } from "../..";
|
|
3
|
-
import { CrudFilters
|
|
3
|
+
import { CrudFilters } from "../../data_providers/types";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { ProviderType } from "./Provider";
|
|
6
6
|
interface IDatasetProps {
|
|
7
|
+
/**Identifiant interne unique du jeu de données*/
|
|
7
8
|
id: string;
|
|
8
|
-
|
|
9
|
+
/** Url du fournisseur */
|
|
9
10
|
url?: string;
|
|
10
|
-
|
|
11
|
+
/** Type de fournisseur */
|
|
12
|
+
type: ProviderType;
|
|
13
|
+
/** Nom de la ressource côté fournisseur
|
|
14
|
+
* (couche, dataset, fichier, etc.)
|
|
15
|
+
*/
|
|
11
16
|
resource: string;
|
|
17
|
+
/**
|
|
18
|
+
* ⚠️ deprecated
|
|
19
|
+
*/
|
|
12
20
|
filters?: CrudFilters;
|
|
13
21
|
children?: ReactNode;
|
|
14
22
|
pageSize?: number;
|
|
23
|
+
/** Paramètres additionnels à passer au fournisseur */
|
|
15
24
|
meta?: any;
|
|
16
25
|
}
|
|
17
26
|
export type dataset = {
|
|
@@ -24,5 +33,8 @@ export type dataset = {
|
|
|
24
33
|
geojson?: any;
|
|
25
34
|
dataHash?: number;
|
|
26
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Composant **logique** permettant de récupérer des données.
|
|
38
|
+
*/
|
|
27
39
|
export declare const DSL_Dataset: React.FC<IDatasetProps>;
|
|
28
40
|
export {};
|
|
@@ -3,14 +3,17 @@ import { useContext, useEffect } from "react";
|
|
|
3
3
|
import { useApi } from "../..";
|
|
4
4
|
import { Producer } from "./Producer";
|
|
5
5
|
import React from "react";
|
|
6
|
-
import { Filter, Transform,
|
|
6
|
+
import { Filter, Transform, useAllDatasets, useDatasets } from "../../dsl";
|
|
7
7
|
import alasql from "alasql";
|
|
8
8
|
import { DataProviderContext, getProviderFromType } from "./Provider";
|
|
9
9
|
import { Join } from "./Join";
|
|
10
10
|
import { from } from "arquero";
|
|
11
11
|
import hashCode from "../../utils/hash_data";
|
|
12
12
|
import { DatasetRegistryContext } from "./context";
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Composant **logique** permettant de récupérer des données.
|
|
15
|
+
*/
|
|
16
|
+
export const DSL_Dataset = ({ children, id, type: providerType, url: providerUrl, resource, pageSize, meta }) => {
|
|
14
17
|
const getTransformerFn = (component) => {
|
|
15
18
|
/*
|
|
16
19
|
* Génére une fonction transformer soit
|
|
@@ -57,18 +60,17 @@ export const DSL_Dataset = ({ children, id, provider: provider_input, type: prov
|
|
|
57
60
|
};
|
|
58
61
|
const datasetRegistryContext = useContext(DatasetRegistryContext);
|
|
59
62
|
const allDatasets = useAllDatasets();
|
|
60
|
-
const controls = useAllControls();
|
|
61
63
|
const providerContext = useContext(DataProviderContext);
|
|
62
|
-
const provider = (providerUrl && getProviderFromType(providerType)(providerUrl)) || providerContext
|
|
64
|
+
const provider = (providerUrl && getProviderFromType(providerType)(providerUrl)) || providerContext;
|
|
63
65
|
if (provider === undefined) {
|
|
64
|
-
throw new Error("Error : No dataProvider, please use
|
|
66
|
+
throw new Error("Error : No dataProvider, please use providerUrl/providerType properties");
|
|
65
67
|
}
|
|
66
68
|
/* Récupérer les props des filtres depuis les composants enfant Filter */
|
|
67
69
|
const filters = [];
|
|
68
70
|
React.Children.toArray(children)
|
|
69
71
|
.filter((c) => React.isValidElement(c))
|
|
70
72
|
.filter((c) => typeof c.type != 'string' && c.type.name == Filter.name).forEach((c) => {
|
|
71
|
-
const value = (typeof c.props.children === "string" ? c.props.children.trim() : c.props.children)
|
|
73
|
+
const value = (typeof c.props.children === "string" ? c.props.children.trim() : c.props.children);
|
|
72
74
|
filters.push({
|
|
73
75
|
operator: c.props.operator || 'eq',
|
|
74
76
|
value: value,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { dataset } from "./Dataset";
|
|
2
|
-
|
|
2
|
+
import { SimpleRecord } from "../..";
|
|
3
|
+
export type datasetInput = string | SimpleRecord[];
|
|
4
|
+
export declare const useDataset: (dataset_id?: datasetInput) => dataset | undefined;
|
|
3
5
|
export declare const useAllDatasets: () => dataset[];
|
|
4
6
|
export declare const useDatasets: (dataset_ids?: string[]) => dataset[];
|
|
5
7
|
/**
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
import { useCallback, useContext, useState } from "react";
|
|
2
2
|
import { DatasetRegistryContext } from "./context";
|
|
3
|
-
const demo_dataset = {
|
|
4
|
-
id: 'demo_dataset',
|
|
5
|
-
isError: false,
|
|
6
|
-
isFetching: false,
|
|
7
|
-
resource: 'demo_dataset',
|
|
8
|
-
data: [
|
|
9
|
-
{ name: 'Mercure', type: 'Planète', satellites: 0, diameter_km: 4879 },
|
|
10
|
-
{ name: 'Vénus', type: 'Planète', satellites: 0, diameter_km: 12104 },
|
|
11
|
-
{ name: 'Terre', type: 'Planète', satellites: 1, diameter_km: 12742 },
|
|
12
|
-
{ name: 'Mars', type: 'Planète', satellites: 2, diameter_km: 6779 },
|
|
13
|
-
{ name: 'Jupiter', type: 'Planète', satellites: 79, diameter_km: 139820 },
|
|
14
|
-
{ name: 'Saturne', type: 'Planète', satellites: 83, diameter_km: 116460 },
|
|
15
|
-
{ name: 'Uranus', type: 'Planète', satellites: 27, diameter_km: 50724 },
|
|
16
|
-
{ name: 'Neptune', type: 'Planète', satellites: 14, diameter_km: 49244 },
|
|
17
|
-
{ name: 'Pluton', type: 'Planète naine', satellites: 5, diameter_km: 2370 },
|
|
18
|
-
{ name: 'Cérès', type: 'Astéroïde', satellites: 0, diameter_km: 946 },
|
|
19
|
-
]
|
|
20
|
-
};
|
|
21
3
|
// 🔹 Hook pour récupérer un dataset unique
|
|
22
4
|
export const useDataset = (dataset_id) => {
|
|
23
|
-
if (dataset_id
|
|
24
|
-
return
|
|
5
|
+
if (Array.isArray(dataset_id)) { //inline dataset
|
|
6
|
+
return { data: dataset_id, isFetching: false, isError: false, resource: '', id: '' };
|
|
25
7
|
}
|
|
26
8
|
const datasetRegistry = useContext(DatasetRegistryContext);
|
|
27
9
|
if (dataset_id) {
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Tag } from "antd";
|
|
3
3
|
import chroma from "chroma-js";
|
|
4
4
|
import { createContext, useContext, useEffect } from "react";
|
|
5
|
-
export const DEFAULT_PALETTE = { steps: ['
|
|
5
|
+
export const DEFAULT_PALETTE = { steps: ['#264653', '#2a9d8f', '#e9c46a', '#f4a261', '#e76f51'], mode: 'hsl' };
|
|
6
6
|
export const PaletteContext = createContext({ palette: DEFAULT_PALETTE, setPalette: () => { } });
|
|
7
7
|
export const usePalette = ({ nColors }) => {
|
|
8
8
|
const palette_context = useContext(PaletteContext);
|
package/dist/dsl/index.d.ts
CHANGED
|
@@ -22,4 +22,6 @@ import { MapLayer, Map } from "../components/Map/Map";
|
|
|
22
22
|
import { Section } from "../components/DashboardPage/Section";
|
|
23
23
|
import { LegendControl } from "../components/MapLegend/MapLegend";
|
|
24
24
|
import { Intro } from "../components/DashboardPage/Intro";
|
|
25
|
-
|
|
25
|
+
import { ChartComparison } from "../components/Charts/ChartComparison";
|
|
26
|
+
import { DataTable } from "../components/Charts/Datatable";
|
|
27
|
+
export { Dashboard, Dataset, Provider, Transform, Join, Filter, Section, Intro, DataPreview, ChartEcharts, ChartPie, ChartYearSerie, ChartComparison, DataTable, Statistics, StatisticsCollection, useDataset, useDatasets, useAllDatasets, useBlockConfig, Producer, Control, useControl, useAllControls, Radio, Select, Input, Palette, usePalette, usePaletteLabels, PalettePreview, Debug, Map, MapLayer, LegendControl };
|
package/dist/dsl/index.js
CHANGED
|
@@ -22,4 +22,6 @@ import { MapLayer, Map } from "../components/Map/Map";
|
|
|
22
22
|
import { Section } from "../components/DashboardPage/Section";
|
|
23
23
|
import { LegendControl } from "../components/MapLegend/MapLegend";
|
|
24
24
|
import { Intro } from "../components/DashboardPage/Intro";
|
|
25
|
-
|
|
25
|
+
import { ChartComparison } from "../components/Charts/ChartComparison";
|
|
26
|
+
import { DataTable } from "../components/Charts/Datatable";
|
|
27
|
+
export { Dashboard, Dataset, Provider, Transform, Join, Filter, Section, Intro, DataPreview, ChartEcharts, ChartPie, ChartYearSerie, ChartComparison, DataTable, Statistics, StatisticsCollection, useDataset, useDatasets, useAllDatasets, useBlockConfig, Producer, Control, useControl, useAllControls, Radio, Select, Input, Palette, usePalette, usePaletteLabels, PalettePreview, Debug, Map, MapLayer, LegendControl };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,5 +28,6 @@ export { WfsProvider, DatafairProvider, FileProvider };
|
|
|
28
28
|
export type { SimpleRecord, Partner, RouteConfig } from "./types";
|
|
29
29
|
export type { LegendItem } from "./components/MapLegend/MapLegend";
|
|
30
30
|
export type { DashboardConfig } from "./components/Layout/DashboardApp";
|
|
31
|
+
export type { datasetInput } from "./components/Dataset/hooks";
|
|
31
32
|
import * as DSL from './dsl';
|
|
32
33
|
export { DSL };
|