survey-analytics 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +1 -0
  2. package/fesm/shared.mjs +1426 -265
  3. package/fesm/shared.mjs.map +1 -1
  4. package/fesm/shared2.mjs +90 -46
  5. package/fesm/shared2.mjs.map +1 -1
  6. package/fesm/survey.analytics.core.mjs +2 -2
  7. package/fesm/survey.analytics.mjs +3 -3
  8. package/fesm/survey.analytics.tabulator.mjs +3 -3
  9. package/package.json +2 -2
  10. package/survey-analytics-tabulator.types/analytics-localization/arabic.d.ts +16 -0
  11. package/survey-analytics-tabulator.types/analytics-localization/dutch.d.ts +16 -0
  12. package/survey-analytics-tabulator.types/analytics-localization/english.d.ts +5 -0
  13. package/survey-analytics-tabulator.types/analytics-localization/farsi.d.ts +16 -0
  14. package/survey-analytics-tabulator.types/analytics-localization/finnish.d.ts +7 -0
  15. package/survey-analytics-tabulator.types/analytics-localization/french.d.ts +16 -0
  16. package/survey-analytics-tabulator.types/analytics-localization/german.d.ts +16 -0
  17. package/survey-analytics-tabulator.types/analytics-localization/italian.d.ts +16 -0
  18. package/survey-analytics-tabulator.types/analytics-localization/japanese.d.ts +16 -0
  19. package/survey-analytics-tabulator.types/analytics-localization/norwegian.d.ts +16 -0
  20. package/survey-analytics-tabulator.types/analytics-localization/polish.d.ts +15 -0
  21. package/survey-analytics-tabulator.types/analytics-localization/portuguese.d.ts +16 -0
  22. package/survey-analytics-tabulator.types/analytics-localization/russian.d.ts +15 -0
  23. package/survey-analytics-tabulator.types/analytics-localization/spanish.d.ts +16 -0
  24. package/survey-analytics-tabulator.types/analytics-localization/swedish.d.ts +3 -0
  25. package/survey-analytics-tabulator.types/localizationManager.d.ts +12 -0
  26. package/survey-analytics-tabulator.types/utils/index.d.ts +2 -2
  27. package/survey-analytics.types/analytics-localization/arabic.d.ts +16 -0
  28. package/survey-analytics.types/analytics-localization/dutch.d.ts +16 -0
  29. package/survey-analytics.types/analytics-localization/english.d.ts +5 -0
  30. package/survey-analytics.types/analytics-localization/farsi.d.ts +16 -0
  31. package/survey-analytics.types/analytics-localization/finnish.d.ts +7 -0
  32. package/survey-analytics.types/analytics-localization/french.d.ts +16 -0
  33. package/survey-analytics.types/analytics-localization/german.d.ts +16 -0
  34. package/survey-analytics.types/analytics-localization/italian.d.ts +16 -0
  35. package/survey-analytics.types/analytics-localization/japanese.d.ts +16 -0
  36. package/survey-analytics.types/analytics-localization/norwegian.d.ts +16 -0
  37. package/survey-analytics.types/analytics-localization/polish.d.ts +15 -0
  38. package/survey-analytics.types/analytics-localization/portuguese.d.ts +16 -0
  39. package/survey-analytics.types/analytics-localization/russian.d.ts +15 -0
  40. package/survey-analytics.types/analytics-localization/spanish.d.ts +16 -0
  41. package/survey-analytics.types/analytics-localization/swedish.d.ts +3 -0
  42. package/survey-analytics.types/histogram.d.ts +4 -4
  43. package/survey-analytics.types/localizationManager.d.ts +12 -0
  44. package/survey-analytics.types/number.d.ts +3 -3
  45. package/survey-analytics.types/pivot.d.ts +7 -4
  46. package/survey-analytics.types/utils/index.d.ts +2 -2
  47. package/survey.analytics.core.css +52 -22
  48. package/survey.analytics.core.css.map +1 -1
  49. package/survey.analytics.core.js +1522 -308
  50. package/survey.analytics.core.js.map +1 -1
  51. package/survey.analytics.core.min.css +2 -2
  52. package/survey.analytics.core.min.js +1 -1
  53. package/survey.analytics.core.min.js.LICENSE.txt +1 -1
  54. package/survey.analytics.css +52 -22
  55. package/survey.analytics.css.map +1 -1
  56. package/survey.analytics.js +1523 -308
  57. package/survey.analytics.js.map +1 -1
  58. package/survey.analytics.min.css +2 -2
  59. package/survey.analytics.min.js +1 -1
  60. package/survey.analytics.min.js.LICENSE.txt +1 -1
  61. package/survey.analytics.tabulator.css +52 -21
  62. package/survey.analytics.tabulator.css.map +1 -1
  63. package/survey.analytics.tabulator.js +1435 -264
  64. package/survey.analytics.tabulator.js.map +1 -1
  65. package/survey.analytics.tabulator.min.css +2 -2
  66. package/survey.analytics.tabulator.min.js +1 -1
  67. package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
