@funnest/charts 0.6.19 → 0.6.21
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/README.md +12 -13
- package/dist/chart.d.ts +6 -0
- package/dist/index.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
# @funnest/charts
|
|
2
2
|
|
|
3
|
-
Canvas
|
|
4
|
-
|
|
5
|
-
Canvas charting engine for financial charts: candles, indicators, realtime helpers.
|
|
3
|
+
Canvas charting engine for financial charts: candles, indicators and realtime helpers.
|
|
6
4
|
|
|
7
5
|
```bash
|
|
8
6
|
npm i @funnest/charts
|
|
9
7
|
```
|
|
10
8
|
|
|
11
|
-
UI
|
|
9
|
+
This is the engine alone, with no UI. For the toolbar, symbol search and indicator UI, use `@funnest/charts-ui` (or `@funnest/charts-react` in React).
|
|
12
10
|
|
|
13
11
|
```ts
|
|
14
12
|
import { createChart } from '@funnest/charts';
|
|
15
13
|
|
|
16
14
|
const chart = createChart(document.getElementById('chart')!, { datafeed: myDatafeed });
|
|
17
|
-
await chart.setSymbol('
|
|
15
|
+
await chart.setSymbol('AAPL', '1D');
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
18
|
+
- Indicators: MA, EMA, Bollinger Bands, RSI, MACD
|
|
19
|
+
- Realtime helpers: `ReconnectingWebSocket`, `TickAggregator`, `combineDatafeeds`, `monitorLatency`
|
|
20
|
+
- Speaks your user's language: English, or Korean for a Korean browser, with matching up/down colors (green-up globally, red-up in Korea)
|
|
21
|
+
- Korean market defaults when it's Korean: KST, KRX sessions and tick sizes (`krxTickSize`)
|
|
22
|
+
- No exchange code inside. Connect any exchange or broker through the `Datafeed` interface.
|
|
24
23
|
|
|
25
|
-
##
|
|
24
|
+
## Links
|
|
26
25
|
|
|
27
|
-
-
|
|
28
|
-
- GitHub: https://github.com/funnest-xyz/funnest-charts
|
|
29
|
-
-
|
|
26
|
+
- Docs: https://charts.funnest.xyz/docs/
|
|
27
|
+
- GitHub: https://github.com/funnest-xyz/funnest-charts ([한국어](https://github.com/funnest-xyz/funnest-charts/blob/main/README.ko.md))
|
|
28
|
+
- License: Apache-2.0
|
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
|
|
3240
|
-
|
|
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
|
-
|
|
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;
|