survey-analytics 2.2.4 → 2.2.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 +2 -1
- package/fesm/shared.mjs.map +1 -1
- package/fesm/shared2.mjs +126 -105
- 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/visualizationMatrixDropdown.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 +210 -144
- 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 +229 -171
- 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,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* surveyjs - SurveyJS Dashboard library v2.2.
|
|
2
|
+
* surveyjs - SurveyJS Dashboard library v2.2.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
|
*/
|
|
6
6
|
|
|
7
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
|
|
8
|
+
import { Event, QuestionCommentModel, settings, ItemValue, hasLicense, surveyLocalization, IsTouch } from 'survey-core';
|
|
9
9
|
|
|
10
10
|
/******************************************************************************
|
|
11
11
|
Copyright (c) Microsoft Corporation.
|
|
@@ -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;
|
|
@@ -10363,6 +10369,17 @@ class VisualizationMatrixDynamic extends VisualizationPanelDynamic {
|
|
|
10363
10369
|
}
|
|
10364
10370
|
VisualizationManager.registerVisualizer("matrixdynamic", VisualizationMatrixDynamic);
|
|
10365
10371
|
|
|
10372
|
+
function isChoicesArraysEqual(choices1, choices2) {
|
|
10373
|
+
if (choices1.length !== choices2.length)
|
|
10374
|
+
return false;
|
|
10375
|
+
for (let i = 0; i < choices1.length; i++) {
|
|
10376
|
+
if (choices1[i].value !== choices2[i].value ||
|
|
10377
|
+
choices1[i].text !== choices2[i].text) {
|
|
10378
|
+
return false;
|
|
10379
|
+
}
|
|
10380
|
+
}
|
|
10381
|
+
return true;
|
|
10382
|
+
}
|
|
10366
10383
|
class VisualizationMatrixDropdown extends VisualizerBase {
|
|
10367
10384
|
constructor(question, data, options = {}, name) {
|
|
10368
10385
|
super(question, data, options, name || "matrixDropdown");
|
|
@@ -10379,8 +10396,7 @@ class VisualizationMatrixDropdown extends VisualizerBase {
|
|
|
10379
10396
|
this._childOptions.seriesValues = question.rows.map((row) => row.value);
|
|
10380
10397
|
this._childOptions.seriesLabels = question.rows.map((row) => row.text);
|
|
10381
10398
|
const innerQuestions = this.getQuestions();
|
|
10382
|
-
|
|
10383
|
-
if (canGroupColumns) {
|
|
10399
|
+
if (this.canGroupColumns) {
|
|
10384
10400
|
var creators = VisualizationManager.getVisualizersByType("matrixdropdown-grouped");
|
|
10385
10401
|
this._matrixDropdownVisualizer = new creators[0](this.question, [], this._childOptions);
|
|
10386
10402
|
}
|
|
@@ -10390,6 +10406,11 @@ class VisualizationMatrixDropdown extends VisualizerBase {
|
|
|
10390
10406
|
this._matrixDropdownVisualizer.onAfterRender.add(this.onPanelAfterRenderCallback);
|
|
10391
10407
|
this.updateData(data);
|
|
10392
10408
|
}
|
|
10409
|
+
get canGroupColumns() {
|
|
10410
|
+
const innerQuestions = this.getQuestions();
|
|
10411
|
+
const canGroupColumns = this._childOptions.seriesValues.length == 1 && innerQuestions.every(innerQuestion => isChoicesArraysEqual(innerQuestion.choices, this.question.choices));
|
|
10412
|
+
return canGroupColumns;
|
|
10413
|
+
}
|
|
10393
10414
|
setLocale(newLocale) {
|
|
10394
10415
|
super.setLocale(newLocale);
|
|
10395
10416
|
this._childOptions.seriesLabels = this.question.rows.map((row) => row.text);
|
|
@@ -12427,5 +12448,5 @@ NpsVisualizer.DetractorScore = 6;
|
|
|
12427
12448
|
NpsVisualizer.PromoterScore = 9;
|
|
12428
12449
|
// VisualizationManager.registerVisualizer("rating", NpsVisualizer);
|
|
12429
12450
|
|
|
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,
|
|
12451
|
+
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
12452
|
//# sourceMappingURL=shared2.mjs.map
|