survey-analytics 2.2.3 → 2.2.4

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 (42) hide show
  1. package/fesm/shared.mjs +1 -1
  2. package/fesm/shared2.mjs +298 -193
  3. package/fesm/shared2.mjs.map +1 -1
  4. package/fesm/survey.analytics.core.mjs +2 -2
  5. package/fesm/survey.analytics.mjs +187 -418
  6. package/fesm/survey.analytics.mjs.map +1 -1
  7. package/fesm/survey.analytics.tabulator.mjs +1 -1
  8. package/package.json +2 -2
  9. package/survey-analytics.types/boolean.d.ts +0 -1
  10. package/survey-analytics.types/entries/summary.core.d.ts +2 -1
  11. package/survey-analytics.types/histogram.d.ts +1 -1
  12. package/survey-analytics.types/pivot.d.ts +2 -0
  13. package/survey-analytics.types/plotly/chart-adapter.d.ts +13 -0
  14. package/survey-analytics.types/plotly/index.d.ts +2 -8
  15. package/survey-analytics.types/plotly/legacy.d.ts +33 -0
  16. package/survey-analytics.types/plotly/setup.d.ts +5 -3
  17. package/survey-analytics.types/{plotly/ranking.d.ts → ranking.d.ts} +2 -2
  18. package/survey-analytics.types/selectBase.d.ts +2 -0
  19. package/survey-analytics.types/visualizerBase.d.ts +11 -0
  20. package/survey.analytics.core.css +1 -1
  21. package/survey.analytics.core.js +178 -23
  22. package/survey.analytics.core.js.map +1 -1
  23. package/survey.analytics.core.min.css +1 -1
  24. package/survey.analytics.core.min.js +1 -1
  25. package/survey.analytics.core.min.js.LICENSE.txt +1 -1
  26. package/survey.analytics.css +1 -1
  27. package/survey.analytics.js +491 -762
  28. package/survey.analytics.js.map +1 -1
  29. package/survey.analytics.min.css +1 -1
  30. package/survey.analytics.min.js +1 -1
  31. package/survey.analytics.min.js.LICENSE.txt +1 -1
  32. package/survey.analytics.tabulator.css +1 -1
  33. package/survey.analytics.tabulator.js +1 -1
  34. package/survey.analytics.tabulator.min.css +1 -1
  35. package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
  36. package/survey-analytics.types/plotly/boolean.d.ts +0 -16
  37. package/survey-analytics.types/plotly/histogram.d.ts +0 -12
  38. package/survey-analytics.types/plotly/matrix.d.ts +0 -11
  39. package/survey-analytics.types/plotly/matrixdropdown-grouped.d.ts +0 -11
  40. package/survey-analytics.types/plotly/pivot.d.ts +0 -12
  41. package/survey-analytics.types/plotly/rating.d.ts +0 -20
  42. package/survey-analytics.types/plotly/selectBase.d.ts +0 -25
package/fesm/shared.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.2.3
2
+ * surveyjs - SurveyJS Dashboard library v2.2.4
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.2.3
2
+ * surveyjs - SurveyJS Dashboard library v2.2.4
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
- import { Event, QuestionCommentModel, settings, ItemValue, hasLicense, surveyLocalization, IsTouch, Helpers } from 'survey-core';
8
7
  import { D as DocumentHelper, l as localization, f as createLoadingIndicator, a as DataHelper, e as svgTemplate, d as createCommercialLicenseLink, t as toPrecision } from './shared.mjs';
8
+ import { Event, QuestionCommentModel, settings, ItemValue, hasLicense, surveyLocalization, IsTouch, Helpers } from 'survey-core';
9
9
 
