trash-and-fire / lightweight-charts-react-wrapper

React wrapper for financial lightweight charts
Other
58 stars 5 forks source link

Is it possible to add HTML to the top left of charts? #13

Open wozhendeai opened 10 months ago

wozhendeai commented 10 months ago

For example, see here: https://tradingview.github.io/lightweight-charts/tutorials/customization/finishing-touches image

trash-and-fire commented 10 months ago

Yes. You can start with "legend" or "moving everage" examples on the demo page

trash-and-fire commented 10 months ago

Oh I should update the examples in the code-sandbox to match version 4.0.0 =(

trash-and-fire commented 10 months ago

So the idea is to wrap the chart component in a relative div and place whatever you want on the chart using absolute position.

            <div className={styles.container}>
                <Chart height={300} width={600}>
                    <AreaSeries data={data}/>
                </Chart>
                <div className={styles.legend}>{legend}</div>
            </div>
 .container {
    position: relative;
}

.legend {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 1;
    font-size: 12px;
    line-height: 18px;
    font-weight: 300;
}