survey-analytics 2.2.4 → 2.2.5
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 +2 -1
- package/fesm/shared.mjs.map +1 -1
- package/fesm/shared2.mjs +108 -102
- package/fesm/shared2.mjs.map +1 -1
- package/fesm/survey.analytics.core.mjs +2 -2
- package/fesm/survey.analytics.mjs +16 -26
- package/fesm/survey.analytics.mjs.map +1 -1
- package/fesm/survey.analytics.tabulator.mjs +16 -4
- package/fesm/survey.analytics.tabulator.mjs.map +1 -1
- package/package.json +6 -5
- package/survey-analytics-tabulator.types/analytics-localization/english.d.ts +1 -0
- package/survey-analytics-tabulator.types/localizationManager.d.ts +1 -0
- package/survey-analytics-tabulator.types/tables/extensions/tableextensions.d.ts +1 -0
- package/survey-analytics.types/analytics-localization/english.d.ts +1 -0
- package/survey-analytics.types/localizationManager.d.ts +1 -0
- package/survey-analytics.types/plotly/chart-adapter.d.ts +9 -0
- package/survey-analytics.types/statisticCalculators.d.ts +4 -0
- package/survey-analytics.types/visualizationManager.d.ts +1 -0
- package/survey-analytics.types/visualizerBase.d.ts +1 -3
- package/survey.analytics.core.css +1 -1
- package/survey.analytics.core.js +179 -130
- 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 +198 -157
- 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 +39 -5
- 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.
|
|
2
|
+
* surveyjs - SurveyJS Dashboard library v2.2.5
|
|
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
|
*/
|
|
@@ -217,10 +217,10 @@ class VisualizationManager {
|
|
|
217
217
|
static getVisualizersByType(questionType) {
|
|
218
218
|
let vDescrs = VisualizationManager.vizualizers[questionType];
|
|
219
219
|
if (!vDescrs) {
|
|
220
|
-
if (
|
|
220
|
+
if (VisualizationManager.defaultVisualizer.suppressVisualizerStubRendering) {
|
|
221
221
|
return [];
|
|
222
222
|
}
|
|
223
|
-
return [
|
|
223
|
+
return [VisualizationManager.defaultVisualizer];
|
|
224
224
|
}
|
|
225
225
|
vDescrs = [].concat(vDescrs);
|
|
226
226
|
vDescrs.sort((v1, v2) => v1.index - v2.index);
|
|
@@ -231,7 +231,7 @@ class VisualizationManager {
|
|
|
231
231
|
* @see registerAltVisualizerSelector
|
|
232
232
|
*/
|
|
233
233
|
static getAltVisualizerSelector() {
|
|
234
|
-
return VisualizationManager.alternativesVisualizer ||
|
|
234
|
+
return VisualizationManager.alternativesVisualizer || VisualizationManager.defaultVisualizer;
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
237
237
|
* Registers an alternative visualizer selector.
|
|
@@ -241,12 +241,13 @@ class VisualizationManager {
|
|
|
241
241
|
VisualizationManager.alternativesVisualizer = constructor;
|
|
242
242
|
}
|
|
243
243
|
static getPivotVisualizerConstructor() {
|
|
244
|
-
return VisualizationManager.pivotVisualizer ||
|
|
244
|
+
return VisualizationManager.pivotVisualizer || VisualizationManager.defaultVisualizer;
|
|
245
245
|
}
|
|
246
246
|
static registerPivotVisualizer(constructor) {
|
|
247
247
|
VisualizationManager.pivotVisualizer = constructor;
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
+
VisualizationManager.defaultVisualizer = undefined;
|
|
250
251
|
VisualizationManager.alternativesVisualizer = undefined;
|
|
251
252
|
VisualizationManager.pivotVisualizer = undefined;
|
|
252
253
|
VisualizationManager.vizualizers = {};
|
|
@@ -294,6 +295,104 @@ class VisualizerFactory {
|
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
297
|
|
|
298
|
+
function defaultStatisticsCalculator(data, dataInfo) {
|
|
299
|
+
const dataNames = dataInfo.dataNames;
|
|
300
|
+
const statistics = [];
|
|
301
|
+
const values = dataInfo.getValues();
|
|
302
|
+
const valuesIndex = {};
|
|
303
|
+
values.forEach((val, index) => {
|
|
304
|
+
valuesIndex[val] = index;
|
|
305
|
+
});
|
|
306
|
+
const processMissingAnswers = values.indexOf(undefined) !== -1;
|
|
307
|
+
const series = dataInfo.getSeriesValues();
|
|
308
|
+
const seriesIndex = {};
|
|
309
|
+
series.forEach((val, index) => {
|
|
310
|
+
seriesIndex[val] = index;
|
|
311
|
+
});
|
|
312
|
+
const seriesLength = series.length || 1;
|
|
313
|
+
for (var i = 0; i < dataNames.length; ++i) {
|
|
314
|
+
const dataNameStatistics = new Array();
|
|
315
|
+
for (var j = 0; j < seriesLength; ++j) {
|
|
316
|
+
dataNameStatistics.push(new Array(values.length).fill(0));
|
|
317
|
+
}
|
|
318
|
+
statistics.push(dataNameStatistics);
|
|
319
|
+
}
|
|
320
|
+
data.forEach((row) => {
|
|
321
|
+
dataNames.forEach((dataName, index) => {
|
|
322
|
+
const rowValue = row[dataName];
|
|
323
|
+
if (rowValue !== undefined || processMissingAnswers) {
|
|
324
|
+
const rowValues = Array.isArray(rowValue) ? rowValue : [rowValue];
|
|
325
|
+
if (series.length > 0) {
|
|
326
|
+
if (row[DataProvider.seriesMarkerKey] !== undefined) {
|
|
327
|
+
// Series are labelled by seriesMarkerKey in row data
|
|
328
|
+
const seriesNo = seriesIndex[row[DataProvider.seriesMarkerKey]] || 0;
|
|
329
|
+
rowValues.forEach((val) => {
|
|
330
|
+
statistics[index][seriesNo][valuesIndex[val]]++;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
// Series are the keys in question value (matrix question)
|
|
335
|
+
// TODO: think about the de-normalization and combine with the previous case
|
|
336
|
+
rowValues.forEach((val) => {
|
|
337
|
+
series.forEach((seriesName) => {
|
|
338
|
+
if (val[seriesName] !== undefined) {
|
|
339
|
+
const seriesNo = seriesIndex[seriesName] || 0;
|
|
340
|
+
statistics[index][seriesNo][valuesIndex[val[seriesName]]]++;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
// No series
|
|
348
|
+
rowValues.forEach((val) => statistics[0][0][valuesIndex[val]]++);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
return dataInfo.dataNames.length > 1 ? statistics : statistics[0];
|
|
354
|
+
}
|
|
355
|
+
function histogramStatisticsCalculator(data, intervals, seriesValues) {
|
|
356
|
+
const statistics = [];
|
|
357
|
+
if (seriesValues.length === 0) {
|
|
358
|
+
seriesValues.push("");
|
|
359
|
+
}
|
|
360
|
+
for (var i = 0; i < seriesValues.length; ++i) {
|
|
361
|
+
statistics.push(intervals.map(i => 0));
|
|
362
|
+
data[seriesValues[i]].forEach(dataValue => {
|
|
363
|
+
for (let j = 0; j < intervals.length; ++j) {
|
|
364
|
+
if (intervals[j].start <= dataValue && (dataValue < intervals[j].end || j == intervals.length - 1)) {
|
|
365
|
+
statistics[i][j]++;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return statistics;
|
|
372
|
+
}
|
|
373
|
+
function mathStatisticsCalculator(data, dataName) {
|
|
374
|
+
let resultMin = Number.MAX_VALUE, resultMax = -Number.MAX_VALUE, resultAverage = 0;
|
|
375
|
+
let actualAnswerCount = 0;
|
|
376
|
+
data.forEach((rowData) => {
|
|
377
|
+
if (rowData[dataName] !== undefined) {
|
|
378
|
+
const questionValue = +rowData[dataName];
|
|
379
|
+
actualAnswerCount++;
|
|
380
|
+
resultAverage += questionValue;
|
|
381
|
+
if (resultMin > questionValue) {
|
|
382
|
+
resultMin = questionValue;
|
|
383
|
+
}
|
|
384
|
+
if (resultMax < questionValue) {
|
|
385
|
+
resultMax = questionValue;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
if (actualAnswerCount > 0) {
|
|
390
|
+
resultAverage = resultAverage / actualAnswerCount;
|
|
391
|
+
}
|
|
392
|
+
resultAverage = Math.ceil(resultAverage * 100) / 100;
|
|
393
|
+
return [resultAverage, resultMin, resultMax];
|
|
394
|
+
}
|
|
395
|
+
|
|
297
396
|
class PostponeHelper {
|
|
298
397
|
static postpone(fn, timeout) {
|
|
299
398
|
if (PostponeHelper.postponeFunction) {
|
|
@@ -1010,63 +1109,7 @@ VisualizerBase.colors = [
|
|
|
1010
1109
|
"#cf37a6",
|
|
1011
1110
|
"#4e6198",
|
|
1012
1111
|
];
|
|
1013
|
-
|
|
1014
|
-
const dataNames = dataInfo.dataNames;
|
|
1015
|
-
const statistics = [];
|
|
1016
|
-
const values = dataInfo.getValues();
|
|
1017
|
-
const valuesIndex = {};
|
|
1018
|
-
values.forEach((val, index) => {
|
|
1019
|
-
valuesIndex[val] = index;
|
|
1020
|
-
});
|
|
1021
|
-
const processMissingAnswers = values.indexOf(undefined) !== -1;
|
|
1022
|
-
const series = dataInfo.getSeriesValues();
|
|
1023
|
-
const seriesIndex = {};
|
|
1024
|
-
series.forEach((val, index) => {
|
|
1025
|
-
seriesIndex[val] = index;
|
|
1026
|
-
});
|
|
1027
|
-
const seriesLength = series.length || 1;
|
|
1028
|
-
for (var i = 0; i < dataNames.length; ++i) {
|
|
1029
|
-
const dataNameStatistics = new Array();
|
|
1030
|
-
for (var j = 0; j < seriesLength; ++j) {
|
|
1031
|
-
dataNameStatistics.push(new Array(values.length).fill(0));
|
|
1032
|
-
}
|
|
1033
|
-
statistics.push(dataNameStatistics);
|
|
1034
|
-
}
|
|
1035
|
-
data.forEach((row) => {
|
|
1036
|
-
dataNames.forEach((dataName, index) => {
|
|
1037
|
-
const rowValue = row[dataName];
|
|
1038
|
-
if (rowValue !== undefined || processMissingAnswers) {
|
|
1039
|
-
const rowValues = Array.isArray(rowValue) ? rowValue : [rowValue];
|
|
1040
|
-
if (series.length > 0) {
|
|
1041
|
-
if (row[DataProvider.seriesMarkerKey] !== undefined) {
|
|
1042
|
-
// Series are labelled by seriesMarkerKey in row data
|
|
1043
|
-
const seriesNo = seriesIndex[row[DataProvider.seriesMarkerKey]] || 0;
|
|
1044
|
-
rowValues.forEach((val) => {
|
|
1045
|
-
statistics[index][seriesNo][valuesIndex[val]]++;
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
else {
|
|
1049
|
-
// Series are the keys in question value (matrix question)
|
|
1050
|
-
// TODO: think about the de-normalization and combine with the previous case
|
|
1051
|
-
rowValues.forEach((val) => {
|
|
1052
|
-
series.forEach((seriesName) => {
|
|
1053
|
-
if (val[seriesName] !== undefined) {
|
|
1054
|
-
const seriesNo = seriesIndex[seriesName] || 0;
|
|
1055
|
-
statistics[index][seriesNo][valuesIndex[val[seriesName]]]++;
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
else {
|
|
1062
|
-
// No series
|
|
1063
|
-
rowValues.forEach((val) => statistics[0][0][valuesIndex[val]]++);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
});
|
|
1068
|
-
return dataInfo.dataNames.length > 1 ? statistics : statistics[0];
|
|
1069
|
-
}
|
|
1112
|
+
VisualizationManager.defaultVisualizer = VisualizerBase;
|
|
1070
1113
|
|
|
1071
1114
|
class NumberModel extends VisualizerBase {
|
|
1072
1115
|
constructor(question, data, options = {}, name) {
|
|
@@ -1162,27 +1205,7 @@ class NumberModel extends VisualizerBase {
|
|
|
1162
1205
|
if (this._resultAverage === undefined ||
|
|
1163
1206
|
this._resultMin === undefined ||
|
|
1164
1207
|
this._resultMax === undefined) {
|
|
1165
|
-
this._resultMin =
|
|
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;
|
|
1208
|
+
[this._resultAverage, this._resultMin, this._resultMax] = mathStatisticsCalculator(this.surveyData, this.dataNames[0]);
|
|
1186
1209
|
}
|
|
1187
1210
|
return [this._resultAverage, this._resultMin, this._resultMax];
|
|
1188
1211
|
}
|
|
@@ -2019,24 +2042,7 @@ class HistogramModel extends SelectBase {
|
|
|
2019
2042
|
}
|
|
2020
2043
|
getCalculatedValuesCore() {
|
|
2021
2044
|
this.getContiniousValues();
|
|
2022
|
-
|
|
2023
|
-
const statistics = [];
|
|
2024
|
-
const series = this.getSeriesValues();
|
|
2025
|
-
if (series.length === 0) {
|
|
2026
|
-
series.push("");
|
|
2027
|
-
}
|
|
2028
|
-
for (var i = 0; i < series.length; ++i) {
|
|
2029
|
-
statistics.push(intervals.map(i => 0));
|
|
2030
|
-
this._continiousData[series[i]].forEach(dataValue => {
|
|
2031
|
-
for (let j = 0; j < intervals.length; ++j) {
|
|
2032
|
-
if (intervals[j].start <= dataValue && (dataValue < intervals[j].end || j == intervals.length - 1)) {
|
|
2033
|
-
statistics[i][j]++;
|
|
2034
|
-
break;
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
});
|
|
2038
|
-
}
|
|
2039
|
-
return statistics;
|
|
2045
|
+
return histogramStatisticsCalculator(this._continiousData, this.intervals, this.getSeriesValues());
|
|
2040
2046
|
}
|
|
2041
2047
|
getValueType() {
|
|
2042
2048
|
return this.valueType;
|
|
@@ -12427,5 +12433,5 @@ NpsVisualizer.DetractorScore = 6;
|
|
|
12427
12433
|
NpsVisualizer.PromoterScore = 9;
|
|
12428
12434
|
// VisualizationManager.registerVisualizer("rating", NpsVisualizer);
|
|
12429
12435
|
|
|
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,
|
|
12436
|
+
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, NpsVisualizerWidget as l, NpsAdapter as m, NpsVisualizer as n, PivotModel as o, defaultStatisticsCalculator as p, textHelper as t };
|
|
12431
12437
|
//# sourceMappingURL=shared2.mjs.map
|