@funnest/charts 0.6.20 → 0.6.22

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/dist/chart.d.ts CHANGED
@@ -243,6 +243,12 @@ export declare class Chart {
243
243
  private historyRequest;
244
244
  /** setSymbol() is between its request and setData(). */
245
245
  private symbolLoading;
246
+ /**
247
+ * What the latest setSymbol() asked for, until it lands (or fails). load() and save() go by it
248
+ * rather than what's still on screen: a layout switched away and back before a slow symbol
249
+ * arrives must not keep — or save — the one it was leaving.
250
+ */
251
+ private requested;
246
252
  private noMoreHistory;
247
253
  private historyRequestedFor;
248
254
  private countdownLabel;
package/dist/index.js CHANGED
@@ -2864,6 +2864,12 @@ var Chart = class {
2864
2864
  historyRequest = 0;
2865
2865
  /** setSymbol() is between its request and setData(). */
2866
2866
  symbolLoading = false;
2867
+ /**
2868
+ * What the latest setSymbol() asked for, until it lands (or fails). load() and save() go by it
2869
+ * rather than what's still on screen: a layout switched away and back before a slow symbol
2870
+ * arrives must not keep — or save — the one it was leaving.
2871
+ */
2872
+ requested = null;
2867
2873
  noMoreHistory = false;
2868
2874
  historyRequestedFor = Number.NaN;
2869
2875
  countdownLabel = null;
@@ -2987,6 +2993,7 @@ var Chart = class {
2987
2993
  const feed = this.datafeed;
2988
2994
  if (!feed) throw new Error("funnest-charts: setSymbol() requires the `datafeed` option");
2989
2995
  const token = ++this.loadToken;
2996
+ this.requested = { symbol, resolution };
2990
2997
  this.endReplay(false);
2991
2998
  this.unsubscribeBars?.();
2992
2999
  this.unsubscribeBars = null;
@@ -3016,6 +3023,7 @@ var Chart = class {
3016
3023
  } finally {
3017
3024
  if (token === this.loadToken) {
3018
3025
  this.symbolLoading = false;
3026
+ this.requested = null;
3019
3027
  this.emitter.emit("loadingChange", false);
3020
3028
  }
3021
3029
  }
@@ -3236,8 +3244,9 @@ var Chart = class {
3236
3244
  drawings[this.symbol?.symbol ?? ""] = this.getDrawings();
3237
3245
  return {
3238
3246
  version: 1,
3239
- symbol: this.symbol?.symbol ?? null,
3240
- resolution: this.resolution,
3247
+ // A symbol still loading is the one this chart is on (see `requested`).
3248
+ symbol: this.requested?.symbol ?? this.symbol?.symbol ?? null,
3249
+ resolution: this.requested?.resolution ?? this.resolution,
3241
3250
  chartType: this.chartType,
3242
3251
  settings: this.settings,
3243
3252
  indicators: this.getIndicators(),
@@ -3257,7 +3266,8 @@ var Chart = class {
3257
3266
  for (const [symbol, list] of Object.entries(state.drawings)) this.drawingsBySymbol.set(symbol, list);
3258
3267
  this.restoreDrawingsFor(this.symbol?.symbol ?? "");
3259
3268
  const wantSymbol = options.symbol !== false && this.datafeed && state.symbol;
3260
- if (wantSymbol && (state.symbol !== this.symbol?.symbol || state.resolution !== this.resolution)) {
3269
+ const target = this.requested ?? { symbol: this.symbol?.symbol, resolution: this.resolution };
3270
+ if (wantSymbol && (state.symbol !== target.symbol || state.resolution !== target.resolution)) {
3261
3271
  await this.setSymbol(state.symbol, state.resolution ?? this.resolution ?? "1D");
3262
3272
  }
3263
3273
  this.settingsValue = state.settings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts",
3
- "version": "0.6.20",
3
+ "version": "0.6.22",
4
4
  "description": "Canvas charting engine for financial charts",
5
5
  "keywords": [
6
6
  "chart",