survey-analytics 2.2.3 → 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 (42) hide show
  1. package/fesm/shared.mjs +1 -1
  2. package/fesm/shared2.mjs +298 -193
  3. package/fesm/shared2.mjs.map +1 -1
  4. package/fesm/survey.analytics.core.mjs +2 -2
  5. package/fesm/survey.analytics.mjs +187 -418
  6. package/fesm/survey.analytics.mjs.map +1 -1
  7. package/fesm/survey.analytics.tabulator.mjs +1 -1
  8. package/package.json +2 -2
  9. package/survey-analytics.types/boolean.d.ts +0 -1
  10. package/survey-analytics.types/entries/summary.core.d.ts +2 -1
  11. package/survey-analytics.types/histogram.d.ts +1 -1
  12. package/survey-analytics.types/pivot.d.ts +2 -0
  13. package/survey-analytics.types/plotly/chart-adapter.d.ts +13 -0
  14. package/survey-analytics.types/plotly/index.d.ts +2 -8
  15. package/survey-analytics.types/plotly/legacy.d.ts +33 -0
  16. package/survey-analytics.types/plotly/setup.d.ts +5 -3
  17. package/survey-analytics.types/{plotly/ranking.d.ts → ranking.d.ts} +2 -2
  18. package/survey-analytics.types/selectBase.d.ts +2 -0
  19. package/survey-analytics.types/visualizerBase.d.ts +11 -0
  20. package/survey.analytics.core.css +1 -1
  21. package/survey.analytics.core.js +178 -23
  22. package/survey.analytics.core.js.map +1 -1
  23. package/survey.analytics.core.min.css +1 -1
  24. package/survey.analytics.core.min.js +1 -1
  25. package/survey.analytics.core.min.js.LICENSE.txt +1 -1
  26. package/survey.analytics.css +1 -1
  27. package/survey.analytics.js +491 -762
  28. package/survey.analytics.js.map +1 -1
  29. package/survey.analytics.min.css +1 -1
  30. package/survey.analytics.min.js +1 -1
  31. package/survey.analytics.min.js.LICENSE.txt +1 -1
  32. package/survey.analytics.tabulator.css +1 -1
  33. package/survey.analytics.tabulator.js +1 -1
  34. package/survey.analytics.tabulator.min.css +1 -1
  35. package/survey.analytics.tabulator.min.js.LICENSE.txt +1 -1
  36. package/survey-analytics.types/plotly/boolean.d.ts +0 -16
  37. package/survey-analytics.types/plotly/histogram.d.ts +0 -12
  38. package/survey-analytics.types/plotly/matrix.d.ts +0 -11
  39. package/survey-analytics.types/plotly/matrixdropdown-grouped.d.ts +0 -11
  40. package/survey-analytics.types/plotly/pivot.d.ts +0 -12
  41. package/survey-analytics.types/plotly/rating.d.ts +0 -20
  42. package/survey-analytics.types/plotly/selectBase.d.ts +0 -25
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.2.3
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
  */
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "lint": "eslint ./src --quiet",
18
18
  "pre-push-check": "npm run lint && npm run test"
19
19
  },
20
- "version": "2.2.3",
20
+ "version": "2.2.4",
21
21
  "name": "survey-analytics",
22
22
  "description": "SurveyJS analytics Library.",
23
23
  "main": "survey.analytics.js",
@@ -89,7 +89,7 @@
89
89
  "peerDependencies": {
90
90
  "@types/plotly.js-dist-min": "^2.3.0",
91
91
  "@types/tabulator-tables": "^6.2.3",
92
- "survey-core": "2.2.3"
92
+ "survey-core": "2.2.4"
93
93
  },
