survey-analytics 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/fesm/shared.mjs +10 -2
  2. package/fesm/shared.mjs.map +1 -1
  3. package/fesm/shared2.mjs +748 -262
  4. package/fesm/shared2.mjs.map +1 -1
  5. package/fesm/survey.analytics.core.mjs +2 -2
  6. package/fesm/survey.analytics.mjs +315 -538
  7. package/fesm/survey.analytics.mjs.map +1 -1
  8. package/fesm/survey.analytics.tabulator.mjs +1 -1
  9. package/package.json +8 -8
  10. package/survey-analytics-tabulator.types/analytics-localization/english.d.ts +2 -0
  11. package/survey-analytics-tabulator.types/localizationManager.d.ts +2 -0
  12. package/survey-analytics-tabulator.types/utils/index.d.ts +1 -1
  13. package/survey-analytics.types/alternativeVizualizersWrapper.d.ts +2 -0
  14. package/survey-analytics.types/analytics-localization/english.d.ts +2 -0
  15. package/survey-analytics.types/boolean.d.ts +0 -1
  16. package/survey-analytics.types/entries/summary.core.d.ts +3 -1
  17. package/survey-analytics.types/histogram.d.ts +1 -1
  18. package/survey-analytics.types/localizationManager.d.ts +2 -0
  19. package/survey-analytics.types/matrix.d.ts +0 -1
  20. package/survey-analytics.types/pivot.d.ts +64 -0
  21. package/survey-analytics.types/plotly/chart-adapter.d.ts +13 -0
  22. package/survey-analytics.types/plotly/index.d.ts +2 -7
  23. package/survey-analytics.types/plotly/legacy.d.ts +33 -0
  24. package/survey-analytics.types/plotly/setup.d.ts +5 -3
  25. package/survey-analytics.types/{plotly/ranking.d.ts → ranking.d.ts} +2 -2
  26. package/survey-analytics.types/selectBase.d.ts +3 -1
  27. package/survey-analytics.types/utils/index.d.ts +1 -1
  28. package/survey-analytics.types/visualizationManager.d.ts +3 -0
  29. package/survey-analytics.types/visualizerBase.d.ts +13 -1
  30. package/survey.analytics.core.css +7 -1
  31. package/survey.analytics.core.css.map +1 -1
  32. package/survey.analytics.core.js +659 -51
  33. package/survey.analytics.core.js.map +1 -1
  34. package/survey.analytics.core.min.css +2 -2
  35. package/survey.analytics.core.min.js +1 -1
  36. package/survey.analytics.core.min.js.LICENSE.txt +1 -1
  37. package/survey.analytics.css +7 -1
  38. package/survey.analytics.css.map +1 -1
  39. package/survey.analytics.js +1048 -817
  40. package/survey.analytics.js.map +1 -1
  41. package/survey.analytics.min.css +2 -2
  42. package/survey.analytics.min.js +1 -1
  43. package/survey.analytics.min.js.LICENSE.txt +1 -1
  44. package/survey.analytics.tabulator.css +1 -1
  45. package/survey.analytics.tabulator.js +10 -2
  46. package/survey.analytics.tabulator.js.map +1 -1
  47. package/survey.analytics.tabulator.min.css +1 -1
  48. package/survey.analytics.tabulator.min.js +1 -1
  49. package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
  50. package/survey-analytics.types/plotly/boolean.d.ts +0 -16
  51. package/survey-analytics.types/plotly/histogram.d.ts +0 -13
  52. package/survey-analytics.types/plotly/matrix.d.ts +0 -11
  53. package/survey-analytics.types/plotly/matrixdropdown-grouped.d.ts +0 -11
  54. package/survey-analytics.types/plotly/rating.d.ts +0 -20
  55. package/survey-analytics.types/plotly/selectBase.d.ts +0 -26
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.2.2
2
+ * surveyjs - SurveyJS Dashboard library v2.2.4
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
  */
@@ -7007,6 +7007,12 @@ var AlternativeVisualizersWrapper = /** @class */ (function (_super) {
7007
7007
  this.visualizer.setState(state.state);
7008
7008
  }
7009
7009
  };
7010
+ AlternativeVisualizersWrapper.prototype.getValues = function () {
7011
+ return this.visualizer.getValues();
7012
+ };
7013
+ AlternativeVisualizersWrapper.prototype.getLabels = function () {
7014
+ return this.visualizer.getLabels();
7015
+ };
7010
7016
  AlternativeVisualizersWrapper.prototype.getCalculatedValues = function () {
7011
7017
  return this.visualizer.getCalculatedValues();
7012
7018
  };
@@ -7314,6 +7320,8 @@ var englishStrings = {
7314
7320
  npsPromoters: "Promoters",
7315
7321
  npsPassives: "Passives",
7316
7322
  npsDetractors: "Detractors",
7323
+ axisXSelectorTitle: "X axis:",
7324
+ axisYSelectorTitle: "Y axis:"
7317
7325
  };
7318
7326
  // Uncomment the lines below if you create a custom dictionary.
7319
7327
  // Replace "en" with a custom locale code (for example, "fr" or "de"),
@@ -8435,6 +8443,8 @@ __webpack_require__.r(__webpack_exports__);
8435
8443
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
8436
8444
  /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./selectBase */ "./src/selectBase.ts");
8437
8445
  /* harmony import */ var _localizationManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./localizationManager */ "./src/localizationManager.ts");
8446
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
8447
+
8438
8448
 
8439
8449
 
8440
8450
 
@@ -8498,6 +8508,7 @@ var BooleanModel = /** @class */ (function (_super) {
8498
8508
  return BooleanModel;
8499
8509
  }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
8500
8510
 
8511
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("boolean", BooleanModel);
8501
8512
 
8502
8513
 
8503
8514
  /***/ }),
@@ -8716,6 +8727,8 @@ __webpack_require__.r(__webpack_exports__);
8716
8727
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
8717
8728
  /* harmony import */ var _dataProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dataProvider */ "./src/dataProvider.ts");
8718
8729
  /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./selectBase */ "./src/selectBase.ts");
8730
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
8731
+
8719
8732
 
8720
8733
 
8721
8734
 
@@ -8729,6 +8742,7 @@ var HistogramModel = /** @class */ (function (_super) {
8729
8742
  _this._continiousData = undefined;
8730
8743
  _this._cachedIntervals = undefined;
8731
8744
  _this._intervalPrecision = 2;
8745
+ _this._transposeData = false;
8732
8746
  if (_this.options.intervalPrecision !== undefined) {
8733
8747
  _this._intervalPrecision = _this.options.intervalPrecision;
8734
8748
  }
@@ -8906,11 +8920,17 @@ var HistogramModel = /** @class */ (function (_super) {
8906
8920
  }
8907
8921
  return statistics;
8908
8922
  };
8923
+ HistogramModel.prototype.getValueType = function () {
8924
+ return this.valueType;
8925
+ };
8909
8926
  HistogramModel.IntervalsCount = 10;
8910
8927
  HistogramModel.UseIntervalsFrom = 10;
8911
8928
  return HistogramModel;
8912
8929
  }(_selectBase__WEBPACK_IMPORTED_MODULE_3__.SelectBase));
8913
8930
 
8931
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("date", HistogramModel);
8932
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("number", HistogramModel, 100);
8933
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("rating", HistogramModel, 100);
8914
8934
 
8915
8935
 
8916
8936
  /***/ }),
@@ -9270,13 +9290,17 @@ __webpack_require__.r(__webpack_exports__);
9270
9290
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! survey-core */ "survey-core");
9271
9291
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
9272
9292
  /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./selectBase */ "./src/selectBase.ts");
9293
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
9294
+
9273
9295
 
