ontotext-yasgui-web-component 1.3.7 → 1.3.9

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.
Files changed (33) hide show
  1. package/dist/cjs/confirmation-dialog_9.cjs.entry.js +432 -50
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/ontotext-yasgui-web-component.cjs.js +1 -1
  4. package/dist/collection/components/ontotext-yasgui-web-component/ontotext-yasgui-web-component.js +25 -2
  5. package/dist/collection/models/plugins/pivot-table/pivot-table-aggregator-type.js +24 -0
  6. package/dist/collection/models/plugins/pivot-table/pivot-table-aggregator.js +32 -0
  7. package/dist/collection/models/plugins/pivot-table/pivot-table-renderer-type.js +14 -0
  8. package/dist/collection/models/plugins/pivot-table/pivot-table-renderer.js +22 -0
  9. package/dist/collection/pages/languages/main.js +5 -1
  10. package/dist/collection/plugins/yasr/pivot-table/pivot-table-plugin.js +113 -33
  11. package/dist/collection/services/plugins/pivot-table-service.js +115 -0
  12. package/dist/collection/services/translation.service.js +7 -1
  13. package/dist/collection/services/utils/object-util.js +19 -0
  14. package/dist/components/ontotext-yasgui.js +360 -49
  15. package/dist/components/translation.service.js +75 -1
  16. package/dist/esm/confirmation-dialog_9.entry.js +432 -50
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/ontotext-yasgui-web-component.js +1 -1
  19. package/dist/ontotext-yasgui-web-component/ontotext-yasgui-web-component.esm.js +1 -1
  20. package/dist/ontotext-yasgui-web-component/p-64607a87.entry.js +1 -0
  21. package/dist/types/components/ontotext-yasgui-web-component/ontotext-yasgui-web-component.d.ts +5 -0
  22. package/dist/types/models/plugins/pivot-table/pivot-table-aggregator-type.d.ts +24 -0
  23. package/dist/types/models/plugins/pivot-table/pivot-table-aggregator.d.ts +16 -0
  24. package/dist/types/models/plugins/pivot-table/pivot-table-persistent-config.d.ts +6 -5
  25. package/dist/types/models/plugins/pivot-table/pivot-table-renderer-type.d.ts +14 -0
  26. package/dist/types/models/plugins/pivot-table/pivot-table-renderer.d.ts +16 -0
  27. package/dist/types/services/plugins/pivot-table-service.d.ts +69 -0
  28. package/dist/types/services/translation.service.d.ts +2 -0
  29. package/dist/types/services/utils/object-util.d.ts +12 -0
  30. package/package.json +1 -1
  31. package/dist/collection/models/plugins/pivot-table/pivot-table-renderer-name.js +0 -15
  32. package/dist/ontotext-yasgui-web-component/p-cb08a3ea.entry.js +0 -1
  33. package/dist/types/models/plugins/pivot-table/pivot-table-renderer-name.d.ts +0 -14