94
94
  "husky": {
95
95
  "hooks": {
@@ -2,7 +2,6 @@ import { Question, QuestionBooleanModel } from "survey-core";
2
2
  import { ItemValue } from "survey-core";
3
3
  import { SelectBase } from "./selectBase";
4
4
  export declare class BooleanModel extends SelectBase {
5
- protected chartTypes: string[];
6
5
  constructor(question: Question, data: Array<{
7
6
  [index: string]: any;
8
7
  }>, options?: Object, name?: string);
@@ -14,11 +14,11 @@ import "../analytics-localization/polish";
14
14
  import "../analytics-localization/finnish";
15
15
  export * from "../dataProvider";
16
16
  export * from "../visualizerFactory";
17
- export * from "../number";
18
17
  export * from "../selectBase";
19
18
  export * from "../matrix";
20
19
  export * from "../boolean";
21
20
  export * from "../histogram";
21
+ export * from "../number";
22
22
  export * from "../visualizerBase";
23
23
  export * from "../visualizationManager";
24
24
  export * from "../visualizationPanel";
@@ -31,5 +31,6 @@ export * from "../wordcloud/stopwords/index";
31
31
  export * from "../text";
32
32
  export * from "../statistics-table";
33
33
  export * from "../nps";
34
+ export * from "../ranking";
34
35
  export * from "../pivot";
35
36
  export { DocumentHelper } from "../utils/index";
@@ -6,7 +6,6 @@ export declare class HistogramModel extends SelectBase {
6
6
  private _continiousData;
7
7
  private _cachedIntervals;
8
8
  private _intervalPrecision;
9
- protected chartTypes: string[];
10
9
  static IntervalsCount: number;
11
10
  static UseIntervalsFrom: number;
12
11
  constructor(question: Question, data: Array<{
@@ -36,4 +35,5 @@ export declare class HistogramModel extends SelectBase {
36
35
  get intervals(): any;
37
36
  convertFromExternalData(externalCalculatedData: any): any[];
38
37
  protected getCalculatedValuesCore(): Array<any>;
38
+ getValueType(): "date" | "number";
39
39
  }
@@ -59,4 +59,6 @@ export declare class PivotModel extends SelectBase {
59
59
  [index: string]: number;
60
60
  }): void;
61
61
  protected getCalculatedValuesCore(): Array<any>;
62
+ getValueType(): "enum" | "date" | "number";
63
+ protected isSupportSoftUpdateContent(): boolean;
62
64
  }
@@ -0,0 +1,13 @@
1
+ import { SelectBase } from "../selectBase";
2
+ import { VisualizerBase, IChartAdapter } from "../visualizerBase";
3
+ export declare class PlotlyChartAdapter implements IChartAdapter {
4
+ protected model: SelectBase | VisualizerBase;
5
+ private _chart;
6
+ constructor(model: SelectBase | VisualizerBase);
7
+ protected patchConfigParameters(chartNode: object, traces: Array<object>, layout: object, config: any): void;
8
+ get chart(): Promise<Plotly.PlotlyHTMLElement>;
9
+ getChartTypes(): string[];
10
+ create(chartNode: HTMLElement): Promise<any>;
11
+ update(chartNode: HTMLElement): Promise<any>;
12
+ destroy(node: HTMLElement): void;
13
+ }
@@ -1,9 +1,3 @@
1
1
  export * from "./setup";
2
- export * from "./selectBase";
3
- export * from "./matrix";
4
- export * from "./boolean";
5
- export * from "./ranking";
6
- export * from "./matrixdropdown-grouped";
7
- export * from "./histogram";
8
- export * from "./rating";
9
- export * from "./pivot";
2
+ export * from "./chart-adapter";
3
+ export * from "./legacy";
@@ -0,0 +1,33 @@
1
+ import { BooleanModel } from "../boolean";
2
+ import { SelectBase } from "../selectBase";
3
+ import { HistogramModel } from "../histogram";
4
+ import { Matrix } from "../matrix";
5
+ import { MatrixDropdownGrouped } from "../matrixDropdownGrouped";
6
+ import { PivotModel } from "../pivot";
7
+ import { NumberModel } from "../number";
8
+ import { RankingModel } from "../ranking";
9
+ export declare class SelectBasePlotly extends SelectBase {
10
+ static types: string[];
11
+ static displayModeBar: any;
12
+ }
13
+ export declare class BooleanPlotly extends BooleanModel {
14
+ static types: string[];
15
+ }
16
+ export declare class HistogramPlotly extends HistogramModel {
17
+ static types: string[];
18
+ }
19
+ export declare class MatrixPlotly extends Matrix {
20
+ static types: string[];
21
+ }
22
+ export declare class MatrixDropdownGroupedPlotly extends MatrixDropdownGrouped {
23
+ static types: string[];
24
+ }
25
+ export declare class PivotPlotly extends PivotModel {
26
+ static types: string[];
27
+ }
28
+ export declare class GaugePlotly extends NumberModel {
29
+ static displayModeBar: any;
30
+ static types: string[];
31
+ }
32
+ export declare class RankingPlotly extends RankingModel {
33
+ }
@@ -1,6 +1,7 @@
1
1
  import { Event } from "survey-core";
2
2
  import { IAnswersData, SelectBase } from "../selectBase";
3
3
  import { VisualizerBase } from "../visualizerBase";
4
+ import { NumberModel } from "../number";
4
5
  export interface PlotlyOptions {
5
6
  traces: Array<any>;
6
7
  layout: any;
@@ -11,19 +12,20 @@ export declare class PlotlySetup {
11
12
  /**
12
13
  * Fires when end user clicks on the 'save as image' button.
13
14
  */
14
- static onImageSaving: Event<(sender: SelectBase, options: any) => any, SelectBase, any>;
15
+ static onImageSaving: Event<(sender: VisualizerBase, options: any) => any, VisualizerBase, any>;
15
16
  /**
16
17
  * Fires before plot will be created. User can change traces, layout and config of the plot.
17
18
  * Options is an object with the following fields: traces, layout and config of the plot.
18
19
  */
19
20
  static onPlotCreating: Event<(sender: VisualizerBase, options: any) => any, VisualizerBase, any>;
20
21
  static setups: {
21
- [type: string]: (model: SelectBase, answersData: IAnswersData) => PlotlyOptions;
22
+ [type: string]: (model: VisualizerBase, answersData: IAnswersData) => PlotlyOptions;
22
23
  };
23
- static setup(charType: string, model: SelectBase, answersData: IAnswersData): PlotlyOptions;
24
+ static setup(charType: string, model: VisualizerBase, answersData: IAnswersData): PlotlyOptions;
24
25
  static getTruncatedLabel: (label: string, labelTruncateLength: number) => string;
25
26
  static setupPie(model: SelectBase, answersData: IAnswersData): PlotlyOptions;
26
27
  static setupBar(model: SelectBase, answersData: IAnswersData): PlotlyOptions;
27
28
  static setupVBar(model: SelectBase, answersData: IAnswersData): PlotlyOptions;
28
29
  static setupScatter(model: SelectBase, answersData: IAnswersData): PlotlyOptions;
30
+ static setupGauge(model: NumberModel, answersData: IAnswersData): PlotlyOptions;
29
31
  }
@@ -1,5 +1,5 @@
1
- import { SelectBasePlotly } from "./selectBase";
2
- export declare class RankingPlotly extends SelectBasePlotly {
1
+ import { SelectBase } from "./selectBase";
2
+ export declare class RankingModel extends SelectBase {
3
3
  getQuestionResults(): any[];
4
4
  getEmptyData(): any;
5
5
  protected getCalculatedValuesCore(): Array<any>;
@@ -51,6 +51,8 @@ export declare class SelectBase extends VisualizerBase implements IVisualizerWit
51
51
  protected onChartTypeChanged(): void;
52
52
  protected setChartType(chartType: string): void;
53
53
  protected getCorrectAnswerText(): string;
54
+ protected isSupportSoftUpdateContent(): boolean;
55
+ protected softUpdateContent(): void;
54
56
  getSelectedItemByText(itemText: string): any;
55
57
  setSelection(item: ItemValue): void;
56
58
  get selection(): ItemValue;
@@ -2,6 +2,12 @@ import { Question } from "survey-core";
2
2
  import { DataProvider, GetDataFn } from "./dataProvider";
3
3
  import { Event } from "survey-core";
4
4
  import "./visualizerBase.scss";
5
+ export interface IChartAdapter {
6
+ getChartTypes(): string[];
7
+ create(chartNode: HTMLElement): Promise<any>;
8
+ update(chartNode: HTMLElement): Promise<any>;
9
+ destroy(node: HTMLElement): void;
10
+ }
5
11
  export interface IDataInfo {
6
12
  name: string;
7
13
  dataNames: Array<string>;
@@ -47,6 +53,7 @@ export declare class VisualizerBase implements IDataInfo {
47
53
  };
48
54
  private _type?;
49
55
  static suppressVisualizerStubRendering: boolean;
56
+ static chartAdapterType: any;
50
57
  private _showToolbar;
51
58
  private _footerVisualizer;
52
59
  private _dataProvider;
@@ -58,6 +65,7 @@ export declare class VisualizerBase implements IDataInfo {
58
65
  protected contentContainer: HTMLElement;
59
66
  protected footerContainer: HTMLElement;
60
67
  protected _supportSelection: boolean;
68
+ protected _chartAdapter: IChartAdapter;
61
69
  static otherCommentCollapsed: boolean;
62
70
  /**
63
71
  * An event that is raised after the visualizer's content is rendered.
@@ -255,6 +263,9 @@ export declare class VisualizerBase implements IDataInfo {
255
263
  */
256
264
  render(targetElement: HTMLElement | string): void;
257
265
  updateToolbar(): void;
266
+ protected isSupportSoftUpdateContent(): boolean;
267
+ protected softUpdateContent(): void;
268
+ protected hardUpdateContent(): void;
258
269
  updateContent(): void;
259
270
  /**
260
271
  * Re-renders the visualizer and its content.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.2.3
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
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.2.3
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
  */
@@ -8443,6 +8443,8 @@ __webpack_require__.r(__webpack_exports__);
8443
8443
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
8444
8444
  /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./selectBase */ "./src/selectBase.ts");
8445
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
+
8446
8448
 
8447
8449
 
8448
8450
 
@@ -8506,6 +8508,7 @@ var BooleanModel = /** @class */ (function (_super) {
8506
8508
  return BooleanModel;
8507
8509
  }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
8508
8510
 
8511
+ _visualizationManager__WEBPACK_IMPORTED_MODULE_4__.VisualizationManager.registerVisualizer("boolean", BooleanModel);
8509
8512
 
8510
8513
 
8511
8514
  /***/ }),
@@ -8724,6 +8727,8 @@ __webpack_require__.r(__webpack_exports__);
8724
8727
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
8725
8728
  /* harmony import */ var _dataProvider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dataProvider */ "./src/dataProvider.ts");
8726
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
+
8727
8732
 
8728
8733
 
8729
8734
 
@@ -8915,11 +8920,17 @@ var HistogramModel = /** @class */ (function (_super) {
8915
8920
  }
8916
8921
  return statistics;
8917
8922
  };
8923
+ HistogramModel.prototype.getValueType = function () {
8924
+ return this.valueType;
8925
+ };
8918
8926
  HistogramModel.IntervalsCount = 10;
8919
8927
  HistogramModel.UseIntervalsFrom = 10;
8920
8928
  return HistogramModel;
8921
8929
  }(_selectBase__WEBPACK_IMPORTED_MODULE_3__.SelectBase));
8922
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);
8923
8934
 
8924
8935
 
8925
8936
  /***/ }),
@@ -9279,6 +9290,8 @@ __webpack_require__.r(__webpack_exports__);
9279
9290
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! survey-core */ "survey-core");
9280
9291
  /* harmony import */ var survey_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(survey_core__WEBPACK_IMPORTED_MODULE_1__);