9274
9296
 
9275
9297
 
9276
9298
  var Matrix = /** @class */ (function (_super) {
9277
9299
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(Matrix, _super);
9278
9300
  function Matrix(question, data, options, name) {
9279
- return _super.call(this, question, data, options, name || "matrix") || this;
9301
+ var _this = _super.call(this, question, data, options, name || "matrix") || this;
9302
+ _this._transposeData = true;
9303
+ return _this;
9280
9304
  // this.getAnswersData();
9281
9305
  }
9282
9306
  Object.defineProperty(Matrix.prototype, "matrixQuestion", {
@@ -9359,20 +9383,10 @@ var Matrix = /** @class */ (function (_super) {
9359
9383
  }
9360
9384
  return result;
9361
9385
  };
9362
- Matrix.prototype.getCalculatedValuesCore = function () {
9363
- var statistics = _super.prototype.getCalculatedValuesCore.call(this);
9364
- var series = this.getSeriesValues();
9365
- var values = this.getValues();
9366
- var preparedData = [];
9367
- values.forEach(function (val, valueIndex) {
9368
- var seriesData = series.map(function (seriesName, seriesIndex) { return statistics[seriesIndex][valueIndex]; });
9369
- preparedData.push(seriesData);
9370
- });
9371
- return preparedData;
9372
- };
9373
9386
  return Matrix;
9374
9387
  }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
9375
9388
 
9389
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_3__.VisualizationManager.registerVisualizer("matrix", Matrix);
9376
9390
 
9377
9391
 
9378
9392
  /***/ }),
@@ -9602,6 +9616,8 @@ __webpack_require__.r(__webpack_exports__);
9602
9616
  /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./visualizerBase */ "./src/visualizerBase.ts");
9603
9617
  /* harmony import */ var _localizationManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./localizationManager */ "./src/localizationManager.ts");
9604
9618
  /* harmony import */ var _utils_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils/index */ "./src/utils/index.ts");
9619
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
9620
+
9605
9621
 
9606
9622
 
9607
9623
 
