diff --git a/config.json b/config.json
index 0ca3e4783..c29938774 100644
--- a/config.json
+++ b/config.json
@@ -8,6 +8,7 @@
"all-documents",
"classif-by",
"close-by",
+ "clustered-precomputed",
"count-all",
"count-by-fields",
"cross-by",
diff --git a/src/app/custom/precomputers/precomputers-catalog.json b/src/app/custom/precomputers/precomputers-catalog.json
index 48db0298b..68ef0d101 100644
--- a/src/app/custom/precomputers/precomputers-catalog.json
+++ b/src/app/custom/precomputers/precomputers-catalog.json
@@ -13,5 +13,10 @@
"id": "post-v1-lda",
"url": "https://data-computer.services.istex.fr/v1/lda",
"doc": "https://gitbucket.inist.fr/tdm/web-services/tree/master/data-computer#v1%252flda"
+ },
+ {
+ "id": "post-v1-lda-segment",
+ "url": "https://data-computer.services.istex.fr/v1/lda-segment",
+ "doc": "https://gitbucket.inist.fr/tdm/web-services/tree/master/data-computer#v1%252flda"
}
]
diff --git a/src/app/custom/routines/routines-precomputed-catalog.json b/src/app/custom/routines/routines-precomputed-catalog.json
index 74d96a151..db1a28b7a 100644
--- a/src/app/custom/routines/routines-precomputed-catalog.json
+++ b/src/app/custom/routines/routines-precomputed-catalog.json
@@ -6,10 +6,10 @@
"recommendedWith": ["Network", "HeatMap"]
},
{
- "id": "r-lda",
- "url": "/api/run/lda-precomputed/",
- "doc": "https://user-doc.lodex.inist.fr/lodex-user-documentation/configuration/routines/lda",
- "recommendedWith": []
+ "id": "r-clustered-precomputed",
+ "url": "/api/run/clustered-precomputed/",
+ "doc": "https://user-doc.lodex.inist.fr/lodex-user-documentation/configuration/routines/clustered-precomputed",
+ "recommendedWith": ["ClusteredChart"]
},
{
"id": "r-tree-by",
diff --git a/src/app/custom/translations.tsv b/src/app/custom/translations.tsv
index 07d4fe2c6..d67643c73 100644
--- a/src/app/custom/translations.tsv
+++ b/src/app/custom/translations.tsv
@@ -1017,4 +1017,12 @@ vega_variable_list You can use these variables to set the size dynamically: Vous
vega_variable_width Replace with the width of the chart container Remplacée par la largeur du conteneur du graphique
vega_variable_height Replace with the height of the chart container Remplacée par la hauteur du conteneur du graphique
theme Application theme Thème de l'application
-"error_precomputed_data_empty" "Precomputed data is empty or unfinished. You might want to relaunch the action" "Les données précalculées sont vides ou non terminées. Vous pouvez relancer l'action"
\ No newline at end of file
+"error_precomputed_data_empty" "Precomputed data is empty or unfinished. You might want to relaunch the action" "Les données précalculées sont vides ou non terminées. Vous pouvez relancer l'action"
+"pc_post-v1-lda-segment_title" "Lda-Segment" "Lda-Segment"
+"pc_post-v1-lda-segment_description" "Create a «lda» field consisting of 5 topics from the set of documents. Each topic contains a «word» field, which is composed of a list of 10 words that are most characteristic of the topic, as well as a «weight» field that corresponds to the weight associated with the topic in the document. The text must be in English." "Créer à partir de l'ensemble des documents un champ «lda» constitué de 5 topics. Chaque topic contient un champ «word», qui est composé d'une liste de 10 mots qui sont les plus caractéristiques du topic, ainsi que d'un champ «weight» qui correspond au poids associé au sujet dans le document. Le texte doit être en anglais."
+r-clustered-precomputed_title clustered-precomputed clustered-precomputed
+r-clustered-precomputed_description Retrieve precomputed data from precomputes like 'Lda-Segment' and display it in the Clustered chart Récupère les données précalculées des précalculs comme 'Lda-Segment' et les affiche dans un Diagramme à barres groupées
+formatClusteredChart Graph - Clustered chart Graphique - Diagramme à barres groupées
+formatClusteredChartDescription Displays several bar charts depending on the category of the element and its weight Affiche plusieurs diagrammes à barres en fonction de la catégorie de l'élément et de son poids
+format_x_axis_title Title of x axis Titre de l'axe x
+format_y_axis_title Title of y axis Titre de l'axe y
diff --git a/src/app/js/formats/formats.js b/src/app/js/formats/formats.js
index 976453446..3586c8f3c 100644
--- a/src/app/js/formats/formats.js
+++ b/src/app/js/formats/formats.js
@@ -41,6 +41,7 @@ import istexCitation from './istexCitation';
import istexRefbibs from './istexRefbibs';
import bubblePlot from './vega-lite/component/bubble-plot';
import flowMap from './vega/component/flow-map';
+import clusteredChart from './vega-lite/component/clustered-chart';
export const FORMATS_CATALOG = [
{
@@ -346,4 +347,11 @@ export const FORMATS_CATALOG = [
component: flowMap,
type: 'chart',
},
+ {
+ name: 'formatClusteredChart',
+ description: 'formatClusteredChartDescription',
+ componentName: 'clusteredChart',
+ component: clusteredChart,
+ type: 'chart',
+ },
];
diff --git a/src/app/js/formats/vega-lite/component/clustered-chart/ClusteredChart.js b/src/app/js/formats/vega-lite/component/clustered-chart/ClusteredChart.js
new file mode 100644
index 000000000..19e0fad36
--- /dev/null
+++ b/src/app/js/formats/vega-lite/component/clustered-chart/ClusteredChart.js
@@ -0,0 +1,82 @@
+import { CustomActionVegaLite } from '../vega-lite-component';
+import { VEGA_LITE_DATA_INJECT_TYPE_A } from '../../../chartsUtils';
+import PropTypes from 'prop-types';
+import React, { useMemo } from 'react';
+
+const ClusteredChart = ({ data, topic, params }) => {
+ const values = useMemo(() => {
+ return data.filter(value => value.source === topic);
+ }, [data, topic]);
+
+ const spec = useMemo(() => {
+ const { colors, xTitle, yTitle } = params;
+ const specToReturn = {
+ $schema: 'https://vega.github.io/schema/vega-lite/v5.json',
+ config: { legend: { disable: true } },
+ title: topic,
+ encoding: {
+ y: { field: 'target', type: 'nominal', sort: null },
+ x: { field: 'weight', type: 'quantitative', sort: null },
+ },
+ layer: [
+ {
+ mark: 'bar',
+ encoding: {
+ color: {
+ field: 'weight',
+ scale: { range: colors.split(' ') },
+ },
+ },
+ },
+ {
+ mark: {
+ type: 'text',
+ align: 'left',
+ baseline: 'middle',
+ dx: 3,
+ },
+ encoding: {
+ text: {
+ field: 'weight',
+ type: 'quantitative',
+ format: '.4f',
+ },
+ },
+ },
+ ],
+ width: 'container',
+ height: { step: 20 },
+ };
+
+ if (xTitle && xTitle !== '') {
+ specToReturn.encoding.x.title = xTitle;
+ }
+
+ if (yTitle && yTitle !== '') {
+ specToReturn.encoding.y.title = yTitle;
+ }
+
+ return specToReturn;
+ }, [values, topic, params]);
+ return (
+