9281
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
+
9282
9295
 
9283
9296
 
9284
9297
 
@@ -9373,6 +9386,7 @@ var Matrix = /** @class */ (function (_super) {
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,9 @@ 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);
9731
9755
 
9732
9756
 
9733
9757
  /***/ }),
@@ -9750,6 +9774,8 @@ __webpack_require__.r(__webpack_exports__);
9750
9774
  /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./src/utils/index.ts");
9751
9775
  /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./visualizerBase */ "./src/visualizerBase.ts");
9752
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
+
9753
9779
 
9754
9780
 
9755
9781
 
@@ -9944,7 +9970,7 @@ var PivotModel = /** @class */ (function (_super) {
9944
9970
  });
9945
9971
  PivotModel.prototype.getSeriesValues = function () {
9946
9972
  var _this = this;
9947
- if (this.questionsY.length === 0) {
9973
+ if (!this.questionsY || this.questionsY.length === 0) {
9948
9974
  return this.options.seriesValues || [];
9949
9975
  }
9950
9976
  var seriesValues = [];
@@ -10133,11 +10159,78 @@ var PivotModel = /** @class */ (function (_super) {
10133
10159
  }
10134
10160
  return statistics;
10135
10161
  };
10162
+ PivotModel.prototype.getValueType = function () {
10163
+ return this.valueType;
10164
+ };
10165
+ PivotModel.prototype.isSupportSoftUpdateContent = function () {
10166
+ return false;
10167
+ };
10136
10168
  PivotModel.IntervalsCount = 10;
10137
10169
  PivotModel.UseIntervalsFrom = 10;
10138
10170
  return PivotModel;
10139
10171
  }(_selectBase__WEBPACK_IMPORTED_MODULE_2__.SelectBase));
