survey-analytics 1.12.61 → 1.12.63

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 (55) hide show
  1. package/package.json +2 -2
  2. package/survey.analytics.css +1 -1
  3. package/survey.analytics.datatables.css +1 -1
  4. package/survey.analytics.datatables.js +1 -1
  5. package/survey.analytics.datatables.min.css +1 -1
  6. package/survey.analytics.datatables.min.js.LICENSE.txt +1 -1
  7. package/survey.analytics.js +1 -1
  8. package/survey.analytics.min.css +1 -1
  9. package/survey.analytics.min.js.LICENSE.txt +1 -1
  10. package/survey.analytics.tabulator.css +1 -1
  11. package/survey.analytics.tabulator.js +1 -1
  12. package/survey.analytics.tabulator.min.css +1 -1
  13. package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
  14. package/fesm/shared.mjs +0 -3225
  15. package/fesm/shared.mjs.map +0 -1
  16. package/fesm/shared2.mjs +0 -13175
  17. package/fesm/shared2.mjs.map +0 -1
  18. package/fesm/survey.analytics.core.mjs +0 -10
  19. package/fesm/survey.analytics.core.mjs.map +0 -1
  20. package/fesm/survey.analytics.mjs +0 -761
  21. package/fesm/survey.analytics.mjs.map +0 -1
  22. package/fesm/survey.analytics.mongo.mjs +0 -221
  23. package/fesm/survey.analytics.mongo.mjs.map +0 -1
  24. package/fesm/survey.analytics.tabulator.mjs +0 -1685
  25. package/fesm/survey.analytics.tabulator.mjs.map +0 -1
  26. package/survey-analytics-tabulator.types/analytics-localization/finnish.d.ts +0 -100
  27. package/survey-analytics-tabulator.types/analytics-localization/swedish.d.ts +0 -100
  28. package/survey-analytics-tabulator.types/svgbundle.d.ts +0 -2
  29. package/survey-analytics.types/analytics-localization/finnish.d.ts +0 -100
  30. package/survey-analytics.types/analytics-localization/swedish.d.ts +0 -100
  31. package/survey-analytics.types/entries/mongo.d.ts +0 -1
  32. package/survey-analytics.types/entries/summary.core.d.ts +0 -38
  33. package/survey-analytics.types/mongo/index.d.ts +0 -16
  34. package/survey-analytics.types/mongo/pipelines.d.ts +0 -1
  35. package/survey-analytics.types/mongo/result-transformers.d.ts +0 -35
  36. package/survey-analytics.types/pivot.d.ts +0 -69
  37. package/survey-analytics.types/plotly/chart-adapter.d.ts +0 -16
  38. package/survey-analytics.types/plotly/legacy.d.ts +0 -33
  39. package/survey-analytics.types/ranking.d.ts +0 -11
  40. package/survey-analytics.types/statisticCalculators.d.ts +0 -14
  41. package/survey-analytics.types/svgbundle.d.ts +0 -2
  42. package/survey-analytics.types/visualizationComposite.d.ts +0 -8
  43. package/survey.analytics.core.css +0 -460
  44. package/survey.analytics.core.css.map +0 -1
  45. package/survey.analytics.core.d.ts +0 -1
  46. package/survey.analytics.core.js +0 -18550
  47. package/survey.analytics.core.js.map +0 -1
  48. package/survey.analytics.core.min.css +0 -10
  49. package/survey.analytics.core.min.js +0 -2
  50. package/survey.analytics.core.min.js.LICENSE.txt +0 -22
  51. package/survey.analytics.mongo.d.ts +0 -1
  52. package/survey.analytics.mongo.js +0 -359
  53. package/survey.analytics.mongo.js.map +0 -1
  54. package/survey.analytics.mongo.min.js +0 -2
  55. package/survey.analytics.mongo.min.js.LICENSE.txt +0 -5