@@ -9611,6 +9627,11 @@ var NumberModel = /** @class */ (function (_super) {
9611
9627
  function NumberModel(question, data, options, name) {
9612
9628
  if (options === void 0) { options = {}; }
9613
9629
  var _this = _super.call(this, question, data, options, name || "number") || this;
9630
+ if (_visualizerBase__WEBPACK_IMPORTED_MODULE_1__.VisualizerBase.chartAdapterType) {
9631
+ _this._chartAdapter = new _visualizerBase__WEBPACK_IMPORTED_MODULE_1__.VisualizerBase.chartAdapterType(_this);
9632
+ _this.chartTypes = _this._chartAdapter.getChartTypes();
9633
+ _this.chartType = _this.chartTypes[0];
9634
+ }
9614
9635
  _this.registerToolbarItem("changeChartType", function () {
9615
9636
  if (_this.chartTypes.length > 1) {
9616
9637
  return _utils_index__WEBPACK_IMPORTED_MODULE_3__.DocumentHelper.createSelector(_this.chartTypes.map(function (chartType) {
@@ -9728,6 +9749,488 @@ var NumberModel = /** @class */ (function (_super) {
9728
9749
  return NumberModel;
9729
9750
  }(_visualizerBase__WEBPACK_IMPORTED_MODULE_1__.VisualizerBase));
9730
9751
 
9752
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("number", NumberModel, 200);
9753
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("rating", NumberModel, 200);
9754
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("expression", NumberModel);
9755
+
9756
+
9757
+ /***/ }),
9758
+
9759
+ /***/ "./src/pivot.ts":
9760
+ /*!**********************!*\
9761
+ !*** ./src/pivot.ts ***!
9762
+ \**********************/
9763
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9764
+
9765
+ "use strict";
9766
+ __webpack_require__.r(__webpack_exports__);
9767
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9768
+ /* harmony export */ PivotModel: () => (/* binding */ PivotModel)
9769
+ /* harmony export */ });
9770
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./src/utils/helpers.ts");
9771
+ /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! survey-core */ "survey-core");
9772
+ /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
9773
+ /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./selectBase */ "./src/selectBase.ts");
9774
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./src/utils/index.ts");
9775
+ /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./visualizerBase */ "./src/visualizerBase.ts");
9776
+ /* harmony import */ var _localizationManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./localizationManager */ "./src/localizationManager.ts");
9777
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
9778
+
9779
+
9780
+
9781
+
9782
+
9783
+
9784
+
9785
+ var PivotModel = /** @class */ (function (_super) {
9786
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(PivotModel, _super);
9787
+ function PivotModel(questions, data, options, name) {
9788
+ var _this = _super.call(this, null, data, options, name || "pivot") || this;
9789
+ _this.questions = questions;
9790
+ _this.valueType = "enum";
9791
+ _this._cachedValues = undefined;
9792
+ _this._continiousData = undefined;
9793
+ _this._cachedIntervals = undefined;
9794
+ _this._intervalPrecision = 2;
9795
+ _this.axisYSelectors = [];
9796
+ _this.axisYQuestionNames = [];
9797
+ _this.questionsY = [];
9798
+ _this.questions = _this.questions.filter(function (question) { return ["matrixdropdown", "matrixdynamic", "matrix", "file", "signature", "multipletext", "comment", "html", "image"].indexOf(question.getType()) === -1; });
9799
+ if (_this.options.intervalPrecision !== undefined) {
9800
+ _this._intervalPrecision = _this.options.intervalPrecision;
9801
+ }
9802
+ _this.axisXQuestionName = _this.questions.length > 0 ? _this.questions[0].name : undefined;
9803
+ _this.registerToolbarItem("axisXSelector", function () {
9804
+ return _this.axisXSelector = _utils__WEBPACK_IMPORTED_MODULE_3__.DocumentHelper.createSelector(_this.questions.map(function (question) {
9805
+ return {
9806
+ value: question.name,
9807
+ text: question.title || question.name,
9808
+ };
9809
+ }), function (option) { return _this.axisXQuestionName === option.value; }, function (e) { _this.axisXQuestionName = e.target.value; _this.setupPivot(); }, _localizationManager__WEBPACK_IMPORTED_MODULE_5__.localization.getString("axisXSelectorTitle"));
9810
+ });
9811
+ _this.registerToolbarItem("axisYSelector0", _this.createYSelecterGenerator());
9812
+ _this.setupPivot();
9813
+ return _this;
9814
+ }
9815
+ PivotModel.prototype.createYSelecterGenerator = function () {
9816
+ var _this = this;
9817
+ var selectorIndex = this.axisYSelectors.length;
9818
+ return function () {
9819
+ var selector = _this.axisYSelectors[selectorIndex];
9820
+ if (!selector) {
9821
+ selector = _this.createAxisYSelector(selectorIndex);
9822
+ _this.axisYSelectors.push(selector);
9823
+ }
9824
+ return selector;
9825
+ };
9826
+ };
9827
+ PivotModel.prototype.setAxisQuestions = function () {
9828
+ var axisQuestionNames = [];
9829
+ for (var _i = 0; _i < arguments.length; _i++) {
9830
+ axisQuestionNames[_i] = arguments[_i];
9831
+ }
9832
+ if (axisQuestionNames.length < 1) {
9833
+ return;
9834
+ }
9835
+ this.axisXQuestionName = axisQuestionNames[0];
9836
+ this.axisYQuestionNames = axisQuestionNames.splice(1);
9837
+ this.setupPivot();
9838
+ };
9839
+ PivotModel.prototype.onAxisYSelectorChanged = function (index, value) {
9840
+ this.axisYQuestionNames[index] = value;
9841
+ if (index < this.axisYSelectors.length - 1) {
9842
+ if (!value) {
9843
+ for (var i = index + 1; i < this.axisYSelectors.length; ++i) {
9844
+ this.unregisterToolbarItem("axisYSelector" + i);
9845
+ }
9846
+ this.axisYSelectors = this.axisYSelectors.slice(0, index + 1);
9847
+ this.axisYQuestionNames = this.axisYQuestionNames.slice(0, index + 1);
9848
+ this.updateToolbar();
9849
+ }
9850
+ }
9851
+ else {
9852
+ if (!!value) {
9853
+ this.registerToolbarItem("axisYSelector" + this.axisYSelectors.length, this.createYSelecterGenerator());
9854
+ this.updateToolbar();
9855
+ }
9856
+ }
9857
+ this.setupPivot();
9858
+ };
9859
+ PivotModel.prototype.createAxisYSelector = function (selectorIndex) {
9860
+ var _this = this;
9861
+ var selector = _utils__WEBPACK_IMPORTED_MODULE_3__.DocumentHelper.createSelector([{ value: "", text: "Not selected" }].concat(this.questions.map(function (question) {
9862
+ return {
9863
+ value: question.name,
9864
+ text: question.title || question.name,
9865
+ };
9866
+ })), function (option) { return _this.axisYQuestionNames[selectorIndex] === option.value; }, function (e) { _this.onAxisYSelectorChanged(selectorIndex, e.target.value); }, selectorIndex ? undefined : _localizationManager__WEBPACK_IMPORTED_MODULE_5__.localization.getString("axisYSelectorTitle"));
9867
+ return selector;
9868
+ };
9869
+ PivotModel.prototype.getQuestionValueType = function (question) {
9870
+ var questionType = question.getType();
9871
+ if (questionType === "text" && (question["inputType"] === "date" || question["inputType"] === "datetime")) {
9872
+ return "date";
9873
+ }
9874
+ else if (questionType === "text" || questionType === "rating" || questionType === "expression" || questionType === "range") {
9875
+ return "number";
9876
+ }
9877
+ return "enum";
9878
+ };
9879
+ PivotModel.prototype.setupPivot = function () {
9880
+ var _this = this;
9881
+ var questionX = this.questions.filter(function (q) { return q.name === _this.axisXQuestionName; })[0];
9882
+ if (!questionX) {
9883
+ return;
9884
+ }
9885
+ this.question = questionX;
9886
+ this.valueType = this.getQuestionValueType(questionX);
9887
+ this.questionsY = this.axisYQuestionNames.map(function (name) {
9888
+ var questionY = _this.questions.filter(function (q) { return q.name === name; })[0];
9889
+ if (!!questionY) {
9890
+ return _this.getQuestionValueType(questionY) === "enum" ? new _selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase(questionY, []) : new _visualizerBase__WEBPACK_IMPORTED_MODULE_4__.VisualizerBase(questionY, []);
9891
+ }
9892
+ }).filter(function (q) { return !!q; });
9893
+ this.onDataChanged();
9894
+ };
9895
+ PivotModel.prototype.reset = function () {
9896
+ this._continiousData = undefined;
9897
+ this._cachedValues = undefined;
9898
+ this._cachedIntervals = undefined;
9899
+ };
9900
+ PivotModel.prototype.getContiniousValue = function (value) {
9901
+ if (this.valueType === "date") {
9902
+ return Date.parse(value);
9903
+ }
9904
+ return parseFloat(value);
9905
+ };
9906
+ PivotModel.prototype.getString = function (value) {
9907
+ if (this.valueType === "date") {
9908
+ return new Date(value).toLocaleDateString();
9909
+ }
9910
+ return "" + value;
9911
+ };
9912
+ PivotModel.prototype.toPrecision = function (value) {
9913
+ var base = Math.pow(10, this._intervalPrecision);
9914
+ return Math.round(base * value) / base;
9915
+ };
9916
+ PivotModel.prototype.getSelectedItemByText = function (itemText) {
9917
+ if (this.hasCustomIntervals || this.getContiniousValues().length > PivotModel.UseIntervalsFrom) {
9918
+ var interval = this.intervals.filter(function (interval) { return interval.label === itemText; })[0];
9919
+ return new survey_core__WEBPACK_IMPORTED_MODULE_1__.ItemValue(interval, interval !== undefined ? interval.label : "");
9920
+ }
9921
+ var labels = this.getLabels();
9922
+ var labelIndex = labels.indexOf(itemText);
9923
+ return new survey_core__WEBPACK_IMPORTED_MODULE_1__.ItemValue(this.getValues()[labelIndex], labels[labelIndex]);
9924
+ };
9925
+ /**
9926
+ * Updates visualizer data.
9927
+ */
9928
+ PivotModel.prototype.updateData = function (data) {
9929
+ this.reset();
9930
+ _super.prototype.updateData.call(this, data);
9931
+ };
9932
+ PivotModel.prototype.onDataChanged = function () {
9933
+ this.reset();
9934
+ _super.prototype.onDataChanged.call(this);
9935
+ };
9936
+ PivotModel.prototype.getContiniousValues = function () {
9937
+ var _this = this;
9938
+ if (this._cachedValues === undefined) {
9939
+ this._continiousData = [];
9940
+ if (this.valueType === "enum") {
9941
+ this._cachedValues = [];
9942
+ return this._cachedValues;
9943
+ }
9944
+ var hash_1 = {};
9945
+ this.data.forEach(function (dataItem) {
9946
+ var answerData = dataItem[_this.name];
9947
+ if (answerData !== undefined) {
9948
+ // TODO: _continiousData should be sorted in order to speed-up statistics calculation in the getData function
9949
+ _this._continiousData.push({ continious: _this.getContiniousValue(answerData), row: dataItem });
9950
+ hash_1[answerData] = { value: answerData, row: dataItem };
9951
+ }
9952
+ });
9953
+ this._cachedValues = Object.keys(hash_1).map(function (key) { return ({ original: hash_1[key].value, continious: _this.getContiniousValue(key), row: hash_1[key].row }); });
9954
+ this._cachedValues.sort(function (a, b) { return a.continious - b.continious; });
9955
+ }
9956
+ return this._cachedValues;
9957
+ };
9958
+ PivotModel.prototype.isSupportAnswersOrder = function () {
9959
+ return false;
9960
+ };
9961
+ PivotModel.prototype.isSupportMissingAnswers = function () {
9962
+ return false;
9963
+ };
9964
+ Object.defineProperty(PivotModel.prototype, "needUseRateValues", {
9965
+ get: function () {
9966
+ return this.question.getType() == "rating" && Array.isArray(this.question["rateValues"]) && this.question["rateValues"].length > 0;
9967
+ },
9968
+ enumerable: false,
9969
+ configurable: true
9970
+ });
9971
+ PivotModel.prototype.getSeriesValues = function () {
9972
+ var _this = this;
9973
+ if (!this.questionsY || this.questionsY.length === 0) {
9974
+ return this.options.seriesValues || [];
9975
+ }
9976
+ var seriesValues = [];
9977
+ this.questionsY.forEach(function (q) {
9978
+ if (_this.getQuestionValueType(q.question) === "enum") {
9979
+ seriesValues.push.apply(seriesValues, q.getValues().reverse());
9980
+ }
9981
+ else {
9982
+ seriesValues.push(q.question.name);
9983
+ }
9984
+ });
9985
+ return seriesValues;
9986
+ };
9987
+ PivotModel.prototype.getSeriesLabels = function () {
9988
+ var _this = this;
9989
+ if (this.questionsY.length === 0) {
9990
+ return this.getSeriesValues();
9991
+ }
9992
+ var seriesLabels = [];
9993
+ this.questionsY.forEach(function (q) {
9994
+ if (_this.getQuestionValueType(q.question) === "enum") {
9995
+ seriesLabels.push.apply(seriesLabels, q.getLabels().reverse());
9996
+ }
9997
+ else {
9998
+ seriesLabels.push(q.question.title || q.question.name);
9999
+ }
10000
+ });
10001
+ return seriesLabels;
10002
+ };
10003
+ PivotModel.prototype.getValues = function () {
10004
+ if (this.valueType === "enum") {
10005
+ return _super.prototype.getValues.call(this).reverse();
10006
+ }
10007
+ return this.intervals.map(function (interval) { return interval.start; });
10008
+ };
10009
+ PivotModel.prototype.getLabels = function () {
10010
+ if (this.valueType === "enum") {
10011
+ return _super.prototype.getLabels.call(this).reverse();
10012
+ }
10013
+ return this.intervals.map(function (interval) { return interval.label; });
10014
+ };
10015
+ Object.defineProperty(PivotModel.prototype, "hasCustomIntervals", {
10016
+ get: function () {
10017
+ return !!this.questionOptions && Array.isArray(this.questionOptions.intervals);
10018
+ },
10019
+ enumerable: false,
10020
+ configurable: true
10021
+ });
10022
+ Object.defineProperty(PivotModel.prototype, "intervals", {
10023
+ get: function () {
10024
+ if (this.hasCustomIntervals) {
10025
+ return this.questionOptions.intervals;
10026
+ }
10027
+ if (this.question.getType() == "rating") {
10028
+ if (this.needUseRateValues) {
10029
+ var rateValues_1 = this.question["rateValues"];
10030
+ rateValues_1.sort(function (iv1, iv2) { return iv1.value - iv2.value; });
10031
+ return rateValues_1.map(function (rateValue, i) { return ({
10032
+ start: rateValue.value,
10033
+ end: i < rateValues_1.length - 1 ? rateValues_1[i + 1].value : rateValue.value + 1,
10034
+ label: rateValue.text
10035
+ }); });
10036
+ }
10037
+ else {
10038
+ var rateIntervals = [];
10039
+ for (var i = (this.question["rateMin"] || 0); i <= (this.question["rateMax"] || (PivotModel.IntervalsCount - 1)); i += (this.question["rateStep"] || 1)) {
10040
+ rateIntervals.push({
10041
+ start: i,
10042
+ end: i + 1,
10043
+ label: "" + (!!this.question["rateMin"] && !!this.question["rateMax"] ? i : (i + "-" + (i + 1)))
10044
+ });
10045
+ }
10046
+ return rateIntervals;
10047
+ }
10048
+ }
10049
+ if (this._cachedIntervals === undefined) {
10050
+ var continiousValues = this.getContiniousValues();
10051
+ this._cachedIntervals = [];
10052
+ if (continiousValues.length) {
10053
+ var start = continiousValues[0].continious;
10054
+ var end = continiousValues[continiousValues.length - 1].continious;
10055
+ var intervalsCount = PivotModel.IntervalsCount;
10056
+ var delta = (end - start) / intervalsCount;
10057
+ for (var i = 0; i < intervalsCount; ++i) {
10058
+ var next = start + delta;
10059
+ var istart = this.toPrecision(start);
10060
+ var inext = this.toPrecision(next);
10061
+ this._cachedIntervals.push({
10062
+ start: istart,
10063
+ end: i < intervalsCount - 1 ? inext : inext + delta / 100,
10064
+ label: "" + this.getString(istart) + "-" + this.getString(inext)
10065
+ });
10066
+ start = next;
10067
+ }
10068
+ }
10069
+ }
10070
+ return this._cachedIntervals;
10071
+ },
10072
+ enumerable: false,
10073
+ configurable: true
10074
+ });
10075
+ PivotModel.prototype.convertFromExternalData = function (externalCalculatedData) {
10076
+ return [externalCalculatedData];
10077
+ };
10078
+ PivotModel.prototype.getSeriesValueIndexes = function () {
10079
+ var _this = this;
10080
+ var seriesValueIndexes = {};
10081
+ var valueIndex = 0;
10082
+ for (var i = 0; i < this.questionsY.length; ++i) {
10083
+ var questionValueType = this.getQuestionValueType(this.questionsY[i].question);
10084
+ if (questionValueType === "enum") {
10085
+ this.questionsY[i].getValues().reverse().forEach(function (value) {
10086
+ seriesValueIndexes[_this.questionsY[i].name + "_" + value] = valueIndex++;
10087
+ });
10088
+ }
10089
+ else {
10090
+ seriesValueIndexes[this.questionsY[i].name] = valueIndex++;
10091
+ }
10092
+ }
10093
+ return seriesValueIndexes;
10094
+ };
10095
+ PivotModel.prototype.updateStatisticsSeriesValue = function (statistics, dataRow, valueIndex, seriesValueIndexes) {
10096
+ for (var j = 0; j < this.questionsY.length; ++j) {
10097
+ if (dataRow[this.questionsY[j].name] !== undefined) {
10098
+ var questionValueType = this.getQuestionValueType(this.questionsY[j].question);
10099
+ if (questionValueType === "enum" || questionValueType === "date") {
10100
+ var seriesValueIndex = seriesValueIndexes[this.questionsY[j].name + "_" + dataRow[this.questionsY[j].name]];
10101
+ statistics[seriesValueIndex][valueIndex]++;
10102
+ }
10103
+ else {
10104
+ var seriesValueIndex = seriesValueIndexes[this.questionsY[j].name];
10105
+ statistics[seriesValueIndex][valueIndex] += parseFloat(dataRow[this.questionsY[j].name]);
10106
+ }
10107
+ }
10108
+ }
10109
+ };
10110
+ PivotModel.prototype.getCalculatedValuesCore = function () {
10111
+ var _this = this;
10112
+ var statistics = [];
10113
+ var series = this.getSeriesValues();
10114
+ if (series.length === 0) {
10115
+ series.push("");
10116
+ }
10117
+ var seriesValueIndexes = this.getSeriesValueIndexes();
10118
+ if (this.valueType === "enum") {
10119
+ var values = this.getValues();
10120
+ var valueIndexes_1 = {};
10121
+ values.forEach(function (value, index) {
10122
+ valueIndexes_1[value] = index;
10123
+ });
10124
+ for (var i = 0; i < series.length; ++i) {
10125
+ statistics.push(values.map(function (i) { return 0; }));
10126
+ }
10127
+ this.data.forEach(function (dataRow) {
10128
+ var answerData = dataRow[_this.name];
10129
+ if (answerData !== undefined && valueIndexes_1[answerData] !== undefined) {
10130
+ var valueIndex = valueIndexes_1[answerData];
10131
+ if (_this.questionsY.length === 0) {
10132
+ statistics[0][valueIndex]++;
10133
+ }
10134
+ else {
10135
+ _this.updateStatisticsSeriesValue(statistics, dataRow, valueIndex, seriesValueIndexes);
10136
+ }
10137
+ }
10138
+ });
10139
+ }
10140
+ else {
10141
+ var continiousValues = this.getContiniousValues();
10142
+ var intervals_1 = this.intervals;
10143
+ for (var i = 0; i < series.length; ++i) {
10144
+ statistics.push(intervals_1.map(function (i) { return 0; }));
10145
+ }
10146
+ this._continiousData.forEach(function (dataValue) {
10147
+ for (var valueIndex = 0; valueIndex < intervals_1.length; ++valueIndex) {
10148
+ if (intervals_1[valueIndex].start <= dataValue.continious && (dataValue.continious < intervals_1[valueIndex].end || valueIndex == intervals_1.length - 1)) {
10149
+ if (_this.questionsY.length === 0) {
10150
+ statistics[0][valueIndex]++;
10151
+ }
10152
+ else {
10153
+ _this.updateStatisticsSeriesValue(statistics, dataValue.row, valueIndex, seriesValueIndexes);
10154
+ }
10155
+ break;
10156
+ }
10157
+ }
10158
+ });
10159
+ }
10160
+ return statistics;
10161
+ };
10162
+ PivotModel.prototype.getValueType = function () {
10163
+ return this.valueType;
10164
+ };
10165
+ PivotModel.prototype.isSupportSoftUpdateContent = function () {
10166
+ return false;
10167
+ };
10168
+ PivotModel.IntervalsCount = 10;
10169
+ PivotModel.UseIntervalsFrom = 10;
10170
+ return PivotModel;
10171
+ }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
10172
+
10173
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_6__.VisualizationManager.registerPivotVisualizer(PivotModel);
10174
+
10175
+
10176
+ /***/ }),
10177
+
10178
+ /***/ "./src/ranking.ts":
10179
+ /*!************************!*\
10180
+ !*** ./src/ranking.ts ***!
10181
+ \************************/
10182
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
10183
+
10184
+ "use strict";
10185
+ __webpack_require__.r(__webpack_exports__);
10186
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10187
+ /* harmony export */ RankingModel: () => (/* binding */ RankingModel)
10188
+ /* harmony export */ });
10189
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./src/utils/helpers.ts");
10190
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
10191
+ /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./selectBase */ "./src/selectBase.ts");
10192
+
10193
+
10194
+
10195
+ var RankingModel = /** @class */ (function (_super) {
10196
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(RankingModel, _super);
10197
+ function RankingModel() {
10198
+ return _super !== null && _super.apply(this, arguments) || this;
10199
+ }
10200
+ RankingModel.prototype.getQuestionResults = function () {
10201
+ var name = this.question.name;
10202
+ return this.data.map(function (dataItem) { return dataItem[name]; });
10203
+ };
10204
+ RankingModel.prototype.getEmptyData = function () {
10205
+ var choices = this.getValues();
10206
+ var data = [];
10207
+ data.length = choices.length;
10208
+ data.fill(0);
10209
+ return data;
10210
+ };
10211
+ RankingModel.prototype.getCalculatedValuesCore = function () {
10212
+ var _this = this;
10213
+ var results = this.getQuestionResults();
10214
+ var choices = this.getValues();
10215
+ var plotlyData = this.getEmptyData();
10216
+ results.forEach(function (result) {
10217
+ _this.applyResultToPlotlyData(result, plotlyData, choices);
10218
+ });
10219
+ return [plotlyData];
10220
+ };
10221
+ RankingModel.prototype.applyResultToPlotlyData = function (result, plotlyData, choices) {
10222
+ if (!result || !plotlyData || !choices)
10223
+ return;
10224
+ result.forEach(function (resultValue, resultValueIndex, result) {
10225
+ var index = choices.indexOf(resultValue);
10226
+ plotlyData[index] =
10227
+ +plotlyData[index] + (result.length - resultValueIndex);
10228
+ });
10229
+ };
10230
+ return RankingModel;
10231
+ }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
10232
+
10233
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_1__.VisualizationManager.registerVisualizer("ranking", RankingModel);
9731
10234
 
9732
10235
 
9733
10236
  /***/ }),