@@ -317,6 +317,40 @@ const en = {
317
317
  "yasr.plugin_control.plugin.name.pivot-table-plugin.cells": "Cells",
318
318
  "yasr.plugin_control.plugin.name.pivot-table-plugin.rows": "Rows",
319
319
  "yasr.plugin_control.plugin.pivot-table-plugin.charts.config.button": "Chart Config",
320
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TABLE": "Table",
321
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TABLE_BARCHART": "Table Barchart",
322
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_HEATMAP": "Heatmap",
323
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_ROW_HEATMAP": "Row Heatmap",
324
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_COL_HEATMAP": "Col Heatmap",
325
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TREEMAP": "Treemap",
326
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_LINE_CHART": "Line Chart",
327
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_BAR_CHART": "Bar Chart",
328
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_STACKED_BAR_CHART": "Stacked Bar Chart",
329
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_AREA_CHART": "Area Chart",
330
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_SCATTER_CHART": "Scatter Chart",
331
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TSV_EXPORT": "TSV Export",
332
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT": "Count",
333
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_UNIQUE_VALUES": "Count Unique Values",
334
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_LIST_UNIQUE_VALUES": "List Unique Values",
335
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM": "Sum",
336
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_INTEGER_SUM": "Integer Sum",
337
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_AVERAGE": "Average",
338
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_MEDIAN": "Median",
339
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SAMPLE_VARIANCE": "Sample Variance",
340
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SAMPLE_STANDARD_DEVIATION": "Sample Standard Deviation",
341
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_MINIMUM": "Minimum",
342
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_MAXIMUM": "Maximum",
343
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_FIRST": "First",
344
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_LAST": "Last",
345
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_OVER_SUM": "Sum over Sum",
346
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_UPPER_BOUND": "80% Upper Bound",
347
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_LOWER_BOUND": "80% Lower Bound",
348
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_AS_FRACTION_OF_TOTAL": "Sum as Fraction of Total",
349
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_AS_FRACTION_OF_ROWS": "Sum as Fraction of Rows",
350
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_AS_FRACTION_OF_COLUMNS": "Sum as Fraction of Columns",
351
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_AS_FRACTION_OF_TOTAL": "Count as Fraction of Total",
352
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_AS_FRACTION_OF_ROWS": "Count as Fraction of Rows",
353
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_AS_FRACTION_OF_COLUMNS": "Count as Fraction of Columns",
320
354
  "yasr.plugin_control.plugin.name.charts": "Google Chart",
321
355
  "yasr.plugin_control.plugin.charts.config.button": "Chart Config",
322
356
  "yasr.plugin_control.shows_view.btn.aria_label": "Shows {{name}} view",
@@ -557,6 +591,40 @@ const fr = {
557
591
  "yasr.plugin_control.plugin.name.pivot-table-plugin.cells": "Cellules",
558
592
  "yasr.plugin_control.plugin.name.pivot-table-plugin.rows": "Lignes",
559
593
  "yasr.plugin_control.plugin.pivot-table-plugin.charts.config.button": "Configuration du graphique",
594
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TABLE": "Table",
595
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TABLE_BARCHART": "Table avec barres",
596
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_HEATMAP": "Carte de chaleur",
597
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_ROW_HEATMAP": "Carte de chaleur par ligne",
598
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_COL_HEATMAP": "Carte de chaleur par colonne",
599
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TREEMAP": "Carte arborescente",
600
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_LINE_CHART": "Graphique linéaire",
601
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_BAR_CHART": "Diagramme à barres",
602
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_STACKED_BAR_CHART": "Diagramme à barres empilées",
603
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_AREA_CHART": "Graphique en aires",
604
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_SCATTER_CHART": "Diagramme de dispersion",
605
+ "yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_TSV_EXPORT": "Exportation TSV",
606
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT": "Nombre",
607
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_UNIQUE_VALUES": "Nombre de valeurs uniques",
608
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_LIST_UNIQUE_VALUES": "Liste de valeurs uniques",
609
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM": "Somme",
610
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_INTEGER_SUM": "Somme en entiers",
611
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_AVERAGE": "Moyenne",
612
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_MEDIAN": "Médiane",
613
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SAMPLE_VARIANCE": "Variance d'échantillonnage",
614
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SAMPLE_STANDARD_DEVIATION": "Écart type d'échantillonnage",
615
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_MINIMUM": "Minimum",
616
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_MAXIMUM": "Maximum",
617
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_FIRST": "Premier",
618
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_LAST": "Dernier",
619
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_OVER_SUM": "Ratio de sommes",
620
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_UPPER_BOUND": "Borne supérieure 80%",
621
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_LOWER_BOUND": "Borne inférieure 80%",
622
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_AS_FRACTION_OF_TOTAL": "Somme en proportion du totale",
623
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_AS_FRACTION_OF_ROWS": "Somme en proportion de la ligne",
624
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_SUM_AS_FRACTION_OF_COLUMNS": "Somme en proportion de la colonne",
625
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_AS_FRACTION_OF_TOTAL": "Nombre en proportion du totale",
626
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_AS_FRACTION_OF_ROWS": "Nombre en proportion de la ligne",
627
+ "yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_COUNT_AS_FRACTION_OF_COLUMNS": "Nombre en proportion de la colonne",
560
628
  "yasr.plugin_control.plugin.name.charts": "Graphique Google",
561
629
  "yasr.plugin_control.plugin.charts.config.button": "Configuration du graphique",
562
630
  "yasr.plugin_control.shows_view.btn.aria_label": "Affiche la vue {{name}}",
@@ -720,6 +788,9 @@ class TranslationService {
720
788
  this.notifyLanguageChangeObservers(this.currentLang);
721
789
  this.notifyTranslationsChanged();
722
790
  }
791
+ getLanguage() {
792
+ return this.currentLang;
793
+ }
723
794
  /**
724
795
  * Subscribes the observer for further language change events.
725
796
  *
@@ -794,7 +865,10 @@ class TranslationService {
794
865
  * @param parameters Optional parameters which to be applied during the translation.
795
866
  */
796
867
  translate(key, parameters) {
797
- let translation = this.bundle[this.currentLang][key];
868
+ return this.translateInLocale(key, this.currentLang, parameters);
869
+ }
870
+ translateInLocale(key, locale, parameters) {
871
+ let translation = this.bundle[locale][key];
798
872
  if (!translation) {
799
873
  // Fallback to the default language
800
874
  translation = this.bundle[DEFAULT_LANG][key];
@@ -3013,22 +3087,6 @@ class TableToCsvConfiguration {
3013
3087
  }
3014
3088
  }
3015
3089
 
3016
- var PivotTableRendererName;
3017
- (function (PivotTableRendererName) {
3018
- PivotTableRendererName["TABLE"] = "Table";
3019
- PivotTableRendererName["TABLE_BARCHART"] = "Table Barchart";
3020
- PivotTableRendererName["HEATMAP"] = "Heatmap";
3021
- PivotTableRendererName["ROW_HEATMAP"] = "Row Heatmap";
3022
- PivotTableRendererName["COL_HEATMAP"] = "Col Heatmap";
3023
- PivotTableRendererName["TREEMAP"] = "Treemap";
3024
- PivotTableRendererName["LINE_CHART"] = "Line Chart";
3025
- PivotTableRendererName["BAR_CHART"] = "Bar Chart";
3026
- PivotTableRendererName["STACKED_BAR_CHART"] = "Stacked Bar Chart";
3027
- PivotTableRendererName["AREA_CHART"] = "Area Chart";
3028
- PivotTableRendererName["SCATTER_CHART"] = "Scatter Chart";
3029
- PivotTableRendererName["TSV_EXPORT"] = "TSV Export";
3030
- })(PivotTableRendererName || (PivotTableRendererName = {}));
3031
-
3032
3090
  const D3_7_8_5_RENDER = (function () {
3033
3091
 
3034
3092
  const DEFAULTS = {
@@ -3124,6 +3182,242 @@ const D3_7_8_5_RENDER = (function () {
3124
3182
  };
3125
3183
  })();
3126
3184
 
3185
+ const PivotTableRendererType = {
3186
+ TABLE: 'TABLE',
3187
+ TABLE_BARCHART: 'TABLE_BARCHART',
3188
+ HEATMAP: 'HEATMAP',
3189
+ ROW_HEATMAP: 'ROW_HEATMAP',
3190
+ COL_HEATMAP: 'COL_HEATMAP',
3191
+ TREEMAP: 'TREEMAP',
3192
+ LINE_CHART: 'LINE_CHART',
3193
+ BAR_CHART: 'BAR_CHART',
3194
+ STACKED_BAR_CHART: 'STACKED_BAR_CHART',
3195
+ AREA_CHART: 'AREA_CHART',
3196
+ SCATTER_CHART: 'SCATTER_CHART',
3197
+ TSV_EXPORT: 'TSV_EXPORT'
3198
+ };
3199
+
3200
+ const RENDERER_ORDER_LIST = [
3201
+ PivotTableRendererType.TABLE,
3202
+ PivotTableRendererType.TABLE_BARCHART,
3203
+ PivotTableRendererType.HEATMAP,
3204
+ PivotTableRendererType.ROW_HEATMAP,
3205
+ PivotTableRendererType.COL_HEATMAP,
3206
+ PivotTableRendererType.TREEMAP,
3207
+ PivotTableRendererType.LINE_CHART,
3208
+ PivotTableRendererType.BAR_CHART,
3209
+ PivotTableRendererType.STACKED_BAR_CHART,
3210
+ PivotTableRendererType.AREA_CHART,
3211
+ PivotTableRendererType.SCATTER_CHART,
3212
+ PivotTableRendererType.TSV_EXPORT
3213
+ ];
3214
+ class PivotTableRenderer {
3215
+ constructor(name, type) {
3216
+ this.name = name;
3217
+ this.type = type;
3218
+ this.order = RENDERER_ORDER_LIST.indexOf(this.type);
3219
+ }
3220
+ }
3221
+
3222
+ const PivotTableAggregatorType = {
3223
+ COUNT: 'COUNT',
3224
+ COUNT_UNIQUE_VALUES: 'COUNT_UNIQUE_VALUES',
3225
+ LIST_UNIQUE_VALUES: 'LIST_UNIQUE_VALUES',
3226
+ SUM: 'SUM',
3227
+ INTEGER_SUM: 'INTEGER_SUM',
3228
+ AVERAGE: 'AVERAGE',
3229
+ MEDIAN: 'MEDIAN',
3230
+ SAMPLE_VARIANCE: 'SAMPLE_VARIANCE',
3231
+ SAMPLE_STANDARD_DEVIATION: 'SAMPLE_STANDARD_DEVIATION',
3232
+ MINIMUM: 'MINIMUM',
3233
+ MAXIMUM: 'MAXIMUM',
3234
+ FIRST: 'FIRST',
3235
+ LAST: 'LAST',
3236
+ SUM_OVER_SUM: 'SUM_OVER_SUM',
3237
+ UPPER_BOUND: 'UPPER_BOUND',
3238
+ LOWER_BOUND: 'LOWER_BOUND',
3239
+ SUM_AS_FRACTION_OF_TOTAL: 'SUM_AS_FRACTION_OF_TOTAL',
3240
+ SUM_AS_FRACTION_OF_ROWS: 'SUM_AS_FRACTION_OF_ROWS',
3241
+ SUM_AS_FRACTION_OF_COLUMNS: 'SUM_AS_FRACTION_OF_COLUMNS',
3242
+ COUNT_AS_FRACTION_OF_TOTAL: 'COUNT_AS_FRACTION_OF_TOTAL',
3243
+ COUNT_AS_FRACTION_OF_ROWS: 'COUNT_AS_FRACTION_OF_ROWS',
3244
+ COUNT_AS_FRACTION_OF_COLUMNS: 'COUNT_AS_FRACTION_OF_COLUMNS'
3245
+ };
3246
+
3247
+ const AGGREGATOR_ORDER_LIST = [
3248
+ PivotTableAggregatorType.COUNT,
3249
+ PivotTableAggregatorType.COUNT_UNIQUE_VALUES,
3250
+ PivotTableAggregatorType.LIST_UNIQUE_VALUES,
3251
+ PivotTableAggregatorType.SUM,
3252
+ PivotTableAggregatorType.INTEGER_SUM,
3253
+ PivotTableAggregatorType.AVERAGE,
3254
+ PivotTableAggregatorType.MEDIAN,
3255
+ PivotTableAggregatorType.SAMPLE_VARIANCE,
3256
+ PivotTableAggregatorType.SAMPLE_STANDARD_DEVIATION,
3257
+ PivotTableAggregatorType.MINIMUM,
3258
+ PivotTableAggregatorType.MAXIMUM,
3259
+ PivotTableAggregatorType.FIRST,
3260
+ PivotTableAggregatorType.LAST,
3261
+ PivotTableAggregatorType.SUM_OVER_SUM,
3262
+ PivotTableAggregatorType.UPPER_BOUND,
3263
+ PivotTableAggregatorType.LOWER_BOUND,
3264
+ PivotTableAggregatorType.SUM_AS_FRACTION_OF_TOTAL,
3265
+ PivotTableAggregatorType.SUM_AS_FRACTION_OF_ROWS,
3266
+ PivotTableAggregatorType.SUM_AS_FRACTION_OF_COLUMNS,
3267
+ PivotTableAggregatorType.COUNT_AS_FRACTION_OF_TOTAL,
3268
+ PivotTableAggregatorType.COUNT_AS_FRACTION_OF_ROWS,
3269
+ PivotTableAggregatorType.COUNT_AS_FRACTION_OF_COLUMNS
3270
+ ];
3271
+ class PivotTableAggregator {
3272
+ constructor(name, type) {
3273
+ this.name = name;
3274
+ this.type = type;
3275
+ this.order = AGGREGATOR_ORDER_LIST.indexOf(this.type);
3276
+ }
3277
+ }
3278
+
3279
+ class PivotTableService {
3280
+ constructor(translationService) {
3281
+ this.translationService = translationService;
3282
+ this.initRenderers();
3283
+ this.initAggregators();
3284
+ }
3285
+ /**
3286
+ * Retrieves an instance of {@link PivotTableRenderer} based on the specified <code>type</code>.
3287
+ *
3288
+ * @param {string} type - renderer type, the value must be one of {@link PivotTableRendererType} values.
3289
+ * @returns {PivotTableRenderer} An instance of {@link PivotTableRenderer} corresponding to the specified type.
3290
+ */
3291
+ getPivotRendererByType(type) {
3292
+ return this.renderers.find((renderer) => renderer.type === type);
3293
+ }
3294
+ /**
3295
+ * Retrieves an instance of {@link PivotTableRenderer} based on the specified <code>name</code>.
3296
+ *
3297
+ * @param {string} name - The renderer name. The value is language-dependent.
3298
+ * @returns {PivotTableRenderer} An instance of {@link PivotTableRenderer} corresponding to the specified name.
3299
+ */
3300
+ getPivotRendererByName(name) {
3301
+ return this.renderers.find((renderer) => renderer.name === name);
3302
+ }
3303
+ /**
3304
+ * Fetches the name of a renderer with the specified <code>type</code>.
3305
+ *
3306
+ * @param {string} type - The renderer type. The value must be one of {@link PivotTableRendererType} values.
3307
+ * @param {string} language - The locale. For instance, "en", "fr", etc.
3308
+ * @return {string} The translated name of the renderer with the specified <code>type</code>.
3309
+ */
3310
+ getPivotTableRenderName(type, language) {
3311
+ if (language) {
3312
+ return this.translationService.translateInLocale((PivotTableService.RENDERER_NAME_PREFIX + type), language);
3313
+ }
3314
+ return this.translationService.translate(PivotTableService.RENDERER_NAME_PREFIX + type);
3315
+ }
3316
+ getPivotTableRenderersCompareByNameFunction() {
3317
+ return (name1, name2) => {
3318
+ const pivotRendererByName = this.getPivotRendererByName(name1);
3319
+ const pivotRendererByName1 = this.getPivotRendererByName(name2);
3320
+ return pivotRendererByName.order - pivotRendererByName1.order;
3321
+ };
3322
+ }
3323
+ /**
3324
+ * Retrieves an instance of {@link PivotTableAggregator} based on the specified <code>type</code>.
3325
+ *
3326
+ * @param {string} type - aggregator type, the value must be one of {@link PivotTableAggregatorType} values.
3327
+ * @returns {PivotTableAggregator} An instance of {@link PivotTableAggregator} corresponding to the specified type.
3328
+ */
3329
+ getPivotTableAggregatorByType(type) {
3330
+ return this.aggregators.find((aggregator) => aggregator.type === type);
3331
+ }
3332
+ /**
3333
+ * Retrieves an instance of {@link PivotTableAggregator} based on the specified <code>name</code>.
3334
+ *
3335
+ * @param {string} name - The aggregator name. The value is language-dependent.
3336
+ * @returns {PivotTableAggregator} An instance of {@link PivotTableAggregator} corresponding to the specified name.
3337
+ */
3338
+ getPivotTableAggregatorByName(name) {
3339
+ return this.aggregators.find((aggregator) => aggregator.name === name);
3340
+ }
3341
+ /**
3342
+ * Fetches the name of an aggregator with the specified <code>type</code>.
3343
+ *
3344
+ * @param {string} type - The aggregator type. The value must be one of {@link PivotTableAggregatorType} values.
3345
+ * @param {string} language - The locale. For instance, "en", "fr", etc.
3346
+ * @return {string} The translated name of the aggregator with the specified <code>type</code>.
3347
+ */
3348
+ getPivotTableAggregatorName(type, language) {
3349
+ if (language) {
3350
+ return this.translationService.translateInLocale(PivotTableService.AGGREGATOR_NAME_PREFIX + type, language);
3351
+ }
3352
+ return this.translationService.translate(PivotTableService.AGGREGATOR_NAME_PREFIX + type);
3353
+ }
3354
+ getPivotTableAggregatorsCompareByNameFunction() {
3355
+ return (name1, name2) => {
3356
+ const pivotTableAggregatorByName = this.getPivotTableAggregatorByName(name1);
3357
+ const pivotTableAggregatorByName1 = this.getPivotTableAggregatorByName(name2);
3358
+ return pivotTableAggregatorByName.order - pivotTableAggregatorByName1.order;
3359
+ };
3360
+ }
3361
+ /**
3362
+ * Initializes renderers. A renderer is an object that contains a mapping between a name and a type. The type is hardcoded and is
3363
+ * described in the {@link PivotTableRendererType}. The name depends on the language. During initialization, the names are translated
3364
+ * via the {@link TranslationService}.
3365
+ */
3366
+ initRenderers() {
3367
+ this.renderers = [];
3368
+ Object.keys(PivotTableRendererType)
3369
+ .forEach((pivotTableRendererType) => {
3370
+ const pivotTableRenderName = this.getPivotTableRenderName(pivotTableRendererType);
3371
+ this.renderers.push(new PivotTableRenderer(pivotTableRenderName, pivotTableRendererType));
3372
+ });
3373
+ }
3374
+ /**
3375
+ * Initializes aggregators. An aggregator is an object that contains a mapping between a name and a type. The type is hardcoded and is
3376
+ * described in the {@link PivotTableAggregatorType} enum. The name depends on the language. During initialization, the names are translated
3377
+ * via the {@link TranslationService}.
3378
+ */
3379
+ initAggregators() {
3380
+ this.aggregators = [];
3381
+ Object.keys(PivotTableAggregatorType)
3382
+ .forEach((pivotTableAggregatorType) => {
3383
+ const pivotTableRenderName = this.getPivotTableAggregatorName(pivotTableAggregatorType);
3384
+ this.aggregators.push(new PivotTableAggregator(pivotTableRenderName, pivotTableAggregatorType));
3385
+ });
3386
+ }
3387
+ }
3388
+ PivotTableService.RENDERER_NAME_PREFIX = 'yasr.plugin_control.plugin.pivot-table-plugin.renderer.type_';
3389
+ PivotTableService.AGGREGATOR_NAME_PREFIX = 'yasr.plugin_control.plugin.pivot-table-plugin.aggregator.type_';
3390
+
3391
+ class ObjectUtil {
3392
+ /**
3393
+ * Reorders an <code>object</code> based on the passed <code>compareFunction</code>.
3394
+ *
3395
+ * @param object - The object whose key-value pairs will be reordered.
3396
+ * @param compareFunction - A function that will be called with two keys from the object.
3397
+ * It should return a positive number if the first key should come before the second,
3398
+ * a negative number if the second key should come before the first, or 0 if both keys are equal.
3399
+ *
3400
+ */
3401
+ static orderObjectByKey(object, compareFunction) {
3402
+ const sortedAggregators = {};
3403
+ Object.keys(object).sort(compareFunction)
3404
+ .forEach((key) => {
3405
+ sortedAggregators[key] = object[key];
3406
+ });
3407
+ return sortedAggregators;
3408
+ }
3409
+ }
3410
+
3411
+ const NOT_TRANSLATED_RENDERERS_TYPES = [
3412
+ PivotTableRendererType.TREEMAP,
3413
+ PivotTableRendererType.LINE_CHART,
3414
+ PivotTableRendererType.BAR_CHART,
3415
+ PivotTableRendererType.STACKED_BAR_CHART,
3416
+ PivotTableRendererType.AREA_CHART,
3417
+ PivotTableRendererType.SCATTER_CHART,
3418
+ PivotTableRendererType.TSV_EXPORT
3419
+ ];
3420
+ const PIVOT_TABLE_SUPPORTED_LANGUAGES = ['cs', 'da', 'de', 'es', 'fr', 'jp', 'nl', 'pl', 'pt', 'ru', 'sq', 'tr', 'zh'];
3127
3421
  class PivotTablePlugin {
3128
3422
  // @ts-ignore
3129
3423
  constructor(yasr) {
@@ -3132,6 +3426,8 @@ class PivotTablePlugin {
3132
3426
  if (yasr) {
3133
3427
  this.yasr = yasr;
3134
3428
  this.translationService = this.yasr.config.translationService;
3429
+ this.currentLanguage = this.translationService.getLanguage();
3430
+ this.pivotTableService = new PivotTableService(this.translationService);
3135
3431
  }
3136
3432
  }
3137
3433
  initialize() {
@@ -3142,9 +3438,14 @@ class PivotTablePlugin {
3142
3438
  HtmlUtil.loadJavaScript('https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js');
3143
3439
  HtmlUtil.loadJavaScript('https://www.gstatic.com/charts/loader.js');
3144
3440
  HtmlUtil.loadJavaScript('https://pivottable.js.org/dist/pivot.js');
3441
+ if (PIVOT_TABLE_SUPPORTED_LANGUAGES.includes(this.currentLanguage)) {
3442
+ HtmlUtil.loadJavaScript(`https://pivottable.js.org/dist/pivot.${this.currentLanguage}.js`);
3443
+ }
3145
3444
  HtmlUtil.loadJavaScript('https://pivottable.js.org/dist/export_renderers.js');
3146
3445
  HtmlUtil.loadJavaScript('https://pivottable.js.org/dist/gchart_renderers.js', () => {
3147
3446
  D3_7_8_5_RENDER.register();
3447
+ this.setupRenderers();
3448
+ this.setupAggregators();
3148
3449
  resolve();
3149
3450
  });
3150
3451
  });
@@ -3162,7 +3463,7 @@ class PivotTablePlugin {
3162
3463
  // @ts-ignore
3163
3464
  google.charts.load('current', { packages: ['corechart', 'charteditor'] });
3164
3465
  // If the render is a Google chart we have to wait the module to be loaded.
3165
- if (persistentConfig && this.isGoogleChartRender(persistentConfig.rendererName)) {
3466
+ if (persistentConfig && persistentConfig.rendererType && this.isGoogleChartRender(this.pivotTableService.getPivotRendererByType(persistentConfig.rendererType))) {
3166
3467
  // @ts-ignore
3167
3468
  google.setOnLoadCallback(() => {
3168
3469
  this.drawPivotTable(persistentConfig);
@@ -3176,8 +3477,9 @@ class PivotTablePlugin {
3176
3477
  }
3177
3478
  drawPivotTable(persistentConfig) {
3178
3479
  const config = Object.assign({}, persistentConfig);
3179
- config.renderers = this.getRenders();
3180
3480
  config.onRefresh = this.onRefresh();
3481
+ config.rendererName = config.rendererType ? this.pivotTableService.getPivotRendererByType(config.rendererType).name : undefined;
3482
+ config.aggregatorName = config.aggregatorType ? this.pivotTableService.getPivotTableAggregatorByType(config.aggregatorType).name : undefined;
3181
3483
  this.showPlugin(config);
3182
3484
  this.addUnusedVariableHeader();
3183
3485
  this.addColumnsHeader();
@@ -3185,13 +3487,16 @@ class PivotTablePlugin {
3185
3487
  this.addRowsHeader();
3186
3488
  this.updateVariablesElement();
3187
3489
  }
3188
- isGoogleChartRender(renderName) {
3189
- switch (renderName) {
3190
- case PivotTableRendererName.BAR_CHART:
3191
- case PivotTableRendererName.LINE_CHART:
3192
- case PivotTableRendererName.STACKED_BAR_CHART:
3193
- case PivotTableRendererName.AREA_CHART:
3194
- case PivotTableRendererName.SCATTER_CHART:
3490
+ isGoogleChartRender(renderer) {
3491
+ if (!renderer) {
3492
+ return false;
3493
+ }
3494
+ switch (renderer.type) {
3495
+ case PivotTableRendererType.BAR_CHART:
3496
+ case PivotTableRendererType.LINE_CHART:
3497
+ case PivotTableRendererType.STACKED_BAR_CHART:
3498
+ case PivotTableRendererType.AREA_CHART:
3499
+ case PivotTableRendererType.SCATTER_CHART:
3195
3500
  return true;
3196
3501
  }
3197
3502
  return false;
@@ -3210,28 +3515,85 @@ class PivotTablePlugin {
3210
3515
  // @ts-ignore
3211
3516
  const options = $(this.yasr.rootEl.querySelector(`.${PivotTablePlugin.PLUGIN_NAME}`)).data('pivotUIOptions');
3212
3517
  if (options) {
3213
- switch (options.rendererName) {
3214
- case PivotTableRendererName.TSV_EXPORT:
3518
+ switch (this.pivotTableService.getPivotRendererByName(options.rendererName).type) {
3519
+ case PivotTableRendererType.TSV_EXPORT:
3215
3520
  return PivotTableDownloadUtil.getTSVDownloadInfo(this.yasr);
3216
- case PivotTableRendererName.TABLE:
3217
- case PivotTableRendererName.TABLE_BARCHART:
3218
- case PivotTableRendererName.HEATMAP:
3219
- case PivotTableRendererName.ROW_HEATMAP:
3220
- case PivotTableRendererName.COL_HEATMAP:
3521
+ case PivotTableRendererType.TABLE:
3522
+ case PivotTableRendererType.TABLE_BARCHART:
3523
+ case PivotTableRendererType.HEATMAP:
3524
+ case PivotTableRendererType.ROW_HEATMAP:
3525
+ case PivotTableRendererType.COL_HEATMAP:
3221
3526
  return PivotTableDownloadUtil.getCSVDownloadInfo(this.yasr);
3222
- case PivotTableRendererName.BAR_CHART:
3223
- case PivotTableRendererName.LINE_CHART:
3224
- case PivotTableRendererName.STACKED_BAR_CHART:
3225
- case PivotTableRendererName.AREA_CHART:
3226
- case PivotTableRendererName.SCATTER_CHART:
3527
+ case PivotTableRendererType.BAR_CHART:
3528
+ case PivotTableRendererType.LINE_CHART:
3529
+ case PivotTableRendererType.STACKED_BAR_CHART:
3530
+ case PivotTableRendererType.AREA_CHART:
3531
+ case PivotTableRendererType.SCATTER_CHART:
3227
3532
  return PivotTableDownloadUtil.getSvgDownloadInfo(this.yasr);
3228
3533
  }
3229
3534
  }
3230
3535
  return;
3231
3536
  }
3232
- getRenders() {
3537
+ setupRenderers() {
3538
+ this.translateRenders();
3539
+ this.sortRenderers();
3540
+ }
3541
+ /**
3542
+ * Pivot table has support for translation of renderers that are loaded by default. For additional renderers, we have to translate them ourselves.
3543
+ */
3544
+ translateRenders() {
3233
3545
  // @ts-ignore
3234
- return $.extend(true, $.pivotUtilities.renderers, $.pivotUtilities[D3_7_8_5_RENDER.RENDER_NAME], $.pivotUtilities.gchart_renderers, $.pivotUtilities.export_renderers);
3546
+ const renderers = $.extend(true, $.pivotUtilities[D3_7_8_5_RENDER.RENDER_NAME], $.pivotUtilities.gchart_renderers, $.pivotUtilities.export_renderers);
3547
+ NOT_TRANSLATED_RENDERERS_TYPES.forEach((rendererType) => {
3548
+ const renderer = this.pivotTableService.getPivotRendererByType(rendererType);
3549
+ const rendererEnName = this.pivotTableService.getPivotTableRenderName(rendererType, 'en');
3550
+ if (renderer) {
3551
+ // @ts-ignore
3552
+ $.pivotUtilities.locales[this.currentLanguage].renderers[renderer.name] = renderers[rendererEnName];
3553
+ }
3554
+ else {
3555
+ console.log(`Missing translation for renderer: [${rendererType}] The default will be used!`);
3556
+ // @ts-ignore
3557
+ $.pivotUtilities.locales[this.currentLanguage].renderers[renderer] = renderers[rendererEnName];
3558
+ }
3559
+ });
3560
+ }
3561
+ /**
3562
+ * Sorts renderers.
3563
+ */
3564
+ sortRenderers() {
3565
+ // @ts-ignore
3566
+ $.pivotUtilities.locales[this.currentLanguage].renderers = ObjectUtil.orderObjectByKey($.pivotUtilities.locales[this.currentLanguage].renderers, this.pivotTableService.getPivotTableRenderersCompareByNameFunction());
3567
+ }
3568
+ setupAggregators() {
3569
+ if ('fr' === this.currentLanguage) {
3570
+ this.addMissedFrenchAggregators();
3571
+ }
3572
+ this.sortAggregators();
3573
+ }
3574
+ /**
3575
+ * Sorts aggregators.
3576
+ */
3577
+ sortAggregators() {
3578
+ // @ts-ignore
3579
+ $.pivotUtilities.locales[this.currentLanguage].aggregators = ObjectUtil.orderObjectByKey($.pivotUtilities.locales[this.currentLanguage].aggregators, this.pivotTableService.getPivotTableAggregatorsCompareByNameFunction());
3580
+ }
3581
+ /**
3582
+ * The French pivot table is missing the 'Median', 'Sample Variance', and 'Sample Standard Deviation' aggregators.
3583
+ * This function adds these aggregators to the French locale object.
3584
+ */
3585
+ addMissedFrenchAggregators() {
3586
+ // @ts-ignore
3587
+ const frFmt = $.pivotUtilities.numberFormat({
3588
+ thousandsSep: " ",
3589
+ decimalSep: ","
3590
+ });
3591
+ // @ts-ignore
3592
+ $.pivotUtilities.locales[this.currentLanguage].aggregators[this.translationService.translate(PivotTableService.AGGREGATOR_NAME_PREFIX + 'MEDIAN')] = $.pivotUtilities.aggregatorTemplates.median(frFmt);
3593
+ // @ts-ignore
3594
+ $.pivotUtilities.locales[this.currentLanguage].aggregators[this.translationService.translate(PivotTableService.AGGREGATOR_NAME_PREFIX + 'SAMPLE_VARIANCE')] = $.pivotUtilities.aggregatorTemplates["var"](1, frFmt);
3595
+ // @ts-ignore
3596
+ $.pivotUtilities.locales[this.currentLanguage].aggregators[this.translationService.translate(PivotTableService.AGGREGATOR_NAME_PREFIX + 'SAMPLE_STANDARD_DEVIATION')] = $.pivotUtilities.aggregatorTemplates.stdev(1, frFmt);
3235
3597
  }
3236
3598
  showPlugin(config) {
3237
3599
  this.pluginElement = document.createElement("div");
@@ -3239,7 +3601,7 @@ class PivotTablePlugin {
3239
3601
  this.yasr.resultsEl.appendChild(this.pluginElement);
3240
3602
  // @ts-ignore
3241
3603
  $(this.yasr.rootEl.querySelector(`.${PivotTablePlugin.PLUGIN_NAME}`))
3242
- .pivotUI((callback) => this.getResults(callback), config);
3604
+ .pivotUI((callback) => this.getResults(callback), config, false, this.currentLanguage);
3243
3605
  }
3244
3606
  /**
3245
3607
  * This function transforms Yasr results into the input type expected by the PivotTable. It is called to fetch all values that need to be populated.
@@ -3334,12 +3696,12 @@ class PivotTablePlugin {
3334
3696
  onRefresh() {
3335
3697
  return (pivotUIOptions) => {
3336
3698
  if (pivotUIOptions) {
3337
- switch (pivotUIOptions.rendererName) {
3338
- case PivotTableRendererName.BAR_CHART:
3339
- case PivotTableRendererName.LINE_CHART:
3340
- case PivotTableRendererName.STACKED_BAR_CHART:
3341
- case PivotTableRendererName.AREA_CHART:
3342
- case PivotTableRendererName.SCATTER_CHART:
3699
+ switch (this.pivotTableService.getPivotRendererByName(pivotUIOptions.rendererName).type) {
3700
+ case PivotTableRendererType.BAR_CHART:
3701
+ case PivotTableRendererType.LINE_CHART:
3702
+ case PivotTableRendererType.STACKED_BAR_CHART:
3703
+ case PivotTableRendererType.AREA_CHART:
3704
+ case PivotTableRendererType.SCATTER_CHART:
3343
3705
  this.addChartConfigButton();
3344
3706
  break;
3345
3707
  default:
@@ -3386,8 +3748,8 @@ class PivotTablePlugin {
3386
3748
  exclusions: pivotUIOptions.exclusions,
3387
3749
  inclusions: pivotUIOptions.inclusions,
3388
3750
  inclusionsInfo: pivotUIOptions.inclusionsInfo,
3389
- aggregatorName: pivotUIOptions.aggregatorName,
3390
- rendererName: pivotUIOptions.rendererName,
3751
+ aggregatorType: this.pivotTableService.getPivotTableAggregatorByName(pivotUIOptions.aggregatorName).type,
3752
+ rendererType: this.pivotTableService.getPivotRendererByName(pivotUIOptions.rendererName).type
3391
3753
  };
3392
3754
  }
3393
3755
  }
@@ -4035,6 +4397,7 @@ const OntotextYasguiWebComponent = class {
4035
4397
  this.shareQuery = index.createEvent(this, "shareQuery", 7);
4036
4398
  this.output = index.createEvent(this, "output", 7);
4037
4399
  this.defaultViewMode = RenderingMode.YASGUI;
4400
+ this.subscriptions = [];
4038
4401
  this.config = undefined;
4039
4402
  this.language = undefined;
4040
4403
  this.savedQueryConfig = undefined;
@@ -4052,12 +4415,16 @@ const OntotextYasguiWebComponent = class {
4052
4415
  this.copiedResourceLink = undefined;
4053
4416
  this.loaderMessage = undefined;
4054
4417
  this.additionalLoaderMessage = undefined;
4418
+ this.yasqeBtnLabel = undefined;
4419
+ this.yasguiBtnLabel = undefined;
4420
+ this.yasrBtnLabel = undefined;
4055
4421
  this.serviceFactory = new ServiceFactory(this.hostElement);
4056
4422
  this.translationService = this.serviceFactory.get(TranslationService);
4057
4423
  this.yasguiConfigurationBuilder = this.serviceFactory.get(YasguiConfigurationBuilder);
4058
4424
  this.yasguiBuilder = this.serviceFactory.get(YasguiBuilder);
4059
4425
  this.ontotextYasguiService = this.serviceFactory.get(OntotextYasguiService);
4060
4426
  this.notificationMessageService = this.serviceFactory.get(NotificationMessageService);
4427
+ this.initComponentTranslationHandlers();
4061
4428
  }
4062
4429
  configurationChanged(newConfig) {
4063
4430
  this.init(newConfig);
@@ -4634,6 +5001,17 @@ const OntotextYasguiWebComponent = class {
4634
5001
  }
4635
5002
  }
4636
5003
  }
5004
+ initComponentTranslationHandlers() {
5005
+ this.subscriptions.push(this.translationService.onTranslate('yasgui.toolbar.mode_yasqe.btn.label', (yasqeBtnLabel) => {
5006
+ this.yasqeBtnLabel = yasqeBtnLabel;
5007
+ }));
5008
+ this.subscriptions.push(this.translationService.onTranslate('yasgui.toolbar.mode_yasgui.btn.label', (yasguiBtnLabel) => {
5009
+ this.yasguiBtnLabel = yasguiBtnLabel;
5010
+ }));
5011
+ this.subscriptions.push(this.translationService.onTranslate('yasgui.toolbar.mode_yasr.btn.label', (yasrBtnLabel) => {
5012
+ this.yasrBtnLabel = yasrBtnLabel;
5013
+ }));
5014
+ }
4637
5015
  init(externalConfiguration) {
4638
5016
  if (!HtmlElementsUtil.getOntotextYasgui(this.hostElement) || !externalConfiguration) {
4639
5017
  return;
@@ -4668,11 +5046,15 @@ const OntotextYasguiWebComponent = class {
4668
5046
  this.init(this.config);
4669
5047
  }
4670
5048
  disconnectedCallback() {
5049
+ if (this.subscriptions) {
5050
+ this.subscriptions.forEach((subscription) => subscription());
5051
+ this.subscriptions = [];
5052
+ }
4671
5053
  this.destroy();
4672
5054
  }
4673
5055
  render() {
4674
5056
  const classList = `yasgui-host-element ${this.getOrientationMode()} ${this.getRenderMode()}`;
4675
- return (index.h(index.Host, { class: classList }, index.h("div", { class: "yasgui-toolbar hidden" }, index.h("button", { class: "yasgui-btn btn-mode-yasqe", onClick: () => this.changeRenderingMode(RenderingMode.YASQE) }, this.translationService.translate('yasgui.toolbar.mode_yasqe.btn.label')), index.h("button", { class: "yasgui-btn btn-mode-yasgui", onClick: () => this.changeRenderingMode(RenderingMode.YASGUI) }, this.translationService.translate('yasgui.toolbar.mode_yasgui.btn.label')), index.h("button", { class: "yasgui-btn btn-mode-yasr", onClick: () => this.changeRenderingMode(RenderingMode.YASR) }, this.translationService.translate('yasgui.toolbar.mode_yasr.btn.label')), index.h("yasgui-tooltip", { "data-tooltip": this.resolveOrientationButtonTooltip(), placement: "left", "show-on-click": true }, index.h("button", { class: "btn-orientation icon-columns red", onClick: () => this.changeOrientation() }, "\u00A0"))), index.h("div", { class: "ontotext-yasgui" }), this.showSaveQueryDialog &&
5057
+ return (index.h(index.Host, { class: classList }, index.h("div", { class: "yasgui-toolbar hidden" }, index.h("button", { class: "yasgui-btn btn-mode-yasqe", onClick: () => this.changeRenderingMode(RenderingMode.YASQE) }, this.yasqeBtnLabel), index.h("button", { class: "yasgui-btn btn-mode-yasgui", onClick: () => this.changeRenderingMode(RenderingMode.YASGUI) }, this.yasguiBtnLabel), index.h("button", { class: "yasgui-btn btn-mode-yasr", onClick: () => this.changeRenderingMode(RenderingMode.YASR) }, this.yasrBtnLabel), index.h("yasgui-tooltip", { "data-tooltip": this.resolveOrientationButtonTooltip(), placement: "left", "show-on-click": true }, index.h("button", { class: "btn-orientation icon-columns red", onClick: () => this.changeOrientation() }, "\u00A0"))), index.h("div", { class: "ontotext-yasgui" }), this.showSaveQueryDialog &&
4676
5058
  index.h("save-query-dialog", { data: this.getSaveQueryData(), serviceFactory: this.serviceFactory }, "\u00A0"), this.showSavedQueriesPopup &&
4677
5059
  index.h("saved-queries-popup", { config: this.getSaveQueriesData(), serviceFactory: this.serviceFactory }), this.showConfirmationDialog &&
4678
5060
  index.h("confirmation-dialog", { translationService: this.translationService, config: this.getDeleteQueryConfirmationConfig() }), this.showShareQueryDialog &&