survey-analytics 2.3.5 → 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.5
2
+ * surveyjs - SurveyJS Dashboard library v2.3.6
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.5
2
+ * surveyjs - SurveyJS Dashboard library v2.3.6
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.5
2
+ * surveyjs - SurveyJS Dashboard library v2.3.6
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -12130,8 +12130,9 @@ var PlotlySetup = /** @class */ (function () {
12130
12130
  text: labels.map(function (label) {
12131
12131
  return PlotlySetup.getTruncatedLabel(label, model.labelTruncateLength);
12132
12132
  }),
12133
- hoverinfo: "label+value+percent",
12133
+ hoverinfo: "value+text",
12134
12134
  textposition: "inside",
12135
+ texttemplate: "%{text}"
12135
12136
  };
12136
12137
  if (model.chartType === "doughnut") {
12137
12138
  traceConfig.type = "pie";
@@ -12145,9 +12146,15 @@ var PlotlySetup = /** @class */ (function () {
12145
12146
  }
12146
12147
  datasets.forEach(function (dataset, index) {
12147
12148
  var isNotEmpty = dataset.some(function (value) { return value != 0; });
12149
+ var pieTexts = traceConfig.text;
12150
+ if (model.showPercentages) {
12151
+ var percentages_1 = model.getPercentages([dataset])[0];
12152
+ pieTexts = labels.map(function (l, li) { return (model.showOnlyPercentages ? percentages_1[li] : PlotlySetup.getTruncatedLabel(l, model.labelTruncateLength) + "<br>" + percentages_1[li]) + "%"; });
12153
+ }
12148
12154
  if (isNotEmpty) {
12149
12155
  traces.push(Object.assign({}, traceConfig, {
12150
12156
  values: dataset,
12157
+ text: pieTexts,
12151
12158
  domain: {
12152
12159
  column: traces.length % layoutColumns,
12153
12160
  row: Math.floor(traces.length / layoutColumns),
@@ -12764,9 +12771,8 @@ var SelectBase = /** @class */ (function (_super) {
12764
12771
  _this.emptyAnswersBtn = undefined;
12765
12772
  _this.transposeDataBtn = undefined;
12766
12773
  _this.topNSelector = undefined;
12767
- _this._showPercentages = false;
12768
12774
  _this._showOnlyPercentages = false;
12769
- _this._percentagePrecision = 0;
12775
+ _this._percentagePrecision = 2;
12770
12776
  _this._answersOrder = "default";
12771
12777
  _this._hideEmptyAnswers = false;
12772
12778
  _this._topN = -1;
@@ -12788,7 +12794,6 @@ var SelectBase = /** @class */ (function (_super) {
12788
12794
  };
12789
12795
  }
12790
12796
  _this._supportSelection = true;
12791
- _this._showPercentages = _this.options.showPercentages === true;
12792
12797
  _this._showOnlyPercentages = _this.options.showOnlyPercentages === true;
12793
12798
  if (_this.options.percentagePrecision) {
12794
12799
  _this._percentagePrecision = _this.options.percentagePrecision;
@@ -13046,12 +13051,23 @@ var SelectBase = /** @class */ (function (_super) {
13046
13051
  enumerable: false,
13047
13052
  configurable: true
13048
13053
  });
13054
+ SelectBase.prototype.getShowPercentagesDefault = function () {
13055
+ if (this.options.showPercentages === undefined) {
13056
+ return ["pie", "doughnut"].indexOf(this.chartType) !== -1;
13057
+ }
13058
+ return this.options.showPercentages === true;
13059
+ };
13049
13060
  Object.defineProperty(SelectBase.prototype, "showPercentages", {
13050
13061
  /**
13051
13062
  * Gets and sets whether chart should show values and percentages.
13052
13063
  */
13053
13064
  get: function () {
13054
- return this._showPercentages;
13065
+ if (this._showPercentages !== undefined) {
13066
+ return this._showPercentages;
13067
+ }
13068
+ else {
13069
+ return this.getShowPercentagesDefault();
13070
+ }
13055
13071
  },
13056
13072
  set: function (val) {
13057
13073
  this._showPercentages = val;
@@ -13213,12 +13229,10 @@ var SelectBase = /** @class */ (function (_super) {
13213
13229
  var percentages = [];
13214
13230
  var percentagePrecision = this._percentagePrecision;
13215
13231
  if (data.length < 2) {
13216
- data.forEach(function (res, index) {
13217
- var sum = res.reduce(function (sum, val) { return sum + val; }, 0);
13218
- percentages[index] = res.map(function (val) {
13219
- var value = percentagePrecision ? +(val / sum).toFixed(percentagePrecision) : Math.round((val / sum) * 10000);
13220
- return sum && (value / 100);
13221
- });
13232
+ var sum = data[0].reduce(function (sum, val) { return sum + val; }, 0);
13233
+ percentages[0] = data[0].map(function (val) {
13234
+ var value = percentagePrecision ? +(val / sum * 100).toFixed(percentagePrecision) : Math.round(val / sum * 100);
13235
+ return sum && value;
13222
13236
  });
13223
13237
  }
13224
13238
  else {
@@ -13230,7 +13244,7 @@ var SelectBase = /** @class */ (function (_super) {
13230
13244
  for (var j = 0; j < data.length; j++) {
13231
13245
  if (!Array.isArray(percentages[j]))
13232
13246
  percentages[j] = [];
13233
- var value = percentagePrecision ? +((data[j][i] / sum) * 100).toFixed(percentagePrecision) : Math.round((data[j][i] / sum) * 100);
13247
+ var value = percentagePrecision ? +(data[j][i] / sum * 100).toFixed(percentagePrecision) : Math.round(data[j][i] / sum * 100);
13234
13248
  percentages[j][i] = sum && value;
13235
13249
  }
13236
13250
  }
@@ -13258,7 +13272,7 @@ var SelectBase = /** @class */ (function (_super) {
13258
13272
  */
13259
13273
  SelectBase.prototype.getAnswersData = function () {
13260
13274
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
13261
- var seriesLabels, datasets, labels, colors, texts, temp, zippedArray, dict, unzippedArray, answersData;
13275
+ var seriesLabels, datasets, labels, colors, temp, texts, zippedArray, dict, unzippedArray, answersData;
13262
13276
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
13263
13277
  switch (_a.label) {
13264
13278
  case 0:
@@ -13268,14 +13282,13 @@ var SelectBase = /** @class */ (function (_super) {
13268
13282
  datasets = (_a.sent());
13269
13283
  labels = this.getLabels();
13270
13284
  colors = this.getColors();
13271
- texts = this.showPercentages ? this.getPercentages(datasets) : datasets;
13272
13285
  if (this.transposeData) {
13273
13286
  datasets = this.transpose(datasets);
13274
- texts = this.transpose(texts);
13275
13287
  temp = seriesLabels;
13276
13288
  seriesLabels = labels;
13277
13289
  labels = temp;
13278
13290
  }
13291
+ texts = this.showPercentages ? this.getPercentages(datasets) : datasets;
13279
13292
  if (this.answersOrder == "asc" || this.answersOrder == "desc") {
13280
13293
  zippedArray = this.showPercentages
13281
13294
  ? _utils_index__WEBPACK_IMPORTED_MODULE_4__.DataHelper.zipArrays(labels, colors, texts[0])
@@ -14435,10 +14448,13 @@ var VisualizationManager = /** @class */ (function () {
14435
14448
  };
14436
14449
  /**
14437
14450
  * Returns all visualizer constructors for a specified question type.
14438
- * @param questionType A question [type](https://surveyjs.io/form-library/documentation/api-reference/question#getType).
14451
+ * @param visualizerType A question [type](https://surveyjs.io/form-library/documentation/api-reference/question#getType).
14439
14452
  */
14440
- VisualizationManager.getVisualizersByType = function (questionType) {
14441
- var vDescrs = VisualizationManager.vizualizers[questionType];
14453
+ VisualizationManager.getVisualizersByType = function (visualizerType, fallbackVisualizerType) {
14454
+ var vDescrs = VisualizationManager.vizualizers[visualizerType];
14455
+ if (!!fallbackVisualizerType && (!vDescrs || vDescrs.length == 0)) {
14456
+ vDescrs = VisualizationManager.vizualizers[fallbackVisualizerType];
14457
+ }
14442
14458
  if (!vDescrs) {
14443
14459
  if (VisualizationManager.defaultVisualizer.suppressVisualizerStubRendering) {
14444
14460
  return [];
@@ -16478,12 +16494,7 @@ var VisualizerFactory = /** @class */ (function () {
16478
16494
  var type = question.getType();
16479
16495
  var creators = [];
16480
16496
  if (type === "text" && question.inputType) {
16481
- type = question.inputType;
16482
- creators = _visualizationManager__WEBPACK_IMPORTED_MODULE_0__.VisualizationManager.getVisualizersByType(type);
16483
- if (creators === undefined || creators.length == 0) {
16484
- type = "text";
16485
- creators = _visualizationManager__WEBPACK_IMPORTED_MODULE_0__.VisualizationManager.getVisualizersByType(type);
16486
- }
16497
+ creators = _visualizationManager__WEBPACK_IMPORTED_MODULE_0__.VisualizationManager.getVisualizersByType(question.inputType, type);
16487
16498
  }
16488
16499
  else {
16489
16500
  creators = _visualizationManager__WEBPACK_IMPORTED_MODULE_0__.VisualizationManager.getVisualizersByType(type);