survey-analytics 2.2.2 → 2.2.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 (46) hide show
  1. package/fesm/shared.mjs +10 -2
  2. package/fesm/shared.mjs.map +1 -1
  3. package/fesm/shared2.mjs +412 -31
  4. package/fesm/shared2.mjs.map +1 -1
  5. package/fesm/survey.analytics.core.mjs +2 -2
  6. package/fesm/survey.analytics.mjs +158 -150
  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/entries/summary.core.d.ts +1 -0
  16. package/survey-analytics.types/localizationManager.d.ts +2 -0
  17. package/survey-analytics.types/matrix.d.ts +0 -1
  18. package/survey-analytics.types/pivot.d.ts +62 -0
  19. package/survey-analytics.types/plotly/histogram.d.ts +0 -1
  20. package/survey-analytics.types/plotly/index.d.ts +1 -0
  21. package/survey-analytics.types/plotly/pivot.d.ts +12 -0
  22. package/survey-analytics.types/plotly/selectBase.d.ts +0 -1
  23. package/survey-analytics.types/selectBase.d.ts +1 -1
  24. package/survey-analytics.types/utils/index.d.ts +1 -1
  25. package/survey-analytics.types/visualizationManager.d.ts +3 -0
  26. package/survey-analytics.types/visualizerBase.d.ts +2 -1
  27. package/survey.analytics.core.css +7 -1
  28. package/survey.analytics.core.css.map +1 -1
  29. package/survey.analytics.core.js +487 -34
  30. package/survey.analytics.core.js.map +1 -1
  31. package/survey.analytics.core.min.css +2 -2
  32. package/survey.analytics.core.min.js +1 -1
  33. package/survey.analytics.core.min.js.LICENSE.txt +1 -1
  34. package/survey.analytics.css +7 -1
  35. package/survey.analytics.css.map +1 -1
  36. package/survey.analytics.js +682 -180
  37. package/survey.analytics.js.map +1 -1
  38. package/survey.analytics.min.css +2 -2
  39. package/survey.analytics.min.js +1 -1
  40. package/survey.analytics.min.js.LICENSE.txt +1 -1
  41. package/survey.analytics.tabulator.css +1 -1
  42. package/survey.analytics.tabulator.js +10 -2
  43. package/survey.analytics.tabulator.js.map +1 -1
  44. package/survey.analytics.tabulator.min.css +1 -1
  45. package/survey.analytics.tabulator.min.js +1 -1
  46. package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.2.2
2
+ * surveyjs - SurveyJS Dashboard library v2.2.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
  */
