survey-analytics 2.5.14 → 3.0.0-beta.0
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 +754 -3179
- package/fesm/shared.mjs.map +1 -1
- package/fesm/shared2.mjs +9687 -8187
- package/fesm/shared2.mjs.map +1 -1
- package/fesm/shared3.mjs +4982 -0
- package/fesm/shared3.mjs.map +1 -0
- package/fesm/shared4.mjs +42 -0
- package/fesm/shared4.mjs.map +1 -0
- package/fesm/survey.analytics.apexcharts.mjs +1061 -0
- package/fesm/survey.analytics.apexcharts.mjs.map +1 -0
- package/fesm/survey.analytics.core.mjs +3 -3
- package/fesm/survey.analytics.mjs +7 -755
- package/fesm/survey.analytics.mjs.map +1 -1
- package/fesm/survey.analytics.mongo.mjs +1 -1
- package/fesm/survey.analytics.plotly.mjs +13 -0
- package/fesm/survey.analytics.plotly.mjs.map +1 -0
- package/fesm/survey.analytics.tabulator.mjs +335 -180
- package/fesm/survey.analytics.tabulator.mjs.map +1 -1
- package/fesm/themes/index.mjs +1942 -0
- package/fesm/themes/index.mjs.map +1 -0
- package/package.json +37 -10
- package/survey-analytics-plotly.types/alternativeVizualizersWrapper.d.ts +73 -0
- package/survey-analytics-plotly.types/analytics-localization/arabic.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/dutch.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/english.d.ts +130 -0
- package/survey-analytics-plotly.types/analytics-localization/farsi.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/finnish.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/french.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/german.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/italian.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/japanese.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/norwegian.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/polish.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/portuguese.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/russian.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/spanish.d.ts +100 -0
- package/survey-analytics-plotly.types/analytics-localization/swedish.d.ts +100 -0
- package/survey-analytics-plotly.types/boolean.d.ts +15 -0
- package/survey-analytics-plotly.types/card.d.ts +29 -0
- package/survey-analytics-plotly.types/chartConfig.d.ts +9 -0
- package/survey-analytics-plotly.types/config.d.ts +35 -0
- package/survey-analytics-plotly.types/dashboard.d.ts +51 -0
- package/survey-analytics-plotly.types/dataProvider.d.ts +69 -0
- package/survey-analytics-plotly.types/entries/plotly.d.ts +2 -0
- package/survey-analytics-plotly.types/entries/summary.core.d.ts +44 -0
- package/survey-analytics-plotly.types/filterInfo.d.ts +11 -0
- package/survey-analytics-plotly.types/histogram.d.ts +102 -0
- package/{survey-analytics.types/layoutEngine.d.ts → survey-analytics-plotly.types/layout-engine.d.ts} +0 -12
- package/survey-analytics-plotly.types/localizationManager.d.ts +152 -0
- package/survey-analytics-plotly.types/matrix.d.ts +17 -0
- package/survey-analytics-plotly.types/matrixDropdownGrouped.d.ts +15 -0
- package/survey-analytics-plotly.types/muuri-layout-engine.d.ts +13 -0
- package/survey-analytics-plotly.types/nps.d.ts +37 -0
- package/survey-analytics-plotly.types/number.d.ts +27 -0
- package/survey-analytics-plotly.types/pivot.d.ts +59 -0
- package/{survey-analytics.types → survey-analytics-plotly.types}/plotly/chart-adapter.d.ts +11 -2
- package/survey-analytics-plotly.types/plotly/setup.d.ts +150 -0
- package/survey-analytics-plotly.types/ranking.d.ts +12 -0
- package/survey-analytics-plotly.types/selectBase.d.ts +116 -0
- package/survey-analytics-plotly.types/statisticCalculators.d.ts +9 -0
- package/survey-analytics-plotly.types/statistics-table.d.ts +28 -0
- package/survey-analytics-plotly.types/svgbundle.d.ts +2 -0
- package/survey-analytics-plotly.types/text.d.ts +25 -0
- package/survey-analytics-plotly.types/theme.d.ts +50 -0
- package/survey-analytics-plotly.types/themes/default-light.d.ts +965 -0
- package/survey-analytics-plotly.types/utils/calculationDateRanges.d.ts +35 -0
- package/survey-analytics-plotly.types/utils/dateRangeModel.d.ts +32 -0
- package/survey-analytics-plotly.types/utils/dateRangeWidget.d.ts +38 -0
- package/survey-analytics-plotly.types/utils/dropdownActionWidget.d.ts +31 -0
- package/survey-analytics-plotly.types/utils/dropdownBase.d.ts +47 -0
- package/survey-analytics-plotly.types/utils/dropdownWidget.d.ts +40 -0
- package/survey-analytics-plotly.types/utils/index.d.ts +62 -0
- package/survey-analytics-plotly.types/utils/toggle.d.ts +17 -0
- package/survey-analytics-plotly.types/utils/utils.d.ts +9 -0
- package/survey-analytics-plotly.types/visualizationComposite.d.ts +8 -0
- package/survey-analytics-plotly.types/visualizationManager.d.ts +60 -0
- package/survey-analytics-plotly.types/visualizationMatrixDropdown.d.ts +23 -0
- package/survey-analytics-plotly.types/visualizationMatrixDynamic.d.ts +8 -0
- package/survey-analytics-plotly.types/visualizationPanel.d.ts +464 -0
- package/survey-analytics-plotly.types/visualizationPanelDynamic.d.ts +20 -0
- package/survey-analytics-plotly.types/visualizerBase.d.ts +422 -0
- package/survey-analytics-plotly.types/visualizerDescription.d.ts +19 -0
- package/survey-analytics-plotly.types/visualizerFactory.d.ts +41 -0
- package/survey-analytics-plotly.types/wordcloud/stopwords/dutch.d.ts +1 -0
- package/survey-analytics-plotly.types/wordcloud/stopwords/english.d.ts +1 -0
- package/survey-analytics-plotly.types/wordcloud/stopwords/index.d.ts +3 -0
- package/survey-analytics-plotly.types/wordcloud/stopwords/norwegian.d.ts +1 -0
- package/survey-analytics-plotly.types/wordcloud/stopwords/spanish.d.ts +1 -0
- package/survey-analytics-plotly.types/wordcloud/widget.d.ts +38 -0
- package/survey-analytics-plotly.types/wordcloud/wordcloud.d.ts +28 -0
- package/survey-analytics-tabulator.types/analytics-localization/english.d.ts +28 -0
- package/survey-analytics-tabulator.types/entries/tabulator.d.ts +2 -25
- package/survey-analytics-tabulator.types/entries/tabulator.fontless.d.ts +26 -0
- package/survey-analytics-tabulator.types/localizationManager.d.ts +28 -0
- package/survey-analytics-tabulator.types/tables/extensions/footerextensions.d.ts +1 -0
- package/survey-analytics-tabulator.types/tables/extensions/tableextensions.d.ts +2 -1
- package/survey-analytics-tabulator.types/tables/tabulator.d.ts +7 -0
- package/survey-analytics-tabulator.types/theme.d.ts +50 -0
- package/survey-analytics-tabulator.types/themes/default-light.d.ts +965 -0
- package/survey-analytics-tabulator.types/utils/dropdownActionWidget.d.ts +31 -0
- package/survey-analytics-tabulator.types/utils/dropdownBase.d.ts +47 -0
- package/survey-analytics-tabulator.types/utils/dropdownWidget.d.ts +40 -0
- package/survey-analytics-tabulator.types/utils/index.d.ts +25 -2
- package/survey-analytics.types/alternativeVizualizersWrapper.d.ts +9 -4
- package/survey-analytics.types/analytics-localization/english.d.ts +28 -0
- package/survey-analytics.types/apexcharts/chart-adapter.d.ts +29 -0
- package/survey-analytics.types/apexcharts/index.d.ts +2 -0
- package/survey-analytics.types/apexcharts/setup.d.ts +185 -0
- package/survey-analytics.types/boolean.d.ts +1 -1
- package/survey-analytics.types/card.d.ts +29 -0
- package/survey-analytics.types/chartConfig.d.ts +9 -0
- package/survey-analytics.types/config.d.ts +1 -33
- package/survey-analytics.types/dashboard.d.ts +51 -0
- package/survey-analytics.types/dataProvider.d.ts +17 -0
- package/survey-analytics.types/entries/apexcharts.d.ts +2 -0
- package/survey-analytics.types/entries/apexcharts.fontless.d.ts +2 -0
- package/survey-analytics.types/entries/summary.core.d.ts +6 -0
- package/survey-analytics.types/histogram.d.ts +29 -13
- package/survey-analytics.types/layout-engine.d.ts +29 -0
- package/survey-analytics.types/localizationManager.d.ts +28 -0
- package/survey-analytics.types/matrix.d.ts +3 -2
- package/survey-analytics.types/matrixDropdownGrouped.d.ts +3 -2
- package/survey-analytics.types/muuri-layout-engine.d.ts +13 -0
- package/survey-analytics.types/nps.d.ts +5 -10
- package/survey-analytics.types/number.d.ts +8 -7
- package/survey-analytics.types/pivot.d.ts +25 -35
- package/survey-analytics.types/ranking.d.ts +3 -2
- package/survey-analytics.types/selectBase.d.ts +12 -15
- package/survey-analytics.types/statisticCalculators.d.ts +8 -13
- package/survey-analytics.types/statistics-table.d.ts +2 -2
- package/survey-analytics.types/text.d.ts +4 -3
- package/survey-analytics.types/theme.d.ts +50 -0
- package/survey-analytics.types/themes/default-light.d.ts +965 -0
- package/survey-analytics.types/utils/calculationDateRanges.d.ts +35 -0
- package/survey-analytics.types/utils/dateRangeModel.d.ts +32 -0
- package/survey-analytics.types/utils/dateRangeWidget.d.ts +38 -0
- package/survey-analytics.types/utils/dropdownActionWidget.d.ts +31 -0
- package/survey-analytics.types/utils/dropdownBase.d.ts +47 -0
- package/survey-analytics.types/utils/dropdownWidget.d.ts +40 -0
- package/survey-analytics.types/utils/index.d.ts +25 -2
- package/survey-analytics.types/utils/toggle.d.ts +17 -0
- package/survey-analytics.types/utils/utils.d.ts +9 -0
- package/survey-analytics.types/visualizationComposite.d.ts +1 -1
- package/survey-analytics.types/visualizationManager.d.ts +5 -5
- package/survey-analytics.types/visualizationMatrixDropdown.d.ts +2 -1
- package/survey-analytics.types/visualizationMatrixDynamic.d.ts +1 -1
- package/survey-analytics.types/visualizationPanel.d.ts +20 -3
- package/survey-analytics.types/visualizationPanelDynamic.d.ts +2 -1
- package/survey-analytics.types/visualizerBase.d.ts +65 -10
- package/survey-analytics.types/visualizerDescription.d.ts +19 -0
- package/survey-analytics.types/visualizerFactory.d.ts +11 -2
- package/survey-analytics.types/wordcloud/wordcloud.d.ts +6 -4
- package/survey.analytics.core.css +1131 -99
- package/survey.analytics.core.css.map +1 -1
- package/survey.analytics.core.js +5063 -1002
- package/survey.analytics.core.js.map +1 -1
- package/survey.analytics.core.min.css +9 -6
- package/survey.analytics.core.min.js +1 -1
- package/survey.analytics.core.min.js.LICENSE.txt +1 -1
- package/survey.analytics.css +1494 -103
- package/survey.analytics.css.map +1 -1
- package/survey.analytics.d.ts +1 -2
- package/survey.analytics.fontless.css +1629 -0
- package/survey.analytics.fontless.css.map +1 -0
- package/survey.analytics.fontless.min.css +14 -0
- package/survey.analytics.js +7427 -3055
- package/survey.analytics.js.map +1 -1
- package/survey.analytics.min.css +11 -6
- package/survey.analytics.min.js +1 -1
- package/survey.analytics.min.js.LICENSE.txt +1 -1
- package/survey.analytics.mongo.js +2 -2
- package/survey.analytics.mongo.js.map +1 -1
- package/survey.analytics.mongo.min.js +1 -1
- package/survey.analytics.mongo.min.js.LICENSE.txt +1 -1
- package/survey.analytics.plotly.css +1714 -0
- package/survey.analytics.plotly.css.map +1 -0
- package/survey.analytics.plotly.d.ts +1 -0
- package/survey.analytics.plotly.fontless.css +1492 -0
- package/survey.analytics.plotly.fontless.css.map +1 -0
- package/survey.analytics.plotly.fontless.min.css +13 -0
- package/survey.analytics.plotly.js +23829 -0
- package/survey.analytics.plotly.js.map +1 -0
- package/survey.analytics.plotly.min.css +14 -0
- package/survey.analytics.plotly.min.js +2 -0
- package/survey.analytics.plotly.min.js.LICENSE.txt +22 -0
- package/survey.analytics.tabulator.css +992 -132
- package/survey.analytics.tabulator.css.map +1 -1
- package/survey.analytics.tabulator.fontless.css +1121 -0
- package/survey.analytics.tabulator.fontless.css.map +1 -0
- package/survey.analytics.tabulator.fontless.min.css +6 -0
- package/survey.analytics.tabulator.js +2608 -235
- package/survey.analytics.tabulator.js.map +1 -1
- package/survey.analytics.tabulator.min.css +3 -2
- package/survey.analytics.tabulator.min.js +1 -1
- package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
- package/themes/default-dark.js +1032 -0
- package/themes/default-dark.js.map +1 -0
- package/themes/default-dark.min.js +2 -0
- package/themes/default-dark.min.js.LICENSE.txt +5 -0
- package/themes/default-light.js +1032 -0
- package/themes/default-light.js.map +1 -0
- package/themes/default-light.min.js +2 -0
- package/themes/default-light.min.js.LICENSE.txt +5 -0
- package/themes/index.js +2063 -0
- package/themes/index.js.map +1 -0
- package/themes/index.min.js +2 -0
- package/themes/index.min.js.LICENSE.txt +5 -0
- package/themes/themes/default-dark.d.ts +965 -0
- package/themes/themes/default-light.d.ts +965 -0
- package/themes/themes/index.d.ts +1934 -0
- package/themes/utils/helpers.d.ts +8 -0
- package/survey-analytics.types/plotly/setup.d.ts +0 -32
- /package/{survey-analytics.types/entries/summary.d.ts → survey-analytics-plotly.types/entries/plotly.fontless.d.ts} +0 -0
- /package/{survey-analytics.types → survey-analytics-plotly.types}/plotly/index.d.ts +0 -0
- /package/{survey-analytics.types → survey-analytics-plotly.types}/plotly/legacy.d.ts +0 -0
|
@@ -1,761 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* surveyjs - SurveyJS Dashboard library
|
|
2
|
+
* surveyjs - SurveyJS Dashboard library v3.0.0-beta.0
|
|
3
3
|
* Copyright (c) 2015-2026 Devsoft Baltic OÜ - http://surveyjs.io/
|
|
4
4
|
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export { D as DocumentHelper, s as setupLocale,
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import
|
|
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 };
|
|
7
|
+
export { B as BooleanPlotly, G as GaugePlotly, H as HistogramPlotly, M as MatrixDropdownGroupedPlotly, a as MatrixPlotly, P as PivotPlotly, b as PlotlyChartAdapter, c as PlotlySetup, R as RankingPlotly, S as SelectBasePlotly, d as chartTypes } from './shared.mjs';
|
|
8
|
+
export { A as AlternativeVisualizersWrapper, B as BooleanModel, C as CardAdapter, a as CardVisualizer, b as CardVisualizerWidget, D as Dashboard, c as DataProvider, H as HistogramModel, L as LayoutEngine, M as Matrix, d as MatrixDropdownGrouped, e as MuuriLayoutEngine, N as NpsAdapter, f as NpsVisualizer, g as NpsVisualizerWidget, h as NumberModel, P as PivotModel, i as PostponeHelper, R as RankingModel, S as SelectBase, j as StatisticsTable, k as StatisticsTableAdapter, l as StatisticsTableBoolean, T as Text, m as TextTableAdapter, V as VisualizationComposite, n as VisualizationManager, o as VisualizationMatrixDropdown, p as VisualizationMatrixDynamic, q as VisualizationPanel, r as VisualizationPanelDynamic, s as VisualizerBase, t as VisualizerFactory, W as WordCloud, u as WordCloudAdapter, v as getBestIntervalMode, w as getVisualizerDescriptions, x as hideEmptyAnswersInData, y as intervalCalculators, z as textHelper } from './shared2.mjs';
|
|
9
|
+
export { D as DashboardTheme, a as DocumentHelper, l as localization, s as setupLocale, b as surveyStrings } from './shared3.mjs';
|
|
10
|
+
import 'survey-core';
|
|
11
|
+
import 'plotly.js-dist-min';
|
|
12
|
+
import './shared4.mjs';
|
|
761
13
|
//# sourceMappingURL=survey.analytics.mjs.map
|