You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-21Lines changed: 23 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,32 +65,31 @@ container?: {
65
65
ref?: (element:HTMLElement|null) =>void;
66
66
class?:string;
67
67
id?:string;
68
+
style?:string;
68
69
}
69
70
```
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:
71
74
```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}/>
74
80
</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>
93
88
```
89
+
90
+
#### SSR
91
+
The chart component will reserve the specified `width` and `height` during SSR if the chart is not auto-sized.
@@ -120,6 +119,9 @@ To pass a data to a series you can use the `data` property. Look [here](https://
120
119
By default `data` represents only the **initial** data. Any subsequent data update does not update series.
121
120
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.
122
121
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
+
123
125
### Price line
124
126
125
127
To draw price line add `<PriceLine>` component inside any series.
0 commit comments