@@ -1,761 +0,0 @@
1
- /*!
2
- * surveyjs - SurveyJS Dashboard library v2.5.15
3
- * Copyright (c) 2015-2026 Devsoft Baltic OÜ - http://surveyjs.io/
4
- * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
- */
6
-
7
- import { Event, ItemValue } from 'survey-core';
8
- import { l as localization, b as DataHelper } from './shared.mjs';
9
- export { D as DocumentHelper, s as setupLocale, a as surveyStrings } from './shared.mjs';
10
- import { c as NumberModel, i as VisualizationManager, S as SelectBase, u as defaultStatisticsCalculator, B as BooleanModel, H as HistogramModel, M as Matrix, P as PivotModel, R as RankingModel, n as VisualizerBase, _ as __awaiter } from './shared2.mjs';
11
- export { A as AlternativeVisualizersWrapper, D as DataProvider, N as NpsAdapter, a as NpsVisualizer, b as NpsVisualizerWidget, d as PostponeHelper, e as StatisticsTable, f as StatisticsTableAdapter, g as StatisticsTableBoolean, T as Text, h as TextTableAdapter, V as VisualizationComposite, j as VisualizationMatrixDropdown, k as VisualizationMatrixDynamic, l as VisualizationPanel, m as VisualizationPanelDynamic, o as VisualizerFactory, W as WordCloud, p as WordCloudAdapter, q as getBestIntervalMode, r as hideEmptyAnswersInData, s as intervalCalculators, t as textHelper } from './shared2.mjs';
12
- import Plotly from 'plotly.js-dist-min';
13
-
14
- class PlotlySetup {
15
- static setup(charType, model, answersData) {
16
- return this.setups[charType](model, answersData);
17
- }
18
- static setupPie(model, answersData) {
19
- let { datasets, labels, colors, texts, seriesLabels, } = answersData;
20
- const hasSeries = seriesLabels.length > 1 || model.question.getType() === "matrix";
21
- const layoutColumns = 2;
22
- let traces = [];
23
- const traceConfig = {
24
- type: model.chartType,
25
- sort: false,
26
- labels: labels,
27
- customdata: labels,
28
- text: labels.map((label) => {
29
- return PlotlySetup.getTruncatedLabel(label, model.labelTruncateLength);
30
- }),
31
- hoverinfo: "value+text",
32
- textposition: "inside",
33
- texttemplate: "%{text}"
34
- };
35
- if (model.chartType === "doughnut") {
36
- traceConfig.type = "pie";
37
- traceConfig.hole = 0.4;
38
- }
39
- if (!hasSeries) {
40
- traceConfig.mode = "markers",
41
- traceConfig.marker = { color: colors };
42
- traceConfig.marker.symbol = "circle";
43
- traceConfig.marker.size = 16;
44
- }
45
- datasets.forEach((dataset, index) => {
46
- const isNotEmpty = dataset.some((value) => value != 0);
47
- let pieTexts = traceConfig.text;
48
- if (model.showPercentages) {
49
- const percentages = model.getPercentages([dataset])[0];
50
- pieTexts = labels.map((l, li) => (model.showOnlyPercentages ? percentages[li] : PlotlySetup.getTruncatedLabel(l, model.labelTruncateLength) + "<br>" + percentages[li]) + "%");
51
- }
52
- if (isNotEmpty) {
53
- traces.push(Object.assign({}, traceConfig, {
54
- values: dataset,
55
- text: pieTexts,
56
- domain: {
57
- column: traces.length % layoutColumns,
58
- row: Math.floor(traces.length / layoutColumns),
59
- },
60
- title: { position: "bottom center", text: seriesLabels[index] }
61
- }));
62
- }
63
- });
64
- const radius = labels.length < 10 ? labels.length * 50 + 100 : 550;
65
- const height = (radius + 25) * Math.ceil(traces.length / layoutColumns);
66
- const layout = {
67
- font: {
68
- family: "Segoe UI, sans-serif",
69
- size: 14,
70
- weight: "normal",
71
- color: "#404040",
72
- },
73
- height: height,
74
- margin: {
75
- l: 0,
76
- t: 25,
77
- b: 0,
78
- r: 10,
79
- },
80
- colorway: colors,
81
- hovermode: "closest",
82
- plot_bgcolor: model.backgroundColor,
83
- paper_bgcolor: model.backgroundColor,
84
- showlegend: false,
85
- };
86
- if (hasSeries) {
87
- layout.annotations = [];
88
- layout.grid = { rows: Math.ceil(traces.length / layoutColumns), columns: layoutColumns };
89
- }
90
- return { traces, layout, hasSeries };
91
- }
92
- static setupBar(model, answersData) {
93
- let lineHeight = 30;
94
- let topMargin = 30;
95
- let bottomMargin = 30;
96
- let { datasets, labels, colors, texts, seriesLabels, labelsTitle, valuesTitle } = answersData;
97
- const hasSeries = seriesLabels.length > 1 || model.question.getType() === "matrix";
98
- const traces = [];
99
- const traceConfig = {
100
- type: model.chartType === "line" ? "line" : "bar",
101
- y: labels,
102
- customdata: labels,
103
- hoverinfo: "text",
104
- orientation: "h",
105
- textposition: "none",
106
- };
107
- if (!hasSeries) {
108
- traceConfig.width = 0.5;
109
- traceConfig.bargap = 0.5;
110
- traceConfig.mode = "markers",
111
- traceConfig.marker = { color: colors };
112
- }
113
- datasets.forEach((dataset, index) => {
114
- const traceName = hasSeries ? seriesLabels[index] : labels[index];
115
- const percentString = model.showPercentages ? "%" : "";
116
- const trace = Object.assign({}, traceConfig, {
117
- x: dataset,
118
- name: traceName,
119
- width: hasSeries && model.chartType !== "stackedbar" ? 0.5 / seriesLabels.length : 0.5,
120
- text: texts[index],
121
- hovertext: labels.map((label, labelIndex) => {
122
- if (model.showOnlyPercentages) {
123
- return `${texts[index][labelIndex]}${percentString}`;
124
- }
125
- else {
126
- return hasSeries ? `${traceName} : ${label}, ${texts[index][labelIndex]}${percentString}` : `${texts[index][labelIndex]}${percentString}, ${label}`;
127
- }
128
- }),
129
- });
130
- if (model.showPercentages) {
131
- let texttemplate = model.showOnlyPercentages ? "%{text}%" : "%{value} (%{text}%)";
132
- trace.textposition = "inside";
133
- trace.texttemplate = texttemplate;
134
- trace.width = hasSeries && model.chartType !== "stackedbar" ? 0.7 / seriesLabels.length : 0.9;
135
- trace.bargap = hasSeries && model.chartType !== "stackedbar" ? 0.3 / seriesLabels.length : 0.1;
136
- }
137
- traces.push(trace);
138
- });
139
- const height = (labels.length + 1) * lineHeight + topMargin + bottomMargin;
140
- const layout = {
141
- font: {
142
- family: "Segoe UI, sans-serif",
143
- size: 14,
144
- weight: "normal",
145
- color: "#404040",
146
- },
147
- height: height,
148
- margin: {
149
- t: topMargin,
150
- b: bottomMargin,
151
- r: 10,
152
- },
153
- colorway: colors,
154
- hovermode: "closest",
155
- plot_bgcolor: model.backgroundColor,
156
- paper_bgcolor: model.backgroundColor,
157
- showlegend: hasSeries,
158
- barmode: hasSeries && model.chartType == "stackedbar" ? "stack" : "group",
159
- xaxis: {
160
- rangemode: "nonnegative",
161
- automargin: true,
162
- },
163
- yaxis: {
164
- automargin: true,
165
- type: "category",
166
- orientation: "h",
167
- tickmode: "array",
168
- tickvals: labels,
169
- ticktext: labels.map((label) => {
170
- return PlotlySetup.getTruncatedLabel(label, model.labelTruncateLength) + " ";
171
- }),
172
- },
173
- };
174
- if (labelsTitle) {
175
- layout.yaxis.title = { text: labelsTitle };
176
- }
177
- if (valuesTitle) {
178
- layout.xaxis.title = { text: valuesTitle };
179
- }
180
- if (hasSeries && model.chartType !== "stackedbar") {
181
- layout.height =
182
- (labels.length * seriesLabels.length + 1) * lineHeight +
183
- topMargin +
184
- bottomMargin;
185
- }
186
- if (["ar", "fa"].indexOf(localization.currentLocale) !== -1) {
187
- layout.xaxis.autorange = "reversed";
188
- layout.yaxis.side = "right";
189
- layout.legend = {
190
- x: 0,
191
- y: 1,
192
- xanchor: "left",
193
- yanchor: "top"
194
- };
195
- }
196
- return { traces, layout, hasSeries };
197
- }
198
- static setupVBar(model, answersData) {
199
- let topMargin = 30;
200
- let bottomMargin = 30;
201
- let { datasets, labels, colors, texts, seriesLabels, labelsTitle, valuesTitle } = answersData;
202
- const hasSeries = seriesLabels.length > 1 || model.question.getType() === "matrix";
203
- if (model.type !== "histogram" && model.type !== "pivot") {
204
- labels = [].concat(labels).reverse();
205
- seriesLabels = [].concat(seriesLabels).reverse();
206
- colors = [].concat(colors.slice(0, hasSeries ? seriesLabels.length : labels.length)).reverse();
207
- const ts = [];
208
- texts.forEach(text => {
209
- ts.push([].concat(text).reverse());
210
- });
211
- texts = ts;
212
- const ds = [];
213
- datasets.forEach(dataset => {
214
- ds.push([].concat(dataset).reverse());
215
- });
216
- datasets = ds;
217
- }
218
- const traces = [];
219
- const traceConfig = {
220
- type: model.chartType === "line" ? "line" : "bar",
221
- x: labels,
222
- customdata: hasSeries ? seriesLabels : labels,
223
- hoverinfo: hasSeries ? undefined : "x+y",
224
- orientation: "v",
225
- textposition: "none",
226
- };
227
- if (!hasSeries) {
228
- traceConfig.width = 0.5;
229
- traceConfig.bargap = 0.5;
230
- traceConfig.mode = "markers",
231
- traceConfig.marker = { color: colors };
232
- }
233
- datasets.forEach((dataset, index) => {
234
- var trace = Object.assign({}, traceConfig, {
235
- y: dataset,
236
- name: hasSeries ? seriesLabels[index] : labels[index],
237
- text: texts[index],
238
- });
239
- if (model.showPercentages) {
240
- let texttemplate = model.showOnlyPercentages ? "%{text}%" : "%{value} (%{text}%)";
241
- trace.textposition = "inside";
242
- trace.texttemplate = texttemplate;
243
- if (!hasSeries) {
244
- trace.width = 0.9;
245
- trace.bargap = 0.1;
246
- }
247
- }
248
- traces.push(trace);
249
- });
250
- const maxTicks = 50;
251
- const tickStep = Math.ceil(labels.length / maxTicks);
252
- const layout = {
253
- font: {
254
- family: "Segoe UI, sans-serif",
255
- size: 14,
256
- weight: "normal",
257
- color: "#404040",
258
- },
259
- margin: {
260
- t: topMargin,
261
- b: bottomMargin,
262
- r: 10,
263
- },
264
- colorway: colors,
265
- hovermode: "closest",
266
- plot_bgcolor: model.backgroundColor,
267
- paper_bgcolor: model.backgroundColor,
268
- showlegend: hasSeries,
269
- yaxis: {
270
- rangemode: "nonnegative",
271
- automargin: true,
272
- },
273
- xaxis: {
274
- automargin: true,
275
- type: "category",
276
- tickmode: "array",
277
- tickvals: labels,
278
- ticktext: labels.map((label, index) => {
279
- if (labels.length > maxTicks && index % tickStep !== 0) {
280
- return "";
281
- }
282
- return PlotlySetup.getTruncatedLabel(label, model.labelTruncateLength);
283
- }),
284
- },
285
- };
286
- if (labelsTitle) {
287
- layout.xaxis.title = { text: labelsTitle };
288
- }
289
- if (valuesTitle) {
290
- layout.yaxis.title = { text: valuesTitle };
291
- }
292
- if (model.showPercentages && model.showOnlyPercentages) {
293
- layout.yaxis = {
294
- automargin: true,
295
- tickformat: ".0%",
296
- range: [0, 1],
297
- ticklen: model.showOnlyPercentages ? 25 : 5,
298
- tickcolor: "transparent",
299
- };
300
- }
301
- if (!model.getValueType || model.getValueType() != "date") {
302
- layout.xaxis = {
303
- automargin: true,
304
- type: "category",
305
- };
306
- }
307
- return { traces, layout, hasSeries };
308
- }
309
- static setupScatter(model, answersData) {
310
- let lineHeight = 30;
311
- let topMargin = 30;
312
- let bottomMargin = 30;
313
- let { datasets, labels, colors, texts, seriesLabels, } = answersData;
314
- const hasSeries = seriesLabels.length > 1 || model.question.getType() === "matrix";
315
- const traces = [];
316
- const traceConfig = {
317
- type: "scatter",
318
- y: (hasSeries ? seriesLabels : labels).map((label) => {
319
- return PlotlySetup.getTruncatedLabel(label, model.labelTruncateLength);
320
- }),
321
- customdata: hasSeries ? seriesLabels : labels,
322
- text: hasSeries ? seriesLabels : labels,
323
- hoverinfo: "x+y",
324
- orientation: "h",
325
- mode: "markers",
326
- width: 0.5,
327
- marker: {},
328
- };
329
- if (!hasSeries) {
330
- traceConfig.marker.symbol = "circle";
331
- traceConfig.marker.size = 16;
332
- }
333
- datasets.forEach((dataset) => {
334
- {
335
- var trace = Object.assign({}, traceConfig, {
336
- x: dataset,
337
- });
338
- traces.push(trace);
339
- }
340
- });
341
- const height = (labels.length + 1) * lineHeight + topMargin + bottomMargin;
342
- const layout = {
343
- font: {
344
- family: "Segoe UI, sans-serif",
345
- size: 14,
346
- weight: "normal",
347
- color: "#404040",
348
- },
349
- height: height,
350
- margin: {
351
- t: topMargin,
352
- b: bottomMargin,
353
- r: 10,
354
- },
355
- colorway: colors,
356
- hovermode: "closest",
357
- yaxis: {
358
- automargin: true,
359
- type: "category",
360
- ticklen: 5,
361
- tickcolor: "transparent",
362
- },
363
- xaxis: {
364
- rangemode: "nonnegative",
365
- automargin: true,
366
- },
367
- plot_bgcolor: model.backgroundColor,
368
- paper_bgcolor: model.backgroundColor,
369
- showlegend: false,
370
- };
371
- if (hasSeries) {
372
- layout.showlegend = true;
373
- layout.height = undefined;
374
- labels.forEach((label, index) => {
375
- traces[index].hoverinfo = "x+name";
376
- traces[index].marker.color = undefined;
377
- traces[index].name = label;
378
- });
379
- }
380
- return { traces, layout, hasSeries };
381
- }
382
- static setupGauge(model, answersData) {
383
- let [level, minValue, maxValue] = answersData;
384
- if (model.question.getType() === "rating") {
385
- const rateValues = model.question.visibleRateValues;
386
- maxValue = rateValues[rateValues.length - 1].value;
387
- minValue = rateValues[0].value;
388
- }
389
- const colors = model.generateColors(maxValue, minValue, NumberModel.stepsCount);
390
- if (NumberModel.showAsPercentage) {
391
- level = DataHelper.toPercentage(level, maxValue);
392
- minValue = DataHelper.toPercentage(minValue, maxValue);
393
- maxValue = DataHelper.toPercentage(maxValue, maxValue);
394
- }
395
- var traces = [
396
- {
397
- type: "indicator",
398
- mode: "gauge+number",
399
- gauge: {
400
- axis: { range: [minValue, maxValue] },
401
- shape: model.chartType,
402
- bgcolor: "white",
403
- bar: { color: colors[0] },
404
- },
405
- value: level,
406
- text: model.name,
407
- domain: { x: [0, 1], y: [0, 1] },
408
- },
409
- ];
410
- const chartMargin = model.chartType === "bullet" ? 60 : 30;
411
- var layout = {
412
- height: 250,
413
- margin: {
414
- l: chartMargin,
415
- r: chartMargin,
416
- b: chartMargin,
417
- t: chartMargin,
418
- pad: 5
419
- },
420
- plot_bgcolor: model.backgroundColor,
421
- paper_bgcolor: model.backgroundColor,
422
- };
423
- return { traces, layout, hasSeries: false };
424
- }
425
- static setupRadar(model, answersData) {
426
- let { datasets, labels, colors, texts, seriesLabels, } = answersData;
427
- const hasSeries = seriesLabels.length > 1 || model.question.getType() === "matrix";
428
- const traces = [];
429
- const traceConfig = {
430
- type: "scatterpolar",
431
- mode: "lines+markers",
432
- fill: "toself",
433
- line: {
434
- width: 2
435
- },
436
- marker: {
437
- size: 6
438
- }
439
- };
440
- datasets.forEach((dataset, index) => {
441
- const traceName = hasSeries ? seriesLabels[index] : "";
442
- const trace = Object.assign({}, traceConfig, {
443
- r: dataset,
444
- theta: labels,
445
- name: traceName,
446
- text: texts[index],
447
- hoverinfo: "r+theta+name",
448
- customdata: labels,
449
- hovertemplate: "%{theta}: %{r}" +
450
- "<extra></extra>",
451
- line: Object.assign(Object.assign({}, traceConfig.line), { color: colors[index % colors.length] }),
452
- marker: Object.assign(Object.assign({}, traceConfig.marker), { color: colors[index % colors.length] })
453
- });
454
- traces.push(trace);
455
- });
456
- const layout = {
457
- font: {
458
- family: "Segoe UI, sans-serif",
459
- size: 14,
460
- weight: "normal",
461
- color: "#404040",
462
- },
463
- polar: {
464
- radialaxis: {
465
- visible: true,
466
- range: [0, Math.max(...datasets.map(s => Math.max(...s))) * 1.1],
467
- tickfont: {
468
- size: 12
469
- }
470
- },
471
- angularaxis: {
472
- tickfont: {
473
- size: 12
474
- },
475
- ticktext: labels.map((label) => {
476
- return PlotlySetup.getTruncatedLabel(label, model.labelTruncateLength);
477
- }),
478
- tickvals: labels
479
- }
480
- },
481
- showlegend: hasSeries,
482
- colorway: colors,
483
- plot_bgcolor: model.backgroundColor,
484
- paper_bgcolor: model.backgroundColor,
485
- margin: {
486
- l: 50,
487
- r: 50,
488
- t: 50,
489
- b: 50
490
- }
491
- };
492
- return { traces, layout, hasSeries };
493
- }
494
- }
495
- PlotlySetup.imageExportFormat = "png";
496
- /**
497
- * Fires when end user clicks on the 'save as image' button.
498
- */
499
- PlotlySetup.onImageSaving = new Event();
500
- /**
501
- * Fires before plot will be created. User can change traces, layout and config of the plot.
502
- * Options is an object with the following fields: traces, layout and config of the plot.
503
- */
504
- PlotlySetup.onPlotCreating = new Event();
505
- PlotlySetup.setups = {
506
- bar: PlotlySetup.setupBar,
507
- vbar: PlotlySetup.setupVBar,
508
- line: PlotlySetup.setupVBar,
509
- stackedbar: PlotlySetup.setupBar,
510
- doughnut: PlotlySetup.setupPie,
511
- pie: PlotlySetup.setupPie,
512
- scatter: PlotlySetup.setupScatter,
513
- gauge: PlotlySetup.setupGauge,
514
- bullet: PlotlySetup.setupGauge,
515
- radar: PlotlySetup.setupRadar,
516
- };
517
- PlotlySetup.getTruncatedLabel = (label, labelTruncateLength) => {
518
- const truncateSymbols = "...";
519
- const truncateSymbolsLength = truncateSymbols.length;
520
- if (!labelTruncateLength)
521
- return label;
522
- if (labelTruncateLength === -1)
523
- return label;
524
- if (label.length <= labelTruncateLength + truncateSymbolsLength)
525
- return label;
526
- return label.substring(0, labelTruncateLength) + truncateSymbols;
527
- };
528
-
529
- class MatrixDropdownGrouped extends SelectBase {
530
- constructor(question, data, options, name) {
531
- super(question, data, options, name || "matrixDropdownGrouped");
532
- }
533
- get matrixQuestion() {
534
- return this.question;
535
- }
536
- get dataNames() {
537
- return this.matrixQuestion.columns.map(column => column.name);
538
- }
539
- getSeriesValues() {
540
- return this.matrixQuestion.columns.map((column) => column.name);
541
- }
542
- getSeriesLabels() {
543
- return this.matrixQuestion.columns.map((column) => column.title);
544
- }
545
- // public getSelectedItemByText(itemText: string) {
546
- // return this.matrixQuestion.columns.filter(
547
- // (column: ItemValue) => column.text === itemText
548
- // )[0];
549
- // }
550
- valuesSource() {
551
- return this.matrixQuestion.choices;
552
- }
553
- isSupportMissingAnswers() {
554
- return false;
555
- }
556
- getCalculatedValuesCore() {
557
- const values = this.getValues();
558
- const series = this.getSeriesValues();
559
- const rows = this.matrixQuestion.rows.map(row => row.value);
560
- const statistics = defaultStatisticsCalculator(this.surveyData, {
561
- name: this.name,
562
- dataNames: series,
563
- dataPath: this.dataPath,
564
- getValues: () => values,
565
- getLabels: () => values,
566
- getSeriesValues: () => rows,
567
- getSeriesLabels: () => rows,
568
- });
569
- return statistics.map(s => s[0]);
570
- }
571
- }
572
- VisualizationManager.registerVisualizer("matrixdropdown-grouped", MatrixDropdownGrouped);
573
-
574
- class SelectBasePlotly extends SelectBase {
575
- }
576
- SelectBasePlotly.types = ["bar", "vbar", "pie", "doughnut"];
577
- SelectBasePlotly.displayModeBar = undefined;
578
- class BooleanPlotly extends BooleanModel {
579
- }
580
- BooleanPlotly.types = ["pie", "bar", "doughnut"];
581
- class HistogramPlotly extends HistogramModel {
582
- }
583
- HistogramPlotly.types = ["vbar", "bar"];
584
- class MatrixPlotly extends Matrix {
585
- }
586
- MatrixPlotly.types = ["bar", "stackedbar", "pie", "doughnut"];
587
- class MatrixDropdownGroupedPlotly extends MatrixDropdownGrouped {
588
- }
589
- MatrixDropdownGroupedPlotly.types = ["stackedbar", "bar", "pie", "doughnut"];
590
- class PivotPlotly extends PivotModel {
591
- }
592
- PivotPlotly.types = ["vbar", "bar", "line", "stackedbar", "pie", "doughnut"]; // ["vbar", "bar"];
593
- class GaugePlotly extends NumberModel {
594
- }
595
- GaugePlotly.displayModeBar = undefined;
596
- GaugePlotly.types = ["gauge", "bullet"];
597
- class RankingPlotly extends RankingModel {
598
- }
599
-
600
- const plotlyChartTypes = {
601
- "boolean": () => BooleanPlotly.types,
602
- "number": () => GaugePlotly.types,
603
- "selectBase": () => SelectBasePlotly.types,
604
- "histogram": () => HistogramPlotly.types,
605
- "matrix": () => MatrixPlotly.types,
606
- "matrixDropdownGrouped": () => MatrixDropdownGroupedPlotly.types,
607
- "pivot": () => PivotPlotly.types,
608
- "ranking": () => [].concat(SelectBasePlotly.types).concat(["radar"]),
609
- };
610
- class PlotlyChartAdapter {
611
- constructor(model) {
612
- this.model = model;
613
- this._chart = undefined;
614
- }
615
- patchConfigParameters(chartNode, traces, layout, config) {
616
- if (this.model.question.getType() === "boolean") {
617
- const colors = this.model.getColors();
618
- const boolColors = [
619
- BooleanModel.trueColor || colors[0],
620
- BooleanModel.falseColor || colors[1],
621
- ];
622
- if (this.model.showMissingAnswers) {
623
- boolColors.push(colors[2]);
624
- }
625
- const chartType = this.model.chartType;
626
- if (chartType === "pie" || chartType === "doughnut") {
627
- traces.forEach((trace) => {
628
- if (!trace)
629
- return;
630
- if (!trace.marker)
631
- trace.marker = {};
632
- trace.marker.colors = boolColors;
633
- });
634
- }
635
- else if (chartType === "bar") {
636
- traces.forEach((trace) => {
637
- if (!trace)
638
- return;
639
- if (!trace.marker)
640
- trace.marker = {};
641
- trace.marker.color = boolColors;
642
- });
643
- }
644
- }
645
- if (this.model.type === "number") {
646
- config.displayModeBar = true;
647
- }
648
- }
649
- get chart() {
650
- return this._chart;
651
- }
652
- getChartTypes() {
653
- const visualizerType = this.model.type;
654
- let chartCtypes = [];
655
- if (plotlyChartTypes[visualizerType]) {
656
- chartCtypes = plotlyChartTypes[visualizerType]();
657
- }
658
- return chartCtypes;
659
- }
660
- create(chartNode) {
661
- return __awaiter(this, void 0, void 0, function* () {
662
- const [plot, plotlyOptions] = yield this.update(chartNode);
663
- if (this.model instanceof SelectBase && this.model.supportSelection) {
664
- const _model = this.model;
665
- chartNode["on"]("plotly_click", (data) => {
666
- if (data.points.length > 0) {
667
- let itemText = "";
668
- if (!plotlyOptions.hasSeries) {
669
- itemText = Array.isArray(data.points[0].customdata)
670
- ? data.points[0].customdata[0]
671
- : data.points[0].customdata;
672
- const item = _model.getSelectedItemByText(itemText);
673
- _model.setSelection(item);
674
- }
675
- else {
676
- itemText = data.points[0].data.name;
677
- const propertyLabel = data.points[0].label;
678
- const seriesValues = this.model.getSeriesValues();
679
- const seriesLabels = this.model.getSeriesLabels();
680
- const propertyValue = seriesValues[seriesLabels.indexOf(propertyLabel)];
681
- const selectedItem = _model.getSelectedItemByText(itemText);
682
- const item = new ItemValue({ [propertyValue]: selectedItem.value }, propertyLabel + ": " + selectedItem.text);
683
- _model.setSelection(item);
684
- }
685
- // const itemText = plotlyOptions.hasSeries
686
- // ? data.points[0].data.name
687
- // : Array.isArray(data.points[0].customdata)
688
- // ? data.points[0].customdata[0]
689
- // : data.points[0].customdata;
690
- // const item: ItemValue = this.model.getSelectedItemByText(itemText);
691
- // this.model.setSelection(item);
692
- }
693
- });
694
- }
695
- var getDragLayer = () => chartNode.getElementsByClassName("nsewdrag")[0];
696
- chartNode["on"]("plotly_hover", () => {
697
- const dragLayer = getDragLayer();
698
- dragLayer && (dragLayer.style.cursor = "pointer");
699
- });
700
- chartNode["on"]("plotly_unhover", () => {
701
- const dragLayer = getDragLayer();
702
- dragLayer && (dragLayer.style.cursor = "");
703
- });
704
- // setTimeout(() => Plotly.Plots.resize(chartNode), 10);
705
- this._chart = plot;
706
- return plot;
707
- });
708
- }
709
- update(chartNode) {
710
- return __awaiter(this, void 0, void 0, function* () {
711
- const answersData = (this.model instanceof SelectBase) ? yield this.model.getAnswersData() : yield this.model.getCalculatedValues();
712
- var plotlyOptions = PlotlySetup.setup(this.model.chartType, this.model, answersData);
713
- let config = {
714
- displaylogo: false,
715
- responsive: true,
716
- locale: localization.currentLocale,
717
- modeBarButtonsToRemove: ["toImage"],
718
- modeBarButtonsToAdd: [
719
- {
720
- name: "toImageSjs",
721
- title: localization.getString("saveDiagramAsPNG"),
722
- icon: Plotly.Icons.camera,
723
- click: (gd) => {
724
- let options = {
725
- format: PlotlySetup.imageExportFormat,
726
- // width: 800,
727
- // height: 600,
728
- filename: this.model.question.name,
729
- };
730
- PlotlySetup.onImageSaving.fire(this.model, options);
731
- Plotly.downloadImage(gd, options);
732
- },
733
- },
734
- ],
735
- };
736
- if (SelectBasePlotly.displayModeBar !== undefined) {
737
- config.displayModeBar = SelectBasePlotly.displayModeBar;
738
- }
739
- this.patchConfigParameters(chartNode, plotlyOptions.traces, plotlyOptions.layout, config);
740
- let options = {
741
- traces: plotlyOptions.traces,
742
- layout: plotlyOptions.layout,
743
- data: answersData,
744
- config: config,
745
- };
746
- PlotlySetup.onPlotCreating.fire(this.model, options);
747
- const plot = Plotly.react(chartNode, options.traces, options.layout, options.config);
748
- return [plot, plotlyOptions];
749
- });
750
- }
751
- destroy(node) {
752
- if (!!node) {
753
- Plotly.purge(node);
754
- }
755
- this._chart = undefined;
756
- }
757
- }
758
- VisualizerBase.chartAdapterType = PlotlyChartAdapter;
759
-
760
- export { BooleanModel, BooleanPlotly, GaugePlotly, HistogramModel, HistogramPlotly, Matrix, MatrixDropdownGroupedPlotly, MatrixPlotly, NumberModel, PivotModel, PivotPlotly, PlotlyChartAdapter, PlotlySetup, RankingModel, RankingPlotly, SelectBase, SelectBasePlotly, VisualizationManager, VisualizerBase, localization, plotlyChartTypes };
761
- //# sourceMappingURL=survey.analytics.mjs.map