package/fesm/shared2.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.1
2
+ * surveyjs - SurveyJS Dashboard library v2.3.3
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
6
6
 
7
- import { D as DocumentHelper, l as localization, f as createLoadingIndicator, a as DataHelper, e as svgTemplate, d as createCommercialLicenseLink, t as toPrecision } from './shared.mjs';
7
+ import { D as DocumentHelper, l as localization, g as createLoadingIndicator, b as DataHelper, f as svgTemplate, e as createCommercialLicenseLink, t as toPrecision } from './shared.mjs';
8
8
  import { Event, QuestionCommentModel, settings, ItemValue, hasLicense, surveyLocalization, IsTouch } from 'survey-core';
9
9
 
10
10
  /******************************************************************************
@@ -1915,7 +1915,7 @@ class HistogramModel extends SelectBase {
1915
1915
  super(question, data, options, name || "histogram");
1916
1916
  this.valueType = "number";
1917
1917
  this._cachedValues = undefined;
1918
- this._continiousData = undefined;
1918
+ this._continuousData = undefined;
1919
1919
  this._cachedIntervals = undefined;
1920
1920
  this._intervalPrecision = 2;
1921
1921
  this._transposeData = false;
@@ -1931,11 +1931,11 @@ class HistogramModel extends SelectBase {
1931
1931
  }
1932
1932
  }
1933
1933
  reset() {
1934
- this._continiousData = undefined;
1934
+ this._continuousData = undefined;
1935
1935
  this._cachedValues = undefined;
1936
1936
  this._cachedIntervals = undefined;
1937
1937
  }
1938
- getContiniousValue(value) {
1938
+ getContinuousValue(value) {
1939
1939
  if (this.valueType === "date") {
1940
1940
  return Date.parse(value);
1941
1941
  }
@@ -1952,7 +1952,7 @@ class HistogramModel extends SelectBase {
1952
1952
  return Math.round(base * value) / base;
1953
1953
  }
1954
1954
  getSelectedItemByText(itemText) {
1955
- if (this.hasCustomIntervals || this.getContiniousValues().length > HistogramModel.UseIntervalsFrom) {
1955
+ if (this.hasCustomIntervals || this.getContinuousValues().length > HistogramModel.UseIntervalsFrom) {
1956
1956
  const interval = this.intervals.filter(interval => interval.label === itemText)[0];
1957
1957
  return new ItemValue(interval, interval !== undefined ? interval.label : "");
1958
1958
  }
@@ -1971,26 +1971,26 @@ class HistogramModel extends SelectBase {
1971
1971
  this.reset();
1972
1972
  super.onDataChanged();
1973
1973
  }
1974
- getContiniousValues() {
1974
+ getContinuousValues() {
1975
1975
  if (this._cachedValues === undefined) {
1976
1976
  const series = this.getSeriesValues();
1977
1977
  if (series.length === 0) {
1978
1978
  series.push("");
1979
1979
  }
1980
- this._continiousData = {};
1981
- series.forEach(seriesValue => this._continiousData[seriesValue] = []);
1980
+ this._continuousData = {};
1981
+ series.forEach(seriesValue => this._continuousData[seriesValue] = []);
1982
1982
  const hash = {};
1983
1983
  this.data.forEach(dataItem => {
1984
1984
  const answerData = dataItem[this.name];
1985
1985
  if (answerData !== undefined) {
1986
1986
  const seriesValue = dataItem[DataProvider.seriesMarkerKey] || "";
1987
- // TODO: _continiousData should be sorted in order to speed-up statistics calculation in the getData function
1988
- this._continiousData[seriesValue].push(this.getContiniousValue(answerData));
1987
+ // TODO: _continuousData should be sorted in order to speed-up statistics calculation in the getData function
1988
+ this._continuousData[seriesValue].push(this.getContinuousValue(answerData));
1989
1989
  hash[answerData] = answerData;
1990
1990
  }
1991
1991
  });
1992
- this._cachedValues = Object.keys(hash).map(key => ({ original: hash[key], continious: this.getContiniousValue(key) }));
1993
- this._cachedValues.sort((a, b) => a.continious - b.continious);
1992
+ this._cachedValues = Object.keys(hash).map(key => ({ original: hash[key], continuous: this.getContinuousValue(key) }));
1993
+ this._cachedValues.sort((a, b) => a.continuous - b.continuous);
1994
1994
  }
1995
1995
  return this._cachedValues;
1996
1996
  }
@@ -2036,11 +2036,11 @@ class HistogramModel extends SelectBase {
2036
2036
  }
2037
2037
  }
2038
2038
  if (this._cachedIntervals === undefined) {
2039
- const continiousValues = this.getContiniousValues();
2039
+ const continuousValues = this.getContinuousValues();
2040
2040
  this._cachedIntervals = [];
2041
- if (continiousValues.length) {
2042
- let start = continiousValues[0].continious;
2043
- const end = continiousValues[continiousValues.length - 1].continious;
2041
+ if (continuousValues.length) {
2042
+ let start = continuousValues[0].continuous;
2043
+ const end = continuousValues[continuousValues.length - 1].continuous;
2044
2044
  const intervalsCount = HistogramModel.IntervalsCount;
2045
2045
  const delta = (end - start) / intervalsCount;
2046
2046
  for (let i = 0; i < intervalsCount; ++i) {
@@ -2062,8 +2062,8 @@ class HistogramModel extends SelectBase {
2062
2062
  return [externalCalculatedData];
2063
2063
  }
2064
2064
  getCalculatedValuesCore() {
2065
- this.getContiniousValues();
2066
- return histogramStatisticsCalculator(this._continiousData, this.intervals, this.getSeriesValues());
2065
+ this.getContinuousValues();
2066
+ return histogramStatisticsCalculator(this._continuousData, this.intervals, this.getSeriesValues());
2067
2067
  }
2068
2068
  getValueType() {
2069
2069
  return this.valueType;
@@ -2163,7 +2163,7 @@ class PivotModel extends SelectBase {
2163
2163
  this.questions = questions;
2164
2164
  this.valueType = "enum";
2165
2165
  this._cachedValues = undefined;
2166
- this._continiousData = undefined;
2166
+ this._continuousData = undefined;
2167
2167
  this._cachedIntervals = undefined;
2168
2168
  this._intervalPrecision = 2;
2169
2169
  this.axisYSelectors = [];
@@ -2179,7 +2179,12 @@ class PivotModel extends SelectBase {
2179
2179
  value: question.name,
2180
2180
  text: question.title || question.name,
2181
2181
  };
2182
- }), (option) => this.axisXQuestionName === option.value, (e) => { this.axisXQuestionName = e.target.value; this.setupPivot(); }, localization.getString("axisXSelectorTitle")));
2182
+ }), (option) => this.axisXQuestionName === option.value, (e) => {
2183
+ this.axisXQuestionName = e.target.value;
2184
+ this.updateQuestionsSelection();
2185
+ this.updateToolbar();
2186
+ this.setupPivot();
2187
+ }, () => this.isXYChart() ? localization.getString("axisXSelectorTitle") : localization.getString("axisXAlternativeSelectorTitle")));
2183
2188
  this.registerToolbarItem("axisYSelector0", this.createYSelecterGenerator());
2184
2189
  this.setupPivot();
2185
2190
  }
@@ -2191,6 +2196,9 @@ class PivotModel extends SelectBase {
2191
2196
  selector = this.createAxisYSelector(selectorIndex);
2192
2197
  this.axisYSelectors.push(selector);
2193
2198
  }
2199
+ else {
2200
+ selector["__updateSelect"] && selector["__updateSelect"]();
2201
+ }
2194
2202
  return selector;
2195
2203
  };
2196
2204
  }
@@ -2211,26 +2219,62 @@ class PivotModel extends SelectBase {
2211
2219
  }
2212
2220
  this.axisYSelectors = this.axisYSelectors.slice(0, index + 1);
2213
2221
  this.axisYQuestionNames = this.axisYQuestionNames.slice(0, index + 1);
2214
- this.updateToolbar();
2215
2222
  }
2216
2223
  }
2217
2224
  else {
2218
2225
  if (!!value) {
2219
2226
  this.registerToolbarItem("axisYSelector" + this.axisYSelectors.length, this.createYSelecterGenerator());
2220
- this.updateToolbar();
2221
2227
  }
2222
2228
  }
2229
+ this.updateQuestionsSelection();
2230
+ this.updateToolbar();
2223
2231
  this.setupPivot();
2224
2232
  }
2233
+ updateQuestionsSelection() {
2234
+ const selectedQuestions = [this.axisXQuestionName];
2235
+ for (let i = 0; i < this.axisYQuestionNames.length; ++i) {
2236
+ const questionName = this.axisYQuestionNames[i];
2237
+ if (selectedQuestions.indexOf(questionName) !== -1) {
2238
+ this.onAxisYSelectorChanged(i, undefined);
2239
+ break;
2240
+ }
2241
+ else {
2242
+ selectedQuestions.push(questionName);
2243
+ }
2244
+ }
2245
+ }
2225
2246
  createAxisYSelector(selectorIndex) {
2226
- const selector = DocumentHelper.createSelector([{ value: "", text: "Not selected" }].concat(this.questions.map((question) => {
2227
- return {
2228
- value: question.name,
2229
- text: question.title || question.name,
2230
- };
2231
- })), (option) => this.axisYQuestionNames[selectorIndex] === option.value, (e) => { this.onAxisYSelectorChanged(selectorIndex, e.target.value); }, selectorIndex ? undefined : localization.getString("axisYSelectorTitle"));
2247
+ const getChoices = () => {
2248
+ const choices = this.questions.filter(q => {
2249
+ if (q.name === this.axisXQuestionName) {
2250
+ return false;
2251
+ }
2252
+ const usedIndex = this.axisYQuestionNames.indexOf(q.name);
2253
+ return usedIndex == -1 || usedIndex >= selectorIndex;
2254
+ }).map((question) => {
2255
+ return {
2256
+ value: question.name,
2257
+ text: question.title || question.name,
2258
+ };
2259
+ });
2260
+ return [{ value: "", text: localization.getString("notSelected") }].concat(choices);
2261
+ };
2262
+ if (getChoices().length == 1) {
2263
+ return undefined;
2264
+ }
2265
+ const selector = DocumentHelper.createSelector(getChoices, (option) => this.axisYQuestionNames[selectorIndex] === option.value, (e) => { this.onAxisYSelectorChanged(selectorIndex, e.target.value); }, () => selectorIndex ? undefined : (this.isXYChart() ? localization.getString("axisYSelectorTitle") : localization.getString("axisYAlternativeSelectorTitle")));
2232
2266
  return selector;
2233
2267
  }
2268
+ setChartType(chartType) {
2269
+ const prev2Dchart = this.isXYChart();
2270
+ super.setChartType(chartType);
2271
+ if (prev2Dchart !== this.isXYChart()) {
2272
+ this.updateToolbar();
2273
+ }
2274
+ }
2275
+ isXYChart() {
2276
+ return ["pie", "doughnut"].indexOf(this.chartType) === -1;
2277
+ }
2234
2278
  getQuestionValueType(question) {
2235
2279
  const questionType = question.getType();
2236
2280
  if (questionType === "text" && (question["inputType"] === "date" || question["inputType"] === "datetime")) {
@@ -2257,11 +2301,11 @@ class PivotModel extends SelectBase {
2257
2301
  this.onDataChanged();
2258
2302
  }
2259
2303
  reset() {
2260
- this._continiousData = undefined;
2304
+ this._continuousData = undefined;
2261
2305
  this._cachedValues = undefined;
2262
2306
  this._cachedIntervals = undefined;
2263
2307
  }
2264
- getContiniousValue(value) {
2308
+ getContinuousValue(value) {
2265
2309
  if (this.valueType === "date") {
2266
2310
  return Date.parse(value);
2267
2311
  }
@@ -2278,7 +2322,7 @@ class PivotModel extends SelectBase {
2278
2322
  return Math.round(base * value) / base;
2279
2323
  }
2280
2324
  getSelectedItemByText(itemText) {
2281
- if (this.hasCustomIntervals || this.getContiniousValues().length > PivotModel.UseIntervalsFrom) {
2325
+ if (this.hasCustomIntervals || this.getContinuousValues().length > PivotModel.UseIntervalsFrom) {
2282
2326
  const interval = this.intervals.filter(interval => interval.label === itemText)[0];
2283
2327
  return new ItemValue(interval, interval !== undefined ? interval.label : "");
2284
2328
  }
@@ -2297,9 +2341,9 @@ class PivotModel extends SelectBase {
2297
2341
  this.reset();
2298
2342
  super.onDataChanged();
2299
2343
  }
2300
- getContiniousValues() {
2344
+ getContinuousValues() {
2301
2345
  if (this._cachedValues === undefined) {
2302
- this._continiousData = [];
2346
+ this._continuousData = [];
2303
2347
  if (this.valueType === "enum") {
2304
2348
  this._cachedValues = [];
2305
2349
  return this._cachedValues;
@@ -2308,13 +2352,13 @@ class PivotModel extends SelectBase {
2308
2352
  this.data.forEach(dataItem => {
2309
2353
  const answerData = dataItem[this.name];
2310
2354
  if (answerData !== undefined) {
2311
- // TODO: _continiousData should be sorted in order to speed-up statistics calculation in the getData function
2312
- this._continiousData.push({ continious: this.getContiniousValue(answerData), row: dataItem });
2355
+ // TODO: _continuousData should be sorted in order to speed-up statistics calculation in the getData function
2356
+ this._continuousData.push({ continuous: this.getContinuousValue(answerData), row: dataItem });
2313
2357
  hash[answerData] = { value: answerData, row: dataItem };
2314
2358
  }
2315
2359
  });
2316
- this._cachedValues = Object.keys(hash).map(key => ({ original: hash[key].value, continious: this.getContiniousValue(key), row: hash[key].row }));
2317
- this._cachedValues.sort((a, b) => a.continious - b.continious);
2360
+ this._cachedValues = Object.keys(hash).map(key => ({ original: hash[key].value, continuous: this.getContinuousValue(key), row: hash[key].row }));
2361
+ this._cachedValues.sort((a, b) => a.continuous - b.continuous);
2318
2362
  }
2319
2363
  return this._cachedValues;
2320
2364
  }
@@ -2399,11 +2443,11 @@ class PivotModel extends SelectBase {
2399
2443
  }
2400
2444
  }
2401
2445
  if (this._cachedIntervals === undefined) {
2402
- const continiousValues = this.getContiniousValues();
2446
+ const continuousValues = this.getContinuousValues();
2403
2447
  this._cachedIntervals = [];
2404
- if (continiousValues.length) {
2405
- let start = continiousValues[0].continious;
2406
- const end = continiousValues[continiousValues.length - 1].continious;
2448
+ if (continuousValues.length) {
2449
+ let start = continuousValues[0].continuous;
2450
+ const end = continuousValues[continuousValues.length - 1].continuous;
2407
2451
  const intervalsCount = PivotModel.IntervalsCount;
2408
2452
  const delta = (end - start) / intervalsCount;
2409
2453
  for (let i = 0; i < intervalsCount; ++i) {
@@ -2485,14 +2529,14 @@ class PivotModel extends SelectBase {
2485
2529
  });
2486
2530
  }
2487
2531
  else {
2488
- this.getContiniousValues();
2532
+ this.getContinuousValues();
2489
2533
  const intervals = this.intervals;
2490
2534
  for (var i = 0; i < series.length; ++i) {
2491
2535
  statistics.push(intervals.map(i => 0));
2492
2536
  }
2493
- this._continiousData.forEach(dataValue => {
2537
+ this._continuousData.forEach(dataValue => {
2494
2538
  for (let valueIndex = 0; valueIndex < intervals.length; ++valueIndex) {
2495
- if (intervals[valueIndex].start <= dataValue.continious && (dataValue.continious < intervals[valueIndex].end || valueIndex == intervals.length - 1)) {
2539
+ if (intervals[valueIndex].start <= dataValue.continuous && (dataValue.continuous < intervals[valueIndex].end || valueIndex == intervals.length - 1)) {
2496
2540
  if (this.questionsY.length === 0) {
2497
2541
  statistics[0][valueIndex]++;
2498
2542
  }
@@ -9835,7 +9879,7 @@ class VisualizationPanel extends VisualizerBase {
9835
9879
  const localeChoices = this.locales.map((element) => {
9836
9880
  return {
9837
9881
  value: element,
9838
- text: localization.localeNames[element] || localization.getString(element) || element
9882
+ text: localization.getLocaleName(element)
9839
9883
  };
9840
9884
  });
9841
9885
  // localeChoices.unshift({