10140
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);
10141
10234
 
10142
10235
 
10143
10236
  /***/ }),
@@ -10160,6 +10253,8 @@ __webpack_require__.r(__webpack_exports__);
10160
10253
  /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./visualizerBase */ "./src/visualizerBase.ts");
10161
10254
  /* harmony import */ var _localizationManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./localizationManager */ "./src/localizationManager.ts");
10162
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
+
10163
10258
 
10164
10259
 
10165
10260
 
@@ -10270,6 +10365,20 @@ var SelectBase = /** @class */ (function (_super) {
10270
10365
  _this._hideEmptyAnswers = _this.options.hideEmptyAnswers === true;
10271
10366
  _this._answersOrder = _this.options.answersOrder || "default";
10272
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
+ }
10273
10382
  _this.registerToolbarItem("changeChartType", function () {
10274
10383
  if (_this.chartTypes.length > 1) {
10275
10384
  return _utils_index__WEBPACK_IMPORTED_MODULE_4__.DocumentHelper.createSelector(_this.chartTypes.map(function (chartType) {
@@ -10452,6 +10561,16 @@ var SelectBase = /** @class */ (function (_super) {
10452
10561
  var selectBaseQuestion = this.question;
10453
10562
  return resultValues.map(function (value) { return survey_core__WEBPACK_IMPORTED_MODULE_1__.ItemValue.getTextOrHtmlByValue(selectBaseQuestion.choices, value); }).join(", ");
10454
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
+ };
10455
10574
  SelectBase.prototype.getSelectedItemByText = function (itemText) {
10456
10575
  var selBase = this.question;
10457
10576
  if (this.question.hasOther && itemText == selBase.otherText) {
@@ -10813,6 +10932,11 @@ var SelectBase = /** @class */ (function (_super) {
10813
10932
  return SelectBase;
10814
10933
  }(_visualizerBase__WEBPACK_IMPORTED_MODULE_2__.VisualizerBase));
10815
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);
10816
10940
 
10817
10941
 
10818
10942
  /***/ }),
@@ -12841,6 +12965,7 @@ var VisualizerBase = /** @class */ (function () {
12841
12965
  this.contentContainer = undefined;
12842
12966
  this.footerContainer = undefined;
12843
12967
  this._supportSelection = false;
12968
+ this._chartAdapter = undefined;
12844
12969
  /**
12845
12970
  * An event that is raised after the visualizer's content is rendered.
12846
12971
  *
@@ -13213,9 +13338,10 @@ var VisualizerBase = /** @class */ (function () {
13213
13338
  if (!!this.options && typeof this.options.destroyContent === "function") {
13214
13339
  this.options.destroyContent(container, this);
13215
13340
  }
13216
- else {
13217
- container.innerHTML = "";
13341
+ else if (this._chartAdapter) {
13342
+ this._chartAdapter.destroy(container.children[0]);
13218
13343
  }
13344
+ container.innerHTML = "";
13219
13345
  };
13220
13346
  VisualizerBase.prototype.renderHeader = function (container) {
13221
13347
  if (!!this.options && typeof this.options.renderHeader === "function") {
@@ -13229,11 +13355,23 @@ var VisualizerBase = /** @class */ (function () {
13229
13355
  };
13230
13356
  VisualizerBase.prototype.renderContentAsync = function (container) {
13231
13357
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
13358
+ var chartNode;
13232
13359
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
13233
- 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:
13234
13371
  container.innerText = _localizationManager__WEBPACK_IMPORTED_MODULE_5__.localization.getString("noVisualizerForQuestion");
13235
- resolve(container);
13236
- })];
13372
+ _a.label = 3;
13373
+ case 3: return [2 /*return*/, container];
13374
+ }
13237
13375
  });
13238
13376
  });
13239
13377
  };
@@ -13325,10 +13463,23 @@ var VisualizerBase = /** @class */ (function () {
13325
13463
  });
13326
13464
  }
13327
13465
  };
13328
- VisualizerBase.prototype.updateContent = function () {
13466
+ VisualizerBase.prototype.isSupportSoftUpdateContent = function () {
13467
+ return false;
13468
+ };
13469
+ VisualizerBase.prototype.softUpdateContent = function () {
13470
+ };
13471
+ VisualizerBase.prototype.hardUpdateContent = function () {
13329
13472
  this.destroyContent(this.contentContainer);
13330
13473
  this.renderContent(this.contentContainer);
13331
13474
  };
13475
+ VisualizerBase.prototype.updateContent = function () {
13476
+ if (!this.isSupportSoftUpdateContent()) {
13477
+ this.hardUpdateContent();
13478
+ }
13479
+ else {
13480
+ this.softUpdateContent();
13481
+ }
13482
+ };
13332
13483
  /**
13333
13484
  * Re-renders the visualizer and its content.
13334
13485
  */
@@ -13533,6 +13684,7 @@ var VisualizerBase = /** @class */ (function () {
13533
13684
  }
13534
13685
  };
13535
13686
  VisualizerBase.suppressVisualizerStubRendering = false;
13687
+ VisualizerBase.chartAdapterType = undefined;
13536
13688
  // public static otherCommentQuestionType = "comment"; // TODO: make it configureable - allow choose what kind of question/visualizer will be used for comments/others
13537
13689
  VisualizerBase.otherCommentCollapsed = true;
13538
13690
  VisualizerBase.customColors = [];
@@ -15577,18 +15729,19 @@ var __webpack_exports__ = {};
15577
15729
  __webpack_require__.r(__webpack_exports__);
15578
15730
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
15579
15731
  /* harmony export */ AlternativeVisualizersWrapper: () => (/* reexport safe */ _alternativeVizualizersWrapper__WEBPACK_IMPORTED_MODULE_27__.AlternativeVisualizersWrapper),
15580
- /* harmony export */ BooleanModel: () => (/* reexport safe */ _boolean__WEBPACK_IMPORTED_MODULE_19__.BooleanModel),
15732
+ /* harmony export */ BooleanModel: () => (/* reexport safe */ _boolean__WEBPACK_IMPORTED_MODULE_18__.BooleanModel),
15581
15733
  /* harmony export */ DataProvider: () => (/* reexport safe */ _dataProvider__WEBPACK_IMPORTED_MODULE_14__.DataProvider),
15582
- /* harmony export */ DocumentHelper: () => (/* reexport safe */ _utils_index__WEBPACK_IMPORTED_MODULE_34__.DocumentHelper),
15583
- /* harmony export */ HistogramModel: () => (/* reexport safe */ _histogram__WEBPACK_IMPORTED_MODULE_20__.HistogramModel),
15584
- /* 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),
15585
15737
  /* harmony export */ NpsAdapter: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsAdapter),
15586
15738
  /* harmony export */ NpsVisualizer: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsVisualizer),
15587
15739
  /* harmony export */ NpsVisualizerWidget: () => (/* reexport safe */ _nps__WEBPACK_IMPORTED_MODULE_32__.NpsVisualizerWidget),
15588
- /* harmony export */ NumberModel: () => (/* reexport safe */ _number__WEBPACK_IMPORTED_MODULE_16__.NumberModel),
15589
- /* harmony export */ PivotModel: () => (/* reexport safe */ _pivot__WEBPACK_IMPORTED_MODULE_33__.PivotModel),
15740
+ /* harmony export */ NumberModel: () => (/* reexport safe */ _number__WEBPACK_IMPORTED_MODULE_20__.NumberModel),
15741
+ /* harmony export */ PivotModel: () => (/* reexport safe */ _pivot__WEBPACK_IMPORTED_MODULE_34__.PivotModel),
15590
15742
  /* harmony export */ PostponeHelper: () => (/* reexport safe */ _visualizerBase__WEBPACK_IMPORTED_MODULE_21__.PostponeHelper),
15591
- /* 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),
15592
15745
  /* harmony export */ StatisticsTable: () => (/* reexport safe */ _statistics_table__WEBPACK_IMPORTED_MODULE_31__.StatisticsTable),
15593
15746
  /* harmony export */ StatisticsTableAdapter: () => (/* reexport safe */ _statistics_table__WEBPACK_IMPORTED_MODULE_31__.StatisticsTableAdapter),
15594
15747
  /* harmony export */ Text: () => (/* reexport safe */ _text__WEBPACK_IMPORTED_MODULE_30__.Text),
@@ -15603,7 +15756,7 @@ __webpack_require__.r(__webpack_exports__);
15603
15756
  /* harmony export */ WordCloud: () => (/* reexport safe */ _wordcloud_wordcloud__WEBPACK_IMPORTED_MODULE_28__.WordCloud),
15604
15757
  /* harmony export */ WordCloudAdapter: () => (/* reexport safe */ _wordcloud_wordcloud__WEBPACK_IMPORTED_MODULE_28__.WordCloudAdapter),
15605
15758
  /* harmony export */ defaultStatisticsCalculator: () => (/* reexport safe */ _visualizerBase__WEBPACK_IMPORTED_MODULE_21__.defaultStatisticsCalculator),
15606
- /* harmony export */ hideEmptyAnswersInData: () => (/* reexport safe */ _selectBase__WEBPACK_IMPORTED_MODULE_17__.hideEmptyAnswersInData),
15759
+ /* harmony export */ hideEmptyAnswersInData: () => (/* reexport safe */ _selectBase__WEBPACK_IMPORTED_MODULE_16__.hideEmptyAnswersInData),
15607
15760
  /* harmony export */ localization: () => (/* reexport safe */ _localizationManager__WEBPACK_IMPORTED_MODULE_0__.localization),
15608
15761
  /* harmony export */ surveyStrings: () => (/* reexport safe */ _localizationManager__WEBPACK_IMPORTED_MODULE_0__.surveyStrings),
15609
15762
  /* harmony export */ textHelper: () => (/* reexport safe */ _wordcloud_stopwords_index__WEBPACK_IMPORTED_MODULE_29__.textHelper)
@@ -15624,11 +15777,11 @@ __webpack_require__.r(__webpack_exports__);
15624
15777
  /* harmony import */ var _analytics_localization_finnish__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../analytics-localization/finnish */ "./src/analytics-localization/finnish.ts");
15625
15778
  /* harmony import */ var _dataProvider__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../dataProvider */ "./src/dataProvider.ts");
15626
15779
  /* harmony import */ var _visualizerFactory__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../visualizerFactory */ "./src/visualizerFactory.ts");
