survey-analytics 2.5.13 → 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.mongo.mjs.map +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 +343 -181
- 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 +38 -11
- 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 +10 -1
- 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 +2634 -251
- 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
|
@@ -0,0 +1,1061 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* surveyjs - SurveyJS Dashboard library v3.0.0-beta.0
|
|
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, c as DataHelper, D as DashboardTheme } from './shared3.mjs';
|
|
9
|
+
export { a as DocumentHelper, s as setupLocale, b as surveyStrings } from './shared3.mjs';
|
|
10
|
+
import { h as NumberModel, s as VisualizerBase, _ as __awaiter, S as SelectBase } from './shared2.mjs';
|
|
11
|
+
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, P as PivotModel, i as PostponeHelper, R as RankingModel, 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, 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';
|
|
12
|
+
import { i as isAllZeros, r as reverseAll, a as removeUndefinedProperties } from './shared4.mjs';
|
|
13
|
+
import ApexCharts from 'apexcharts';
|
|
14
|
+
|
|
15
|
+
class ApexChartsSetup {
|
|
16
|
+
static defaultDataLabelsConfig(theme) {
|
|
17
|
+
const insideLabelFont = theme.insideLabelFont;
|
|
18
|
+
return {
|
|
19
|
+
enabled: true,
|
|
20
|
+
style: {
|
|
21
|
+
colors: [insideLabelFont.color],
|
|
22
|
+
fontSize: insideLabelFont.size,
|
|
23
|
+
fontFamily: insideLabelFont.family,
|
|
24
|
+
fontWeight: insideLabelFont.weight,
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static defaultTooltipConfig(theme) {
|
|
29
|
+
const font = theme.tooltipFont;
|
|
30
|
+
return {
|
|
31
|
+
enabled: true,
|
|
32
|
+
fillSeriesColor: false,
|
|
33
|
+
style: {
|
|
34
|
+
fontSize: font.size,
|
|
35
|
+
fontFamily: font.family,
|
|
36
|
+
},
|
|
37
|
+
marker: {
|
|
38
|
+
show: false,
|
|
39
|
+
},
|
|
40
|
+
x: {
|
|
41
|
+
formatter: () => "",
|
|
42
|
+
},
|
|
43
|
+
y: {
|
|
44
|
+
formatter: function (val) {
|
|
45
|
+
return val.toString();
|
|
46
|
+
},
|
|
47
|
+
title: {
|
|
48
|
+
formatter: () => "",
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static defaultLegendConfig(model) {
|
|
54
|
+
const font = model.theme.legendLabelFont;
|
|
55
|
+
return {
|
|
56
|
+
position: model.legendPosition,
|
|
57
|
+
horizontalAlign: "left",
|
|
58
|
+
verticalAlign: "top",
|
|
59
|
+
fontSize: font.size,
|
|
60
|
+
fontFamily: font.family,
|
|
61
|
+
fontWeight: font.weight,
|
|
62
|
+
labels: {
|
|
63
|
+
colors: font.color
|
|
64
|
+
},
|
|
65
|
+
markers: {
|
|
66
|
+
size: 10,
|
|
67
|
+
strokeWidth: 1,
|
|
68
|
+
shape: "square",
|
|
69
|
+
// customHTML: function() {
|
|
70
|
+
// return '<span class="sa-legend-item-marker"><i class="sa-legend-item-text"></i></span>';
|
|
71
|
+
// }
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
static defaultAxisZerolineConfig(theme) {
|
|
76
|
+
return {
|
|
77
|
+
show: false,
|
|
78
|
+
color: theme.axisGridColor,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
static defaultGridConfig(theme) {
|
|
82
|
+
return {
|
|
83
|
+
borderColor: theme.axisGridColor,
|
|
84
|
+
strokeDashArray: 4,
|
|
85
|
+
position: "back",
|
|
86
|
+
xaxis: {
|
|
87
|
+
lines: {
|
|
88
|
+
show: false,
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
yaxis: {
|
|
92
|
+
lines: {
|
|
93
|
+
show: false,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
static defaultAxisLabelFont(theme) {
|
|
99
|
+
const font = theme.axisLabelFont;
|
|
100
|
+
return {
|
|
101
|
+
colors: font.color,
|
|
102
|
+
fontSize: font.size,
|
|
103
|
+
fontFamily: font.family,
|
|
104
|
+
fontWeight: font.weight,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
static defaultAxisLabelConfig(theme) {
|
|
108
|
+
return {
|
|
109
|
+
labels: {
|
|
110
|
+
trim: true,
|
|
111
|
+
hideOverlappingLabels: false,
|
|
112
|
+
style: Object.assign({}, ApexChartsSetup.defaultAxisLabelFont(theme)),
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
static defaultGaugeValueFont(theme) {
|
|
117
|
+
const font = theme.gaugeValueFont;
|
|
118
|
+
return {
|
|
119
|
+
colors: font.color,
|
|
120
|
+
fontSize: font.size,
|
|
121
|
+
fontFamily: font.family,
|
|
122
|
+
fontWeight: font.weight,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
static defaultGaugeTickFont(theme) {
|
|
126
|
+
const font = theme.gaugeTickFont;
|
|
127
|
+
return {
|
|
128
|
+
colors: font.color,
|
|
129
|
+
fontSize: font.size,
|
|
130
|
+
fontFamily: font.family,
|
|
131
|
+
fontWeight: font.weight,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
static defaultNoDataConfig(theme) {
|
|
135
|
+
const font = theme.noDataFont;
|
|
136
|
+
return {
|
|
137
|
+
text: localization.getString("noData"),
|
|
138
|
+
align: "center",
|
|
139
|
+
verticalAlign: "middle",
|
|
140
|
+
offsetX: 0,
|
|
141
|
+
offsetY: 0,
|
|
142
|
+
style: {
|
|
143
|
+
color: font.color,
|
|
144
|
+
fontSize: font.size,
|
|
145
|
+
fontFamily: font.family
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
static dataListFormatter(model, text, value) {
|
|
150
|
+
if (model.showPercentages) {
|
|
151
|
+
if (model.showOnlyPercentages) {
|
|
152
|
+
return text + "%";
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return value + " (" + text + "%)";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
static setup(charType, model, answersData) {
|
|
161
|
+
return this.setups[charType](model, answersData);
|
|
162
|
+
}
|
|
163
|
+
static setupPie(model, answersData) {
|
|
164
|
+
let { datasets, labels, colors, texts, seriesLabels, } = answersData;
|
|
165
|
+
const hasSeries = seriesLabels.length > 1 || model.dataType === "matrix";
|
|
166
|
+
// Prepare data series
|
|
167
|
+
let series = [];
|
|
168
|
+
if (hasSeries) {
|
|
169
|
+
// For matrix questions or multiple series
|
|
170
|
+
datasets.forEach((dataset, index) => {
|
|
171
|
+
if (!isAllZeros(dataset)) {
|
|
172
|
+
series.push({
|
|
173
|
+
series: dataset,
|
|
174
|
+
labels: labels,
|
|
175
|
+
title: seriesLabels[index]
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
// For simple questions
|
|
182
|
+
if (!isAllZeros(datasets[0])) {
|
|
183
|
+
series = datasets[0];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const diameter = labels.length < 10 ? labels.length * 50 + 100 : 550;
|
|
187
|
+
// Chart settings
|
|
188
|
+
const chart = {
|
|
189
|
+
type: model.chartType === "doughnut" ? "donut" : "pie",
|
|
190
|
+
height: diameter,
|
|
191
|
+
toolbar: Object.assign({}, ApexChartsSetup.defaultToolbarConfig),
|
|
192
|
+
background: "transparent"
|
|
193
|
+
};
|
|
194
|
+
// Data label settings
|
|
195
|
+
const dataLabels = Object.assign(Object.assign({}, ApexChartsSetup.defaultDataLabelsConfig(model.theme)), { formatter: function (val, opts) {
|
|
196
|
+
const name = opts.w.globals.labels[opts.seriesIndex];
|
|
197
|
+
const text = name.length > 15 ? name.substring(0, 15) + "..." : name;
|
|
198
|
+
return [text, val.toFixed(model.percentagePrecision) + "%"];
|
|
199
|
+
} });
|
|
200
|
+
// Chart options settings
|
|
201
|
+
const plotOptions = {
|
|
202
|
+
pie: {
|
|
203
|
+
donut: {
|
|
204
|
+
size: model.chartType === "doughnut" ? "40%" : "0%",
|
|
205
|
+
},
|
|
206
|
+
customScale: 1,
|
|
207
|
+
offsetX: 0,
|
|
208
|
+
offsetY: 0,
|
|
209
|
+
startAngle: 0,
|
|
210
|
+
endAngle: 360,
|
|
211
|
+
expandOnClick: true,
|
|
212
|
+
dataLabels: {
|
|
213
|
+
offset: model.chartType === "doughnut" ? -10 : -25,
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
// Tooltip settings
|
|
218
|
+
const tooltip = ApexChartsSetup.defaultTooltipConfig(model.theme);
|
|
219
|
+
tooltip.y.title.formatter = (seriesName, opts) => {
|
|
220
|
+
const val = opts.w.globals.seriesPercent[opts.seriesIndex][0];
|
|
221
|
+
return [seriesName, val.toFixed(model.percentagePrecision) + "%"];
|
|
222
|
+
};
|
|
223
|
+
const legend = {
|
|
224
|
+
show: false,
|
|
225
|
+
};
|
|
226
|
+
const options = {
|
|
227
|
+
series,
|
|
228
|
+
chart,
|
|
229
|
+
labels: hasSeries ? seriesLabels : labels,
|
|
230
|
+
colors,
|
|
231
|
+
plotOptions,
|
|
232
|
+
dataLabels,
|
|
233
|
+
legend,
|
|
234
|
+
noData: ApexChartsSetup.defaultNoDataConfig(model.theme),
|
|
235
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
236
|
+
tooltip,
|
|
237
|
+
hasSeries
|
|
238
|
+
};
|
|
239
|
+
if (hasSeries) {
|
|
240
|
+
options.title = {
|
|
241
|
+
align: "center",
|
|
242
|
+
style: Object.assign({}, ApexChartsSetup.defaultAxisLabelFont(model.theme)),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return options;
|
|
246
|
+
}
|
|
247
|
+
static setupBar(model, answersData) {
|
|
248
|
+
let { datasets, labels, colors, texts, seriesLabels, } = answersData;
|
|
249
|
+
const hasSeries = seriesLabels.length > 1 || model.dataType === "matrix";
|
|
250
|
+
const isHistogram = model.type === "histogram";
|
|
251
|
+
if (!isHistogram) {
|
|
252
|
+
const reversedAnswersData = reverseAll(labels, seriesLabels, colors, hasSeries, texts, datasets);
|
|
253
|
+
labels = reversedAnswersData.labels;
|
|
254
|
+
datasets = reversedAnswersData.datasets;
|
|
255
|
+
}
|
|
256
|
+
// Prepare data series
|
|
257
|
+
let series = [];
|
|
258
|
+
if (hasSeries) {
|
|
259
|
+
// For matrix questions or multiple series
|
|
260
|
+
datasets.forEach((dataset, index) => {
|
|
261
|
+
series.push({
|
|
262
|
+
name: seriesLabels[index],
|
|
263
|
+
data: dataset
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
// For simple questions
|
|
269
|
+
series.push({
|
|
270
|
+
name: "Values",
|
|
271
|
+
data: datasets[0]
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
let lineHeight = 30;
|
|
275
|
+
let margin = 35;
|
|
276
|
+
let height = (labels.length) * lineHeight + 2 * margin;
|
|
277
|
+
if (hasSeries && (model.legendPosition === "top" || model.legendPosition === "bottom")) {
|
|
278
|
+
height += (labels.length * seriesLabels.length) * lineHeight;
|
|
279
|
+
}
|
|
280
|
+
else if (hasSeries) {
|
|
281
|
+
height = (labels.length * seriesLabels.length) * lineHeight + 2 * margin;
|
|
282
|
+
}
|
|
283
|
+
// Chart settings
|
|
284
|
+
const chart = {
|
|
285
|
+
type: "bar",
|
|
286
|
+
height: height,
|
|
287
|
+
toolbar: Object.assign({}, ApexChartsSetup.defaultToolbarConfig),
|
|
288
|
+
background: "transparent"
|
|
289
|
+
};
|
|
290
|
+
// Axis settings
|
|
291
|
+
const xaxis = Object.assign(Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme)), { categories: labels, axisBorder: {
|
|
292
|
+
show: false,
|
|
293
|
+
} });
|
|
294
|
+
const yaxis = Object.assign(Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme)), { axisBorder: Object.assign({}, ApexChartsSetup.defaultAxisZerolineConfig(model.theme)) });
|
|
295
|
+
const grid = Object.assign(Object.assign({}, ApexChartsSetup.defaultGridConfig(model.theme)), { xaxis: {
|
|
296
|
+
lines: {
|
|
297
|
+
show: true
|
|
298
|
+
}
|
|
299
|
+
} });
|
|
300
|
+
// Legend settings
|
|
301
|
+
const legend = Object.assign(Object.assign({}, ApexChartsSetup.defaultLegendConfig(model)), { show: hasSeries });
|
|
302
|
+
// Data label settings
|
|
303
|
+
const dataLabels = Object.assign(Object.assign({}, ApexChartsSetup.defaultDataLabelsConfig(model.theme)), { formatter: function (val, opts) {
|
|
304
|
+
return ApexChartsSetup.dataListFormatter(model, texts[opts.seriesIndex][opts.dataPointIndex], val);
|
|
305
|
+
} });
|
|
306
|
+
// Chart options settings
|
|
307
|
+
const plotOptions = {
|
|
308
|
+
bar: {
|
|
309
|
+
horizontal: true,
|
|
310
|
+
distributed: !isHistogram && !hasSeries,
|
|
311
|
+
barHeight: isHistogram ? "100%" : (1 - ApexChartsSetup.defaultBarGap) * 100 + "%",
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
// Tooltip settings
|
|
315
|
+
const tooltip = ApexChartsSetup.defaultTooltipConfig(model.theme);
|
|
316
|
+
// RTL language handling
|
|
317
|
+
if (["ar", "fa"].indexOf(localization.currentLocale) !== -1) {
|
|
318
|
+
chart.direction = "rtl";
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
series,
|
|
322
|
+
chart,
|
|
323
|
+
labels,
|
|
324
|
+
colors,
|
|
325
|
+
plotOptions,
|
|
326
|
+
dataLabels,
|
|
327
|
+
legend,
|
|
328
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
329
|
+
tooltip,
|
|
330
|
+
hasSeries,
|
|
331
|
+
grid,
|
|
332
|
+
xaxis,
|
|
333
|
+
yaxis
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
static setupVBar(model, answersData) {
|
|
337
|
+
let { datasets, labels, colors, texts, seriesLabels, } = answersData;
|
|
338
|
+
const hasSeries = seriesLabels.length > 1 || model.dataType === "matrix";
|
|
339
|
+
const isHistogram = model.type === "histogram";
|
|
340
|
+
if (!isHistogram && model.type !== "pivot") {
|
|
341
|
+
({ labels, seriesLabels, colors, texts, datasets } = reverseAll(labels, seriesLabels, colors, hasSeries, texts, datasets));
|
|
342
|
+
}
|
|
343
|
+
// Prepare data series
|
|
344
|
+
let series = [];
|
|
345
|
+
if (hasSeries) {
|
|
346
|
+
// For matrix questions or multiple series
|
|
347
|
+
datasets.forEach((dataset, index) => {
|
|
348
|
+
series.push({
|
|
349
|
+
name: seriesLabels[index],
|
|
350
|
+
data: dataset
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
// For simple questions
|
|
356
|
+
series.push({
|
|
357
|
+
name: "Values",
|
|
358
|
+
data: datasets[0]
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
// Chart settings
|
|
362
|
+
const chart = {
|
|
363
|
+
type: "bar",
|
|
364
|
+
height: ApexChartsSetup.defaultChartHeight,
|
|
365
|
+
toolbar: Object.assign({}, ApexChartsSetup.defaultToolbarConfig),
|
|
366
|
+
background: "transparent"
|
|
367
|
+
};
|
|
368
|
+
// Axis settings
|
|
369
|
+
const xaxis = Object.assign(Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme)), { categories: labels, axisBorder: Object.assign({}, ApexChartsSetup.defaultAxisZerolineConfig(model.theme)) });
|
|
370
|
+
const yaxis = Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme));
|
|
371
|
+
const grid = Object.assign(Object.assign({}, ApexChartsSetup.defaultGridConfig(model.theme)), { yaxis: {
|
|
372
|
+
lines: {
|
|
373
|
+
show: true
|
|
374
|
+
}
|
|
375
|
+
} });
|
|
376
|
+
// Legend settings
|
|
377
|
+
const legend = Object.assign(Object.assign({}, ApexChartsSetup.defaultLegendConfig(model)), { show: hasSeries });
|
|
378
|
+
// Data label settings
|
|
379
|
+
const dataLabels = Object.assign(Object.assign({}, ApexChartsSetup.defaultDataLabelsConfig(model.theme)), { formatter: function (val, opts) {
|
|
380
|
+
return ApexChartsSetup.dataListFormatter(model, texts[opts.seriesIndex][opts.dataPointIndex], val);
|
|
381
|
+
} });
|
|
382
|
+
// Chart options settings
|
|
383
|
+
const plotOptions = {
|
|
384
|
+
bar: {
|
|
385
|
+
horizontal: false,
|
|
386
|
+
distributed: !isHistogram && !hasSeries,
|
|
387
|
+
columnWidth: isHistogram ? "100%" : (1 - ApexChartsSetup.defaultBarGap) * 100 + "%",
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
// Tooltip settings
|
|
391
|
+
const tooltip = ApexChartsSetup.defaultTooltipConfig(model.theme);
|
|
392
|
+
// RTL language handling
|
|
393
|
+
if (["ar", "fa"].indexOf(localization.currentLocale) !== -1) {
|
|
394
|
+
chart.direction = "rtl";
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
series,
|
|
398
|
+
chart,
|
|
399
|
+
labels,
|
|
400
|
+
colors,
|
|
401
|
+
plotOptions,
|
|
402
|
+
dataLabels,
|
|
403
|
+
legend,
|
|
404
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
405
|
+
tooltip,
|
|
406
|
+
hasSeries,
|
|
407
|
+
grid,
|
|
408
|
+
xaxis,
|
|
409
|
+
yaxis
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
static setupLine(model, answersData) {
|
|
413
|
+
let { datasets, labels, colors, texts, seriesLabels, } = answersData;
|
|
414
|
+
const hasSeries = seriesLabels.length > 1 || model.dataType === "matrix";
|
|
415
|
+
// Prepare data series
|
|
416
|
+
let series = [];
|
|
417
|
+
if (hasSeries) {
|
|
418
|
+
// For matrix questions or multiple series
|
|
419
|
+
datasets.forEach((dataset, index) => {
|
|
420
|
+
series.push({
|
|
421
|
+
name: seriesLabels[index],
|
|
422
|
+
data: dataset
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
// For simple questions
|
|
428
|
+
series.push({
|
|
429
|
+
name: "Values",
|
|
430
|
+
data: datasets[0]
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
// Chart settings
|
|
434
|
+
const chart = {
|
|
435
|
+
type: "line",
|
|
436
|
+
height: ApexChartsSetup.defaultChartHeight,
|
|
437
|
+
toolbar: Object.assign({}, ApexChartsSetup.defaultToolbarConfig),
|
|
438
|
+
background: "transparent"
|
|
439
|
+
};
|
|
440
|
+
// Axis settings
|
|
441
|
+
const xaxis = {
|
|
442
|
+
axisBorder: Object.assign({}, ApexChartsSetup.defaultAxisZerolineConfig(model.theme)),
|
|
443
|
+
categories: labels,
|
|
444
|
+
labels: {
|
|
445
|
+
style: Object.assign({}, ApexChartsSetup.defaultAxisLabelFont(model.theme))
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
const yaxis = Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme));
|
|
449
|
+
// Legend settings
|
|
450
|
+
const legend = Object.assign(Object.assign({}, ApexChartsSetup.defaultLegendConfig(model)), { show: hasSeries });
|
|
451
|
+
// Data label settings
|
|
452
|
+
const dataLabels = {
|
|
453
|
+
enabled: false
|
|
454
|
+
};
|
|
455
|
+
// Chart options settings
|
|
456
|
+
const plotOptions = {
|
|
457
|
+
line: {
|
|
458
|
+
curve: "smooth"
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
// Tooltip settings
|
|
462
|
+
const tooltip = ApexChartsSetup.defaultTooltipConfig(model.theme);
|
|
463
|
+
// RTL language handling
|
|
464
|
+
if (["ar", "fa"].indexOf(localization.currentLocale) !== -1) {
|
|
465
|
+
chart.direction = "rtl";
|
|
466
|
+
}
|
|
467
|
+
return {
|
|
468
|
+
series,
|
|
469
|
+
chart,
|
|
470
|
+
labels,
|
|
471
|
+
colors,
|
|
472
|
+
plotOptions,
|
|
473
|
+
dataLabels,
|
|
474
|
+
legend,
|
|
475
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
476
|
+
tooltip,
|
|
477
|
+
hasSeries,
|
|
478
|
+
xaxis,
|
|
479
|
+
yaxis
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
static setupStackedBar(model, answersData) {
|
|
483
|
+
let { datasets, labels, colors, texts, seriesLabels, } = answersData;
|
|
484
|
+
const hasSeries = seriesLabels.length > 1 || model.dataType === "matrix";
|
|
485
|
+
const reversedAnswersData = reverseAll(labels, seriesLabels, colors, hasSeries, texts, datasets);
|
|
486
|
+
labels = reversedAnswersData.labels;
|
|
487
|
+
datasets = reversedAnswersData.datasets;
|
|
488
|
+
// Prepare data series
|
|
489
|
+
let series = [];
|
|
490
|
+
if (hasSeries) {
|
|
491
|
+
// For matrix questions or multiple series
|
|
492
|
+
datasets.forEach((dataset, index) => {
|
|
493
|
+
series.push({
|
|
494
|
+
name: seriesLabels[index],
|
|
495
|
+
data: dataset
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
// For simple questions
|
|
501
|
+
series.push({
|
|
502
|
+
name: "Values",
|
|
503
|
+
data: datasets[0]
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
let lineHeight = 30;
|
|
507
|
+
let margin = 35;
|
|
508
|
+
let height = labels.length * lineHeight + 2 * margin;
|
|
509
|
+
if (hasSeries && (model.legendPosition === "top" || model.legendPosition === "bottom")) {
|
|
510
|
+
height += labels.length * lineHeight;
|
|
511
|
+
}
|
|
512
|
+
// Chart settings
|
|
513
|
+
const chart = {
|
|
514
|
+
type: "bar",
|
|
515
|
+
stacked: true,
|
|
516
|
+
height: height,
|
|
517
|
+
toolbar: Object.assign({}, ApexChartsSetup.defaultToolbarConfig),
|
|
518
|
+
background: "transparent"
|
|
519
|
+
};
|
|
520
|
+
// Axis settings
|
|
521
|
+
const maxValue = Math.max(...series[0].data.map((_, index) => series.reduce((sum, s) => sum + s.data[index], 0)));
|
|
522
|
+
const xaxis = Object.assign(Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme)), { categories: labels, max: Math.ceil(maxValue), axisBorder: Object.assign({}, ApexChartsSetup.defaultAxisZerolineConfig(model.theme)) });
|
|
523
|
+
const yaxis = Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme));
|
|
524
|
+
const grid = Object.assign(Object.assign({}, ApexChartsSetup.defaultGridConfig(model.theme)), { xaxis: {
|
|
525
|
+
lines: {
|
|
526
|
+
show: true
|
|
527
|
+
}
|
|
528
|
+
} });
|
|
529
|
+
// Legend settings
|
|
530
|
+
const legend = Object.assign(Object.assign({}, ApexChartsSetup.defaultLegendConfig(model)), { show: hasSeries });
|
|
531
|
+
// Data label settings
|
|
532
|
+
const dataLabels = Object.assign({}, ApexChartsSetup.defaultDataLabelsConfig(model.theme));
|
|
533
|
+
// Chart options settings
|
|
534
|
+
const plotOptions = {
|
|
535
|
+
bar: {
|
|
536
|
+
horizontal: true,
|
|
537
|
+
barHeight: (1 - ApexChartsSetup.defaultBarGap) * 100 + "%",
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
// Tooltip settings
|
|
541
|
+
const tooltip = ApexChartsSetup.defaultTooltipConfig(model.theme);
|
|
542
|
+
// RTL language handling
|
|
543
|
+
if (["ar", "fa"].indexOf(localization.currentLocale) !== -1) {
|
|
544
|
+
chart.direction = "rtl";
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
series,
|
|
548
|
+
chart,
|
|
549
|
+
labels,
|
|
550
|
+
colors,
|
|
551
|
+
plotOptions,
|
|
552
|
+
dataLabels,
|
|
553
|
+
legend,
|
|
554
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
555
|
+
tooltip,
|
|
556
|
+
hasSeries,
|
|
557
|
+
grid,
|
|
558
|
+
xaxis,
|
|
559
|
+
yaxis
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
static setupScatter(model, answersData) {
|
|
563
|
+
let { datasets, labels, colors, texts, seriesLabels, } = answersData;
|
|
564
|
+
const hasSeries = seriesLabels.length > 1 || model.dataType === "matrix";
|
|
565
|
+
// Prepare data series
|
|
566
|
+
let series = [];
|
|
567
|
+
if (hasSeries) {
|
|
568
|
+
// For matrix questions or multiple series
|
|
569
|
+
datasets.forEach((dataset, index) => {
|
|
570
|
+
const scatterData = dataset.map((value, valueIndex) => ({
|
|
571
|
+
x: valueIndex,
|
|
572
|
+
y: value
|
|
573
|
+
}));
|
|
574
|
+
series.push({
|
|
575
|
+
name: seriesLabels[index],
|
|
576
|
+
data: scatterData
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
// For simple questions
|
|
582
|
+
const scatterData = datasets[0].map((value, index) => ({
|
|
583
|
+
x: index,
|
|
584
|
+
y: value
|
|
585
|
+
}));
|
|
586
|
+
series.push({
|
|
587
|
+
name: "Values",
|
|
588
|
+
data: scatterData
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
// Chart settings
|
|
592
|
+
const chart = {
|
|
593
|
+
type: "scatter",
|
|
594
|
+
height: ApexChartsSetup.defaultChartHeight,
|
|
595
|
+
toolbar: Object.assign({}, ApexChartsSetup.defaultToolbarConfig),
|
|
596
|
+
background: "transparent"
|
|
597
|
+
};
|
|
598
|
+
// Axis settings
|
|
599
|
+
const xaxis = {
|
|
600
|
+
categories: labels,
|
|
601
|
+
axisBorder: Object.assign({}, ApexChartsSetup.defaultAxisZerolineConfig(model.theme)),
|
|
602
|
+
labels: {
|
|
603
|
+
style: Object.assign({}, ApexChartsSetup.defaultAxisLabelFont(model.theme))
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
const yaxis = Object.assign({}, ApexChartsSetup.defaultAxisLabelConfig(model.theme));
|
|
607
|
+
// Legend settings
|
|
608
|
+
const legend = Object.assign(Object.assign({}, ApexChartsSetup.defaultLegendConfig(model)), { show: hasSeries });
|
|
609
|
+
// Data label settings
|
|
610
|
+
const dataLabels = {
|
|
611
|
+
enabled: false
|
|
612
|
+
};
|
|
613
|
+
// Chart options settings
|
|
614
|
+
const plotOptions = {
|
|
615
|
+
scatter: {
|
|
616
|
+
size: 6
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
// Tooltip settings
|
|
620
|
+
const tooltip = ApexChartsSetup.defaultTooltipConfig(model.theme);
|
|
621
|
+
// RTL language handling
|
|
622
|
+
if (["ar", "fa"].indexOf(localization.currentLocale) !== -1) {
|
|
623
|
+
chart.direction = "rtl";
|
|
624
|
+
}
|
|
625
|
+
return {
|
|
626
|
+
series,
|
|
627
|
+
chart,
|
|
628
|
+
labels,
|
|
629
|
+
colors,
|
|
630
|
+
plotOptions,
|
|
631
|
+
dataLabels,
|
|
632
|
+
legend,
|
|
633
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
634
|
+
tooltip,
|
|
635
|
+
hasSeries,
|
|
636
|
+
xaxis,
|
|
637
|
+
yaxis
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
static setupGauge(model, answersData) {
|
|
641
|
+
let value = answersData.datasets[0][answersData.values.indexOf(model.displayValueName || "value")];
|
|
642
|
+
let minValue = answersData.datasets[0][answersData.values.indexOf("min")] || 0;
|
|
643
|
+
let maxValue = answersData.datasets[0][answersData.values.indexOf("max")] || value * 1.25;
|
|
644
|
+
if (model.dataType === "rating") {
|
|
645
|
+
const rateValues = model.question.visibleRateValues;
|
|
646
|
+
maxValue = rateValues[rateValues.length - 1].value;
|
|
647
|
+
minValue = rateValues[0].value;
|
|
648
|
+
}
|
|
649
|
+
if (NumberModel.showAsPercentage) {
|
|
650
|
+
value = DataHelper.toPercentage(value, maxValue);
|
|
651
|
+
minValue = DataHelper.toPercentage(minValue, maxValue);
|
|
652
|
+
maxValue = DataHelper.toPercentage(maxValue, maxValue);
|
|
653
|
+
}
|
|
654
|
+
const chart = {
|
|
655
|
+
type: "radialBar",
|
|
656
|
+
height: ApexChartsSetup.defaultChartHeight,
|
|
657
|
+
background: "transparent",
|
|
658
|
+
toolbar: {
|
|
659
|
+
show: false
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
const plotOptions = {
|
|
663
|
+
radialBar: {
|
|
664
|
+
startAngle: -90,
|
|
665
|
+
endAngle: 90,
|
|
666
|
+
track: {
|
|
667
|
+
background: model.theme.gaugeBackground,
|
|
668
|
+
strokeWidth: "97%",
|
|
669
|
+
},
|
|
670
|
+
dataLabels: {
|
|
671
|
+
name: {
|
|
672
|
+
show: false,
|
|
673
|
+
},
|
|
674
|
+
value: Object.assign(Object.assign({}, ApexChartsSetup.defaultGaugeValueFont(model.theme)), { show: true, offsetY: -10, formatter: function (val) {
|
|
675
|
+
return isNaN(value) ? "_" : value.toString();
|
|
676
|
+
} })
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
const percent = ((value - minValue) / (maxValue - minValue)) * 100;
|
|
681
|
+
const yaxis = {
|
|
682
|
+
min: minValue,
|
|
683
|
+
max: maxValue,
|
|
684
|
+
labels: {
|
|
685
|
+
formatter: (val) => {
|
|
686
|
+
const realValue = minValue + (val / 100) * (maxValue - minValue);
|
|
687
|
+
return realValue.toFixed(1);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
const series = [percent];
|
|
692
|
+
const labels = [model.name];
|
|
693
|
+
const colors = [model.theme.gaugeBarColor];
|
|
694
|
+
return {
|
|
695
|
+
series,
|
|
696
|
+
chart,
|
|
697
|
+
labels,
|
|
698
|
+
colors,
|
|
699
|
+
plotOptions,
|
|
700
|
+
yaxis,
|
|
701
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
702
|
+
// dataLabels,
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
static setupBullet(model, answersData) {
|
|
706
|
+
let value = answersData.datasets[0][answersData.values.indexOf(model.displayValueName || "value")];
|
|
707
|
+
let minValue = answersData.datasets[0][answersData.values.indexOf("min")] || 0;
|
|
708
|
+
let maxValue = answersData.datasets[0][answersData.values.indexOf("max")] || value * 1.25;
|
|
709
|
+
if (model.dataType === "rating") {
|
|
710
|
+
const rateValues = model.question.visibleRateValues;
|
|
711
|
+
maxValue = rateValues[rateValues.length - 1].value;
|
|
712
|
+
minValue = rateValues[0].value;
|
|
713
|
+
}
|
|
714
|
+
if (NumberModel.showAsPercentage) {
|
|
715
|
+
value = DataHelper.toPercentage(value, maxValue);
|
|
716
|
+
minValue = DataHelper.toPercentage(minValue, maxValue);
|
|
717
|
+
maxValue = DataHelper.toPercentage(maxValue, maxValue);
|
|
718
|
+
}
|
|
719
|
+
const chart = {
|
|
720
|
+
type: "bar",
|
|
721
|
+
height: 100,
|
|
722
|
+
background: "transparent",
|
|
723
|
+
toolbar: {
|
|
724
|
+
show: false
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
const plotOptions = {
|
|
728
|
+
bar: {
|
|
729
|
+
horizontal: true,
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
const dataLabels = {
|
|
733
|
+
enabled: false
|
|
734
|
+
};
|
|
735
|
+
const xaxis = {
|
|
736
|
+
min: minValue,
|
|
737
|
+
max: maxValue,
|
|
738
|
+
style: ApexChartsSetup.defaultGaugeTickFont(model.theme),
|
|
739
|
+
axisBorder: {
|
|
740
|
+
color: model.theme.gaugeBackground,
|
|
741
|
+
},
|
|
742
|
+
};
|
|
743
|
+
const yaxis = {
|
|
744
|
+
axisBorder: {
|
|
745
|
+
color: model.theme.gaugeBackground,
|
|
746
|
+
},
|
|
747
|
+
labels: {
|
|
748
|
+
offsetY: 10,
|
|
749
|
+
style: ApexChartsSetup.defaultGaugeValueFont(model.theme)
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
// Tooltip settings
|
|
753
|
+
const tooltip = { enabled: false };
|
|
754
|
+
const series = [{
|
|
755
|
+
data: [{
|
|
756
|
+
x: "",
|
|
757
|
+
y: value,
|
|
758
|
+
goals: [{
|
|
759
|
+
value: maxValue,
|
|
760
|
+
strokeWidth: 1,
|
|
761
|
+
strokeColor: model.theme.gaugeBackground,
|
|
762
|
+
}]
|
|
763
|
+
}]
|
|
764
|
+
}];
|
|
765
|
+
const labels = [value];
|
|
766
|
+
const colors = [model.theme.gaugeBarColor];
|
|
767
|
+
return {
|
|
768
|
+
series,
|
|
769
|
+
chart,
|
|
770
|
+
labels,
|
|
771
|
+
colors,
|
|
772
|
+
plotOptions,
|
|
773
|
+
xaxis,
|
|
774
|
+
yaxis,
|
|
775
|
+
dataLabels,
|
|
776
|
+
tooltip,
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
static setupRadar(model, answersData) {
|
|
780
|
+
let { datasets, labels, colors, texts, seriesLabels, } = answersData;
|
|
781
|
+
const hasSeries = seriesLabels.length > 1 || model.dataType === "matrix";
|
|
782
|
+
const series = datasets.map((dataset, index) => {
|
|
783
|
+
const seriesName = hasSeries ? seriesLabels[index] : "";
|
|
784
|
+
return {
|
|
785
|
+
name: seriesName,
|
|
786
|
+
data: dataset
|
|
787
|
+
};
|
|
788
|
+
});
|
|
789
|
+
const chart = {
|
|
790
|
+
type: "radar",
|
|
791
|
+
height: ApexChartsSetup.defaultChartHeight,
|
|
792
|
+
background: "transparent",
|
|
793
|
+
toolbar: Object.assign({}, ApexChartsSetup.defaultToolbarConfig),
|
|
794
|
+
};
|
|
795
|
+
const plotOptions = {
|
|
796
|
+
radar: {
|
|
797
|
+
polygons: {
|
|
798
|
+
strokeColors: model.theme.axisGridColor,
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
const radarLabelFont = model.theme.radarLabelFont;
|
|
803
|
+
const xaxis = {
|
|
804
|
+
labels: {
|
|
805
|
+
style: {
|
|
806
|
+
colors: radarLabelFont.color,
|
|
807
|
+
fontSize: radarLabelFont.size,
|
|
808
|
+
fontFamily: radarLabelFont.family,
|
|
809
|
+
fontWeight: radarLabelFont.weight,
|
|
810
|
+
},
|
|
811
|
+
},
|
|
812
|
+
categories: labels,
|
|
813
|
+
};
|
|
814
|
+
xaxis.labels.style.colors = Array(labels.length).fill(model.theme.axisLabelFont.color);
|
|
815
|
+
const yaxis = {
|
|
816
|
+
show: true,
|
|
817
|
+
labels: {
|
|
818
|
+
show: true,
|
|
819
|
+
style: Object.assign({}, ApexChartsSetup.defaultAxisLabelFont(model.theme))
|
|
820
|
+
},
|
|
821
|
+
tickAmount: 5
|
|
822
|
+
};
|
|
823
|
+
const legend = Object.assign(Object.assign({}, ApexChartsSetup.defaultLegendConfig(model)), { show: hasSeries, markers: {
|
|
824
|
+
width: 12,
|
|
825
|
+
height: 12,
|
|
826
|
+
radius: 6
|
|
827
|
+
} });
|
|
828
|
+
const tooltip = {
|
|
829
|
+
enabled: true,
|
|
830
|
+
style: Object.assign({}, ApexChartsSetup.defaultTooltipConfig(model.theme)),
|
|
831
|
+
y: {
|
|
832
|
+
formatter: function (val, opts) {
|
|
833
|
+
const seriesName = opts.w.globals.seriesNames[opts.seriesIndex];
|
|
834
|
+
const label = opts.w.globals.labels[opts.dataPointIndex];
|
|
835
|
+
return !!seriesName ? `${seriesName}: ${val} (${label})` : `${label}: ${val}`;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
return {
|
|
840
|
+
series,
|
|
841
|
+
chart,
|
|
842
|
+
labels,
|
|
843
|
+
colors,
|
|
844
|
+
plotOptions,
|
|
845
|
+
xaxis,
|
|
846
|
+
yaxis,
|
|
847
|
+
tooltip,
|
|
848
|
+
legend,
|
|
849
|
+
responsive: [Object.assign({}, ApexChartsSetup.defaultResponsive)],
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
ApexChartsSetup.imageExportFormat = "png";
|
|
854
|
+
ApexChartsSetup.defaultChartHeight = 450;
|
|
855
|
+
ApexChartsSetup.defaultBarGap = DashboardTheme.barGap;
|
|
856
|
+
ApexChartsSetup.defaultToolbarConfig = {
|
|
857
|
+
show: true,
|
|
858
|
+
tools: {
|
|
859
|
+
download: true,
|
|
860
|
+
selection: true,
|
|
861
|
+
zoom: true,
|
|
862
|
+
zoomin: true,
|
|
863
|
+
zoomout: true,
|
|
864
|
+
pan: true,
|
|
865
|
+
reset: true
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
ApexChartsSetup.defaultStrokeConfig = {
|
|
869
|
+
width: 2,
|
|
870
|
+
curve: "smooth"
|
|
871
|
+
};
|
|
872
|
+
ApexChartsSetup.defaultFillConfig = {
|
|
873
|
+
type: "solid",
|
|
874
|
+
opacity: 0.8
|
|
875
|
+
};
|
|
876
|
+
ApexChartsSetup.defaultResponsive = {
|
|
877
|
+
breakpoint: 600,
|
|
878
|
+
options: {
|
|
879
|
+
legend: {
|
|
880
|
+
position: "bottom"
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
/**
|
|
885
|
+
* Fires when end user clicks on the 'save as image' button.
|
|
886
|
+
*/
|
|
887
|
+
ApexChartsSetup.onImageSaving = new Event();
|
|
888
|
+
/**
|
|
889
|
+
* Fires before chart will be created. User can change series, chart options and config of the chart.
|
|
890
|
+
* Options is an object with the following fields: series, chart, xaxis, yaxis, labels, colors, plotOptions, dataLabels, legend, tooltip, grid and hasSeries.
|
|
891
|
+
*/
|
|
892
|
+
ApexChartsSetup.onChartCreating = new Event();
|
|
893
|
+
ApexChartsSetup.setups = {
|
|
894
|
+
bar: ApexChartsSetup.setupBar,
|
|
895
|
+
vbar: ApexChartsSetup.setupVBar,
|
|
896
|
+
line: ApexChartsSetup.setupLine,
|
|
897
|
+
stackedbar: ApexChartsSetup.setupStackedBar,
|
|
898
|
+
doughnut: ApexChartsSetup.setupPie,
|
|
899
|
+
pie: ApexChartsSetup.setupPie,
|
|
900
|
+
scatter: ApexChartsSetup.setupScatter,
|
|
901
|
+
gauge: ApexChartsSetup.setupGauge,
|
|
902
|
+
bullet: ApexChartsSetup.setupBullet,
|
|
903
|
+
radar: ApexChartsSetup.setupRadar,
|
|
904
|
+
histogram: ApexChartsSetup.setupBar,
|
|
905
|
+
vhistogram: ApexChartsSetup.setupVBar,
|
|
906
|
+
stackedhistogram: ApexChartsSetup.setupStackedBar,
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
const chartTypes = {
|
|
910
|
+
"boolean": ["pie", "doughnut", "bar"],
|
|
911
|
+
"number": ["gauge", "bullet"],
|
|
912
|
+
"average": ["gauge", "bullet"],
|
|
913
|
+
"selectBase": ["bar", "vbar", "pie", "doughnut"],
|
|
914
|
+
"histogram": ["vhistogram", "histogram"],
|
|
915
|
+
"matrix": ["bar", "stackedbar", "pie", "doughnut"],
|
|
916
|
+
"matrixDropdownGrouped": ["stackedbar", "bar", "pie", "doughnut"],
|
|
917
|
+
"pivot": ["vbar", "bar", "line", "stackedbar", "pie", "doughnut"], // ["vbar", "bar"];
|
|
918
|
+
"ranking": ["bar", "vbar", "pie", "doughnut", "radar"],
|
|
919
|
+
};
|
|
920
|
+
class ApexChartsAdapter {
|
|
921
|
+
static getChartTypesByVisualizerType(vType) {
|
|
922
|
+
return (chartTypes[vType] || []).slice();
|
|
923
|
+
}
|
|
924
|
+
updatePieCharts(options, chartOptions, chartNode) {
|
|
925
|
+
if (this._pieCharts) {
|
|
926
|
+
this._pieCharts.forEach((chart) => chart.updateOptions(options));
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
chartNode.classList.add("sa-pie-charts");
|
|
930
|
+
this._pieCharts = chartOptions.series.map((s, i) => {
|
|
931
|
+
const chartDiv = document.createElement("div");
|
|
932
|
+
chartDiv.id = "sa-chart" + i;
|
|
933
|
+
chartDiv.classList.add("sa-pie-chart");
|
|
934
|
+
chartNode.appendChild(chartDiv);
|
|
935
|
+
const _options = Object.assign({}, options, {
|
|
936
|
+
series: s.series,
|
|
937
|
+
labels: s.labels
|
|
938
|
+
});
|
|
939
|
+
_options.title.text = s.title;
|
|
940
|
+
removeUndefinedProperties(_options);
|
|
941
|
+
const chart = new ApexCharts(chartDiv, _options);
|
|
942
|
+
return chart;
|
|
943
|
+
});
|
|
944
|
+
this._pieCharts.forEach((chart) => chart.render());
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
constructor(model) {
|
|
948
|
+
this.model = model;
|
|
949
|
+
this._chart = undefined;
|
|
950
|
+
this._pieCharts = undefined;
|
|
951
|
+
}
|
|
952
|
+
patchConfigParameters(chartNode, options) { }
|
|
953
|
+
get chart() {
|
|
954
|
+
return this._chart;
|
|
955
|
+
}
|
|
956
|
+
getChartTypes() {
|
|
957
|
+
const visualizerType = this.model.type;
|
|
958
|
+
const chartCtypes = chartTypes[visualizerType];
|
|
959
|
+
return (chartCtypes || []).slice();
|
|
960
|
+
}
|
|
961
|
+
create(chartNode) {
|
|
962
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
963
|
+
yield this.update(chartNode);
|
|
964
|
+
const currentCharts = this._pieCharts || [this._chart];
|
|
965
|
+
if (this.model instanceof SelectBase) {
|
|
966
|
+
// Handle chart clicks
|
|
967
|
+
this.model;
|
|
968
|
+
}
|
|
969
|
+
return currentCharts;
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
update(chartNode) {
|
|
973
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
974
|
+
const _chartType = this.model.chartType;
|
|
975
|
+
const answersData = yield this.model.getAnswersData();
|
|
976
|
+
var chartOptions = ApexChartsSetup.setup(_chartType, this.model, answersData);
|
|
977
|
+
if (this.model instanceof SelectBase && this.model.supportSelection) {
|
|
978
|
+
const _model = this.model;
|
|
979
|
+
chartOptions.chart.events = {
|
|
980
|
+
dataPointMouseEnter: function () { chartNode.style.cursor = "pointer"; },
|
|
981
|
+
dataPointMouseLeave: function () { chartNode.style.cursor = ""; },
|
|
982
|
+
dataPointSelection: function (event, chartContext, opts) {
|
|
983
|
+
if (opts.dataPointIndex !== undefined && opts.seriesIndex !== undefined) {
|
|
984
|
+
let itemText = "";
|
|
985
|
+
if (!chartOptions.hasSeries) {
|
|
986
|
+
itemText = config.labels[opts.dataPointIndex];
|
|
987
|
+
const item = _model.getSelectedItemByText(itemText);
|
|
988
|
+
_model.setSelection(item);
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
itemText = config.series[opts.seriesIndex].name;
|
|
992
|
+
const propertyLabel = config.labels[opts.dataPointIndex];
|
|
993
|
+
const seriesValues = _model.getSeriesValues();
|
|
994
|
+
const seriesLabels = _model.getSeriesLabels();
|
|
995
|
+
const propertyValue = seriesValues[seriesLabels.indexOf(propertyLabel)];
|
|
996
|
+
const selectedItem = _model.getSelectedItemByText(itemText);
|
|
997
|
+
const item = new ItemValue({ [propertyValue]: selectedItem.value }, propertyLabel + ": " + selectedItem.text);
|
|
998
|
+
_model.setSelection(item);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
// The last parameter opts contains additional information like `seriesIndex` and `dataPointIndex` for cartesian charts
|
|
1002
|
+
/*if (data.points.length > 0) {
|
|
1003
|
+
let itemText = "";
|
|
1004
|
+
if (!chartOptions.hasSeries) {
|
|
1005
|
+
itemText = Array.isArray(data.points[0].customdata)
|
|
1006
|
+
? data.points[0].customdata[0]
|
|
1007
|
+
: data.points[0].customdata;
|
|
1008
|
+
const item: ItemValue = _model.getSelectedItemByText(itemText);
|
|
1009
|
+
_model.setSelection(item);
|
|
1010
|
+
} else {
|
|
1011
|
+
itemText = data.points[0].data.name;
|
|
1012
|
+
const propertyLabel = data.points[0].label;
|
|
1013
|
+
// const seriesValues = this.model.getSeriesValues();
|
|
1014
|
+
// const seriesLabels = this.model.getSeriesLabels();
|
|
1015
|
+
// const propertyValue = seriesValues[seriesLabels.indexOf(propertyLabel)];
|
|
1016
|
+
// const selectedItem: ItemValue = _model.getSelectedItemByText(itemText);
|
|
1017
|
+
// const item = new ItemValue({ [propertyValue]: selectedItem.value }, propertyLabel + ": " + selectedItem.text);
|
|
1018
|
+
// _model.setSelection(item);
|
|
1019
|
+
}
|
|
1020
|
+
}*/
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
let config = Object.assign({ chart: Object.assign(Object.assign({}, chartOptions.chart), { locales: [{
|
|
1025
|
+
name: localization.currentLocale,
|
|
1026
|
+
}], defaultLocale: localization.currentLocale }) }, chartOptions);
|
|
1027
|
+
this.patchConfigParameters(chartNode, config);
|
|
1028
|
+
let options = Object.assign({}, config);
|
|
1029
|
+
ApexChartsSetup.onChartCreating.fire(this.model, options);
|
|
1030
|
+
if ((_chartType === "pie" || _chartType === "doughnut") && chartOptions.series.length > 0 && typeof chartOptions.series[0] !== "number") {
|
|
1031
|
+
this.updatePieCharts(options, chartOptions, chartNode);
|
|
1032
|
+
}
|
|
1033
|
+
else {
|
|
1034
|
+
const availableUpdateOptions = this._chart && !!this._chart["el"] && this._chart["el"].getRootNode() === document;
|
|
1035
|
+
if (availableUpdateOptions) {
|
|
1036
|
+
yield this._chart.updateOptions({ series: options.series });
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
removeUndefinedProperties(options);
|
|
1040
|
+
this._chart = new ApexCharts(chartNode, options);
|
|
1041
|
+
yield this._chart.render();
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
return chartOptions;
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
destroy(node) {
|
|
1048
|
+
if (this._chart) {
|
|
1049
|
+
this._chart.destroy();
|
|
1050
|
+
this._chart = undefined;
|
|
1051
|
+
}
|
|
1052
|
+
if (this._pieCharts) {
|
|
1053
|
+
this._pieCharts.forEach(ch => ch.destroy());
|
|
1054
|
+
this._pieCharts = undefined;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
VisualizerBase.chartAdapterType = ApexChartsAdapter;
|
|
1059
|
+
|
|
1060
|
+
export { ApexChartsAdapter, ApexChartsSetup, DashboardTheme, NumberModel, SelectBase, VisualizerBase, chartTypes, localization };
|
|
1061
|
+
//# sourceMappingURL=survey.analytics.apexcharts.mjs.map
|