WIP improve pane api
Type of PR:
PR checklist:
- [ ] Addresses an existing issue: fixes #
- [ ] Includes tests
- [ ] Documentation update
Overview of change:
Is there anything you'd like reviewers to focus on?
size-limit report 📦
| Path | Size |
|---|---|
| ESM | 45.65 KB (+0.26% 🔺) |
| ESM createChart | 37.38 KB (+0.34% 🔺) |
| ESM createChartEx | 36.18 KB (+0.37% 🔺) |
| ESM createYieldCurveChart | 37.68 KB (+0.57% 🔺) |
| ESM createOptionsChart | 36.33 KB (+0.22% 🔺) |
| Standalone-ESM | 47.11 KB (+0.27% 🔺) |
| Standalone | 47.05 KB (+0.37% 🔺) |
| Plugin: Text Watermark | 1.88 KB (0%) |
| Plugin: Image Watermark | 1.69 KB (+0.24% 🔺) |
| Plugin: Series Markers | 4.26 KB (0%) |
| Series: LineSeries | 2.56 KB (+0.12% 🔺) |
| Series: BaselineSeries | 3.2 KB (-0.37% 🔽) |
| Series: AreaSeries | 3.13 KB (-0.16% 🔽) |
| Series: BarSeries | 2.16 KB (+0.1% 🔺) |
| Series: CandlestickSeries | 2.45 KB (0%) |
| Series: HistogramSeries | 2.2 KB (-0.27% 🔽) |
| Plugin: UpDownMarkersPrimitive | 2.4 KB (+0.54% 🔺) |
Could we add a few e2e graphics tests (and have each test check one thing)
- stretchFactor
- preservePane
- Skip default pane, add 2 panes manually, only add a series to second one
- ...
I think we should also update the coverage tests because we have increased the API.
@vishnuc Hi I've added better example in tsdoc https://github.com/tradingview/lightweight-charts/pull/1894/files#diff-c8cf914ef60b765fed227cad366e10a5401ac8d321e695bf684c3463d2ac6093R107-R119
We changed the default to 1, to be less confusing. Sum of stretches shouldn't equal 1 or any other particular number, what's matter is a total sum of stretches of all panes and their difference between each others. You can check _adjustSizeImpl https://github.com/tradingview/lightweight-charts/blob/master/src/gui/chart-widget.ts#L455 and check how the library is calculating height of panes
@vishnuc Hi I've added better example in tsdoc https://github.com/tradingview/lightweight-charts/pull/1894/files#diff-c8cf914ef60b765fed227cad366e10a5401ac8d321e695bf684c3463d2ac6093R107-R119
We changed the default to 1, to be less confusing. Sum of stretches shouldn't equal 1 or any other particular number, what's matter is a total sum of stretches of all panes and their difference between each others. You can check
_adjustSizeImplhttps://github.com/tradingview/lightweight-charts/blob/master/src/gui/chart-widget.ts#L455 and check how the library is calculating height of panes
thanks makes sense.. on users drag and resizing does this stretchFactor change.. and can we get the changed via getsetfactor ?
Hey @illetid, thanks a lot for that long-awaited update!
Just to clarify, if a user decides to preserve 0 pane and 2 pane, with 0 and 2 indexes accordingly, how it would assign indexes if a user removes, for instance, pane with index 1? Will it shift them, making previously 2nd pane having index of 1 or there will be a "gap"?
Hey @illetid, thanks a lot for that long-awaited update! Just to clarify, if a user decides to preserve 0 pane and 2 pane, with 0 and 2 indexes accordingly, how it would assign indexes if a user removes, for instance, pane with index
1? Will it shift them, making previously 2nd pane having index of 1 or there will be a "gap"?
my assumption was if you want to build a component based wrapper you should always use preserve empty pane and addDefaultPane: false. and if you want to remove pane you just not reder the component in react.
Answering your question yes indexes will be recalculated since it's an array indexes
Hey @illetid, thanks a lot for that long-awaited update! Just to clarify, if a user decides to preserve 0 pane and 2 pane, with 0 and 2 indexes accordingly, how it would assign indexes if a user removes, for instance, pane with index
1? Will it shift them, making previously 2nd pane having index of 1 or there will be a "gap"?my assumption was if you want to build a component based wrapper you should always use preserve empty pane and
addDefaultPane: false. and if you want to remove pane you just not reder the component in react.Answering your question yes indexes will be recalculated since it's an array indexes
Agree with the assumption, it solves the base problem of wrapper component. I'm currently looking a bit further onto the controllable pane indexes, but it is not related to the current scope.