survey-analytics 2.3.5 → 2.3.6
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 +1 -1
- package/fesm/shared2.mjs +27 -23
- package/fesm/shared2.mjs.map +1 -1
- package/fesm/survey.analytics.core.mjs +1 -1
- package/fesm/survey.analytics.mjs +9 -2
- package/fesm/survey.analytics.mjs.map +1 -1
- package/fesm/survey.analytics.tabulator.mjs +1 -1
- package/package.json +2 -2
- package/survey-analytics.types/selectBase.d.ts +1 -0
- package/survey-analytics.types/visualizationManager.d.ts +2 -2
- package/survey-analytics.types/visualizationPanel.d.ts +1 -1
- package/survey.analytics.core.css +1 -1
- package/survey.analytics.core.js +28 -24
- 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 +36 -25
- 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 +1 -1
- package/survey.analytics.tabulator.min.css +1 -1
- package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
package/fesm/shared.mjs
CHANGED
package/fesm/shared2.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* surveyjs - SurveyJS Dashboard library v2.3.
|
|
2
|
+
* surveyjs - SurveyJS Dashboard library v2.3.6
|
|
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
|
*/
|
|
@@ -212,10 +212,13 @@ class VisualizationManager {
|
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* Returns all visualizer constructors for a specified question type.
|
|
215
|
-
* @param
|
|
215
|
+
* @param visualizerType A question [type](https://surveyjs.io/form-library/documentation/api-reference/question#getType).
|
|
216
216
|
*/
|
|
217
|
-
static getVisualizersByType(
|
|
218
|
-
let vDescrs = VisualizationManager.vizualizers[
|
|
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 [];
|
|
@@ -280,12 +283,7 @@ class VisualizerFactory {
|
|
|
280
283
|
let type = question.getType();
|
|
281
284
|
let creators = [];
|
|
282
285
|
if (type === "text" && question.inputType) {
|
|
283
|
-
|
|
284
|
-
creators = VisualizationManager.getVisualizersByType(type);
|
|
285
|
-
if (creators === undefined || creators.length == 0) {
|
|
286
|
-
type = "text";
|
|
287
|
-
creators = VisualizationManager.getVisualizersByType(type);
|
|
288
|
-
}
|
|
286
|
+
creators = VisualizationManager.getVisualizersByType(question.inputType, type);
|
|
289
287
|
}
|
|
290
288
|
else {
|
|
291
289
|
creators = VisualizationManager.getVisualizersByType(type);
|
|
@@ -1340,9 +1338,8 @@ class SelectBase extends VisualizerBase {
|
|
|
1340
1338
|
this.emptyAnswersBtn = undefined;
|
|
1341
1339
|
this.transposeDataBtn = undefined;
|
|
1342
1340
|
this.topNSelector = undefined;
|
|
1343
|
-
this._showPercentages = false;
|
|
1344
1341
|
this._showOnlyPercentages = false;
|
|
1345
|
-
this._percentagePrecision =
|
|
1342
|
+
this._percentagePrecision = 2;
|
|
1346
1343
|
this._answersOrder = "default";
|
|
1347
1344
|
this._hideEmptyAnswers = false;
|
|
1348
1345
|
this._topN = -1;
|
|
@@ -1364,7 +1361,6 @@ class SelectBase extends VisualizerBase {
|
|
|
1364
1361
|
};
|
|
1365
1362
|
}
|
|
1366
1363
|
this._supportSelection = true;
|
|
1367
|
-
this._showPercentages = this.options.showPercentages === true;
|
|
1368
1364
|
this._showOnlyPercentages = this.options.showOnlyPercentages === true;
|
|
1369
1365
|
if (this.options.percentagePrecision) {
|
|
1370
1366
|
this._percentagePrecision = this.options.percentagePrecision;
|
|
@@ -1607,11 +1603,22 @@ class SelectBase extends VisualizerBase {
|
|
|
1607
1603
|
this.refreshContent();
|
|
1608
1604
|
this.stateChanged("showOnlyPercentages", val);
|
|
1609
1605
|
}
|
|
1606
|
+
getShowPercentagesDefault() {
|
|
1607
|
+
if (this.options.showPercentages === undefined) {
|
|
1608
|
+
return ["pie", "doughnut"].indexOf(this.chartType) !== -1;
|
|
1609
|
+
}
|
|
1610
|
+
return this.options.showPercentages === true;
|
|
1611
|
+
}
|
|
1610
1612
|
/**
|
|
1611
1613
|
* Gets and sets whether chart should show values and percentages.
|
|
1612
1614
|
*/
|
|
1613
1615
|
get showPercentages() {
|
|
1614
|
-
|
|
1616
|
+
if (this._showPercentages !== undefined) {
|
|
1617
|
+
return this._showPercentages;
|
|
1618
|
+
}
|
|
1619
|
+
else {
|
|
1620
|
+
return this.getShowPercentagesDefault();
|
|
1621
|
+
}
|
|
1615
1622
|
}
|
|
1616
1623
|
set showPercentages(val) {
|
|
1617
1624
|
this._showPercentages = val;
|
|
@@ -1743,12 +1750,10 @@ class SelectBase extends VisualizerBase {
|
|
|
1743
1750
|
var percentages = [];
|
|
1744
1751
|
var percentagePrecision = this._percentagePrecision;
|
|
1745
1752
|
if (data.length < 2) {
|
|
1746
|
-
data.
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
return sum && (value / 100);
|
|
1751
|
-
});
|
|
1753
|
+
var sum = data[0].reduce((sum, val) => sum + val, 0);
|
|
1754
|
+
percentages[0] = data[0].map((val) => {
|
|
1755
|
+
var value = percentagePrecision ? +(val / sum * 100).toFixed(percentagePrecision) : Math.round(val / sum * 100);
|
|
1756
|
+
return sum && value;
|
|
1752
1757
|
});
|
|
1753
1758
|
}
|
|
1754
1759
|
else {
|
|
@@ -1760,7 +1765,7 @@ class SelectBase extends VisualizerBase {
|
|
|
1760
1765
|
for (var j = 0; j < data.length; j++) {
|
|
1761
1766
|
if (!Array.isArray(percentages[j]))
|
|
1762
1767
|
percentages[j] = [];
|
|
1763
|
-
var value = percentagePrecision ? +(
|
|
1768
|
+
var value = percentagePrecision ? +(data[j][i] / sum * 100).toFixed(percentagePrecision) : Math.round(data[j][i] / sum * 100);
|
|
1764
1769
|
percentages[j][i] = sum && value;
|
|
1765
1770
|
}
|
|
1766
1771
|
}
|
|
@@ -1792,14 +1797,13 @@ class SelectBase extends VisualizerBase {
|
|
|
1792
1797
|
let datasets = (yield this.getCalculatedValues());
|
|
1793
1798
|
let labels = this.getLabels();
|
|
1794
1799
|
let colors = this.getColors();
|
|
1795
|
-
var texts = this.showPercentages ? this.getPercentages(datasets) : datasets;
|
|
1796
1800
|
if (this.transposeData) {
|
|
1797
1801
|
datasets = this.transpose(datasets);
|
|
1798
|
-
texts = this.transpose(texts);
|
|
1799
1802
|
const temp = seriesLabels;
|
|
1800
1803
|
seriesLabels = labels;
|
|
1801
1804
|
labels = temp;
|
|
1802
1805
|
}
|
|
1806
|
+
var texts = this.showPercentages ? this.getPercentages(datasets) : datasets;
|
|
1803
1807
|
if (this.answersOrder == "asc" || this.answersOrder == "desc") {
|
|
1804
1808
|
var zippedArray = this.showPercentages
|
|
1805
1809
|
? DataHelper.zipArrays(labels, colors, texts[0])
|