@@ -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"),
@@ -8729,6 +8737,7 @@ var HistogramModel = /** @class */ (function (_super) {
8729
8737
  _this._continiousData = undefined;
8730
8738
  _this._cachedIntervals = undefined;
8731
8739
  _this._intervalPrecision = 2;
8740
+ _this._transposeData = false;
8732
8741
  if (_this.options.intervalPrecision !== undefined) {
8733
8742
  _this._intervalPrecision = _this.options.intervalPrecision;
8734
8743
  }
@@ -9276,7 +9285,9 @@ __webpack_require__.r(__webpack_exports__);
9276
9285
  var Matrix = /** @class */ (function (_super) {
9277
9286
  (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(Matrix, _super);
9278
9287
  function Matrix(question, data, options, name) {
9279
- return _super.call(this, question, data, options, name || "matrix") || this;
9288
+ var _this = _super.call(this, question, data, options, name || "matrix") || this;
9289
+ _this._transposeData = true;
9290
+ return _this;
9280
9291
  // this.getAnswersData();
9281
9292
  }
9282
9293
  Object.defineProperty(Matrix.prototype, "matrixQuestion", {
@@ -9359,17 +9370,6 @@ var Matrix = /** @class */ (function (_super) {
9359
9370
  }
9360
9371
  return result;
9361
9372
  };
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
9373
  return Matrix;
9374
9374
  }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
9375
9375
 
@@ -9730,6 +9730,416 @@ var NumberModel = /** @class */ (function (_super) {
9730
9730
 
9731
9731
 
9732
9732
 
9733
+ /***/ }),
9734
+
9735
+ /***/ "./src/pivot.ts":
9736
+ /*!**********************!*\
9737
+ !*** ./src/pivot.ts ***!
9738
+ \**********************/
9739
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9740
+
9741
+ "use strict";
9742
+ __webpack_require__.r(__webpack_exports__);
9743
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9744
+ /* harmony export */ PivotModel: () => (/* binding */ PivotModel)
9745
+ /* harmony export */ });
9746
+ /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./src/utils/helpers.ts");
9747
+ /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! survey-core */ "survey-core");
9748
+ /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
9749
+ /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./selectBase */ "./src/selectBase.ts");
9750
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./src/utils/index.ts");
9751
+ /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./visualizerBase */ "./src/visualizerBase.ts");
9752
+ /* harmony import */ var _localizationManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./localizationManager */ "./src/localizationManager.ts");
9753
+
9754
+
9755
+
9756
+
9757
+
9758
+
9759
+ var PivotModel = /** @class */ (function (_super) {
9760
+ (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(PivotModel, _super);
9761
+ function PivotModel(questions, data, options, name) {
9762
+ var _this = _super.call(this, null, data, options, name || "pivot") || this;
9763
+ _this.questions = questions;
9764
+ _this.valueType = "enum";
9765
+ _this._cachedValues = undefined;
9766
+ _this._continiousData = undefined;
9767
+ _this._cachedIntervals = undefined;
9768
+ _this._intervalPrecision = 2;
9769
+ _this.axisYSelectors = [];
9770
+ _this.axisYQuestionNames = [];
9771
+ _this.questionsY = [];
9772
+ _this.questions = _this.questions.filter(function (question) { return ["matrixdropdown", "matrixdynamic", "matrix", "file", "signature", "multipletext", "comment", "html", "image"].indexOf(question.getType()) === -1; });
9773
+ if (_this.options.intervalPrecision !== undefined) {
9774
+ _this._intervalPrecision = _this.options.intervalPrecision;
9775
+ }
9776
+ _this.axisXQuestionName = _this.questions.length > 0 ? _this.questions[0].name : undefined;
9777
+ _this.registerToolbarItem("axisXSelector", function () {
9778
+ return _this.axisXSelector = _utils__WEBPACK_IMPORTED_MODULE_3__.DocumentHelper.createSelector(_this.questions.map(function (question) {
9779
+ return {
9780
+ value: question.name,
9781
+ text: question.title || question.name,
9782
+ };
9783
+ }), function (option) { return _this.axisXQuestionName === option.value; }, function (e) { _this.axisXQuestionName = e.target.value; _this.setupPivot(); }, _localizationManager__WEBPACK_IMPORTED_MODULE_5__.localization.getString("axisXSelectorTitle"));
9784
+ });
9785
+ _this.registerToolbarItem("axisYSelector0", _this.createYSelecterGenerator());
9786
+ _this.setupPivot();
9787
+ return _this;
9788
+ }
9789
+ PivotModel.prototype.createYSelecterGenerator = function () {
9790
+ var _this = this;
9791
+ var selectorIndex = this.axisYSelectors.length;
9792
+ return function () {
9793
+ var selector = _this.axisYSelectors[selectorIndex];
9794
+ if (!selector) {
9795
+ selector = _this.createAxisYSelector(selectorIndex);
9796
+ _this.axisYSelectors.push(selector);
9797
+ }
9798
+ return selector;
9799
+ };
9800
+ };
9801
+ PivotModel.prototype.setAxisQuestions = function () {
9802
+ var axisQuestionNames = [];
9803
+ for (var _i = 0; _i < arguments.length; _i++) {
9804
+ axisQuestionNames[_i] = arguments[_i];
9805
+ }
9806
+ if (axisQuestionNames.length < 1) {
9807
+ return;
9808
+ }
9809
+ this.axisXQuestionName = axisQuestionNames[0];
9810
+ this.axisYQuestionNames = axisQuestionNames.splice(1);
9811
+ this.setupPivot();
9812
+ };
9813
+ PivotModel.prototype.onAxisYSelectorChanged = function (index, value) {
9814
+ this.axisYQuestionNames[index] = value;
9815
+ if (index < this.axisYSelectors.length - 1) {
9816
+ if (!value) {
9817
+ for (var i = index + 1; i < this.axisYSelectors.length; ++i) {
9818
+ this.unregisterToolbarItem("axisYSelector" + i);
9819
+ }
9820
+ this.axisYSelectors = this.axisYSelectors.slice(0, index + 1);
9821
+ this.axisYQuestionNames = this.axisYQuestionNames.slice(0, index + 1);
9822
+ this.updateToolbar();
9823
+ }
9824
+ }
9825
+ else {
9826
+ if (!!value) {
9827
+ this.registerToolbarItem("axisYSelector" + this.axisYSelectors.length, this.createYSelecterGenerator());
9828
+ this.updateToolbar();
9829
+ }
9830
+ }
9831
+ this.setupPivot();
9832
+ };
9833
+ PivotModel.prototype.createAxisYSelector = function (selectorIndex) {
9834
+ var _this = this;
9835
+ var selector = _utils__WEBPACK_IMPORTED_MODULE_3__.DocumentHelper.createSelector([{ value: "", text: "Not selected" }].concat(this.questions.map(function (question) {
9836
+ return {
9837
+ value: question.name,
9838
+ text: question.title || question.name,
9839
+ };
9840
+ })), 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"));
9841
+ return selector;
9842
+ };
9843
+ PivotModel.prototype.getQuestionValueType = function (question) {
9844
+ var questionType = question.getType();
9845
+ if (questionType === "text" && (question["inputType"] === "date" || question["inputType"] === "datetime")) {
9846
+ return "date";
9847
+ }
9848
+ else if (questionType === "text" || questionType === "rating" || questionType === "expression" || questionType === "range") {
9849
+ return "number";
9850
+ }
9851
+ return "enum";
9852
+ };
9853
+ PivotModel.prototype.setupPivot = function () {
9854
+ var _this = this;
9855
+ var questionX = this.questions.filter(function (q) { return q.name === _this.axisXQuestionName; })[0];
9856
+ if (!questionX) {
9857
+ return;
9858
+ }
9859
+ this.question = questionX;
9860
+ this.valueType = this.getQuestionValueType(questionX);
9861
+ this.questionsY = this.axisYQuestionNames.map(function (name) {
9862
+ var questionY = _this.questions.filter(function (q) { return q.name === name; })[0];
9863
+ if (!!questionY) {
9864
+ return _this.getQuestionValueType(questionY) === "enum" ? new _selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase(questionY, []) : new _visualizerBase__WEBPACK_IMPORTED_MODULE_4__.VisualizerBase(questionY, []);
9865
+ }
9866
+ }).filter(function (q) { return !!q; });
9867
+ this.onDataChanged();
9868
+ };
9869
+ PivotModel.prototype.reset = function () {
9870
+ this._continiousData = undefined;
9871
+ this._cachedValues = undefined;
9872
+ this._cachedIntervals = undefined;
9873
+ };
9874
+ PivotModel.prototype.getContiniousValue = function (value) {
9875
+ if (this.valueType === "date") {
9876
+ return Date.parse(value);
9877
+ }
9878
+ return parseFloat(value);
9879
+ };
9880
+ PivotModel.prototype.getString = function (value) {
9881
+ if (this.valueType === "date") {
9882
+ return new Date(value).toLocaleDateString();
9883
+ }
9884
+ return "" + value;
9885
+ };
9886
+ PivotModel.prototype.toPrecision = function (value) {
9887
+ var base = Math.pow(10, this._intervalPrecision);
9888
+ return Math.round(base * value) / base;
9889
+ };
9890
+ PivotModel.prototype.getSelectedItemByText = function (itemText) {
9891
+ if (this.hasCustomIntervals || this.getContiniousValues().length > PivotModel.UseIntervalsFrom) {
9892
+ var interval = this.intervals.filter(function (interval) { return interval.label === itemText; })[0];
9893
+ return new survey_core__WEBPACK_IMPORTED_MODULE_1__.ItemValue(interval, interval !== undefined ? interval.label : "");
9894
+ }
9895
+ var labels = this.getLabels();
9896
+ var labelIndex = labels.indexOf(itemText);
9897
+ return new survey_core__WEBPACK_IMPORTED_MODULE_1__.ItemValue(this.getValues()[labelIndex], labels[labelIndex]);
9898
+ };
9899
+ /**
9900
+ * Updates visualizer data.
9901
+ */
9902
+ PivotModel.prototype.updateData = function (data) {
9903
+ this.reset();
9904
+ _super.prototype.updateData.call(this, data);
9905
+ };
9906
+ PivotModel.prototype.onDataChanged = function () {
9907
+ this.reset();
9908
+ _super.prototype.onDataChanged.call(this);
9909
+ };
9910
+ PivotModel.prototype.getContiniousValues = function () {
9911
+ var _this = this;
9912
+ if (this._cachedValues === undefined) {
9913
+ this._continiousData = [];
9914
+ if (this.valueType === "enum") {
9915
+ this._cachedValues = [];
9916
+ return this._cachedValues;
9917
+ }
9918
+ var hash_1 = {};
9919
+ this.data.forEach(function (dataItem) {
9920
+ var answerData = dataItem[_this.name];
9921
+ if (answerData !== undefined) {
9922
+ // TODO: _continiousData should be sorted in order to speed-up statistics calculation in the getData function
9923
+ _this._continiousData.push({ continious: _this.getContiniousValue(answerData), row: dataItem });
9924
+ hash_1[answerData] = { value: answerData, row: dataItem };
9925
+ }
9926
+ });
9927
+ this._cachedValues = Object.keys(hash_1).map(function (key) { return ({ original: hash_1[key].value, continious: _this.getContiniousValue(key), row: hash_1[key].row }); });
9928
+ this._cachedValues.sort(function (a, b) { return a.continious - b.continious; });
9929
+ }
9930
+ return this._cachedValues;
9931
+ };
9932
+ PivotModel.prototype.isSupportAnswersOrder = function () {
9933
+ return false;
9934
+ };
9935
+ PivotModel.prototype.isSupportMissingAnswers = function () {
9936
+ return false;
9937
+ };
9938
+ Object.defineProperty(PivotModel.prototype, "needUseRateValues", {
9939
+ get: function () {
9940
+ return this.question.getType() == "rating" && Array.isArray(this.question["rateValues"]) && this.question["rateValues"].length > 0;
9941
+ },
9942
+ enumerable: false,
9943
+ configurable: true
9944
+ });
9945
+ PivotModel.prototype.getSeriesValues = function () {
9946
+ var _this = this;
9947
+ if (this.questionsY.length === 0) {
9948
+ return this.options.seriesValues || [];
9949
+ }
9950
+ var seriesValues = [];
9951
+ this.questionsY.forEach(function (q) {
9952
+ if (_this.getQuestionValueType(q.question) === "enum") {
9953
+ seriesValues.push.apply(seriesValues, q.getValues().reverse());
9954
+ }
9955
+ else {
9956
+ seriesValues.push(q.question.name);
9957
+ }
9958
+ });
9959
+ return seriesValues;
9960
+ };
9961
+ PivotModel.prototype.getSeriesLabels = function () {
9962
+ var _this = this;
9963
+ if (this.questionsY.length === 0) {
9964
+ return this.getSeriesValues();
9965
+ }
9966
+ var seriesLabels = [];
9967
+ this.questionsY.forEach(function (q) {
9968
+ if (_this.getQuestionValueType(q.question) === "enum") {
9969
+ seriesLabels.push.apply(seriesLabels, q.getLabels().reverse());
9970
+ }
9971
+ else {
9972
+ seriesLabels.push(q.question.title || q.question.name);
9973
+ }
9974
+ });
9975
+ return seriesLabels;
9976
+ };
9977
+ PivotModel.prototype.getValues = function () {
9978
+ if (this.valueType === "enum") {
9979
+ return _super.prototype.getValues.call(this).reverse();
9980
+ }
9981
+ return this.intervals.map(function (interval) { return interval.start; });
9982
+ };
9983
+ PivotModel.prototype.getLabels = function () {
9984
+ if (this.valueType === "enum") {
9985
+ return _super.prototype.getLabels.call(this).reverse();
9986
+ }
9987
+ return this.intervals.map(function (interval) { return interval.label; });
9988
+ };
9989
+ Object.defineProperty(PivotModel.prototype, "hasCustomIntervals", {
9990
+ get: function () {
9991
+ return !!this.questionOptions && Array.isArray(this.questionOptions.intervals);
9992
+ },
9993
+ enumerable: false,
9994
+ configurable: true
9995
+ });
9996
+ Object.defineProperty(PivotModel.prototype, "intervals", {
9997
+ get: function () {
9998
+ if (this.hasCustomIntervals) {
9999
+ return this.questionOptions.intervals;
10000
+ }
10001
+ if (this.question.getType() == "rating") {
10002
+ if (this.needUseRateValues) {
10003
+ var rateValues_1 = this.question["rateValues"];
10004
+ rateValues_1.sort(function (iv1, iv2) { return iv1.value - iv2.value; });
10005
+ return rateValues_1.map(function (rateValue, i) { return ({
10006
+ start: rateValue.value,
10007
+ end: i < rateValues_1.length - 1 ? rateValues_1[i + 1].value : rateValue.value + 1,
10008
+ label: rateValue.text
10009
+ }); });
10010
+ }
10011
+ else {
10012
+ var rateIntervals = [];
10013
+ for (var i = (this.question["rateMin"] || 0); i <= (this.question["rateMax"] || (PivotModel.IntervalsCount - 1)); i += (this.question["rateStep"] || 1)) {
10014
+ rateIntervals.push({
10015
+ start: i,
10016
+ end: i + 1,
10017
+ label: "" + (!!this.question["rateMin"] && !!this.question["rateMax"] ? i : (i + "-" + (i + 1)))
10018
+ });
10019
+ }
10020
+ return rateIntervals;
10021
+ }
10022
+ }
10023
+ if (this._cachedIntervals === undefined) {
10024
+ var continiousValues = this.getContiniousValues();
10025
+ this._cachedIntervals = [];
10026
+ if (continiousValues.length) {
10027
+ var start = continiousValues[0].continious;
10028
+ var end = continiousValues[continiousValues.length - 1].continious;
10029
+ var intervalsCount = PivotModel.IntervalsCount;
10030
+ var delta = (end - start) / intervalsCount;
10031
+ for (var i = 0; i < intervalsCount; ++i) {
10032
+ var next = start + delta;
10033
+ var istart = this.toPrecision(start);
10034
+ var inext = this.toPrecision(next);
10035
+ this._cachedIntervals.push({
10036
+ start: istart,
10037
+ end: i < intervalsCount - 1 ? inext : inext + delta / 100,
10038
+ label: "" + this.getString(istart) + "-" + this.getString(inext)
10039
+ });
10040
+ start = next;
10041
+ }
10042
+ }
10043
+ }
10044
+ return this._cachedIntervals;
10045
+ },
10046
+ enumerable: false,
10047
+ configurable: true
10048
+ });
10049
+ PivotModel.prototype.convertFromExternalData = function (externalCalculatedData) {
10050
+ return [externalCalculatedData];
10051
+ };
10052
+ PivotModel.prototype.getSeriesValueIndexes = function () {
10053
+ var _this = this;
10054
+ var seriesValueIndexes = {};
10055
+ var valueIndex = 0;
10056
+ for (var i = 0; i < this.questionsY.length; ++i) {
10057
+ var questionValueType = this.getQuestionValueType(this.questionsY[i].question);
10058
+ if (questionValueType === "enum") {
10059
+ this.questionsY[i].getValues().reverse().forEach(function (value) {
10060
+ seriesValueIndexes[_this.questionsY[i].name + "_" + value] = valueIndex++;
10061
+ });
10062
+ }
10063
+ else {
10064
+ seriesValueIndexes[this.questionsY[i].name] = valueIndex++;
10065
+ }
10066
+ }
10067
+ return seriesValueIndexes;
10068
+ };
10069
+ PivotModel.prototype.updateStatisticsSeriesValue = function (statistics, dataRow, valueIndex, seriesValueIndexes) {
10070
+ for (var j = 0; j < this.questionsY.length; ++j) {
10071
+ if (dataRow[this.questionsY[j].name] !== undefined) {
10072
+ var questionValueType = this.getQuestionValueType(this.questionsY[j].question);
10073
+ if (questionValueType === "enum" || questionValueType === "date") {
10074
+ var seriesValueIndex = seriesValueIndexes[this.questionsY[j].name + "_" + dataRow[this.questionsY[j].name]];
10075
+ statistics[seriesValueIndex][valueIndex]++;
10076
+ }
10077
+ else {
10078
+ var seriesValueIndex = seriesValueIndexes[this.questionsY[j].name];
10079
+ statistics[seriesValueIndex][valueIndex] += parseFloat(dataRow[this.questionsY[j].name]);
10080
+ }
10081
+ }
10082
+ }
10083
+ };
10084
+ PivotModel.prototype.getCalculatedValuesCore = function () {
10085
+ var _this = this;
10086
+ var statistics = [];
10087
+ var series = this.getSeriesValues();
10088
+ if (series.length === 0) {
10089
+ series.push("");
10090
+ }
10091
+ var seriesValueIndexes = this.getSeriesValueIndexes();
10092
+ if (this.valueType === "enum") {
10093
+ var values = this.getValues();
10094
+ var valueIndexes_1 = {};
10095
+ values.forEach(function (value, index) {
10096
+ valueIndexes_1[value] = index;
10097
+ });
10098
+ for (var i = 0; i < series.length; ++i) {
10099
+ statistics.push(values.map(function (i) { return 0; }));
10100
+ }
10101
+ this.data.forEach(function (dataRow) {
10102
+ var answerData = dataRow[_this.name];
10103
+ if (answerData !== undefined && valueIndexes_1[answerData] !== undefined) {
10104
+ var valueIndex = valueIndexes_1[answerData];
10105
+ if (_this.questionsY.length === 0) {
10106
+ statistics[0][valueIndex]++;
10107
+ }
10108
+ else {
10109
+ _this.updateStatisticsSeriesValue(statistics, dataRow, valueIndex, seriesValueIndexes);
10110
+ }
10111
+ }
10112
+ });
10113
+ }
10114
+ else {
10115
+ var continiousValues = this.getContiniousValues();
10116
+ var intervals_1 = this.intervals;
10117
+ for (var i = 0; i < series.length; ++i) {
10118
+ statistics.push(intervals_1.map(function (i) { return 0; }));
10119
+ }
10120
+ this._continiousData.forEach(function (dataValue) {
10121
+ for (var valueIndex = 0; valueIndex < intervals_1.length; ++valueIndex) {
10122
+ if (intervals_1[valueIndex].start <= dataValue.continious && (dataValue.continious < intervals_1[valueIndex].end || valueIndex == intervals_1.length - 1)) {
10123
+ if (_this.questionsY.length === 0) {
10124
+ statistics[0][valueIndex]++;
10125
+ }
10126
+ else {
10127
+ _this.updateStatisticsSeriesValue(statistics, dataValue.row, valueIndex, seriesValueIndexes);
10128
+ }
10129
+ break;
10130
+ }
10131
+ }
10132
+ });
10133
+ }
10134
+ return statistics;
10135
+ };
10136
+ PivotModel.IntervalsCount = 10;
10137
+ PivotModel.UseIntervalsFrom = 10;
10138
+ return PivotModel;
10139
+ }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
10140
+
10141
+
10142
+
9733
10143
  /***/ }),
9734
10144
 
9735
10145
  /***/ "./src/selectBase.ts":
@@ -9780,9 +10190,9 @@ function hideEmptyAnswersInData(answersData) {
9780
10190
  seriesDataExistence.length = answersData.seriesLabels.length;
9781
10191
  var valuesDataExistence = [];
9782
10192
  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) {
10193
+ for (var seriesIndex = 0; seriesIndex < answersData.seriesLabels.length; seriesIndex++) {
10194
+ for (var valueIndex = 0; valueIndex < answersData.labels.length; valueIndex++) {
10195
+ if (answersData.datasets[seriesIndex][valueIndex] != 0) {
9786
10196
  seriesDataExistence[seriesIndex] = true;
9787
10197
  valuesDataExistence[valueIndex] = true;
9788
10198
  }
@@ -9799,14 +10209,14 @@ function hideEmptyAnswersInData(answersData) {
9799
10209
  result.seriesLabels.push(answersData.seriesLabels[seriesIndex]);
9800
10210
  }
9801
10211
  }
9802
- for (var valueIndex = 0; valueIndex < answersData.labels.length; valueIndex++) {
9803
- if (valuesDataExistence[valueIndex]) {
10212
+ for (var seriesIndex = 0; seriesIndex < answersData.datasets.length; seriesIndex++) {
10213
+ if (seriesDataExistence[seriesIndex]) {
9804
10214
  var dataset = [];
9805
10215
  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]);
10216
+ for (var valueIndex = 0; valueIndex < answersData.labels.length; valueIndex++) {
10217
+ if (valuesDataExistence[valueIndex]) {
10218
+ dataset.push(answersData.datasets[seriesIndex][valueIndex]);
10219
+ texts.push(answersData.texts[seriesIndex][valueIndex]);
9810
10220
  }
9811
10221
  }
9812
10222
  result.datasets.push(dataset);
@@ -9844,14 +10254,19 @@ var SelectBase = /** @class */ (function (_super) {
9844
10254
  * options fields can be modified
9845
10255
  */
9846
10256
  _this.onAnswersDataReady = new survey_core__WEBPACK_IMPORTED_MODULE_1__.Event();
9847
- question.visibleChoicesChangedCallback = function () {
9848
- _this.dataProvider.raiseDataChanged();
9849
- };
10257
+ if (!!question) { // TODO: move somewhere else
10258
+ question.visibleChoicesChangedCallback = function () {
10259
+ _this.dataProvider.raiseDataChanged();
10260
+ };
10261
+ }
9850
10262
  _this._showPercentages = _this.options.showPercentages === true;
9851
10263
  _this._showOnlyPercentages = _this.options.showOnlyPercentages === true;
9852
10264
  if (_this.options.percentagePrecision) {
9853
10265
  _this._percentagePrecision = _this.options.percentagePrecision;
9854
10266
  }
10267
+ if (_this.options.transposeData !== undefined) {
10268
+ _this._transposeData = _this.options.transposeData;
10269
+ }
9855
10270
  _this._hideEmptyAnswers = _this.options.hideEmptyAnswers === true;
9856
10271
  _this._answersOrder = _this.options.answersOrder || "default";
9857
10272
  _this._showMissingAnswers = _this.isSupportMissingAnswers() && _this.options.showMissingAnswers === true;
@@ -10339,9 +10754,9 @@ var SelectBase = /** @class */ (function (_super) {
10339
10754
  var series = this.getSeriesValues();
10340
10755
  var innerCalculatedData = [];
10341
10756
  if (series.length > 0) {
10342
- for (var i = 0; i < values.length; i++) {
10757
+ for (var j = 0; j < series.length; j++) {
10343
10758
  var seriesData = [];
10344
- for (var j = 0; j < series.length; j++) {
10759
+ for (var i = 0; i < values.length; i++) {
10345
10760
  if (!!externalCalculatedData[series[j]]) {
10346
10761
  seriesData.push(externalCalculatedData[series[j]][values[i]] || 0);
10347
10762
  }
@@ -10955,9 +11370,15 @@ __webpack_require__.r(__webpack_exports__);
10955
11370
  var DocumentHelper = /** @class */ (function () {
10956
11371
  function DocumentHelper() {
10957
11372
  }
10958
- DocumentHelper.createSelector = function (options, isSelected, handler) {
11373
+ DocumentHelper.createSelector = function (options, isSelected, handler, title) {
10959
11374
  var selectWrapper = document.createElement("div");
10960
11375
  selectWrapper.className = "sa-question__select-wrapper";
11376
+ if (title) {
11377
+ var titleElement = DocumentHelper.createElement("span", "sa-question__select-title", {
11378
+ innerText: title,
11379
+ });
11380
+ selectWrapper.appendChild(titleElement);
11381
+ }
10961
11382
  var select = document.createElement("select");
10962
11383
  select.className = "sa-question__select";
10963
11384
  options.forEach(function (option) {
@@ -11263,7 +11684,14 @@ var VisualizationManager = /** @class */ (function () {
11263
11684
  VisualizationManager.registerAltVisualizerSelector = function (constructor) {
11264
11685
  VisualizationManager.alternativesVisualizer = constructor;
11265
11686
  };
11687
+ VisualizationManager.getPivotVisualizerConstructor = function () {
11688
+ return VisualizationManager.pivotVisualizer || _visualizerBase__WEBPACK_IMPORTED_MODULE_0__.VisualizerBase;
11689
+ };
11690
+ VisualizationManager.registerPivotVisualizer = function (constructor) {
11691
+ VisualizationManager.pivotVisualizer = constructor;
11692
+ };
11266
11693
  VisualizationManager.alternativesVisualizer = undefined;
11694
+ VisualizationManager.pivotVisualizer = undefined;
11267
11695
  VisualizationManager.vizualizers = {};
11268
11696
  return VisualizationManager;
11269
11697
  }());
@@ -11310,6 +11738,7 @@ var VisualizationMatrixDropdown = /** @class */ (function (_super) {
11310
11738
  _this._childOptions.disableLocaleSwitch = true;
11311
11739
  _this._childOptions.dataProvider = undefined;
11312
11740
  _this._childOptions.allowDynamicLayout = false;
11741
+ _this._childOptions.transposeData = true;
11313
11742
  _this._childOptions.seriesValues = question.rows.map(function (row) { return row.value; });
11314
11743
  _this._childOptions.seriesLabels = question.rows.map(function (row) { return row.text; });
11315
11744
  var innerQuestions = _this.getQuestions();
@@ -11469,6 +11898,8 @@ __webpack_require__.r(__webpack_exports__);
11469
11898
  /* harmony import */ var _layoutEngine__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./layoutEngine */ "./src/layoutEngine.ts");
11470
11899
  /* harmony import */ var _svgbundle__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./svgbundle */ "./src/svgbundle.ts");
11471
11900
  /* harmony import */ var _visualizationPanel_scss__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./visualizationPanel.scss */ "./src/visualizationPanel.scss");
11901
+ /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./visualizationManager */ "./src/visualizationManager.ts");
11902
+
11472
11903
 
11473
11904
 
11474
11905
 
@@ -11790,7 +12221,15 @@ var VisualizationPanel = /** @class */ (function (_super) {
11790
12221
  VisualizationPanel.prototype.buildVisualizers = function (questions) {
11791
12222
  var _this = this;
11792
12223
  questions.forEach(function (question) {
11793
- var visualizer = _this.createVisualizer(question);
12224
+ var visualizerOptions = Object.assign({}, _this.options);
12225
+ var visualizerData = _this.surveyData;
12226
+ var visualizer;
12227
+ if (Array.isArray(question)) {
12228
+ visualizer = new (_visualizationManager__WEBPACK_IMPORTED_MODULE_11__.VisualizationManager.getPivotVisualizerConstructor())(question, visualizerData, visualizerOptions);
12229
+ }
12230
+ else {
12231
+ visualizer = _this.createVisualizer(question, visualizerOptions, visualizerData);
12232
+ }
11794
12233
  if (!visualizer) {
11795
12234
  return;
11796
12235
  }
@@ -11859,6 +12298,7 @@ var VisualizationPanel = /** @class */ (function (_super) {
11859
12298
  var _this = this;
11860
12299
  _super.prototype.setLocale.call(this, newLocale);
11861
12300
  (this.questions || []).forEach(function (question) {
12301
+ question = Array.isArray(question) ? question[0] : question;
11862
12302
  var element = _this.getElement(question.name);
11863
12303
  if (!!element) {
11864
12304
  element.displayName = _this.processText(question.title);
@@ -11926,6 +12366,7 @@ var VisualizationPanel = /** @class */ (function (_super) {
11926
12366
  VisualizationPanel.prototype.buildElements = function (questions) {
11927
12367
  var _this = this;
11928
12368
  return (questions || []).map(function (question) {
12369
+ question = Array.isArray(question) ? question[0] : question;
11929
12370
  return {
11930
12371
  name: question.name,
11931
12372
  displayName: _this.processText(question.title),
@@ -12150,7 +12591,7 @@ var VisualizationPanel = /** @class */ (function (_super) {
12150
12591
  this._settingState = true;
12151
12592
  try {
12152
12593
  if (Array.isArray(newState.elements)) {
12153
- var questionNames_1 = this.questions.map(function (q) { return q.name; });
12594
+ var questionNames_1 = this.questions.map(function (q) { return Array.isArray(q) ? q[0].name : q.name; });
12154
12595
  this._elements = [].concat(newState.elements.filter(function (e) { return (questionNames_1.indexOf(e.name) !== -1); }));
12155
12596
  }
12156
12597
  if (typeof newState.locale !== "undefined")
@@ -12527,12 +12968,12 @@ var VisualizerBase = /** @class */ (function () {
12527
12968
  enumerable: false,
12528
12969
  configurable: true
12529
12970
  });
12530
- VisualizerBase.prototype.createVisualizer = function (question, options) {
12971
+ VisualizerBase.prototype.createVisualizer = function (question, options, data) {
12531
12972
  var visualizerOptions = Object.assign({}, options || this.options);
12532
12973
  if (visualizerOptions.dataProvider === undefined) {
12533
12974
  visualizerOptions.dataProvider = this.dataProvider;
12534
12975
  }
12535
- return _visualizerFactory__WEBPACK_IMPORTED_MODULE_3__.VisualizerFactory.createVisualizer(question, this.data, visualizerOptions);
12976
+ return _visualizerFactory__WEBPACK_IMPORTED_MODULE_3__.VisualizerFactory.createVisualizer(question, data || this.data, visualizerOptions);
12536
12977
  };
12537
12978
  Object.defineProperty(VisualizerBase.prototype, "footerVisualizer", {
12538
12979
  /**
@@ -12875,6 +13316,15 @@ var VisualizerBase = /** @class */ (function () {
12875
13316
  targetElement.appendChild(this.footerContainer);
12876
13317
  this.renderFooter(this.footerContainer);
12877
13318
  };
13319
+ VisualizerBase.prototype.updateToolbar = function () {
13320
+ var _this = this;
13321
+ if (!!this.toolbarContainer) {
13322
+ PostponeHelper.postpone(function () {
13323
+ _this.destroyToolbar(_this.toolbarContainer);
13324
+ _this.renderToolbar(_this.toolbarContainer);
13325
+ });
13326
+ }
13327
+ };
12878
13328
  VisualizerBase.prototype.updateContent = function () {
12879
13329
  this.destroyContent(this.contentContainer);
12880
13330
  this.renderContent(this.contentContainer);
@@ -15129,13 +15579,14 @@ __webpack_require__.r(__webpack_exports__);
15129
15579
  /* harmony export */ AlternativeVisualizersWrapper: () => (/* reexport safe */ _alternativeVizualizersWrapper__WEBPACK_IMPORTED_MODULE_27__.AlternativeVisualizersWrapper),
15130
15580
  /* harmony export */ BooleanModel: () => (/* reexport safe */ _boolean__WEBPACK_IMPORTED_MODULE_19__.BooleanModel),
15131
15581
  /* harmony export */ DataProvider: () => (/* reexport safe */ _dataProvider__WEBPACK_IMPORTED_MODULE_14__.DataProvider),
15132
- /* harmony export */ DocumentHelper: () => (/* reexport safe */ _utils_index__WEBPACK_IMPORTED_MODULE_33__.DocumentHelper),
15582
+ /* harmony export */ DocumentHelper: () => (/* reexport safe */ _utils_index__WEBPACK_IMPORTED_MODULE_34__.DocumentHelper),
15133
15583
  /* harmony export */ HistogramModel: () => (/* reexport safe */ _histogram__WEBPACK_IMPORTED_MODULE_20__.HistogramModel),
15134
15584
  /* harmony export */ Matrix: () => (/* reexport safe */ _matrix__WEBPACK_IMPORTED_MODULE_18__.Matrix),
15135
15585
  /* harmony export */ NpsAdapter: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsAdapter),
15136
15586
  /* harmony export */ NpsVisualizer: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsVisualizer),
15137
15587
  /* harmony export */ NpsVisualizerWidget: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsVisualizerWidget),
15138
15588
  /* harmony export */ NumberModel: () => (/* reexport safe */ _number__WEBPACK_IMPORTED_MODULE_16__.NumberModel),
15589
+ /* harmony export */ PivotModel: () => (/* reexport safe */ _pivot__WEBPACK_IMPORTED_MODULE_33__.PivotModel),
15139
15590
  /* harmony export */ PostponeHelper: () => (/* reexport safe */ _visualizerBase__WEBPACK_IMPORTED_MODULE_21__.PostponeHelper),
15140
15591
  /* harmony export */ SelectBase: () => (/* reexport safe */ _selectBase__WEBPACK_IMPORTED_MODULE_17__.SelectBase),
15141
15592
  /* harmony export */ StatisticsTable: () => (/* reexport safe */ _statistics_table__WEBPACK_IMPORTED_MODULE_31__.StatisticsTable),
@@ -15190,7 +15641,8 @@ __webpack_require__.r(__webpack_exports__);
15190
15641
  /* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../text */ "./src/text.ts");
15191
15642
  /* harmony import */ var _statistics_table__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../statistics-table */ "./src/statistics-table.ts");
15192
15643
  /* 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");
15644
+ /* harmony import */ var _pivot__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../pivot */ "./src/pivot.ts");
15645
+ /* harmony import */ var _utils_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ../utils/index */ "./src/utils/index.ts");
15194
15646
 
15195
15647
  //localization
15196
15648
 
@@ -15225,6 +15677,7 @@ __webpack_require__.r(__webpack_exports__);
15225
15677
 
15226
15678
 
15227
15679
 
15680
+
15228
15681
 
15229
15682
 
15230
15683
  })();