survey-analytics 2.2.6 → 2.3.1
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/fesm/shared.mjs +84 -1
- package/fesm/shared.mjs.map +1 -1
- package/fesm/shared2.mjs +46 -20
- package/fesm/shared2.mjs.map +1 -1
- package/fesm/survey.analytics.core.mjs +1 -1
- package/fesm/survey.analytics.mjs +80 -19
- package/fesm/survey.analytics.mjs.map +1 -1
- package/fesm/survey.analytics.tabulator.mjs +47 -4
- package/fesm/survey.analytics.tabulator.mjs.map +1 -1
- package/package.json +3 -3
- package/survey-analytics-tabulator.types/analytics-localization/english.d.ts +1 -0
- package/survey-analytics-tabulator.types/analytics-localization/swedish.d.ts +79 -0
- package/survey-analytics-tabulator.types/entries/tabulator.d.ts +1 -0
- package/survey-analytics-tabulator.types/localizationManager.d.ts +1 -0
- package/survey-analytics-tabulator.types/tables/columnbuilder.d.ts +7 -1
- package/survey-analytics-tabulator.types/tables/columns.d.ts +10 -1
- package/survey-analytics.types/analytics-localization/english.d.ts +1 -0
- package/survey-analytics.types/analytics-localization/swedish.d.ts +79 -0
- package/survey-analytics.types/config.d.ts +1 -0
- package/survey-analytics.types/entries/summary.core.d.ts +1 -0
- package/survey-analytics.types/localizationManager.d.ts +1 -0
- package/survey-analytics.types/plotly/chart-adapter.d.ts +1 -0
- package/survey-analytics.types/plotly/setup.d.ts +1 -0
- package/survey-analytics.types/ranking.d.ts +4 -0
- package/survey-analytics.types/visualizationPanel.d.ts +4 -2
- package/survey-analytics.types/visualizerBase.d.ts +11 -4
- package/survey.analytics.core.css +1 -1
- package/survey.analytics.core.js +201 -75
- package/survey.analytics.core.js.map +1 -1
- package/survey.analytics.core.min.css +1 -1
- package/survey.analytics.core.min.js +1 -1
- package/survey.analytics.core.min.js.LICENSE.txt +1 -1
- package/survey.analytics.css +1 -1
- package/survey.analytics.js +295 -106
- package/survey.analytics.js.map +1 -1
- package/survey.analytics.min.css +1 -1
- package/survey.analytics.min.js +1 -1
- package/survey.analytics.min.js.LICENSE.txt +1 -1
- package/survey.analytics.tabulator.css +1 -1
- package/survey.analytics.tabulator.js +214 -23
- package/survey.analytics.tabulator.js.map +1 -1
- package/survey.analytics.tabulator.min.css +1 -1
- package/survey.analytics.tabulator.min.js +1 -1
- package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
package/fesm/shared2.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* surveyjs - SurveyJS Dashboard library v2.
|
|
2
|
+
* surveyjs - SurveyJS Dashboard library v2.3.1
|
|
3
3
|
* Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
|
|
4
4
|
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
|
5
5
|
*/
|
|
@@ -189,7 +189,7 @@ class VisualizationManager {
|
|
|
189
189
|
if (constructor) {
|
|
190
190
|
let visualizers = VisualizationManager.vizualizers[qType];
|
|
191
191
|
if (!!visualizers) {
|
|
192
|
-
const vDescr = visualizers.filter(v => v.ctor === constructor)[0];
|
|
192
|
+
const vDescr = visualizers.filter(v => v.ctor === constructor || v.ctor.isPrototypeOf(constructor))[0];
|
|
193
193
|
if (!!vDescr) {
|
|
194
194
|
let index = visualizers.indexOf(vDescr);
|
|
195
195
|
if (index !== -1) {
|
|
@@ -317,17 +317,24 @@ function defaultStatisticsCalculator(data, dataInfo) {
|
|
|
317
317
|
}
|
|
318
318
|
statistics.push(dataNameStatistics);
|
|
319
319
|
}
|
|
320
|
+
const getValueIndex = (val) => {
|
|
321
|
+
if (val !== null && typeof val === "object")
|
|
322
|
+
return valuesIndex[val.value];
|
|
323
|
+
return valuesIndex[val];
|
|
324
|
+
};
|
|
320
325
|
data.forEach((row) => {
|
|
321
326
|
dataNames.forEach((dataName, index) => {
|
|
322
327
|
const rowValue = row[dataName];
|
|
323
328
|
if (rowValue !== undefined || processMissingAnswers) {
|
|
324
329
|
const rowValues = Array.isArray(rowValue) ? rowValue : [rowValue];
|
|
325
330
|
if (series.length > 0) {
|
|
326
|
-
|
|
331
|
+
const rowName = row[DataProvider.seriesMarkerKey];
|
|
332
|
+
if (rowName !== undefined) {
|
|
327
333
|
// Series are labelled by seriesMarkerKey in row data
|
|
328
|
-
const seriesNo = seriesIndex[
|
|
334
|
+
const seriesNo = seriesIndex[rowName] || 0;
|
|
329
335
|
rowValues.forEach((val) => {
|
|
330
|
-
|
|
336
|
+
const valIndex = getValueIndex(val);
|
|
337
|
+
statistics[index][seriesNo][valIndex]++;
|
|
331
338
|
});
|
|
332
339
|
}
|
|
333
340
|
else {
|
|
@@ -337,7 +344,11 @@ function defaultStatisticsCalculator(data, dataInfo) {
|
|
|
337
344
|
series.forEach((seriesName) => {
|
|
338
345
|
if (val[seriesName] !== undefined) {
|
|
339
346
|
const seriesNo = seriesIndex[seriesName] || 0;
|
|
340
|
-
|
|
347
|
+
const values = Array.isArray(val[seriesName]) ? val[seriesName] : [val[seriesName]];
|
|
348
|
+
values.forEach(value => {
|
|
349
|
+
const valIndex = getValueIndex(value);
|
|
350
|
+
statistics[index][seriesNo][valIndex]++;
|
|
351
|
+
});
|
|
341
352
|
}
|
|
342
353
|
});
|
|
343
354
|
});
|
|
@@ -345,7 +356,10 @@ function defaultStatisticsCalculator(data, dataInfo) {
|
|
|
345
356
|
}
|
|
346
357
|
else {
|
|
347
358
|
// No series
|
|
348
|
-
rowValues.forEach((val) =>
|
|
359
|
+
rowValues.forEach((val) => {
|
|
360
|
+
const valIndex = getValueIndex(val);
|
|
361
|
+
statistics[0][0][valIndex]++;
|
|
362
|
+
});
|
|
349
363
|
}
|
|
350
364
|
}
|
|
351
365
|
});
|
|
@@ -439,6 +453,9 @@ class VisualizerBase {
|
|
|
439
453
|
}
|
|
440
454
|
this.onStateChanged.fire(this, this.getState());
|
|
441
455
|
}
|
|
456
|
+
getToolbarItemCreators() {
|
|
457
|
+
return Object.assign({}, this.toolbarItemCreators, this.onGetToolbarItemCreators && this.onGetToolbarItemCreators() || {});
|
|
458
|
+
}
|
|
442
459
|
constructor(question, data, options = {}, _type) {
|
|
443
460
|
var _a;
|
|
444
461
|
this.question = question;
|
|
@@ -645,8 +662,8 @@ class VisualizerBase {
|
|
|
645
662
|
* @param creator A function that accepts the toolbar and should return an `HTMLElement` with the toolbar item.
|
|
646
663
|
* @see unregisterToolbarItem
|
|
647
664
|
*/
|
|
648
|
-
registerToolbarItem(name, creator) {
|
|
649
|
-
this.toolbarItemCreators[name] = creator;
|
|
665
|
+
registerToolbarItem(name, creator, order = 100) {
|
|
666
|
+
this.toolbarItemCreators[name] = { creator, order };
|
|
650
667
|
}
|
|
651
668
|
/**
|
|
652
669
|
*
|
|
@@ -657,9 +674,9 @@ class VisualizerBase {
|
|
|
657
674
|
*/
|
|
658
675
|
unregisterToolbarItem(name) {
|
|
659
676
|
if (this.toolbarItemCreators[name] !== undefined) {
|
|
660
|
-
const
|
|
677
|
+
const item = this.toolbarItemCreators[name];
|
|
661
678
|
delete this.toolbarItemCreators[name];
|
|
662
|
-
return creator;
|
|
679
|
+
return item.creator;
|
|
663
680
|
}
|
|
664
681
|
return undefined;
|
|
665
682
|
}
|
|
@@ -741,8 +758,12 @@ class VisualizerBase {
|
|
|
741
758
|
}
|
|
742
759
|
}
|
|
743
760
|
createToolbarItems(toolbar) {
|
|
744
|
-
|
|
745
|
-
|
|
761
|
+
const toolbarItemCreators = this.getToolbarItemCreators();
|
|
762
|
+
const sortedItems = Object.keys(toolbarItemCreators || {})
|
|
763
|
+
.map(name => (Object.assign({ name }, toolbarItemCreators[name])))
|
|
764
|
+
.sort((a, b) => a.order - b.order);
|
|
765
|
+
sortedItems.forEach((item) => {
|
|
766
|
+
let toolbarItem = item.creator(toolbar);
|
|
746
767
|
if (!!toolbarItem) {
|
|
747
768
|
toolbar.appendChild(toolbarItem);
|
|
748
769
|
}
|
|
@@ -1377,7 +1398,7 @@ class SelectBase extends VisualizerBase {
|
|
|
1377
1398
|
this.updateEmptyAnswersBtn();
|
|
1378
1399
|
}
|
|
1379
1400
|
return this.emptyAnswersBtn;
|
|
1380
|
-
});
|
|
1401
|
+
}, 1000);
|
|
1381
1402
|
this.registerToolbarItem("topNAnswers", () => {
|
|
1382
1403
|
if (this.options.allowTopNAnswers &&
|
|
1383
1404
|
this.getSeriesValues().length === 0) {
|
|
@@ -2497,6 +2518,9 @@ PivotModel.UseIntervalsFrom = 10;
|
|
|
2497
2518
|
VisualizationManager.registerPivotVisualizer(PivotModel);
|
|
2498
2519
|
|
|
2499
2520
|
class RankingModel extends SelectBase {
|
|
2521
|
+
constructor(question, data, options, name) {
|
|
2522
|
+
super(question, data, options, name || "ranking");
|
|
2523
|
+
}
|
|
2500
2524
|
getQuestionResults() {
|
|
2501
2525
|
const name = this.question.name;
|
|
2502
2526
|
return this.data.map((dataItem) => dataItem[name]);
|
|
@@ -2549,12 +2573,14 @@ class AlternativeVisualizersWrapper extends VisualizerBase {
|
|
|
2549
2573
|
* The event is fired right after AlternativeVisualizersWrapper content type has been changed.
|
|
2550
2574
|
**/
|
|
2551
2575
|
this.onVisualizerChanged = new Event();
|
|
2576
|
+
this.showToolbar = false;
|
|
2552
2577
|
this.loadingData = false;
|
|
2553
2578
|
if (!visualizers || visualizers.length < 2) {
|
|
2554
2579
|
throw new Error("VisualizerArrayWrapper works with visualizers collection only.");
|
|
2555
2580
|
}
|
|
2556
2581
|
this.visualizers.forEach((visualizer) => {
|
|
2557
2582
|
visualizer.onUpdate = () => this.invokeOnUpdate();
|
|
2583
|
+
visualizer.onGetToolbarItemCreators = () => this.toolbarItemCreators;
|
|
2558
2584
|
if (visualizer.supportSelection) {
|
|
2559
2585
|
this._supportSelection = true;
|
|
2560
2586
|
this.visualizersWithSelection.push(visualizer);
|
|
@@ -2565,7 +2591,7 @@ class AlternativeVisualizersWrapper extends VisualizerBase {
|
|
|
2565
2591
|
value: visualizer.type,
|
|
2566
2592
|
text: localization.getString("visualizer_" + visualizer.type),
|
|
2567
2593
|
};
|
|
2568
|
-
}), (option) => this.visualizer.type === option.value, (e) => this.setVisualizer(e.target.value)));
|
|
2594
|
+
}), (option) => this.visualizer.type === option.value, (e) => this.setVisualizer(e.target.value)), 0);
|
|
2569
2595
|
this.visualizer = visualizers[0];
|
|
2570
2596
|
this.visualizer.onAfterRender.add(this.onAfterVisualizerRenderCallback);
|
|
2571
2597
|
this.visualizer.onStateChanged.add(this.onVisualizerStateChangedCallback);
|
|
@@ -9768,7 +9794,7 @@ class VisualizationPanel extends VisualizerBase {
|
|
|
9768
9794
|
}
|
|
9769
9795
|
});
|
|
9770
9796
|
}, localization.getString("resetFilter"));
|
|
9771
|
-
});
|
|
9797
|
+
}, 900);
|
|
9772
9798
|
this.registerToolbarItem("addElement", (toolbar) => {
|
|
9773
9799
|
if (this.allowHideQuestions) {
|
|
9774
9800
|
let addElementSelector = undefined;
|
|
@@ -9941,7 +9967,7 @@ class VisualizationPanel extends VisualizerBase {
|
|
|
9941
9967
|
return DocumentHelper.createButton(() => {
|
|
9942
9968
|
setTimeout(() => this.hideElement(question.name), 0);
|
|
9943
9969
|
}, localization.getString("hideButton"));
|
|
9944
|
-
});
|
|
9970
|
+
}, 1000);
|
|
9945
9971
|
}
|
|
9946
9972
|
if (this.allowMakeQuestionsPrivate) {
|
|
9947
9973
|
visualizer.registerToolbarItem("makePrivatePublic", () => {
|
|
@@ -9966,7 +9992,7 @@ class VisualizationPanel extends VisualizerBase {
|
|
|
9966
9992
|
visualizer.registerToolbarItem("questionFilterInfo", () => {
|
|
9967
9993
|
filterInfo.update(visualizerWithSelection.selection);
|
|
9968
9994
|
return filterInfo.htmlElement;
|
|
9969
|
-
});
|
|
9995
|
+
}, 900);
|
|
9970
9996
|
visualizerWithSelection.onDataItemSelected = (selectedValue, selectedText) => {
|
|
9971
9997
|
filterInfo.update({ value: selectedValue, text: selectedText });
|
|
9972
9998
|
this.setFilter(question.name, selectedValue);
|
|
@@ -10395,12 +10421,12 @@ class VisualizationMatrixDropdown extends VisualizerBase {
|
|
|
10395
10421
|
this._childOptions.transposeData = true;
|
|
10396
10422
|
this._childOptions.seriesValues = question.rows.map((row) => row.value);
|
|
10397
10423
|
this._childOptions.seriesLabels = question.rows.map((row) => row.text);
|
|
10398
|
-
const innerQuestions = this.getQuestions();
|
|
10399
10424
|
if (this.canGroupColumns) {
|
|
10400
10425
|
var creators = VisualizationManager.getVisualizersByType("matrixdropdown-grouped");
|
|
10401
10426
|
this._matrixDropdownVisualizer = new creators[0](this.question, [], this._childOptions);
|
|
10402
10427
|
}
|
|
10403
10428
|
else {
|
|
10429
|
+
const innerQuestions = this.getQuestions();
|
|
10404
10430
|
this._matrixDropdownVisualizer = new VisualizationPanel(innerQuestions, [], this._childOptions);
|
|
10405
10431
|
}
|
|
10406
10432
|
this._matrixDropdownVisualizer.onAfterRender.add(this.onPanelAfterRenderCallback);
|
|
@@ -10408,7 +10434,7 @@ class VisualizationMatrixDropdown extends VisualizerBase {
|
|
|
10408
10434
|
}
|
|
10409
10435
|
get canGroupColumns() {
|
|
10410
10436
|
const innerQuestions = this.getQuestions();
|
|
10411
|
-
const canGroupColumns = this._childOptions.seriesValues.length == 1 && innerQuestions.every(innerQuestion => isChoicesArraysEqual(innerQuestion.choices, this.question.choices));
|
|
10437
|
+
const canGroupColumns = this._childOptions.seriesValues.length == 1 && innerQuestions.every(innerQuestion => innerQuestion.getType() !== "boolean" && isChoicesArraysEqual(innerQuestion.choices, this.question.choices));
|
|
10412
10438
|
return canGroupColumns;
|
|
10413
10439
|
}
|
|
10414
10440
|
setLocale(newLocale) {
|