Skip to content

Commit 25fc6c1

Browse files
Merge pull request #75 from trash-and-fire/70_update_readme_and_changelog
70: change README and CHANGELOG
2 parents 60f1420 + ec3a562 commit 25fc6c1

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 2.1.0
44

55
- Added `markers` property to `<[Type]Series>` components.
6+
- Supported `kineticScroll` and `trackingMode` options on `<Chart>` component.
67
- Supported `autoSize` option on `<Chart>` component.
78
- Reduced layout shift on SSR. The chart component will reserve the specified width and height if the chart is not auto-sized.
89

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,32 +65,31 @@ container?: {
6565
ref?: (element: HTMLElement | null) => void;
6666
class?: string;
6767
id?: string;
68+
style?: string;
6869
}
6970
```
70-
It might be helpful to [auto-size](https://svelte.dev/repl/22c14c4729d44d65a69346d1e3cc6e89) your chart container via ResizeObserver.
71+
If you need a reference to the containing dom element you can use `ref` property. It might be useful to setup IntersectionObserver on this dom element.
72+
73+
Use `class` or `style` properties with `<Chart autoSize={true}/>` to set up an adaptive chart:
7174
```svelte
72-
<Chart {width} {height} container={{ref}}>
73-
<CandlestickSeries {data}/>
75+
<Chart
76+
autoSize={true}
77+
container={{class: 'chart-container'}}
78+
>
79+
<LineSeries data={data}/>
7480
</Chart>
75-
<script>
76-
let observer;
77-
let width = 600;
78-
let height = 300;
79-
let ref = (element) => {
80-
if (observer) {
81-
observer.disconnect();
82-
}
83-
if (!element) {
84-
return;
85-
}
86-
observer = new ResizeObserver(([entry]) => {
87-
width = entry.contentRect.width;
88-
height = entry.contentRect.height;
89-
});
90-
observer.observe(element);
91-
}
92-
</script>
81+
<style>
82+
:global(.chart-container) {
83+
aspect-ratio: 16 / 9;
84+
width: 80%;
85+
margin: auto;
86+
}
87+
</style>
9388
```
89+
90+
#### SSR
91+
The chart component will reserve the specified `width` and `height` during SSR if the chart is not auto-sized.
92+
9493
Events:
9594
- [`on:crosshairMove`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/IChartApi#subscribeclick): `(event: CustomEvent<MouseEventParams>) => void`
9695
- [`on:click`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/IChartApi#subscribecrosshairmove): `(event: CustomEvent<MouseEventParams>) => void`
@@ -120,6 +119,9 @@ To pass a data to a series you can use the `data` property. Look [here](https://
120119
By default `data` represents only the **initial** data. Any subsequent data update does not update series.
121120
If you want to change this behavior please add [`reactive={true}`](https://svelte.dev/repl/0efb2840a9844ed5a1d84f2a1c9a2269) to your series component. In this case series will apply a new data if it is not reference equal to previous array.
122121

122+
#### Passing markers
123+
To pass markers to a series you can use the `markers` property. Markers should be an array of `SeriesMarker<Time>`.
124+
123125
### Price line
124126

125127
To draw price line add `<PriceLine>` component inside any series.

0 commit comments

Comments
 (0)