lightweight-charts icon indicating copy to clipboard operation
lightweight-charts copied to clipboard

Enable pane support

Open illetid opened this issue 10 months ago • 9 comments

Type of PR: enhancement

PR checklist:

  • [ ] Addresses an existing issue: fixes #50
  • [ ] Includes tests
  • [ ] Documentation update

Overview of change: Based on community implementation https://github.com/tradingview/lightweight-charts/pull/824

illetid avatar Apr 05 '24 10:04 illetid

Also take a look at horizontal crosshair line visibility, it should be painted on the active pane only. The same logic should be applied for crosshair price label as well.

image

And for some reason vertical line is not painted on the first pane

kirchet avatar Apr 10 '24 17:04 kirchet

Also take a look at horizontal crosshair line visibility, it should be painted on the active pane only. The same logic should be applied for crosshair price label as well.

image

And for some reason vertical line is not painted on the first pane

thanks for spotting this one, fixed crosshair in https://github.com/tradingview/lightweight-charts/pull/1557/commits/5fc37ee4450b9db08174c048ed61b045e0d63677

illetid avatar Apr 11 '24 11:04 illetid

It's something wrong here 🙂

image

kirchet avatar Apr 18 '24 10:04 kirchet

It's something wrong here 🙂

image

'QA' testing coming soon. 😅 Been focused on the API design review first.

Agree that we should only have a single TV attribution logo (on the bottom pane). Also the price label is different. Is it the exact same data? or is it randomised a bit?

SlicedSilver avatar Apr 18 '24 10:04 SlicedSilver

It's something wrong here 🙂 image

'QA' testing coming soon. 😅 Been focused on the API design review first.

Agree that we should only have a single TV attribution logo (on the bottom pane). Also the price label is different. Is it the exact same data? or is it randomised a bit?

fixed logo duplication in https://github.com/tradingview/lightweight-charts/pull/1557/commits/c391ec18accda43087f4bf3a345fe69a7b167f8e

illetid avatar Apr 22 '24 11:04 illetid

  1. After an error of using moveToPane(-1) then you can no longer move the pane.
// ...create a normal chart above...
volumeSeries = chart.addHistogramSeries(
    {
        priceFormat: {
            type: 'volume',
        },
    },
    1 // Pane index
);

volumeSeries.setData(generateLineData())

volumeSeries.moveToPane(2); // okay
volumeSeries.moveToPane(5); // okay
volumeSeries.moveToPane(-1); // error, but expected

volumeSeries.moveToPane(2); // error, but should work

  1. Moving a series to a different price scale seems to also move the series to pane 0
// ...create a normal chart above...
volumeSeries = chart.addHistogramSeries(
    {
        priceFormat: {
            type: 'volume',
        },
    },
    1 // Pane index
);

volumeSeries.setData(generateLineData())

// make left price scale visible
chart.applyOptions({leftPriceScale: {visible: true}})

// move volume series to left price scale
volumeSeries.applyOptions({priceScaleId: 'left'})

// !! now appears in pane 0

volumeSeries.moveToPane(1) // does nothing since it thinks it is in pane 1

volumeSeries.moveToPane(0) // hides empty pane 1
volumeSeries.moveToPane(1) // now the volume is back into the correct position

  1. Using the above bug, it is possible to get an empty pane within the middle of the chart
// ...create a normal chart above...
volumeSeries = chart.addHistogramSeries(
    {
        priceFormat: {
            type: 'volume',
        },
    },
    1 // Pane index
);

volumeSeries.setData(generateLineData())

// make left price scale visible
chart.applyOptions({leftPriceScale: {visible: true}})

// move volume series to left price scale
volumeSeries.applyOptions({priceScaleId: 'left'})

// !! now appears in pane 0

volumeSeries.moveToPane(2) // There is now an empty pane 1. Showing 3 panes

SlicedSilver avatar Apr 29 '24 12:04 SlicedSilver

[Minor] When dragging the pane separator, the time scale width can change. Maybe we would want to 'fix' the time scale width while dragging?

Let's only do this if it is easy, and lightweight to implement.

https://github.com/tradingview/lightweight-charts/assets/3482679/39e30ada-f9eb-4c0e-8339-68ef59572bbd

SlicedSilver avatar Apr 29 '24 12:04 SlicedSilver

  1. After an error of using moveToPane(-1) then you can no longer move the pane.
// ...create a normal chart above...
volumeSeries = chart.addHistogramSeries(
    {
        priceFormat: {
            type: 'volume',
        },
    },
    1 // Pane index
);

volumeSeries.setData(generateLineData())

volumeSeries.moveToPane(2); // okay
volumeSeries.moveToPane(5); // okay
volumeSeries.moveToPane(-1); // error, but expected

volumeSeries.moveToPane(2); // error, but should work
  1. Moving a series to a different price scale seems to also move the series to pane 0
// ...create a normal chart above...
volumeSeries = chart.addHistogramSeries(
    {
        priceFormat: {
            type: 'volume',
        },
    },
    1 // Pane index
);

volumeSeries.setData(generateLineData())

// make left price scale visible
chart.applyOptions({leftPriceScale: {visible: true}})

// move volume series to left price scale
volumeSeries.applyOptions({priceScaleId: 'left'})

// !! now appears in pane 0

volumeSeries.moveToPane(1) // does nothing since it thinks it is in pane 1

volumeSeries.moveToPane(0) // hides empty pane 1
volumeSeries.moveToPane(1) // now the volume is back into the correct position
  1. Using the above bug, it is possible to get an empty pane within the middle of the chart
// ...create a normal chart above...
volumeSeries = chart.addHistogramSeries(
    {
        priceFormat: {
            type: 'volume',
        },
    },
    1 // Pane index
);

volumeSeries.setData(generateLineData())

// make left price scale visible
chart.applyOptions({leftPriceScale: {visible: true}})

// move volume series to left price scale
volumeSeries.applyOptions({priceScaleId: 'left'})

// !! now appears in pane 0

volumeSeries.moveToPane(2) // There is now an empty pane 1. Showing 3 panes
  1. we are throwing an error and a developer who uses the library should handle the error
  2. and 3 fixed in https://github.com/tradingview/lightweight-charts/pull/1557/commits/745e4bfac02cf29d62fa9bff43f962a4c79b954d

illetid avatar Apr 30 '24 10:04 illetid

[Minor] When dragging the pane separator, the time scale width can change. Maybe we would want to 'fix' the time scale width while dragging?

Let's only do this if it is easy, and lightweight to implement.

time-scale-width-changing.mov

@SlicedSilver could we move this to future improvements

illetid avatar Apr 30 '24 10:04 illetid

can't express how much I am waiting for this feature, guys! So grateful for everyones work ❤️

SigmaU avatar Jun 09 '24 10:06 SigmaU