survey-analytics 2.3.5 → 2.3.7

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 (36) hide show
  1. package/fesm/shared.mjs +1 -1
  2. package/fesm/shared2.mjs +84 -51
  3. package/fesm/shared2.mjs.map +1 -1
  4. package/fesm/survey.analytics.core.mjs +2 -2
  5. package/fesm/survey.analytics.mjs +11 -4
  6. package/fesm/survey.analytics.mjs.map +1 -1
  7. package/fesm/survey.analytics.tabulator.mjs +6 -3
  8. package/fesm/survey.analytics.tabulator.mjs.map +1 -1
  9. package/package.json +2 -2
  10. package/survey-analytics-tabulator.types/tables/table.d.ts +18 -5
  11. package/survey-analytics.types/entries/summary.core.d.ts +1 -0
  12. package/survey-analytics.types/selectBase.d.ts +1 -0
  13. package/survey-analytics.types/visualizationComposite.d.ts +8 -0
  14. package/survey-analytics.types/visualizationManager.d.ts +2 -2
  15. package/survey-analytics.types/visualizationMatrixDynamic.d.ts +1 -2
  16. package/survey-analytics.types/visualizationPanel.d.ts +1 -1
  17. package/survey-analytics.types/visualizationPanelDynamic.d.ts +1 -2
  18. package/survey-analytics.types/visualizerBase.d.ts +1 -1
  19. package/survey.analytics.core.css +1 -1
  20. package/survey.analytics.core.js +141 -84
  21. package/survey.analytics.core.js.map +1 -1
  22. package/survey.analytics.core.min.css +1 -1
  23. package/survey.analytics.core.min.js +1 -1
  24. package/survey.analytics.core.min.js.LICENSE.txt +1 -1
  25. package/survey.analytics.css +1 -1
  26. package/survey.analytics.js +150 -85
  27. package/survey.analytics.js.map +1 -1
  28. package/survey.analytics.min.css +1 -1
  29. package/survey.analytics.min.js +1 -1
  30. package/survey.analytics.min.js.LICENSE.txt +1 -1
  31. package/survey.analytics.tabulator.css +1 -1
  32. package/survey.analytics.tabulator.js +11 -4
  33. package/survey.analytics.tabulator.js.map +1 -1
  34. package/survey.analytics.tabulator.min.css +1 -1
  35. package/survey.analytics.tabulator.min.js +1 -1
  36. package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
package/fesm/shared.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.5
2
+ * surveyjs - SurveyJS Dashboard library v2.3.7
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
  */
package/fesm/shared2.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.5
2
+ * surveyjs - SurveyJS Dashboard library v2.3.7
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
  */
6
6
 
7
7
  import { D as DocumentHelper, l as localization, g as createLoadingIndicator, b as DataHelper, e as createCommercialLicenseLink, f as svgTemplate, t as toPrecision } from './shared.mjs';
8
- import { Event, hasLicense, QuestionCommentModel, settings, ItemValue, surveyLocalization, IsTouch } from 'survey-core';
8
+ import { Event, QuestionCustomModel, QuestionCompositeModel, hasLicense, QuestionCommentModel, settings, ItemValue, surveyLocalization, IsTouch } from 'survey-core';
9
9
 
10
10
  /******************************************************************************
11
11
  Copyright (c) Microsoft Corporation.
@@ -212,10 +212,13 @@ class VisualizationManager {
212
212
  }
213
213
  /**
214
214
  * Returns all visualizer constructors for a specified question type.
215
- * @param questionType A question [type](https://surveyjs.io/form-library/documentation/api-reference/question#getType).
215
+ * @param visualizerType A question [type](https://surveyjs.io/form-library/documentation/api-reference/question#getType).
216
216
  */
