lightweight-charts-react-components 1.0.1 → 1.1.0
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 +9 -9
- package/dist/index.d.ts +285 -1
- package/dist/lightweight-charts-react-components.mjs +2 -2
- package/dist/lightweight-charts-react-components.mjs.map +1 -1
- package/dist/lightweight-charts-react-components.standalone.js +2 -2
- package/dist/lightweight-charts-react-components.standalone.js.map +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -151,7 +151,7 @@ const data = [
|
|
|
151
151
|
{ time: "2023-01-03", value: 102 },
|
|
152
152
|
];
|
|
153
153
|
|
|
154
|
-
const
|
|
154
|
+
const App = () => {
|
|
155
155
|
return (
|
|
156
156
|
<Chart>
|
|
157
157
|
<LineSeries data={data} />
|
|
@@ -159,7 +159,7 @@ const Example = () => {
|
|
|
159
159
|
);
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
-
export {
|
|
162
|
+
export { App };
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
The following is an advanced example that demonstrates how to use custom scales, panes and multiple series in a single chart:
|
|
@@ -169,7 +169,7 @@ import React from "react";
|
|
|
169
169
|
import {
|
|
170
170
|
Chart,
|
|
171
171
|
LineSeries,
|
|
172
|
-
|
|
172
|
+
HistogramSeries,
|
|
173
173
|
PriceScale,
|
|
174
174
|
TimeScale,
|
|
175
175
|
TimeScaleFitContentTrigger,
|
|
@@ -182,9 +182,9 @@ const data = [
|
|
|
182
182
|
{ time: "2023-01-03", value: 102 },
|
|
183
183
|
];
|
|
184
184
|
const volumeData = [
|
|
185
|
-
{ time: "2023-01-01", value: 1000 },
|
|
186
|
-
{ time: "2023-01-02", value: 1100 },
|
|
187
|
-
{ time: "2023-01-03", value: 1200 },
|
|
185
|
+
{ time: "2023-01-01", value: 1000, color: "rgba(0, 150, 136, 0.5)" },
|
|
186
|
+
{ time: "2023-01-02", value: 1100, color: "rgba(0, 150, 136, 0.5)" },
|
|
187
|
+
{ time: "2023-01-03", value: 1200, color: "rgba(0, 150, 136, 0.5)" },
|
|
188
188
|
];
|
|
189
189
|
|
|
190
190
|
const chartOptions = {
|
|
@@ -195,7 +195,7 @@ const priceScaleOptions = {
|
|
|
195
195
|
// Price scale options can be customized here
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
-
const
|
|
198
|
+
const App = () => {
|
|
199
199
|
return (
|
|
200
200
|
<Chart options={chartOptions}>
|
|
201
201
|
<Pane stretchFactor={2}>
|
|
@@ -203,7 +203,7 @@ const AdvancedExample = () => {
|
|
|
203
203
|
<PriceScale id="left" options={priceScaleOptions} />
|
|
204
204
|
</Pane>
|
|
205
205
|
<Pane>
|
|
206
|
-
<
|
|
206
|
+
<HistogramSeries data={volumeData} />
|
|
207
207
|
</Pane>
|
|
208
208
|
<TimeScale>
|
|
209
209
|
<TimeScaleFitContentTrigger deps={[]} />
|
|
@@ -212,7 +212,7 @@ const AdvancedExample = () => {
|
|
|
212
212
|
);
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
-
export {
|
|
215
|
+
export { App };
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
## Examples
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/**!
|
|
3
|
-
* lightweight-charts-react-components v1.0
|
|
3
|
+
* lightweight-charts-react-components v1.1.0
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE.md file in the root directory of this source tree.
|
|
@@ -43,14 +43,107 @@ import { Time } from 'lightweight-charts';
|
|
|
43
43
|
import type { TimeRangeChangeEventHandler } from 'lightweight-charts';
|
|
44
44
|
import type { TimeScaleOptions as TimeScaleOptions_2 } from 'lightweight-charts';
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* AreaSeries component that can be used to create an area series in a chart.
|
|
48
|
+
*
|
|
49
|
+
* @param props - The properties for the area series.
|
|
50
|
+
* @param ref - The ref to access the area series API.
|
|
51
|
+
* @returns A React component that renders the area series.
|
|
52
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
|
|
53
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#area | TradingView documentation for area series}
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <AreaSeries
|
|
57
|
+
* data={[
|
|
58
|
+
* { time: '2021-01-01', value: 100 },
|
|
59
|
+
* { time: '2021-01-02', value: 200 }
|
|
60
|
+
* ]}
|
|
61
|
+
* options={{}}
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
46
65
|
export declare const AreaSeries: ForwardRefExoticComponent<SeriesProps<"Area"> & RefAttributes<SeriesApiRef<"Area">>>;
|
|
47
66
|
|
|
67
|
+
/**
|
|
68
|
+
* BarSeries component that can be used to create a bar series in a chart.
|
|
69
|
+
*
|
|
70
|
+
* @param props - The properties for the bar series.
|
|
71
|
+
* @param ref - The ref to access the bar series API.
|
|
72
|
+
* @returns A React component that renders the bar series.
|
|
73
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
|
|
74
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#bar | TradingView documentation for bar series}
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <BarSeries
|
|
78
|
+
* data={[
|
|
79
|
+
* { time: '2021-01-01', open: 100, high: 110, low: 90, close: 105 },
|
|
80
|
+
* { time: '2021-01-02', open: 105, high: 115, low: 95, close: 110 }
|
|
81
|
+
* ]}
|
|
82
|
+
* options={{}}
|
|
83
|
+
* />
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
48
86
|
export declare const BarSeries: ForwardRefExoticComponent<SeriesProps<"Bar"> & RefAttributes<SeriesApiRef<"Bar">>>;
|
|
49
87
|
|
|
88
|
+
/**
|
|
89
|
+
* BaselineSeries component that can be used to create a baseline series in a chart.
|
|
90
|
+
*
|
|
91
|
+
* @param props - The properties for the baseline series.
|
|
92
|
+
* @param ref - The ref to access the baseline series API.
|
|
93
|
+
* @returns A React component that renders the baseline series.
|
|
94
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
|
|
95
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#baseline | TradingView documentation for baseline series}
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* <BaselineSeries
|
|
99
|
+
* data={[
|
|
100
|
+
* { time: '2021-01-01', value: 100 },
|
|
101
|
+
* { time: '2021-01-02', value: 200 }
|
|
102
|
+
* ]}
|
|
103
|
+
* options={{}}
|
|
104
|
+
* />
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
50
107
|
export declare const BaselineSeries: ForwardRefExoticComponent<SeriesProps<"Baseline"> & RefAttributes<SeriesApiRef<"Baseline">>>;
|
|
51
108
|
|
|
109
|
+
/**
|
|
110
|
+
* CandlestickSeries component that can be used to create a candlestick series in a chart.
|
|
111
|
+
*
|
|
112
|
+
* @param props - The properties for the candlestick series.
|
|
113
|
+
* @param ref - The ref to access the candlestick series API.
|
|
114
|
+
* @returns A React component that renders the candlestick series.
|
|
115
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
|
|
116
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#candlestick | TradingView documentation for candlestick series}
|
|
117
|
+
* @example
|
|
118
|
+
* ```tsx
|
|
119
|
+
* <CandlestickSeries
|
|
120
|
+
* data={[
|
|
121
|
+
* { time: '2021-01-01', open: 100, high: 110, low: 90, close: 105 },
|
|
122
|
+
* { time: '2021-01-02', open: 105, high: 115, low: 95, close: 110 }
|
|
123
|
+
* ]}
|
|
124
|
+
* options={{}}
|
|
125
|
+
* />
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
52
128
|
export declare const CandlestickSeries: ForwardRefExoticComponent<SeriesProps<"Candlestick"> & RefAttributes<SeriesApiRef<"Candlestick">>>;
|
|
53
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Chart component that can be used to create a chart.
|
|
132
|
+
*
|
|
133
|
+
* @param props - The properties for the chart.
|
|
134
|
+
* @param ref - The ref to access the chart API.
|
|
135
|
+
* @returns A React component that renders the chart.
|
|
136
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/chart | Chart documentation}
|
|
137
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/chart-types | TradingView documentation for charts}
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <Chart>
|
|
141
|
+
* <Pane stretchFactor={2}>
|
|
142
|
+
* ...
|
|
143
|
+
* </Pane>
|
|
144
|
+
* </Chart>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
54
147
|
export declare const Chart: ForwardRefExoticComponent<ChartProps & RefAttributes<HTMLDivElement>>;
|
|
55
148
|
|
|
56
149
|
export declare type ChartApiRef = {
|
|
@@ -70,6 +163,26 @@ export declare type ChartProps = {
|
|
|
70
163
|
onDblClick?: MouseEventHandler<Time>;
|
|
71
164
|
};
|
|
72
165
|
|
|
166
|
+
/**
|
|
167
|
+
* CustomSeries component that can be used to create a custom series in a chart.
|
|
168
|
+
*
|
|
169
|
+
* @param props - The properties for the custom series.
|
|
170
|
+
* @param ref - The ref to access the custom series API.
|
|
171
|
+
* @returns A React component that renders the custom series.
|
|
172
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
|
|
173
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#custom-series-plugins | TradingView documentation for custom series}
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* <CustomSeries
|
|
177
|
+
* data={[
|
|
178
|
+
* { time: '2021-01-01', value: 100 },
|
|
179
|
+
* { time: '2021-01-02', value: 200 }
|
|
180
|
+
* ]}
|
|
181
|
+
* options={{}}
|
|
182
|
+
* plugin={{}}
|
|
183
|
+
* />
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
73
186
|
export declare const CustomSeries: ForwardRefExoticComponent<SeriesProps<"Custom"> & RefAttributes<SeriesApiRef<"Custom">>>;
|
|
74
187
|
|
|
75
188
|
declare type CustomSeriesUniqueProps = {
|
|
@@ -82,6 +195,25 @@ declare type GenericSeriesPrimitiveComponent = (<T extends SeriesType>(props: Se
|
|
|
82
195
|
displayName: string;
|
|
83
196
|
};
|
|
84
197
|
|
|
198
|
+
/**
|
|
199
|
+
* HistogramSeries component that can be used to create a histogram series in a chart.
|
|
200
|
+
*
|
|
201
|
+
* @param props - The properties for the histogram series.
|
|
202
|
+
* @param ref - The ref to access the histogram series API.
|
|
203
|
+
* @returns A React component that renders the histogram series.
|
|
204
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
|
|
205
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#histogram | TradingView documentation for histogram series}
|
|
206
|
+
* @example
|
|
207
|
+
* ```tsx
|
|
208
|
+
* <HistogramSeries
|
|
209
|
+
* data={[
|
|
210
|
+
* { time: '2021-01-01', value: 100 },
|
|
211
|
+
* { time: '2021-01-02', value: 200 }
|
|
212
|
+
* ]}
|
|
213
|
+
* options={{}}
|
|
214
|
+
* />
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
85
217
|
export declare const HistogramSeries: ForwardRefExoticComponent<SeriesProps<"Histogram"> & RefAttributes<SeriesApiRef<"Histogram">>>;
|
|
86
218
|
|
|
87
219
|
export declare type ImageWatermarkProps = {
|
|
@@ -93,8 +225,45 @@ export declare interface IPaneContext {
|
|
|
93
225
|
isReady: boolean;
|
|
94
226
|
}
|
|
95
227
|
|
|
228
|
+
/**
|
|
229
|
+
* LineSeries component that can be used to create a line series in a chart.
|
|
230
|
+
*
|
|
231
|
+
* @param props - The properties for the line series.
|
|
232
|
+
* @param ref - The ref to access the line series API.
|
|
233
|
+
* @returns A React component that renders the line series.
|
|
234
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series | Series documentation}
|
|
235
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/series-types#line | TradingView documentation for line series}
|
|
236
|
+
* @example
|
|
237
|
+
* ```tsx
|
|
238
|
+
* <LineSeries
|
|
239
|
+
* data={[
|
|
240
|
+
* { time: '2021-01-01', value: 100 },
|
|
241
|
+
* { time: '2021-01-02', value: 200 }
|
|
242
|
+
* ]}
|
|
243
|
+
* options={{}}
|
|
244
|
+
* />
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
96
247
|
export declare const LineSeries: ForwardRefExoticComponent<SeriesProps<"Line"> & RefAttributes<SeriesApiRef<"Line">>>;
|
|
97
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Markers component that can be used to add markers to a chart pane.
|
|
251
|
+
*
|
|
252
|
+
* @param props - The properties for the markers.
|
|
253
|
+
* @param ref - The ref to access the markers API.
|
|
254
|
+
* @returns A React component that renders the markers.
|
|
255
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/series-markers | Markers documentation}
|
|
256
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/markers | TradingView documentation for markers}
|
|
257
|
+
* @example
|
|
258
|
+
* ```tsx
|
|
259
|
+
* <Markers
|
|
260
|
+
* markers={[
|
|
261
|
+
* { time: 1622548800, position: "aboveBar", color: "red", shape: "arrowUp" },
|
|
262
|
+
* { time: 1622548800, position: "belowBar", color: "green", shape: "arrowDown" },
|
|
263
|
+
* ]}
|
|
264
|
+
* />
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
98
267
|
export declare const Markers: ForwardRefExoticComponent<MarkersProps & RefAttributes<MarkersApiRef>>;
|
|
99
268
|
|
|
100
269
|
export declare type MarkersApiRef = {
|
|
@@ -109,6 +278,21 @@ export declare type MarkersProps = {
|
|
|
109
278
|
reactive?: boolean;
|
|
110
279
|
};
|
|
111
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Pane component that can be used to create a pane in a chart.
|
|
283
|
+
*
|
|
284
|
+
* @param props - The properties for the pane.
|
|
285
|
+
* @param ref - The ref to access the pane API.
|
|
286
|
+
* @returns A React component that renders the pane.
|
|
287
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/panes | Panes documentation}
|
|
288
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/panes | TradingView documentation for panes}
|
|
289
|
+
* @example
|
|
290
|
+
* ```tsx
|
|
291
|
+
* <Pane stretchFactor={2}>
|
|
292
|
+
* ...
|
|
293
|
+
* </Pane>
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
112
296
|
export declare const Pane: ForwardRefExoticComponent<PaneProps & RefAttributes<PaneApiRef>>;
|
|
113
297
|
|
|
114
298
|
export declare type PaneApiRef = {
|
|
@@ -123,6 +307,19 @@ export declare type PaneProps = {
|
|
|
123
307
|
stretchFactor?: number;
|
|
124
308
|
};
|
|
125
309
|
|
|
310
|
+
/**
|
|
311
|
+
* PriceLine component that can be used to add a price line to a chart pane.
|
|
312
|
+
*
|
|
313
|
+
* @param props - The properties for the price line.
|
|
314
|
+
* @param ref - The ref to access the price line API.
|
|
315
|
+
* @returns A React component that renders the price line.
|
|
316
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/price-lines | Price Lines documentation}
|
|
317
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/price-line | TradingView documentation for price lines}
|
|
318
|
+
* @example
|
|
319
|
+
* ```tsx
|
|
320
|
+
* <PriceLine price={100} options={{}} />
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
126
323
|
export declare const PriceLine: ForwardRefExoticComponent<PriceLineProps & RefAttributes<PriceLineApiRef>>;
|
|
127
324
|
|
|
128
325
|
export declare type PriceLineApiRef = {
|
|
@@ -137,6 +334,19 @@ export declare type PriceLineProps = {
|
|
|
137
334
|
options?: Omit<Partial<PriceLineOptions>, "price">;
|
|
138
335
|
};
|
|
139
336
|
|
|
337
|
+
/**
|
|
338
|
+
* PriceScale component that can be used to create/customize price scale in a chart.
|
|
339
|
+
*
|
|
340
|
+
* @param props - The properties for the price scale.
|
|
341
|
+
* @param ref - The ref to access the price scale API.
|
|
342
|
+
* @returns A React component that renders the price scale.
|
|
343
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/price-scale | Price Scale documentation}
|
|
344
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/price-scale | TradingView documentation for price scale}
|
|
345
|
+
* @example
|
|
346
|
+
* ```tsx
|
|
347
|
+
* <PriceScale id="right" options={{}} />
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
140
350
|
export declare const PriceScale: ForwardRefExoticComponent<PriceScaleProps & RefAttributes<PriceScaleApiRef>>;
|
|
141
351
|
|
|
142
352
|
export declare type PriceScaleApiRef = {
|
|
@@ -174,6 +384,20 @@ declare type SeriesParameters<T extends SeriesType> = {
|
|
|
174
384
|
options?: SeriesOptions<T>;
|
|
175
385
|
} & (T extends "Custom" ? CustomSeriesUniqueProps : {});
|
|
176
386
|
|
|
387
|
+
/**
|
|
388
|
+
* SeriesPrimitive component that can be used to create a primitive on series.
|
|
389
|
+
*
|
|
390
|
+
* @param props - The properties for the series primitive.
|
|
391
|
+
* @param ref - The ref to access the series primitive API.
|
|
392
|
+
* @returns A React component that renders the series primitive.
|
|
393
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/series-primitives | Series primitives documentation}
|
|
394
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives | TradingView documentation for series primitive}
|
|
395
|
+
* @example
|
|
396
|
+
* ```tsx
|
|
397
|
+
* <SeriesPrimitive render={{}} />
|
|
398
|
+
* <SeriesPrimitive plugin={{}} />
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
177
401
|
export declare const SeriesPrimitive: GenericSeriesPrimitiveComponent;
|
|
178
402
|
|
|
179
403
|
export declare type SeriesPrimitiveApiRef = {
|
|
@@ -206,6 +430,19 @@ declare type SeriesTemplateProps<T extends SeriesType> = {
|
|
|
206
430
|
|
|
207
431
|
export declare type TextWatermarkProps = DeepPartial<TextWatermarkOptions>;
|
|
208
432
|
|
|
433
|
+
/**
|
|
434
|
+
* TimeScale component that can be used to create/customize time scale in a chart.
|
|
435
|
+
*
|
|
436
|
+
* @param props - The properties for the time scale.
|
|
437
|
+
* @param ref - The ref to access the time scale API.
|
|
438
|
+
* @returns A React component that renders the time scale.
|
|
439
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/time-scale | Time Scale documentation}
|
|
440
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/docs/time-scale | TradingView documentation for time scale}
|
|
441
|
+
* @example
|
|
442
|
+
* ```tsx
|
|
443
|
+
* <TimeScale visibleRange={{ from: 0, to: 100 }} onVisibleRangeChanged={() => {}} />
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
209
446
|
export declare const TimeScale: ForwardRefExoticComponent<TimeScaleProps & RefAttributes<TimeScaleApiRef>>;
|
|
210
447
|
|
|
211
448
|
export declare type TimeScaleApiRef = {
|
|
@@ -215,6 +452,17 @@ export declare type TimeScaleApiRef = {
|
|
|
215
452
|
clear: () => void;
|
|
216
453
|
};
|
|
217
454
|
|
|
455
|
+
/**
|
|
456
|
+
* TimeScaleFitContentTrigger component that triggers a fit content operation on the time scale.
|
|
457
|
+
*
|
|
458
|
+
* @param props - The properties for the time scale fit content trigger.
|
|
459
|
+
* @returns A React component that triggers a fit content operation on the time scale.
|
|
460
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/time-scale-fit-content-trigger | Time Scale Fit Content Trigger documentation}
|
|
461
|
+
* @example
|
|
462
|
+
* ```tsx
|
|
463
|
+
* <TimeScaleFitContentTrigger deps={[...]} />
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
218
466
|
export declare const TimeScaleFitContentTrigger: ({ deps, }: TimeScaleFitContentTriggerProps) => JSX.Element | null;
|
|
219
467
|
|
|
220
468
|
export declare type TimeScaleFitContentTriggerProps = {
|
|
@@ -235,6 +483,23 @@ export declare type TimeScaleProps = {
|
|
|
235
483
|
|
|
236
484
|
export declare type WatermarkApiRef<T extends WatermarkType> = T extends "text" ? WatermarkTextApiRefBase : WatermarkImageApiRefBase;
|
|
237
485
|
|
|
486
|
+
/**
|
|
487
|
+
* Watermark component that can be used to add an image watermark to a chart pane.
|
|
488
|
+
*
|
|
489
|
+
* @param props - The properties for the image watermark.
|
|
490
|
+
* @param ref - The ref to access the watermark API.
|
|
491
|
+
* @returns A React component that renders the image watermark.
|
|
492
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/watermarks | Watermarks documentation}
|
|
493
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/watermark | TradingView documentation for watermarks}
|
|
494
|
+
* @example
|
|
495
|
+
* ```tsx
|
|
496
|
+
* <WatermarkImage
|
|
497
|
+
* src="data:image/svg+xml;base64,..."
|
|
498
|
+
* alpha={0.5}
|
|
499
|
+
* padding={20}
|
|
500
|
+
* />
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
238
503
|
export declare const WatermarkImage: ForwardRefExoticComponent<ImageWatermarkProps & RefAttributes<WatermarkApiRef<"image">>>;
|
|
239
504
|
|
|
240
505
|
declare type WatermarkImageApiRefBase = {
|
|
@@ -244,6 +509,25 @@ declare type WatermarkImageApiRefBase = {
|
|
|
244
509
|
clear: () => void;
|
|
245
510
|
};
|
|
246
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Watermark component that can be used to add a text or image watermark to a chart pane.
|
|
514
|
+
*
|
|
515
|
+
* @param props - The properties for the watermark.
|
|
516
|
+
* @param ref - The ref to access the watermark API.
|
|
517
|
+
* @returns A React component that renders the watermark.
|
|
518
|
+
* @see {@link https://ukorvl.github.io/lightweight-charts-react-components/docs/watermarks | Watermarks documentation}
|
|
519
|
+
* @see {@link https://tradingview.github.io/lightweight-charts/tutorials/how_to/watermark | TradingView documentation for watermarks}
|
|
520
|
+
* @example
|
|
521
|
+
* ```tsx
|
|
522
|
+
* <WatermarkText
|
|
523
|
+
* lines={[
|
|
524
|
+
* { text: "Your chart name", color: "blue", fontSize: 24 },
|
|
525
|
+
* { text: "Some other text", color: "pink", fontSize: 16 },
|
|
526
|
+
* ]}
|
|
527
|
+
* horzAlign="center"
|
|
528
|
+
* />
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
247
531
|
export declare const WatermarkText: ForwardRefExoticComponent<TextWatermarkProps & RefAttributes<WatermarkApiRef<"text">>>;
|
|
248
532
|
|
|
249
533
|
declare type WatermarkTextApiRefBase = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/**!
|
|
3
|
-
* lightweight-charts-react-components v1.0
|
|
3
|
+
* lightweight-charts-react-components v1.1.0
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE.md file in the root directory of this source tree.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @license MIT
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import*as e from"react";import*as t from"lightweight-charts";let i=(0,e.createContext)(null);i.displayName="ChartContext";let r={addDefaultPane:!1},a=({container:i,onClick:a,onCrosshairMove:l,onInit:n,options:s={},onDblClick:u})=>{let[c,f]=(0,e.useState)(!1),o=(0,e.useRef)({_chart:null,api(){return this._chart},init(){if(null===this._chart){let e=(0,t.createChart)(i,{...r,...s});this._chart=e,n&&n(this._chart)}return c||f(!0),this._chart},clear(){null!==this._chart&&(f(!1),this._chart.remove(),this._chart=null)}});return(0,e.useLayoutEffect)(()=>(o.current.init(),()=>{o.current.clear()}),[]),(0,e.useLayoutEffect)(()=>{if(i){if(a){var e;null===(e=o.current.api())||void 0===e||e.subscribeClick(a)}return()=>{if(a){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeClick(a)}}}},[a]),(0,e.useLayoutEffect)(()=>{if(i){if(l){var e;null===(e=o.current.api())||void 0===e||e.subscribeCrosshairMove(l)}return()=>{if(l){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeCrosshairMove(l)}}}},[l]),(0,e.useLayoutEffect)(()=>{if(i){if(u){var e;null===(e=o.current.api())||void 0===e||e.subscribeDblClick(u)}return()=>{if(u){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeDblClick(u)}}}},[u]),(0,e.useLayoutEffect)(()=>{var e;i&&(null===(e=o.current.api())||void 0===e||e.applyOptions({...r,...s}))},[s]),{chartApiRef:o,isReady:c}},l=({children:t,container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u})=>{let{chartApiRef:{current:c},isReady:f}=a({container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u});return e.default.createElement(i.Provider,{value:{chartApiRef:c,isReady:f}},t)},n=(0,e.forwardRef)(({children:t,containerProps:i,...r},a)=>{let[n,s]=(0,e.useState)(),u=(0,e.useCallback)(e=>{s(e),a&&("function"==typeof a?u(e):a.current=e)},[a]);return e.default.createElement("div",{ref:u,...i},!!n&&e.default.createElement(l,{container:n,...r},t))});n.displayName="ChartWrapper";let s=(0,e.createContext)(null);s.displayName="TimeScaleContext";let u="1.0
|
|
11
|
+
import*as e from"react";import*as t from"lightweight-charts";let i=(0,e.createContext)(null);i.displayName="ChartContext";let r={addDefaultPane:!1},a=({container:i,onClick:a,onCrosshairMove:l,onInit:n,options:s={},onDblClick:u})=>{let[c,f]=(0,e.useState)(!1),o=(0,e.useRef)({_chart:null,api(){return this._chart},init(){if(null===this._chart){let e=(0,t.createChart)(i,{...r,...s});this._chart=e,n&&n(this._chart)}return c||f(!0),this._chart},clear(){null!==this._chart&&(f(!1),this._chart.remove(),this._chart=null)}});return(0,e.useLayoutEffect)(()=>(o.current.init(),()=>{o.current.clear()}),[]),(0,e.useLayoutEffect)(()=>{if(i){if(a){var e;null===(e=o.current.api())||void 0===e||e.subscribeClick(a)}return()=>{if(a){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeClick(a)}}}},[a]),(0,e.useLayoutEffect)(()=>{if(i){if(l){var e;null===(e=o.current.api())||void 0===e||e.subscribeCrosshairMove(l)}return()=>{if(l){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeCrosshairMove(l)}}}},[l]),(0,e.useLayoutEffect)(()=>{if(i){if(u){var e;null===(e=o.current.api())||void 0===e||e.subscribeDblClick(u)}return()=>{if(u){var e;null===(e=o.current.api())||void 0===e||e.unsubscribeDblClick(u)}}}},[u]),(0,e.useLayoutEffect)(()=>{var e;i&&(null===(e=o.current.api())||void 0===e||e.applyOptions({...r,...s}))},[s]),{chartApiRef:o,isReady:c}},l=({children:t,container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u})=>{let{chartApiRef:{current:c},isReady:f}=a({container:r,onClick:l,onCrosshairMove:n,onInit:s,options:u});return e.default.createElement(i.Provider,{value:{chartApiRef:c,isReady:f}},t)},n=(0,e.forwardRef)(({children:t,containerProps:i,...r},a)=>{let[n,s]=(0,e.useState)(),u=(0,e.useCallback)(e=>{s(e),a&&("function"==typeof a?u(e):a.current=e)},[a]);return e.default.createElement("div",{ref:u,...i},!!n&&e.default.createElement(l,{container:n,...r},t))});n.displayName="ChartWrapper";let s=(0,e.createContext)(null);s.displayName="TimeScaleContext";let u="1.1.0";function c(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class f extends Error{constructor(e,{isOperational:t=!0,cause:i,docsPath:r}={}){super(e),c(this,"isOperational",void 0),c(this,"cause",void 0),this.name=this.constructor.name??"InternalError",this.isOperational=t,this.cause=i,this.message=`${e??"An error occurred"}`,r&&(this.message=`${this.message}
|
|
12
12
|
|
|
13
13
|
Docs: see ${"https://ukorvl.github.io/lightweight-charts-react-components/docs/"+r}`),u&&(this.message=`${this.message}
|
|
14
14
|
|