10
10
  /******************************************************************************
11
11
  Copyright (c) Microsoft Corporation.
@@ -356,6 +356,7 @@ class VisualizerBase {
356
356
  this.contentContainer = undefined;
357
357
  this.footerContainer = undefined;
358
358
  this._supportSelection = false;
359
+ this._chartAdapter = undefined;
359
360
  /**
360
361
  * An event that is raised after the visualizer's content is rendered.
361
362
  *
@@ -673,9 +674,10 @@ class VisualizerBase {
673
674
  if (!!this.options && typeof this.options.destroyContent === "function") {
674
675
  this.options.destroyContent(container, this);
675
676
  }
676
- else {
677
- container.innerHTML = "";
677
+ else if (this._chartAdapter) {
678
+ this._chartAdapter.destroy(container.children[0]);
678
679
  }
680
+ container.innerHTML = "";
679
681
  }
680
682
  renderHeader(container) {
681
683
  if (!!this.options && typeof this.options.renderHeader === "function") {
@@ -689,10 +691,16 @@ class VisualizerBase {
689
691
  }
690
692
  renderContentAsync(container) {
691
693
  return __awaiter(this, void 0, void 0, function* () {
692
- return new Promise((resolve, reject) => {
694
+ if (this._chartAdapter) {
695
+ const chartNode = DocumentHelper.createElement("div");
696
+ container.innerHTML = "";
697
+ container.appendChild(chartNode);
698
+ yield this._chartAdapter.create(chartNode);
699
+ }
700
+ else {
693
701
  container.innerText = localization.getString("noVisualizerForQuestion");
694
- resolve(container);
695
- });
702
+ }
703
+ return container;
696
704
  });
697
705
  }
698
706
  ensureQuestionIsReady() {
@@ -779,10 +787,23 @@ class VisualizerBase {
779
787
  });
780
788
  }
781
789
  }
782
- updateContent() {
790
+ isSupportSoftUpdateContent() {
791
+ return false;
792
+ }
793
+ softUpdateContent() {
794
+ }
795
+ hardUpdateContent() {
783
796
  this.destroyContent(this.contentContainer);
784
797
  this.renderContent(this.contentContainer);
785
798
  }
799
+ updateContent() {
800
+ if (!this.isSupportSoftUpdateContent()) {
801
+ this.hardUpdateContent();
802
+ }
803
+ else {
804
+ this.softUpdateContent();
805
+ }
806
+ }
786
807
  /**
787
808
  * Re-renders the visualizer and its content.
788
809
  */
@@ -973,6 +994,7 @@ class VisualizerBase {
973
994
  }
974
995
  }
975
996
  VisualizerBase.suppressVisualizerStubRendering = false;
997
+ VisualizerBase.chartAdapterType = undefined;
976
998
  // public static otherCommentQuestionType = "comment"; // TODO: make it configureable - allow choose what kind of question/visualizer will be used for comments/others
977
999
  VisualizerBase.otherCommentCollapsed = true;
978
1000
  VisualizerBase.customColors = [];
@@ -1046,6 +1068,131 @@ function defaultStatisticsCalculator(data, dataInfo) {
1046
1068
  return dataInfo.dataNames.length > 1 ? statistics : statistics[0];
1047
1069
  }
1048
1070
 
