tradingview / lightweight-charts

Performant financial charts built with HTML5 canvas
https://www.tradingview.com/lightweight-charts/
Apache License 2.0
9.31k stars 1.61k forks source link

Auto fitting to the height of pane1 histograms #1709

Open vishnuc opened 4 days ago

vishnuc commented 4 days ago

hi , I am testing out v5-candidate with multpane , I added volume series to new pane via

   const volumeSeries = chart.addHistogramSeries({
            color: '#26a69a', // Default color (used for volume bars)
            priceFormat: {
                type: 'volume',
            },
        }, 1); // Add to second pane (pane index 1)

now if i want to scale this volumeseries , it is also scaling the pane 0 price series.

volumeSeries.priceScale().applyOptions({
    autoScale: false, // disables auto scaling based on visible content
    scaleMargins: {
        top: 0.9,
        bottom: 0,
    },
});
Screenshot 2024-10-14 at 1 56 53 PM Screenshot 2024-10-14 at 1 57 43 PM

Its expected to fit / scale only pane 1 as the series is in pane1

safaritrader commented 3 days ago

image

use an id for price scale :

    const volumeSeries = chart.addHistogramSeries({
    color: '#26a69a',
    priceFormat: {
        type: 'volume',
    },
    priceScaleId: 'rightVolume',
}, 1);
chart.priceScale('rightVolume').applyOptions({
    autoScale: false,
    scaleMargins: {
        top: 0.9,
        bottom: 0,
    },
});
vishnuc commented 3 days ago

If i set priceScaleId: 'rightVolume', , I am not able to scale by dragging its pricescale.. also when i hover the volume its not displaying price label on right side.

safaritrader commented 3 days ago

If i set priceScaleId: 'rightVolume', , I am not able to scale by dragging its pricescale.. also when i hover the volume its not displaying price label on right side.

As I understand it, if you want to have full control over the volume, the best approach is to build a plugin, or you can use a secondary overlay canvas or a second price scale at the left

vishnuc commented 2 days ago

sorry , I am not a professional to build plugin..Also i want both price and volume scale on the right, thats why using the pane.

so can you tell me about secondary overlay canvas ?

safaritrader commented 2 days ago

sorry , I am not a professional to build plugin..Also i want both price and volume scale on the right, thats why using the pane.

so can you tell me about secondary overlay canvas ?

as i am a fan of pure js i created a plugin for lightweight chart. you can see the concept and use it : https://github.com/safaritrader/lightweight-chart-plugin

vishnuc commented 2 days ago

wow , thanks i was thinking to create volume profile for my project , but did u extend version 4 or 5 ..i need multi pane support.

safaritrader commented 2 days ago

wow , thanks i was thinking to create volume profile for my project , but did u extend version 4 or 5 ..i need multi pane support.

your welcome. i am expanding that plugin frequently. it's based on v 4.2.0

vishnuc commented 2 days ago

ok , then I want to build plugin for my v5 , can you guide me with any basic tutorials ? there is no documentation in TV how to create a plugin from scratch.

I am coding vanilla js for past 8 years.. since there was no use for constructor , canvas I did not learn , but I am willing to learn now .. can you tell me what should I learn ? because I am new to constructor , canvas etc ..

is there a skeleton or template that i must follow to create plugin from scratch and how it works.

safaritrader commented 2 days ago

ok , then I want to build plugin for my v5 , can you guide me with any basic tutorials ? there is no documentation in TV how to create a plugin from scratch.

I am coding vanilla js for past 8 years.. since there was no use for constructor , canvas I did not learn , but I am willing to learn now .. can you tell me what should I learn ? because I am new to constructor , canvas etc ..

is there a skeleton or template that i must follow to create plugin from scratch and how it works.

As i know the last version for lightweight charts is 4.2

vishnuc commented 2 days ago

ok there is another branch named 5 , you can use that to checkout multi pane feature - https://github.com/tradingview/lightweight-charts/tree/v5-candidate

btw please tell me what should I learn , or any tutorials from scratch to create one simple plugin

safaritrader commented 2 days ago

ok there is another branch named 5 , you can use that to checkout multi pane feature - https://github.com/tradingview/lightweight-charts/tree/v5-candidate

btw please tell me what should I learn , or any tutorials from scratch to create one simple plugin

Official Library suggest to do that : https://github.com/tradingview/lightweight-charts/tree/master/packages/create-lwc-plugin which i am working with pure js and its not fitting my requirements and im using overlay canvas which i described in my Lightwight charts plugin. its very simple when you read you will learn!. the main approach of mine is to use another canvas over the lwc canvas and do every thing you want

vishnuc commented 2 days ago

Ok I am reading your code now. along with chatgpt help

On Wed, 16 Oct, 2024, 4:17 pm Hassan Safari, @.***> wrote:

ok there is another branch named 5 , you can use that to checkout multi pane feature - https://github.com/tradingview/lightweight-charts/tree/v5-candidate

btw please tell me what should I learn , or any tutorials from scratch to create one simple plugin

Official Library suggest to do that :

https://github.com/tradingview/lightweight-charts/tree/master/packages/create-lwc-plugin which i am working with pure js and its not fitting my requirements and im using overlay canvas which i described in my Lightwight charts plugin. its very simple when you read you will learn!. the main approach of mine is to use another canvas over the lwc canvas and do every thing you want

— Reply to this email directly, view it on GitHub https://github.com/tradingview/lightweight-charts/issues/1709#issuecomment-2416441546, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ5HCSFGTVALQBKU4NOK3TZ3Y75TAVCNFSM6AAAAABP4OUWBWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJWGQ2DCNJUGY . You are receiving this because you authored the thread.Message ID: @.***>