15627
- /* harmony import */ var _number__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../number */ "./src/number.ts");
15628
- /* harmony import */ var _selectBase__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../selectBase */ "./src/selectBase.ts");
15629
- /* harmony import */ var _matrix__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../matrix */ "./src/matrix.ts");
15630
- /* harmony import */ var _boolean__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../boolean */ "./src/boolean.ts");
15631
- /* 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");
15632
15785
  /* harmony import */ var _visualizerBase__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../visualizerBase */ "./src/visualizerBase.ts");
15633
15786
  /* harmony import */ var _visualizationManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../visualizationManager */ "./src/visualizationManager.ts");
15634
15787
  /* harmony import */ var _visualizationPanel__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../visualizationPanel */ "./src/visualizationPanel.ts");
@@ -15641,8 +15794,9 @@ __webpack_require__.r(__webpack_exports__);
15641
15794
  /* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../text */ "./src/text.ts");
15642
15795
  /* harmony import */ var _statistics_table__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../statistics-table */ "./src/statistics-table.ts");
15643
15796
  /* harmony import */ var _nps__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../nps */ "./src/nps.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");
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");
15646
15800
 
15647
15801
  //localization
15648
15802
 
@@ -15678,6 +15832,7 @@ __webpack_require__.r(__webpack_exports__);
15678
15832
 
15679
15833
 
15680
15834
 
15835
+
15681
15836
 
15682
15837
 
15683
15838
  })();