@@ -9750,6 +10253,8 @@ __webpack_require__.r(__webpack_exports__);
9750
10253
  /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./visualizerBase */ "./src/visualizerBase.ts");
9751
10254
  /* harmony import */ var _localizationManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./localizationManager */ "./src/localizationManager.ts");
9752
10255
  /* harmony import */ var _utils_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils/index */ "./src/utils/index.ts");
10256
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
10257
+
9753
10258
 
9754
10259
 
9755
10260
 
@@ -9780,9 +10285,9 @@ function hideEmptyAnswersInData(answersData) {
9780
10285
  seriesDataExistence.length = answersData.seriesLabels.length;
9781
10286
  var valuesDataExistence = [];
9782
10287
  valuesDataExistence.length = answersData.labels.length;
9783
- for (var valueIndex = 0; valueIndex < answersData.labels.length; valueIndex++) {
9784
- for (var seriesIndex = 0; seriesIndex < answersData.seriesLabels.length; seriesIndex++) {
9785
- if (answersData.datasets[valueIndex][seriesIndex] != 0) {
10288
+ for (var seriesIndex = 0; seriesIndex < answersData.seriesLabels.length; seriesIndex++) {
10289
+ for (var valueIndex = 0; valueIndex < answersData.labels.length; valueIndex++) {
10290
+ if (answersData.datasets[seriesIndex][valueIndex] != 0) {
9786
10291
  seriesDataExistence[seriesIndex] = true;
9787
10292
  valuesDataExistence[valueIndex] = true;
9788
10293
  }
@@ -9799,14 +10304,14 @@ function hideEmptyAnswersInData(answersData) {
9799
10304
  result.seriesLabels.push(answersData.seriesLabels[seriesIndex]);
9800
10305
  }
9801
10306
  }
9802
- for (var valueIndex = 0; valueIndex < answersData.labels.length; valueIndex++) {
9803
- if (valuesDataExistence[valueIndex]) {
10307
+ for (var seriesIndex = 0; seriesIndex < answersData.datasets.length; seriesIndex++) {
10308
+ if (seriesDataExistence[seriesIndex]) {
9804
10309
  var dataset = [];
9805
10310
  var texts = [];
9806
- for (var seriesIndex = 0; seriesIndex < answersData.datasets.length; seriesIndex++) {
9807
- if (seriesDataExistence[seriesIndex]) {
9808
- dataset.push(answersData.datasets[valueIndex][seriesIndex]);
9809
- texts.push(answersData.texts[valueIndex][seriesIndex]);
10311
+ for (var valueIndex = 0; valueIndex < answersData.labels.length; valueIndex++) {
10312
+ if (valuesDataExistence[valueIndex]) {
10313
+ dataset.push(answersData.datasets[seriesIndex][valueIndex]);
10314
+ texts.push(answersData.texts[seriesIndex][valueIndex]);
9810
10315
  }
9811
10316
  }
9812
10317
  result.datasets.push(dataset);
@@ -9844,17 +10349,36 @@ var SelectBase = /** @class */ (function (_super) {
9844
10349
  * options fields can be modified
9845
10350
  */
9846
10351
  _this.onAnswersDataReady = new survey_core__WEBPACK_IMPORTED_MODULE_1__.Event();
9847
- question.visibleChoicesChangedCallback = function () {
9848
- _this.dataProvider.raiseDataChanged();
9849
- };
10352
+ if (!!question) { // TODO: move somewhere else
10353
+ question.visibleChoicesChangedCallback = function () {
10354
+ _this.dataProvider.raiseDataChanged();
10355
+ };
10356
+ }
9850
10357
  _this._showPercentages = _this.options.showPercentages === true;
9851
10358
  _this._showOnlyPercentages = _this.options.showOnlyPercentages === true;
9852
10359
  if (_this.options.percentagePrecision) {
9853
10360
  _this._percentagePrecision = _this.options.percentagePrecision;
9854
10361
  }
10362
+ if (_this.options.transposeData !== undefined) {
10363
+ _this._transposeData = _this.options.transposeData;
10364
+ }
9855
10365
  _this._hideEmptyAnswers = _this.options.hideEmptyAnswers === true;
9856
10366
  _this._answersOrder = _this.options.answersOrder || "default";
9857
10367
  _this._showMissingAnswers = _this.isSupportMissingAnswers() && _this.options.showMissingAnswers === true;
10368
+ if (_this.options.allowExperimentalFeatures) {
10369
+ // this.chartTypes.splice(1, 0, "vbar");
10370
+ }
10371
+ if (_visualizerBase__WEBPACK_IMPORTED_MODULE_2__.VisualizerBase.chartAdapterType) {
10372
+ _this._chartAdapter = new _visualizerBase__WEBPACK_IMPORTED_MODULE_2__.VisualizerBase.chartAdapterType(_this);
10373
+ _this.chartTypes = _this._chartAdapter.getChartTypes();
10374
+ if (_this.getSeriesValues().length > 0 && _this.chartTypes.indexOf("stackedbar") === -1) {
10375
+ _this.chartTypes.push("stackedbar");
10376
+ }
10377
+ _this._chartType = _this.chartTypes[0];
10378
+ if (_this.chartTypes.indexOf(_this.options.defaultChartType) !== -1) {
10379
+ _this._chartType = _this.options.defaultChartType;
10380
+ }
10381
+ }
9858
10382
  _this.registerToolbarItem("changeChartType", function () {
9859
10383
  if (_this.chartTypes.length > 1) {
9860
10384
  return _utils_index__WEBPACK_IMPORTED_MODULE_4__.DocumentHelper.createSelector(_this.chartTypes.map(function (chartType) {
@@ -10037,6 +10561,16 @@ var SelectBase = /** @class */ (function (_super) {
10037
10561
  var selectBaseQuestion = this.question;
10038
10562
  return resultValues.map(function (value) { return survey_core__WEBPACK_IMPORTED_MODULE_1__.ItemValue.getTextOrHtmlByValue(selectBaseQuestion.choices, value); }).join(", ");
10039
10563
  };
10564
+ SelectBase.prototype.isSupportSoftUpdateContent = function () {
10565
+ return true;
10566
+ };
10567
+ SelectBase.prototype.softUpdateContent = function () {
10568
+ var _a;
10569
+ var chartNode = (_a = this.contentContainer) === null || _a === void 0 ? void 0 : _a.children[0];
10570
+ if (chartNode) {
10571
+ this._chartAdapter.update(chartNode);
10572
+ }
10573
+ };
10040
10574
  SelectBase.prototype.getSelectedItemByText = function (itemText) {
10041
10575
  var selBase = this.question;
10042
10576
  if (this.question.hasOther && itemText == selBase.otherText) {
@@ -10339,9 +10873,9 @@ var SelectBase = /** @class */ (function (_super) {
10339
10873
  var series = this.getSeriesValues();
10340
10874
  var innerCalculatedData = [];
10341
10875
  if (series.length > 0) {
10342
- for (var i = 0; i < values.length; i++) {
10876
+ for (var j = 0; j < series.length; j++) {
10343
10877
  var seriesData = [];
10344
- for (var j = 0; j < series.length; j++) {
10878
+ for (var i = 0; i < values.length; i++) {
10345
10879
  if (!!externalCalculatedData[series[j]]) {
10346
10880
  seriesData.push(externalCalculatedData[series[j]][values[i]] || 0);
10347
10881
  }
@@ -10398,6 +10932,11 @@ var SelectBase = /** @class */ (function (_super) {
10398
10932
  return SelectBase;
10399
10933
  }(_visualizerBase__WEBPACK_IMPORTED_MODULE_2__.VisualizerBase));
10400
10934
 
10935
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_5__.VisualizationManager.registerVisualizer("checkbox", SelectBase);
10936
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_5__.VisualizationManager.registerVisualizer("radiogroup", SelectBase);
10937
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_5__.VisualizationManager.registerVisualizer("dropdown", SelectBase);
10938
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_5__.VisualizationManager.registerVisualizer("imagepicker", SelectBase);
10939
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_5__.VisualizationManager.registerVisualizer("tagbox", SelectBase);
10401
10940
 
10402
10941
 
10403
10942
  /***/ }),
@@ -10955,9 +11494,15 @@ __webpack_require__.r(__webpack_exports__);
10955
11494
  var DocumentHelper = /** @class */ (function () {
10956
11495
  function DocumentHelper() {
10957
11496
  }
10958
- DocumentHelper.createSelector = function (options, isSelected, handler) {
11497
+ DocumentHelper.createSelector = function (options, isSelected, handler, title) {
10959
11498
  var selectWrapper = document.createElement("div");
10960
11499
  selectWrapper.className = "sa-question__select-wrapper";
11500
+ if (title) {
11501
+ var titleElement = DocumentHelper.createElement("span", "sa-question__select-title", {
11502
+ innerText: title,
11503
+ });
11504
+ selectWrapper.appendChild(titleElement);
11505
+ }
10961
11506
  var select = document.createElement("select");
10962
11507
  select.className = "sa-question__select";
10963
11508
  options.forEach(function (option) {
@@ -11263,7 +11808,14 @@ var VisualizationManager = /** @class */ (function () {
11263
11808
  VisualizationManager.registerAltVisualizerSelector = function (constructor) {
11264
11809
  VisualizationManager.alternativesVisualizer = constructor;
11265
11810
  };
11811
+ VisualizationManager.getPivotVisualizerConstructor = function () {
11812
+ return VisualizationManager.pivotVisualizer || _visualizerBase__WEBPACK_IMPORTED_MODULE_0__.VisualizerBase;
11813
+ };
11814
+ VisualizationManager.registerPivotVisualizer = function (constructor) {
11815
+ VisualizationManager.pivotVisualizer = constructor;
11816
+ };
11266
11817
  VisualizationManager.alternativesVisualizer = undefined;
11818
+ VisualizationManager.pivotVisualizer = undefined;
11267
11819
  VisualizationManager.vizualizers = {};
11268
11820
  return VisualizationManager;
11269
11821
  }());
@@ -11310,6 +11862,7 @@ var VisualizationMatrixDropdown = /** @class */ (function (_super) {
11310
11862
  _this._childOptions.disableLocaleSwitch = true;
11311
11863
  _this._childOptions.dataProvider = undefined;
11312
11864
  _this._childOptions.allowDynamicLayout = false;
11865
+ _this._childOptions.transposeData = true;
11313
11866
  _this._childOptions.seriesValues = question.rows.map(function (row) { return row.value; });
11314
11867
  _this._childOptions.seriesLabels = question.rows.map(function (row) { return row.text; });
11315
11868
  var innerQuestions = _this.getQuestions();
@@ -11469,6 +12022,8 @@ __webpack_require__.r(__webpack_exports__);
11469
12022
  /* harmony import */ var _layoutEngine__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./layoutEngine */ "./src/layoutEngine.ts");
11470
12023
  /* harmony import */ var _svgbundle__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./svgbundle */ "./src/svgbundle.ts");
11471
12024
  /* harmony import */ var _visualizationPanel_scss__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./visualizationPanel.scss */ "./src/visualizationPanel.scss");
12025
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
12026
+
11472
12027
 
11473
12028
 
11474
12029
 
@@ -11790,7 +12345,15 @@ var VisualizationPanel = /** @class */ (function (_super) {
11790
12345
  VisualizationPanel.prototype.buildVisualizers = function (questions) {
11791
12346
  var _this = this;
11792
12347
  questions.forEach(function (question) {
11793
- var visualizer = _this.createVisualizer(question);
12348
+ var visualizerOptions = Object.assign({}, _this.options);
12349
+ var visualizerData = _this.surveyData;
12350
+ var visualizer;
12351
+ if (Array.isArray(question)) {
12352
+ visualizer = new (_visualizationManager__WEBPACK_IMPORTED_MODULE_11__.VisualizationManager.getPivotVisualizerConstructor())(question, visualizerData, visualizerOptions);
12353
+ }
12354
+ else {
12355
+ visualizer = _this.createVisualizer(question, visualizerOptions, visualizerData);
12356
+ }
11794
12357
  if (!visualizer) {
11795
12358
  return;
11796
12359
  }
@@ -11859,6 +12422,7 @@ var VisualizationPanel = /** @class */ (function (_super) {
11859
12422
  var _this = this;
11860
12423
  _super.prototype.setLocale.call(this, newLocale);
11861
12424
  (this.questions || []).forEach(function (question) {
12425
+ question = Array.isArray(question) ? question[0] : question;
11862
12426
  var element = _this.getElement(question.name);
11863
12427
  if (!!element) {
11864
12428
  element.displayName = _this.processText(question.title);
@@ -11926,6 +12490,7 @@ var VisualizationPanel = /** @class */ (function (_super) {
11926
12490
  VisualizationPanel.prototype.buildElements = function (questions) {
11927
12491
  var _this = this;
11928
12492
  return (questions || []).map(function (question) {
12493
+ question = Array.isArray(question) ? question[0] : question;
11929
12494
  return {
11930
12495
  name: question.name,
11931
12496
  displayName: _this.processText(question.title),
@@ -12150,7 +12715,7 @@ var VisualizationPanel = /** @class */ (function (_super) {
12150
12715
  this._settingState = true;
12151
12716
  try {
12152
12717
  if (Array.isArray(newState.elements)) {
12153
- var questionNames_1 = this.questions.map(function (q) { return q.name; });
12718
+ var questionNames_1 = this.questions.map(function (q) { return Array.isArray(q) ? q[0].name : q.name; });
12154
12719
  this._elements = [].concat(newState.elements.filter(function (e) { return (questionNames_1.indexOf(e.name) !== -1); }));
12155
12720
  }
12156
12721
  if (typeof newState.locale !== "undefined")
@@ -12400,6 +12965,7 @@ var VisualizerBase = /** @class */ (function () {
12400
12965
  this.contentContainer = undefined;
12401
12966
  this.footerContainer = undefined;
12402
12967
  this._supportSelection = false;
12968
+ this._chartAdapter = undefined;
12403
12969
  /**
12404
12970
  * An event that is raised after the visualizer's content is rendered.
12405
12971
  *
@@ -12527,12 +13093,12 @@ var VisualizerBase = /** @class */ (function () {
12527
13093
  enumerable: false,
12528
13094
  configurable: true
12529
13095
  });
12530
- VisualizerBase.prototype.createVisualizer = function (question, options) {
13096
+ VisualizerBase.prototype.createVisualizer = function (question, options, data) {
12531
13097
  var visualizerOptions = Object.assign({}, options || this.options);
12532
13098
  if (visualizerOptions.dataProvider === undefined) {
12533
13099
  visualizerOptions.dataProvider = this.dataProvider;
12534
13100
  }
12535
- return _visualizerFactory__WEBPACK_IMPORTED_MODULE_3__.VisualizerFactory.createVisualizer(question, this.data, visualizerOptions);
13101
+ return _visualizerFactory__WEBPACK_IMPORTED_MODULE_3__.VisualizerFactory.createVisualizer(question, data || this.data, visualizerOptions);
12536
13102
  };
12537
13103
  Object.defineProperty(VisualizerBase.prototype, "footerVisualizer", {
12538
13104
  /**
@@ -12772,9 +13338,10 @@ var VisualizerBase = /** @class */ (function () {
12772
13338
  if (!!this.options && typeof this.options.destroyContent === "function") {
12773
13339
  this.options.destroyContent(container, this);
12774
13340
  }
12775
- else {
12776
- container.innerHTML = "";
13341
+ else if (this._chartAdapter) {
13342
+ this._chartAdapter.destroy(container.children[0]);
12777
13343
  }
13344
+ container.innerHTML = "";
12778
13345
  };
12779
13346
  VisualizerBase.prototype.renderHeader = function (container) {
12780
13347
  if (!!this.options && typeof this.options.renderHeader === "function") {
@@ -12788,11 +13355,23 @@ var VisualizerBase = /** @class */ (function () {
12788
13355
  };
12789
13356
  VisualizerBase.prototype.renderContentAsync = function (container) {
12790
13357
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
13358
+ var chartNode;
12791
13359
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
12792
- return [2 /*return*/, new Promise(function (resolve, reject) {
13360
+ switch (_a.label) {
13361
+ case 0:
13362
+ if (!this._chartAdapter) return [3 /*break*/, 2];
13363
+ chartNode = _utils__WEBPACK_IMPORTED_MODULE_4__.DocumentHelper.createElement("div");
13364
+ container.innerHTML = "";
13365
+ container.appendChild(chartNode);
13366
+ return [4 /*yield*/, this._chartAdapter.create(chartNode)];
13367
+ case 1:
13368
+ _a.sent();
13369
+ return [3 /*break*/, 3];
13370
+ case 2:
12793
13371
  container.innerText = _localizationManager__WEBPACK_IMPORTED_MODULE_5__.localization.getString("noVisualizerForQuestion");
12794
- resolve(container);
12795
- })];
13372
+ _a.label = 3;
13373
+ case 3: return [2 /*return*/, container];
13374
+ }
12796
13375
  });
12797
13376
  });
12798
13377
  };
@@ -12875,10 +13454,32 @@ var VisualizerBase = /** @class */ (function () {
12875
13454
  targetElement.appendChild(this.footerContainer);
12876
13455
  this.renderFooter(this.footerContainer);
12877
13456
  };
12878
- VisualizerBase.prototype.updateContent = function () {
13457
+ VisualizerBase.prototype.updateToolbar = function () {
13458
+ var _this = this;
13459
+ if (!!this.toolbarContainer) {
13460
+ PostponeHelper.postpone(function () {
13461
+ _this.destroyToolbar(_this.toolbarContainer);
13462
+ _this.renderToolbar(_this.toolbarContainer);
13463
+ });
13464
+ }
13465
+ };
13466
+ VisualizerBase.prototype.isSupportSoftUpdateContent = function () {
13467
+ return false;
13468
+ };
13469
+ VisualizerBase.prototype.softUpdateContent = function () {
13470
+ };
13471
+ VisualizerBase.prototype.hardUpdateContent = function () {
12879
13472
  this.destroyContent(this.contentContainer);
12880
13473
  this.renderContent(this.contentContainer);
12881
13474
  };
13475
+ VisualizerBase.prototype.updateContent = function () {
13476
+ if (!this.isSupportSoftUpdateContent()) {
13477
+ this.hardUpdateContent();
13478
+ }
13479
+ else {
13480
+ this.softUpdateContent();
13481
+ }
13482
+ };
12882
13483
  /**
12883
13484
  * Re-renders the visualizer and its content.
12884
13485
  */
@@ -13083,6 +13684,7 @@ var VisualizerBase = /** @class */ (function () {
13083
13684
  }
13084
13685
  };
13085
13686
  VisualizerBase.suppressVisualizerStubRendering = false;
13687
+ VisualizerBase.chartAdapterType = undefined;
13086
13688
  // public static otherCommentQuestionType = "comment"; // TODO: make it configureable - allow choose what kind of question/visualizer will be used for comments/others
13087
13689
  VisualizerBase.otherCommentCollapsed = true;
13088
13690
  VisualizerBase.customColors = [];
@@ -15127,17 +15729,19 @@ var __webpack_exports__ = {};
15127
15729
  __webpack_require__.r(__webpack_exports__);
15128
15730
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
15129
15731
  /* harmony export */ AlternativeVisualizersWrapper: () => (/* reexport safe */ _alternativeVizualizersWrapper__WEBPACK_IMPORTED_MODULE_27__.AlternativeVisualizersWrapper),
15130
- /* harmony export */ BooleanModel: () => (/* reexport safe */ _boolean__WEBPACK_IMPORTED_MODULE_19__.BooleanModel),
15732
+ /* harmony export */ BooleanModel: () => (/* reexport safe */ _boolean__WEBPACK_IMPORTED_MODULE_18__.BooleanModel),
15131
15733
  /* harmony export */ DataProvider: () => (/* reexport safe */ _dataProvider__WEBPACK_IMPORTED_MODULE_14__.DataProvider),
15132
- /* harmony export */ DocumentHelper: () => (/* reexport safe */ _utils_index__WEBPACK_IMPORTED_MODULE_33__.DocumentHelper),
15133
- /* harmony export */ HistogramModel: () => (/* reexport safe */ _histogram__WEBPACK_IMPORTED_MODULE_20__.HistogramModel),
15134
- /* harmony export */ Matrix: () => (/* reexport safe */ _matrix__WEBPACK_IMPORTED_MODULE_18__.Matrix),
15734
+ /* harmony export */ DocumentHelper: () => (/* reexport safe */ _utils_index__WEBPACK_IMPORTED_MODULE_35__.DocumentHelper),
15735
+ /* harmony export */ HistogramModel: () => (/* reexport safe */ _histogram__WEBPACK_IMPORTED_MODULE_19__.HistogramModel),
15736
+ /* harmony export */ Matrix: () => (/* reexport safe */ _matrix__WEBPACK_IMPORTED_MODULE_17__.Matrix),
15135
15737
  /* harmony export */ NpsAdapter: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsAdapter),
15136
15738
  /* harmony export */ NpsVisualizer: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsVisualizer),
15137
15739
  /* harmony export */ NpsVisualizerWidget: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsVisualizerWidget),
15138
- /* harmony export */ NumberModel: () => (/* reexport safe */ _number__WEBPACK_IMPORTED_MODULE_16__.NumberModel),
15740
+ /* harmony export */ NumberModel: () => (/* reexport safe */ _number__WEBPACK_IMPORTED_MODULE_20__.NumberModel),
15741
+ /* harmony export */ PivotModel: () => (/* reexport safe */ _pivot__WEBPACK_IMPORTED_MODULE_34__.PivotModel),
15139
15742
  /* harmony export */ PostponeHelper: () => (/* reexport safe */ _visualizerBase__WEBPACK_IMPORTED_MODULE_21__.PostponeHelper),
15140
- /* harmony export */ SelectBase: () => (/* reexport safe */ _selectBase__WEBPACK_IMPORTED_MODULE_17__.SelectBase),
15743
+ /* harmony export */ RankingModel: () => (/* reexport safe */ _ranking__WEBPACK_IMPORTED_MODULE_33__.RankingModel),
15744
+ /* harmony export */ SelectBase: () => (/* reexport safe */ _selectBase__WEBPACK_IMPORTED_MODULE_16__.SelectBase),
15141
15745
  /* harmony export */ StatisticsTable: () => (/* reexport safe */ _statistics_table__WEBPACK_IMPORTED_MODULE_31__.StatisticsTable),
15142
15746
  /* harmony export */ StatisticsTableAdapter: () => (/* reexport safe */ _statistics_table__WEBPACK_IMPORTED_MODULE_31__.StatisticsTableAdapter),
15143
15747
  /* harmony export */ Text: () => (/* reexport safe */ _text__WEBPACK_IMPORTED_MODULE_30__.Text),
@@ -15152,7 +15756,7 @@ __webpack_require__.r(__webpack_exports__);
15152
15756
  /* harmony export */ WordCloud: () => (/* reexport safe */ _wordcloud_wordcloud__WEBPACK_IMPORTED_MODULE_28__.WordCloud),
15153
15757
  /* harmony export */ WordCloudAdapter: () => (/* reexport safe */ _wordcloud_wordcloud__WEBPACK_IMPORTED_MODULE_28__.WordCloudAdapter),
15154
15758
  /* harmony export */ defaultStatisticsCalculator: () => (/* reexport safe */ _visualizerBase__WEBPACK_IMPORTED_MODULE_21__.defaultStatisticsCalculator),
15155
- /* harmony export */ hideEmptyAnswersInData: () => (/* reexport safe */ _selectBase__WEBPACK_IMPORTED_MODULE_17__.hideEmptyAnswersInData),
15759
+ /* harmony export */ hideEmptyAnswersInData: () => (/* reexport safe */ _selectBase__WEBPACK_IMPORTED_MODULE_16__.hideEmptyAnswersInData),
15156
15760
  /* harmony export */ localization: () => (/* reexport safe */ _localizationManager__WEBPACK_IMPORTED_MODULE_0__.localization),
15157
15761
  /* harmony export */ surveyStrings: () => (/* reexport safe */ _localizationManager__WEBPACK_IMPORTED_MODULE_0__.surveyStrings),
15158
15762
  /* harmony export */ textHelper: () => (/* reexport safe */ _wordcloud_stopwords_index__WEBPACK_IMPORTED_MODULE_29__.textHelper)
@@ -15173,11 +15777,11 @@ __webpack_require__.r(__webpack_exports__);
15173
15777
  /* harmony import */ var _analytics_localization_finnish__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../analytics-localization/finnish */ "./src/analytics-localization/finnish.ts");
15174
15778
  /* harmony import */ var _dataProvider__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../dataProvider */ "./src/dataProvider.ts");
15175
15779
  /* harmony import */ var _visualizerFactory__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../visualizerFactory */ "./src/visualizerFactory.ts");
15176
- /* harmony import */ var _number__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../number */ "./src/number.ts");
15177
- /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../selectBase */ "./src/selectBase.ts");
15178
- /* harmony import */ var _matrix__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../matrix */ "./src/matrix.ts");
15179
- /* harmony import */ var _boolean__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../boolean */ "./src/boolean.ts");
15180
- /* harmony import */ var _histogram__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../histogram */ "./src/histogram.ts");
15780
+ /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../selectBase */ "./src/selectBase.ts");
15781
+ /* harmony import */ var _matrix__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../matrix */ "./src/matrix.ts");
15782
+ /* harmony import */ var _boolean__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../boolean */ "./src/boolean.ts");
15783
+ /* harmony import */ var _histogram__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../histogram */ "./src/histogram.ts");
15784
+ /* harmony import */ var _number__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../number */ "./src/number.ts");
15181
15785
  /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../visualizerBase */ "./src/visualizerBase.ts");
15182
15786
  /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../visualizationManager */ "./src/visualizationManager.ts");
15183
15787
  /* harmony import */ var _visualizationPanel__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../visualizationPanel */ "./src/visualizationPanel.ts");
@@ -15190,7 +15794,9 @@ __webpack_require__.r(__webpack_exports__);
15190
15794
  /* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../text */ "./src/text.ts");
15191
15795
  /* harmony import */ var _statistics_table__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../statistics-table */ "./src/statistics-table.ts");
15192
15796
  /* harmony import */ var _nps__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../nps */ "./src/nps.ts");
15193
- /* harmony import */ var _utils_index__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../utils/index */ "./src/utils/index.ts");
15797
+ /* harmony import */ var _ranking__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../ranking */ "./src/ranking.ts");
15798
+ /* harmony import */ var _pivot__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ../pivot */ "./src/pivot.ts");
15799
+ /* harmony import */ var _utils_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ../utils/index */ "./src/utils/index.ts");
15194
15800
 
15195
15801
  //localization
15196
15802
 
@@ -15224,6 +15830,8 @@ __webpack_require__.r(__webpack_exports__);
15224
15830
 
15225
15831
 
15226
15832
 
15833
+
15834
+
15227
15835
 
15228
15836
 
15229
15837