217
- static getVisualizersByType(questionType) {
218
- let vDescrs = VisualizationManager.vizualizers[questionType];
217
+ static getVisualizersByType(visualizerType, fallbackVisualizerType) {
218
+ let vDescrs = VisualizationManager.vizualizers[visualizerType];
219
+ if (!!fallbackVisualizerType && (!vDescrs || vDescrs.length == 0)) {
220
+ vDescrs = VisualizationManager.vizualizers[fallbackVisualizerType];
221
+ }
219
222
  if (!vDescrs) {
220
223
  if (VisualizationManager.defaultVisualizer.suppressVisualizerStubRendering) {
221
224
  return [];
@@ -279,21 +282,26 @@ class VisualizerFactory {
279
282
  static createVisualizer(question, data, options) {
280
283
  let type = question.getType();
281
284
  let creators = [];
285
+ let questionForCreator = question;
286
+ let optionsForCreator = Object.assign({}, options);
282
287
  if (type === "text" && question.inputType) {
283
- type = question.inputType;
284
- creators = VisualizationManager.getVisualizersByType(type);
285
- if (creators === undefined || creators.length == 0) {
286
- type = "text";
287
- creators = VisualizationManager.getVisualizersByType(type);
288
- }
288
+ creators = VisualizationManager.getVisualizersByType(question.inputType, type);
289
289
  }
290
290
  else {
291
- creators = VisualizationManager.getVisualizersByType(type);
291
+ let fallbackType = undefined;
292
+ if (question instanceof QuestionCustomModel) {
293
+ fallbackType = question.getDynamicType();
294
+ // questionForCreator = question.contentQuestion;
295
+ }
296
+ else if (question instanceof QuestionCompositeModel) {
297
+ fallbackType = "composite";
298
+ }
299
+ creators = VisualizationManager.getVisualizersByType(type, fallbackType);
292
300
  }
293
- var visualizers = creators.map((creator) => new creator(question, data, options));
301
+ var visualizers = creators.map((creator) => new creator(questionForCreator, data, optionsForCreator));
294
302
  if (visualizers.length > 1) {
295
303
  const alternativesVisualizerConstructor = VisualizationManager.getAltVisualizerSelector();
296
- let visualizer = new alternativesVisualizerConstructor(visualizers, question, data, options);
304
+ let visualizer = new alternativesVisualizerConstructor(visualizers, questionForCreator, data, optionsForCreator);
297
305
  return visualizer;
298
306
  }
299
307
  return visualizers[0];
@@ -719,11 +727,26 @@ class VisualizerBase {
719
727
  * @param data A data array with survey results to be visualized.
720
728
  */
721
729
  updateData(data) {
730
+ const dataPath = this.options.dataPath;
731
+ let dataToAssign = data;
732
+ if (!!dataPath && Array.isArray(data)) {
733
+ dataToAssign = [];
734
+ data.forEach(dataItem => {
735
+ if (!!dataItem && dataItem[dataPath] !== undefined) {
736
+ if (Array.isArray(dataItem[dataPath])) {
737
+ dataToAssign = dataToAssign.concat(dataItem[dataPath]);
738
+ }
739
+ else {
740
+ dataToAssign.push(dataItem[dataPath]);
741
+ }
742
+ }
743
+ });
744
+ }
722
745
  if (!this.options.dataProvider) {
723
- this.dataProvider.data = data;
746
+ this.dataProvider.data = dataToAssign;
724
747
  }
725
748
  if (this.hasFooter) {
726
- this.footerVisualizer.updateData(data);
749
+ this.footerVisualizer.updateData(dataToAssign);
727
750
  }
728
751
  }
729
752
  invokeOnUpdate() {
@@ -1340,9 +1363,8 @@ class SelectBase extends VisualizerBase {
1340
1363
  this.emptyAnswersBtn = undefined;
1341
1364
  this.transposeDataBtn = undefined;
1342
1365
  this.topNSelector = undefined;
1343
- this._showPercentages = false;
1344
1366
  this._showOnlyPercentages = false;
1345
- this._percentagePrecision = 0;
1367
+ this._percentagePrecision = 2;
1346
1368
  this._answersOrder = "default";
1347
1369
  this._hideEmptyAnswers = false;
1348
1370
  this._topN = -1;
@@ -1364,7 +1386,6 @@ class SelectBase extends VisualizerBase {
1364
1386
  };
1365
1387
  }
1366
1388
  this._supportSelection = true;
1367
- this._showPercentages = this.options.showPercentages === true;
1368
1389
  this._showOnlyPercentages = this.options.showOnlyPercentages === true;
1369
1390
  if (this.options.percentagePrecision) {
1370
1391
  this._percentagePrecision = this.options.percentagePrecision;
@@ -1607,11 +1628,22 @@ class SelectBase extends VisualizerBase {
1607
1628
  this.refreshContent();
1608
1629
  this.stateChanged("showOnlyPercentages", val);
1609
1630
  }
1631
+ getShowPercentagesDefault() {
1632
+ if (this.options.showPercentages === undefined) {
1633
+ return ["pie", "doughnut"].indexOf(this.chartType) !== -1;
1634
+ }
1635
+ return this.options.showPercentages === true;
1636
+ }
1610
1637
  /**
1611
1638
  * Gets and sets whether chart should show values and percentages.
1612
1639
  */
1613
1640
  get showPercentages() {
1614
- return this._showPercentages;
1641
+ if (this._showPercentages !== undefined) {
1642
+ return this._showPercentages;
1643
+ }
1644
+ else {
1645
+ return this.getShowPercentagesDefault();
1646
+ }
1615
1647
  }
1616
1648
  set showPercentages(val) {
1617
1649
  this._showPercentages = val;
@@ -1743,12 +1775,10 @@ class SelectBase extends VisualizerBase {
1743
1775
  var percentages = [];
1744
1776
  var percentagePrecision = this._percentagePrecision;
1745
1777
  if (data.length < 2) {
1746
- data.forEach((res, index) => {
1747
- var sum = res.reduce((sum, val) => sum + val, 0);
1748
- percentages[index] = res.map((val) => {
1749
- var value = percentagePrecision ? +(val / sum).toFixed(percentagePrecision) : Math.round((val / sum) * 10000);
1750
- return sum && (value / 100);
1751
- });
1778
+ var sum = data[0].reduce((sum, val) => sum + val, 0);
1779
+ percentages[0] = data[0].map((val) => {
1780
+ var value = percentagePrecision ? +(val / sum * 100).toFixed(percentagePrecision) : Math.round(val / sum * 100);
1781
+ return sum && value;
1752
1782
  });
1753
1783
  }
1754
1784
  else {
@@ -1760,7 +1790,7 @@ class SelectBase extends VisualizerBase {
1760
1790
  for (var j = 0; j < data.length; j++) {
1761
1791
  if (!Array.isArray(percentages[j]))
1762
1792
  percentages[j] = [];
1763
- var value = percentagePrecision ? +((data[j][i] / sum) * 100).toFixed(percentagePrecision) : Math.round((data[j][i] / sum) * 100);
1793
+ var value = percentagePrecision ? +(data[j][i] / sum * 100).toFixed(percentagePrecision) : Math.round(data[j][i] / sum * 100);
1764
1794
  percentages[j][i] = sum && value;
1765
1795
  }
1766
1796
  }
@@ -1792,14 +1822,13 @@ class SelectBase extends VisualizerBase {
1792
1822
  let datasets = (yield this.getCalculatedValues());
1793
1823
  let labels = this.getLabels();
1794
1824
  let colors = this.getColors();
1795
- var texts = this.showPercentages ? this.getPercentages(datasets) : datasets;
1796
1825
  if (this.transposeData) {
1797
1826
  datasets = this.transpose(datasets);
1798
- texts = this.transpose(texts);
1799
1827
  const temp = seriesLabels;
1800
1828
  seriesLabels = labels;
1801
1829
  labels = temp;
1802
1830
  }
1831
+ var texts = this.showPercentages ? this.getPercentages(datasets) : datasets;
1803
1832
  if (this.answersOrder == "asc" || this.answersOrder == "desc") {
1804
1833
  var zippedArray = this.showPercentages
1805
1834
  ? DataHelper.zipArrays(labels, colors, texts[0])
@@ -2660,7 +2689,7 @@ class AlternativeVisualizersWrapper extends VisualizerBase {
2660
2689
  }
2661
2690
  }
2662
2691
  constructor(visualizers, question, data, options) {
2663
- super(question, data, options);
2692
+ super(question, data, options, "alternative");
2664
2693
  this.visualizers = visualizers;
2665
2694
  this.visualizersWithSelection = [];
2666
2695
  this.onAfterVisualizerRenderCallback = () => {
@@ -9882,7 +9911,7 @@ class VisualizationPanel extends VisualizerBase {
9882
9911
  options.layoutEngine ||
9883
9912
  new MuuriLayoutEngine(this.allowDynamicLayout, "." + questionLayoutedElementClassName, this.allowDragDrop);
9884
9913
  this._layoutEngine.onMoveCallback = (order) => this.reorderVisibleElements(order);
9885
- this.showToolbar = true;
9914
+ this.showToolbar = isRoot;
9886
9915
  if (this.options.survey) {
9887
9916
  localization.currentLocale = this.options.survey.locale;
9888
9917
  }
@@ -9890,6 +9919,7 @@ class VisualizationPanel extends VisualizerBase {
9890
9919
  this._elements = this.buildElements(questions);
9891
9920
  }
9892
9921
  this.buildVisualizers(questions);
9922
+ this.updateData(this.surveyData);
9893
9923
  if (!this.haveCommercialLicense && this.isRoot) {
9894
9924
  this.registerToolbarItem("commercialLicense", () => {
9895
9925
  return createCommercialLicenseLink();
@@ -10454,34 +10484,27 @@ class VisualizationPanelDynamic extends VisualizerBase {
10454
10484
  };
10455
10485
  this.loadingData = false;
10456
10486
  var options = Object.assign({}, options);
10487
+ options.allowHideQuestions = false;
10457
10488
  options.allowDynamicLayout = false;
10458
10489
  options.dataProvider = undefined;
10490
+ options.dataPath = this.dataNames[0];
10459
10491
  this._panelVisualizer = new VisualizationPanel(this.getQuestions(), [], options, undefined, false);
10460
10492
  this._panelVisualizer.onAfterRender.add(this.onAfterRenderPanelCallback);
10461
10493
  this.updateData(data);
10462
10494
  }
10495
+ get contentVisualizer() {
10496
+ return this._panelVisualizer;
10497
+ }
10463
10498
  setLocale(newLocale) {
10464
10499
  super.setLocale(newLocale);
10465
10500
  this._panelVisualizer.locale = newLocale;
10466
10501
  }
10467
- get type() {
10468
- return "panelDynamic";
10469
- }
10470
- updatePanelVisualizerData() {
10471
- let panelData = [];
10472
- this.data.forEach((dataItem) => {
10473
- if (dataItem[this.question.name] !== undefined) {
10474
- panelData = panelData.concat(dataItem[this.question.name]);
10475
- }
10476
- });
10477
- this._panelVisualizer.updateData(panelData);
10478
- }
10479
10502
  updateData(data) {
10480
10503
  super.updateData(data);
10481
- this.updatePanelVisualizerData();
10504
+ this._panelVisualizer.updateData(data);
10482
10505
  }
10483
10506
  onDataChanged() {
10484
- this.updatePanelVisualizerData();
10507
+ this._panelVisualizer.updateData(this.dataProvider.filteredData);
10485
10508
  super.onDataChanged();
10486
10509
  }
10487
10510
  getQuestions() {
@@ -10503,11 +10526,8 @@ class VisualizationPanelDynamic extends VisualizerBase {
10503
10526
  VisualizationManager.registerVisualizer("paneldynamic", VisualizationPanelDynamic);
10504
10527
 
10505
10528
  class VisualizationMatrixDynamic extends VisualizationPanelDynamic {
10506
- constructor(question, data, options) {
10507
- super(question, data, options);
10508
- }
10509
- get type() {
10510
- return "matrixDynamic";
10529
+ constructor(question, data, options, name) {
10530
+ super(question, data, options, name || "matrixDynamic");
10511
10531
  }
10512
10532
  getQuestions() {
10513
10533
  const matrixdynamic = this.question;
@@ -10615,6 +10635,19 @@ class VisualizationMatrixDropdown extends VisualizerBase {
10615
10635
  }
10616
10636
  VisualizationManager.registerVisualizer("matrixdropdown", VisualizationMatrixDropdown);
10617
10637
 
10638
+ class VisualizationComposite extends VisualizationPanelDynamic {
10639
+ constructor(question, data, options, name) {
10640
+ super(question, data, options, name || "composite");
10641
+ }
10642
+ getQuestions() {
10643
+ const matrixdynamic = this.question;
10644
+ const innerQuestions = [];
10645
+ matrixdynamic.contentPanel.addQuestionsToList(innerQuestions);
10646
+ return innerQuestions;
10647
+ }
10648
+ }
10649
+ VisualizationManager.registerVisualizer("composite", VisualizationComposite);
10650
+
10618
10651
  var stopWords$3 = [
10619
10652
  "...",
10620
10653
  "a",
@@ -12623,5 +12656,5 @@ NpsVisualizer.DetractorScore = 6;
12623
12656
  NpsVisualizer.PromoterScore = 9;
12624
12657
  // VisualizationManager.registerVisualizer("rating", NpsVisualizer);
12625
12658
 
12626
- export { AlternativeVisualizersWrapper as A, BooleanModel as B, DataProvider as D, HistogramModel as H, Matrix as M, NumberModel as N, PostponeHelper as P, RankingModel as R, SelectBase as S, TextTableAdapter as T, VisualizerFactory as V, WordCloudAdapter as W, __awaiter as _, VisualizerBase as a, VisualizationManager as b, VisualizationPanel as c, VisualizationPanelDynamic as d, VisualizationMatrixDynamic as e, VisualizationMatrixDropdown as f, WordCloud as g, hideEmptyAnswersInData as h, Text as i, StatisticsTableAdapter as j, StatisticsTable as k, StatisticsTableBoolean as l, NpsVisualizerWidget as m, NpsAdapter as n, NpsVisualizer as o, PivotModel as p, defaultStatisticsCalculator as q, textHelper as t };
12659
+ export { AlternativeVisualizersWrapper as A, BooleanModel as B, DataProvider as D, HistogramModel as H, Matrix as M, NumberModel as N, PostponeHelper as P, RankingModel as R, SelectBase as S, TextTableAdapter as T, VisualizerFactory as V, WordCloudAdapter as W, __awaiter as _, VisualizerBase as a, VisualizationManager as b, VisualizationPanel as c, VisualizationPanelDynamic as d, VisualizationMatrixDynamic as e, VisualizationMatrixDropdown as f, VisualizationComposite as g, hideEmptyAnswersInData as h, WordCloud as i, Text as j, StatisticsTableAdapter as k, StatisticsTable as l, StatisticsTableBoolean as m, NpsVisualizerWidget as n, NpsAdapter as o, NpsVisualizer as p, PivotModel as q, defaultStatisticsCalculator as r, textHelper as t };
12627
12660
  //# sourceMappingURL=shared2.mjs.map