survey-analytics 2.0.1 → 2.0.2

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.
package/fesm/shared.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.0.1
2
+ * surveyjs - SurveyJS Dashboard library v2.0.2
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.0.1
2
+ * surveyjs - SurveyJS Dashboard library v2.0.2
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
  */
@@ -153,6 +153,16 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
153
153
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
154
154
  };
155
155
 
156
+ class PostponeHelper {
157
+ static postpone(fn, timeout) {
158
+ if (PostponeHelper.postponeFunction) {
159
+ return PostponeHelper.postponeFunction(fn, timeout);
160
+ }
161
+ else {
162
+ return setTimeout(fn, timeout);
163
+ }
164
+ }
165
+ }
156
166
  /**
157
167
  * A base object for all visualizers. Use it to implement a custom visualizer.
158
168
  *
@@ -610,26 +620,29 @@ class VisualizerBase {
610
620
  targetElement.appendChild(this.footerContainer);
611
621
  this.renderFooter(this.footerContainer);
612
622
  }
623
+ updateContent() {
624
+ this.destroyContent(this.contentContainer);
625
+ this.renderContent(this.contentContainer);
626
+ }
613
627
  /**
614
628
  * Re-renders the visualizer and its content.
615
629
  */
616
630
  refresh() {
617
631
  if (!!this.headerContainer) {
618
- setTimeout(() => {
632
+ PostponeHelper.postpone(() => {
619
633
  this.destroyHeader(this.headerContainer);
620
634
  this.renderHeader(this.headerContainer);
621
635
  this.invokeOnUpdate();
622
636
  });
623
637
  }
624
638
  if (!!this.contentContainer) {
625
- setTimeout(() => {
626
- this.destroyContent(this.contentContainer);
627
- this.renderContent(this.contentContainer);
639
+ PostponeHelper.postpone(() => {
640
+ this.updateContent();
628
641
  this.invokeOnUpdate();
629
642
  });
630
643
  }
631
644
  if (!!this.footerContainer) {
632
- setTimeout(() => {
645
+ PostponeHelper.postpone(() => {
633
646
  this.destroyFooter(this.footerContainer);
634
647
  this.renderFooter(this.footerContainer);
635
648
  this.invokeOnUpdate();
@@ -9325,6 +9338,8 @@ class VisualizationPanel extends VisualizerBase {
9325
9338
  this._elements = newElements;
9326
9339
  this.visibleElementsChanged(undefined, "REORDERED");
9327
9340
  }
9341
+ onDataChanged() {
9342
+ }
9328
9343
  showElementCore(element, elementIndex = -1) {
9329
9344
  element.isVisible = true;
9330
9345
  const questionElement = this.renderPanelElement(element, this.contentContainer);
@@ -10301,42 +10316,7 @@ class PlotlyChartAdapter {
10301
10316
  }
10302
10317
  create(chartNode) {
10303
10318
  return __awaiter(this, void 0, void 0, function* () {
10304
- const answersData = yield this.model.getAnswersData();
10305
- var plotlyOptions = PlotlySetup.setup(this.model.chartType, this.model, answersData);
10306
- let config = {
10307
- displaylogo: false,
10308
- responsive: true,
10309
- locale: localization.currentLocale,
10310
- modeBarButtonsToRemove: ["toImage"],
10311
- modeBarButtonsToAdd: [
10312
- {
10313
- name: "toImageSjs",
10314
- title: localization.getString("saveDiagramAsPNG"),
10315
- icon: Plotly.Icons.camera,
10316
- click: (gd) => {
10317
- let options = {
10318
- format: PlotlySetup.imageExportFormat,
10319
- // width: 800,
10320
- // height: 600,
10321
- filename: this.model.question.name,
10322
- };
10323
- PlotlySetup.onImageSaving.fire(this.model, options);
10324
- Plotly.downloadImage(gd, options);
10325
- },
10326
- },
10327
- ],
10328
- };
10329
- if (SelectBasePlotly.displayModeBar !== undefined) {
10330
- config.displayModeBar = SelectBasePlotly.displayModeBar;
10331
- }
10332
- this.patchConfigParameters(chartNode, plotlyOptions.traces, plotlyOptions.layout, config);
10333
- let options = {
10334
- traces: plotlyOptions.traces,
10335
- layout: plotlyOptions.layout,
10336
- config: config,
10337
- };
10338
- PlotlySetup.onPlotCreating.fire(this.model, options);
10339
- const plot = Plotly.newPlot(chartNode, options.traces, options.layout, options.config);
10319
+ const [plot, plotlyOptions] = yield this.update(chartNode);
10340
10320
  chartNode["on"]("plotly_click", (data) => {
10341
10321
  if (data.points.length > 0) {
10342
10322
  let itemText = "";
@@ -10380,6 +10360,47 @@ class PlotlyChartAdapter {
10380
10360
  return plot;
10381
10361
  });
10382
10362
  }
10363
+ update(chartNode) {
10364
+ return __awaiter(this, void 0, void 0, function* () {
10365
+ const answersData = yield this.model.getAnswersData();
10366
+ var plotlyOptions = PlotlySetup.setup(this.model.chartType, this.model, answersData);
10367
+ let config = {
10368
+ displaylogo: false,
10369
+ responsive: true,
10370
+ locale: localization.currentLocale,
10371
+ modeBarButtonsToRemove: ["toImage"],
10372
+ modeBarButtonsToAdd: [
10373
+ {
10374
+ name: "toImageSjs",
10375
+ title: localization.getString("saveDiagramAsPNG"),
10376
+ icon: Plotly.Icons.camera,
10377
+ click: (gd) => {
10378
+ let options = {
10379
+ format: PlotlySetup.imageExportFormat,
10380
+ // width: 800,
10381
+ // height: 600,
10382
+ filename: this.model.question.name,
10383
+ };
10384
+ PlotlySetup.onImageSaving.fire(this.model, options);
10385
+ Plotly.downloadImage(gd, options);
10386
+ },
10387
+ },
10388
+ ],
10389
+ };
10390
+ if (SelectBasePlotly.displayModeBar !== undefined) {
10391
+ config.displayModeBar = SelectBasePlotly.displayModeBar;
10392
+ }
10393
+ this.patchConfigParameters(chartNode, plotlyOptions.traces, plotlyOptions.layout, config);
10394
+ let options = {
10395
+ traces: plotlyOptions.traces,
10396
+ layout: plotlyOptions.layout,
10397
+ config: config,
10398
+ };
10399
+ PlotlySetup.onPlotCreating.fire(this.model, options);
10400
+ const plot = Plotly.react(chartNode, options.traces, options.layout, options.config);
10401
+ return [plot, plotlyOptions];
10402
+ });
10403
+ }
10383
10404
  destroy(node) {
10384
10405
  if (!!node) {
10385
10406
  Plotly.purge(node);
@@ -10414,6 +10435,13 @@ class SelectBasePlotly extends SelectBase {
10414
10435
  return container;
10415
10436
  });
10416
10437
  }
10438
+ updateContent() {
10439
+ var _a;
10440
+ const chartNode = (_a = this.contentContainer) === null || _a === void 0 ? void 0 : _a.children[0];
10441
+ if (chartNode) {
10442
+ this._chartAdapter.update(chartNode);
10443
+ }
10444
+ }
10417
10445
  getCalculatedValuesCore() {
10418
10446
  const statistics = super.getCalculatedValuesCore();
10419
10447
  const series = this.getSeriesValues();
@@ -12765,5 +12793,5 @@ NpsVisualizer.DetractorScore = 6;
12765
12793
  NpsVisualizer.PromoterScore = 9;
12766
12794
  // VisualizationManager.registerVisualizer("rating", NpsVisualizer);
12767
12795
 
12768
- export { AlternativeVisualizersWrapper, BooleanModel, BooleanPlotly, DataProvider, DocumentHelper, GaugePlotly, HistogramModel, HistogramPlotly, Matrix, MatrixDropdownGroupedPlotly, MatrixPlotly, NpsAdapter, NpsVisualizer, NpsVisualizerWidget, NumberModel, PlotlyBoolChartAdapter, PlotlyChartAdapter, PlotlyGaugeAdapter, PlotlySetup, RankingPlotly, SelectBase, SelectBasePlotly, StatisticsTable, StatisticsTableAdapter, Text, TextTableAdapter, VisualizationManager, VisualizationMatrixDropdown, VisualizationMatrixDynamic, VisualizationPanel, VisualizationPanelDynamic, VisualizerBase, VisualizerFactory, WordCloud, WordCloudAdapter, defaultStatisticsCalculator, hideEmptyAnswersInData, localization, textHelper };
12796
+ export { AlternativeVisualizersWrapper, BooleanModel, BooleanPlotly, DataProvider, DocumentHelper, GaugePlotly, HistogramModel, HistogramPlotly, Matrix, MatrixDropdownGroupedPlotly, MatrixPlotly, NpsAdapter, NpsVisualizer, NpsVisualizerWidget, NumberModel, PlotlyBoolChartAdapter, PlotlyChartAdapter, PlotlyGaugeAdapter, PlotlySetup, PostponeHelper, RankingPlotly, SelectBase, SelectBasePlotly, StatisticsTable, StatisticsTableAdapter, Text, TextTableAdapter, VisualizationManager, VisualizationMatrixDropdown, VisualizationMatrixDynamic, VisualizationPanel, VisualizationPanelDynamic, VisualizerBase, VisualizerFactory, WordCloud, WordCloudAdapter, defaultStatisticsCalculator, hideEmptyAnswersInData, localization, textHelper };
12769
12797
  //# sourceMappingURL=survey.analytics.js.map