1071
+ class NumberModel extends VisualizerBase {
1072
+ constructor(question, data, options = {}, name) {
1073
+ super(question, data, options, name || "number");
1074
+ if (VisualizerBase.chartAdapterType) {
1075
+ this._chartAdapter = new VisualizerBase.chartAdapterType(this);
1076
+ this.chartTypes = this._chartAdapter.getChartTypes();
1077
+ this.chartType = this.chartTypes[0];
1078
+ }
1079
+ this.registerToolbarItem("changeChartType", () => {
1080
+ if (this.chartTypes.length > 1) {
1081
+ return DocumentHelper.createSelector(this.chartTypes.map((chartType) => {
1082
+ return {
1083
+ value: chartType,
1084
+ text: localization.getString("chartType_" + chartType),
1085
+ };
1086
+ }), (option) => this.chartType === option.value, (e) => {
1087
+ this.setChartType(e.target.value);
1088
+ });
1089
+ }
1090
+ return null;
1091
+ });
1092
+ }
1093
+ onDataChanged() {
1094
+ this._resultAverage = undefined;
1095
+ this._resultMin = undefined;
1096
+ this._resultMax = undefined;
1097
+ super.onDataChanged();
1098
+ }
1099
+ onChartTypeChanged() { }
1100
+ setChartType(chartType) {
1101
+ if (this.chartTypes.indexOf(chartType) !== -1 &&
1102
+ this.chartType !== chartType) {
1103
+ this.chartType = chartType;
1104
+ this.onChartTypeChanged();
1105
+ if (!!this.contentContainer) {
1106
+ this.destroyContent(this.contentContainer);
1107
+ this.renderContent(this.contentContainer);
1108
+ }
1109
+ this.invokeOnUpdate();
1110
+ }
1111
+ }
1112
+ destroy() {
1113
+ this._resultAverage = undefined;
1114
+ this._resultMin = undefined;
1115
+ this._resultMax = undefined;
1116
+ super.destroy();
1117
+ }
1118
+ generateText(maxValue, minValue, stepsCount) {
1119
+ let texts = [];
1120
+ if (stepsCount === 5) {
1121
+ texts = [
1122
+ "very high (" + maxValue + ")",
1123
+ "high",
1124
+ "medium",
1125
+ "low",
1126
+ "very low (" + minValue + ")",
1127
+ ];
1128
+ }
1129
+ else {
1130
+ texts.push(maxValue);
1131
+ for (let i = 0; i < stepsCount - 2; i++) {
1132
+ texts.push("");
1133
+ }
1134
+ texts.push(minValue);
1135
+ }
1136
+ if (!!NumberModel.generateTextsCallback) {
1137
+ return NumberModel.generateTextsCallback(this.question, maxValue, minValue, stepsCount, texts);
1138
+ }
1139
+ return texts;
1140
+ }
1141
+ generateValues(maxValue, stepsCount) {
1142
+ const values = [];
1143
+ for (let i = 0; i < stepsCount; i++) {
1144
+ values.push(maxValue / stepsCount);
1145
+ }
1146
+ values.push(maxValue);
1147
+ return values;
1148
+ }
1149
+ generateColors(maxValue, minValue, stepsCount) {
1150
+ const palette = this.getColors();
1151
+ const colors = [];
1152
+ for (let i = 0; i < stepsCount; i++) {
1153
+ colors.push(palette[i]);
1154
+ }
1155
+ colors.push("rgba(255, 255, 255, 0)");
1156
+ return colors;
1157
+ }
1158
+ convertFromExternalData(externalCalculatedData) {
1159
+ return [externalCalculatedData.value || 0, externalCalculatedData.minValue || 0, externalCalculatedData.maxValue || 0];
1160
+ }
1161
+ getCalculatedValuesCore() {
1162
+ if (this._resultAverage === undefined ||
1163
+ this._resultMin === undefined ||
1164
+ this._resultMax === undefined) {
1165
+ this._resultMin = Number.MAX_VALUE;
1166
+ this._resultMax = -Number.MAX_VALUE;
1167
+ this._resultAverage = 0;
1168
+ let actualAnswerCount = 0;
1169
+ this.data.forEach((rowData) => {
1170
+ if (rowData[this.question.name] !== undefined) {
1171
+ const questionValue = +rowData[this.question.name];
1172
+ actualAnswerCount++;
1173
+ this._resultAverage += questionValue;
1174
+ if (this._resultMin > questionValue) {
1175
+ this._resultMin = questionValue;
1176
+ }
1177
+ if (this._resultMax < questionValue) {
1178
+ this._resultMax = questionValue;
1179
+ }
1180
+ }
1181
+ });
1182
+ if (actualAnswerCount > 0) {
1183
+ this._resultAverage = this._resultAverage / actualAnswerCount;
1184
+ }
1185
+ this._resultAverage = Math.ceil(this._resultAverage * 100) / 100;
1186
+ }
1187
+ return [this._resultAverage, this._resultMin, this._resultMax];
1188
+ }
1189
+ }
1190
+ NumberModel.stepsCount = 5;
1191
+ NumberModel.showAsPercentage = false;
1192
+ VisualizationManager.registerVisualizer("number", NumberModel, 200);
1193
+ VisualizationManager.registerVisualizer("rating", NumberModel, 200);
1194
+ VisualizationManager.registerVisualizer("expression", NumberModel);
1195
+
1049
1196
  function hideEmptyAnswersInData(answersData) {
1050
1197
  const result = {
1051
1198
  datasets: [],
@@ -1150,6 +1297,18 @@ class SelectBase extends VisualizerBase {
1150
1297
  this._hideEmptyAnswers = this.options.hideEmptyAnswers === true;
1151
1298
  this._answersOrder = this.options.answersOrder || "default";
1152
1299
  this._showMissingAnswers = this.isSupportMissingAnswers() && this.options.showMissingAnswers === true;
1300
+ if (this.options.allowExperimentalFeatures) ;
1301
+ if (VisualizerBase.chartAdapterType) {
1302
+ this._chartAdapter = new VisualizerBase.chartAdapterType(this);
1303
+ this.chartTypes = this._chartAdapter.getChartTypes();
1304
+ if (this.getSeriesValues().length > 0 && this.chartTypes.indexOf("stackedbar") === -1) {
1305
+ this.chartTypes.push("stackedbar");
1306
+ }
1307
+ this._chartType = this.chartTypes[0];
1308
+ if (this.chartTypes.indexOf(this.options.defaultChartType) !== -1) {
1309
+ this._chartType = this.options.defaultChartType;
1310
+ }
1311
+ }
1153
1312
  this.registerToolbarItem("changeChartType", () => {
1154
1313
  if (this.chartTypes.length > 1) {
1155
1314
  return DocumentHelper.createSelector(this.chartTypes.map((chartType) => {
@@ -1327,6 +1486,16 @@ class SelectBase extends VisualizerBase {
1327
1486
  const selectBaseQuestion = this.question;
1328
1487
  return resultValues.map((value) => ItemValue.getTextOrHtmlByValue(selectBaseQuestion.choices, value)).join(", ");
1329
1488
  }
1489
+ isSupportSoftUpdateContent() {
1490
+ return true;
1491
+ }
1492
+ softUpdateContent() {
1493
+ var _a;
1494
+ const chartNode = (_a = this.contentContainer) === null || _a === void 0 ? void 0 : _a.children[0];
1495
+ if (chartNode) {
1496
+ this._chartAdapter.update(chartNode);
1497
+ }
1498
+ }
1330
1499
  getSelectedItemByText(itemText) {
1331
1500
  const selBase = this.question;
1332
1501
  if (this.question.hasOther && itemText == selBase.otherText) {
@@ -1637,87 +1806,11 @@ class SelectBase extends VisualizerBase {
1637
1806
  }
1638
1807
  SelectBase.topNValuesDefaults = [-1, 5, 10, 20];
1639
1808
  SelectBase._stateProperties = ["chartType", "answersOrder", "hideEmptyAnswers", "topN"];
1640
-
1641
- class Matrix extends SelectBase {
1642
- constructor(question, data, options, name) {
1643
- super(question, data, options, name || "matrix");
1644
- this._transposeData = true;
1645
- // this.getAnswersData();
1646
- }
1647
- get matrixQuestion() {
1648
- return this.question;
1649
- }
1650
- isSupportMissingAnswers() {
1651
- return false;
1652
- }
1653
- getSeriesValues() {
1654
- return this.matrixQuestion.rows.map((row) => "" + row.value);
1655
- }
1656
- getSeriesLabels() {
1657
- return this.matrixQuestion.rows.map((row) => ItemValue.getTextOrHtmlByValue(this.matrixQuestion.rows, row.value));
1658
- }
1659
- getSelectedItemByText(itemText) {
1660
- return this.matrixQuestion.columns.filter((column) => column.text === itemText)[0];
1661
- }
1662
- valuesSource() {
1663
- return this.matrixQuestion.columns;
1664
- }
1665
- getHasAnswersInAllSeriesArray(datasets) {
1666
- let result = Array();
1667
- for (let i = 0; i < datasets[0].length; i++) {
1668
- for (let j = 0; j < datasets.length; j++) {
1669
- if (datasets[j][i] != 0) {
1670
- result[i] = true;
1671
- }
1672
- }
1673
- }
1674
- return result;
1675
- }
1676
- getHasAnswersInSeries(dataset) {
1677
- for (let i = 0; i < dataset.length; i++) {
1678
- if (dataset[i] != 0) {
1679
- return true;
1680
- }
1681
- }
1682
- return false;
1683
- }
1684
- hideEmptyAnswersInData(answersData) {
1685
- const result = {
1686
- datasets: [],
1687
- labels: [],
1688
- colors: [],
1689
- texts: [],
1690
- seriesLabels: [],
1691
- };
1692
- const hasAnswersInAllSeriesArr = this.getHasAnswersInAllSeriesArray(answersData.datasets);
1693
- for (let i = 0; i < answersData.datasets.length; i++) {
1694
- const hasAnswersInSeries = this.getHasAnswersInSeries(answersData.datasets[i]);
1695
- if (hasAnswersInSeries) {
1696
- result.labels.push(answersData.labels[i]);
1697
- result.colors.push(answersData.colors[i]);
1698
- }
1699
- else {
1700
- continue;
1701
- }
1702
- const datasets = [];
1703
- const texts = [];
1704
- for (let j = 0; j < answersData.datasets[0].length; j++) {
1705
- if (hasAnswersInAllSeriesArr[j]) {
1706
- datasets.push(answersData.datasets[i][j]);
1707
- texts.push(answersData.texts[i][j]);
1708
- }
1709
- }
1710
- result.datasets.push(datasets);
1711
- result.texts.push(texts);
1712
- }
1713
- for (let i = 0; i < answersData.datasets[0].length; i++) {
1714
- if (hasAnswersInAllSeriesArr[i]) {
1715
- result.seriesLabels.push(answersData.seriesLabels[i]);
1716
- }
1717
- }
1718
- return result;
1719
- }
1720
- }
1809
+ VisualizationManager.registerVisualizer("checkbox", SelectBase);
1810
+ VisualizationManager.registerVisualizer("radiogroup", SelectBase);
1811
+ VisualizationManager.registerVisualizer("dropdown", SelectBase);
1812
+ VisualizationManager.registerVisualizer("imagepicker", SelectBase);
1813
+ VisualizationManager.registerVisualizer("tagbox", SelectBase);
1721
1814
 
1722
1815
  class BooleanModel extends SelectBase {
1723
1816
  constructor(question, data, options, name) {
@@ -1771,6 +1864,7 @@ class BooleanModel extends SelectBase {
1771
1864
  }
1772
1865
  BooleanModel.trueColor = "";
1773
1866
  BooleanModel.falseColor = "";
1867
+ VisualizationManager.registerVisualizer("boolean", BooleanModel);
1774
1868
 
1775
1869
  class HistogramModel extends SelectBase {
1776
1870
  constructor(question, data, options, name) {
@@ -1944,126 +2038,97 @@ class HistogramModel extends SelectBase {
1944
2038
  }
1945
2039
  return statistics;
1946
2040
  }
2041
+ getValueType() {
2042
+ return this.valueType;
2043
+ }
1947
2044
  }
1948
2045
  HistogramModel.IntervalsCount = 10;
1949
2046
  HistogramModel.UseIntervalsFrom = 10;
2047
+ VisualizationManager.registerVisualizer("date", HistogramModel);
2048
+ VisualizationManager.registerVisualizer("number", HistogramModel, 100);
2049
+ VisualizationManager.registerVisualizer("rating", HistogramModel, 100);
1950
2050
 
1951
- class NumberModel extends VisualizerBase {
1952
- constructor(question, data, options = {}, name) {
1953
- super(question, data, options, name || "number");
1954
- this.registerToolbarItem("changeChartType", () => {
1955
- if (this.chartTypes.length > 1) {
1956
- return DocumentHelper.createSelector(this.chartTypes.map((chartType) => {
1957
- return {
1958
- value: chartType,
1959
- text: localization.getString("chartType_" + chartType),
1960
- };
1961
- }), (option) => this.chartType === option.value, (e) => {
1962
- this.setChartType(e.target.value);
1963
- });
1964
- }
1965
- return null;
1966
- });
2051
+ class Matrix extends SelectBase {
2052
+ constructor(question, data, options, name) {
2053
+ super(question, data, options, name || "matrix");
2054
+ this._transposeData = true;
2055
+ // this.getAnswersData();
1967
2056
  }
1968
- onDataChanged() {
1969
- this._resultAverage = undefined;
1970
- this._resultMin = undefined;
1971
- this._resultMax = undefined;
1972
- super.onDataChanged();
2057
+ get matrixQuestion() {
2058
+ return this.question;
1973
2059
  }
1974
- onChartTypeChanged() { }
1975
- setChartType(chartType) {
1976
- if (this.chartTypes.indexOf(chartType) !== -1 &&
1977
- this.chartType !== chartType) {
1978
- this.chartType = chartType;
1979
- this.onChartTypeChanged();
1980
- if (!!this.contentContainer) {
1981
- this.destroyContent(this.contentContainer);
1982
- this.renderContent(this.contentContainer);
1983
- }
1984
- this.invokeOnUpdate();
1985
- }
2060
+ isSupportMissingAnswers() {
2061
+ return false;
1986
2062
  }
1987
- destroy() {
1988
- this._resultAverage = undefined;
1989
- this._resultMin = undefined;
1990
- this._resultMax = undefined;
1991
- super.destroy();
2063
+ getSeriesValues() {
2064
+ return this.matrixQuestion.rows.map((row) => "" + row.value);
1992
2065
  }
1993
- generateText(maxValue, minValue, stepsCount) {
1994
- let texts = [];
1995
- if (stepsCount === 5) {
1996
- texts = [
1997
- "very high (" + maxValue + ")",
1998
- "high",
1999
- "medium",
2000
- "low",
2001
- "very low (" + minValue + ")",
2002
- ];
2003
- }
2004
- else {
2005
- texts.push(maxValue);
2006
- for (let i = 0; i < stepsCount - 2; i++) {
2007
- texts.push("");
2008
- }
2009
- texts.push(minValue);
2010
- }
2011
- if (!!NumberModel.generateTextsCallback) {
2012
- return NumberModel.generateTextsCallback(this.question, maxValue, minValue, stepsCount, texts);
2013
- }
2014
- return texts;
2066
+ getSeriesLabels() {
2067
+ return this.matrixQuestion.rows.map((row) => ItemValue.getTextOrHtmlByValue(this.matrixQuestion.rows, row.value));
2015
2068
  }
2016
- generateValues(maxValue, stepsCount) {
2017
- const values = [];
2018
- for (let i = 0; i < stepsCount; i++) {
2019
- values.push(maxValue / stepsCount);
2020
- }
2021
- values.push(maxValue);
2022
- return values;
2069
+ getSelectedItemByText(itemText) {
2070
+ return this.matrixQuestion.columns.filter((column) => column.text === itemText)[0];
2023
2071
  }
2024
- generateColors(maxValue, minValue, stepsCount) {
2025
- const palette = this.getColors();
2026
- const colors = [];
2027
- for (let i = 0; i < stepsCount; i++) {
2028
- colors.push(palette[i]);
2072
+ valuesSource() {
2073
+ return this.matrixQuestion.columns;
2074
+ }
2075
+ getHasAnswersInAllSeriesArray(datasets) {
2076
+ let result = Array();
2077
+ for (let i = 0; i < datasets[0].length; i++) {
2078
+ for (let j = 0; j < datasets.length; j++) {
2079
+ if (datasets[j][i] != 0) {
2080
+ result[i] = true;
2081
+ }
2082
+ }
2029
2083
  }
2030
- colors.push("rgba(255, 255, 255, 0)");
2031
- return colors;
2084
+ return result;
2032
2085
  }
2033
- convertFromExternalData(externalCalculatedData) {
2034
- return [externalCalculatedData.value || 0, externalCalculatedData.minValue || 0, externalCalculatedData.maxValue || 0];
2086
+ getHasAnswersInSeries(dataset) {
2087
+ for (let i = 0; i < dataset.length; i++) {
2088
+ if (dataset[i] != 0) {
2089
+ return true;
2090
+ }
2091
+ }
2092
+ return false;
2035
2093
  }
2036
- getCalculatedValuesCore() {
2037
- if (this._resultAverage === undefined ||
2038
- this._resultMin === undefined ||
2039
- this._resultMax === undefined) {
2040
- this._resultMin = Number.MAX_VALUE;
2041
- this._resultMax = -Number.MAX_VALUE;
2042
- this._resultAverage = 0;
2043
- let actualAnswerCount = 0;
2044
- this.data.forEach((rowData) => {
2045
- if (rowData[this.question.name] !== undefined) {
2046
- const questionValue = +rowData[this.question.name];
2047
- actualAnswerCount++;
2048
- this._resultAverage += questionValue;
2049
- if (this._resultMin > questionValue) {
2050
- this._resultMin = questionValue;
2051
- }
2052
- if (this._resultMax < questionValue) {
2053
- this._resultMax = questionValue;
2054
- }
2094
+ hideEmptyAnswersInData(answersData) {
2095
+ const result = {
2096
+ datasets: [],
2097
+ labels: [],
2098
+ colors: [],
2099
+ texts: [],
2100
+ seriesLabels: [],
2101
+ };
2102
+ const hasAnswersInAllSeriesArr = this.getHasAnswersInAllSeriesArray(answersData.datasets);
2103
+ for (let i = 0; i < answersData.datasets.length; i++) {
2104
+ const hasAnswersInSeries = this.getHasAnswersInSeries(answersData.datasets[i]);
2105
+ if (hasAnswersInSeries) {
2106
+ result.labels.push(answersData.labels[i]);
2107
+ result.colors.push(answersData.colors[i]);
2108
+ }
2109
+ else {
2110
+ continue;
2111
+ }
2112
+ const datasets = [];
2113
+ const texts = [];
2114
+ for (let j = 0; j < answersData.datasets[0].length; j++) {
2115
+ if (hasAnswersInAllSeriesArr[j]) {
2116
+ datasets.push(answersData.datasets[i][j]);
2117
+ texts.push(answersData.texts[i][j]);
2055
2118
  }
2056
- });
2057
- if (actualAnswerCount > 0) {
2058
- this._resultAverage = this._resultAverage / actualAnswerCount;
2059
2119
  }
2060
- this._resultAverage = Math.ceil(this._resultAverage * 100) / 100;
2120
+ result.datasets.push(datasets);
2121
+ result.texts.push(texts);
2061
2122
  }
2062
- return [this._resultAverage, this._resultMin, this._resultMax];
2123
+ for (let i = 0; i < answersData.datasets[0].length; i++) {
2124
+ if (hasAnswersInAllSeriesArr[i]) {
2125
+ result.seriesLabels.push(answersData.seriesLabels[i]);
2126
+ }
2127
+ }
2128
+ return result;
2063
2129
  }
2064
2130
  }
2065
- NumberModel.stepsCount = 5;
2066
- NumberModel.showAsPercentage = false;
2131
+ VisualizationManager.registerVisualizer("matrix", Matrix);
2067
2132
 
2068
2133
  class PivotModel extends SelectBase {
2069
2134
  constructor(questions, data, options, name) {
@@ -2236,7 +2301,7 @@ class PivotModel extends SelectBase {
2236
2301
  return this.question.getType() == "rating" && Array.isArray(this.question["rateValues"]) && this.question["rateValues"].length > 0;
2237
2302
  }
2238
2303
  getSeriesValues() {
2239
- if (this.questionsY.length === 0) {
2304
+ if (!this.questionsY || this.questionsY.length === 0) {
2240
2305
  return this.options.seriesValues || [];
2241
2306
  }
2242
2307
  const seriesValues = [];
@@ -2414,9 +2479,49 @@ class PivotModel extends SelectBase {
2414
2479
  }
2415
2480
  return statistics;
2416
2481
  }
2482
+ getValueType() {
2483
+ return this.valueType;
2484
+ }
2485
+ isSupportSoftUpdateContent() {
2486
+ return false;
2487
+ }
2417
2488
  }
2418
2489
  PivotModel.IntervalsCount = 10;
2419
2490
  PivotModel.UseIntervalsFrom = 10;
2491
+ VisualizationManager.registerPivotVisualizer(PivotModel);
2492
+
2493
+ class RankingModel extends SelectBase {
2494
+ getQuestionResults() {
2495
+ const name = this.question.name;
2496
+ return this.data.map((dataItem) => dataItem[name]);
2497
+ }
2498
+ getEmptyData() {
2499
+ const choices = this.getValues();
2500
+ let data = [];
2501
+ data.length = choices.length;
2502
+ data.fill(0);
2503
+ return data;
2504
+ }
2505
+ getCalculatedValuesCore() {
2506
+ const results = this.getQuestionResults();
2507
+ const choices = this.getValues();
2508
+ let plotlyData = this.getEmptyData();
2509
+ results.forEach((result) => {
2510
+ this.applyResultToPlotlyData(result, plotlyData, choices);
2511
+ });
2512
+ return [plotlyData];
2513
+ }
2514
+ applyResultToPlotlyData(result, plotlyData, choices) {
2515
+ if (!result || !plotlyData || !choices)
2516
+ return;
2517
+ result.forEach((resultValue, resultValueIndex, result) => {
2518
+ let index = choices.indexOf(resultValue);
2519
+ plotlyData[index] =
2520
+ +plotlyData[index] + (result.length - resultValueIndex);
2521
+ });
2522
+ }
2523
+ }
2524
+ VisualizationManager.registerVisualizer("ranking", RankingModel);
2420
2525
 
2421
2526
  class AlternativeVisualizersWrapper extends VisualizerBase {
2422
2527
  updateVisualizerSelector() {
@@ -12322,5 +12427,5 @@ NpsVisualizer.DetractorScore = 6;
12322
12427
  NpsVisualizer.PromoterScore = 9;
12323
12428
  // VisualizationManager.registerVisualizer("rating", NpsVisualizer);
12324
12429
 
12325
- export { AlternativeVisualizersWrapper as A, BooleanModel as B, DataProvider as D, HistogramModel as H, Matrix as M, NumberModel as N, PostponeHelper as P, SelectBase as S, TextTableAdapter as T, VisualizerFactory as V, WordCloudAdapter as W, __awaiter as _, VisualizerBase as a, VisualizationManager as b, VisualizationPanel as c, defaultStatisticsCalculator as d, VisualizationPanelDynamic as e, VisualizationMatrixDynamic as f, VisualizationMatrixDropdown as g, hideEmptyAnswersInData as h, WordCloud as i, Text as j, StatisticsTableAdapter as k, StatisticsTable as l, NpsVisualizerWidget as m, NpsAdapter as n, NpsVisualizer as o, PivotModel as p, textHelper as t };
12430
+ 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, defaultStatisticsCalculator as d, VisualizationPanelDynamic as e, VisualizationMatrixDynamic as f, VisualizationMatrixDropdown as g, hideEmptyAnswersInData as h, WordCloud as i, Text as j, StatisticsTableAdapter as k, StatisticsTable as l, NpsVisualizerWidget as m, NpsAdapter as n, NpsVisualizer as o, PivotModel as p, textHelper as t };
12326
12431
  //# sourceMappingURL=shared2.mjs.map