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

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

PriceScale `scaleMargins` doesn't work #9

Closed cjkoepke closed 1 year ago

cjkoepke commented 1 year ago

The PriceScale component does not update the actual price scale of the matching Series.

<Chart
            handleScale={{
              axisDoubleClickReset: true,
            }}
            timeScale={{
              timeVisible: true,
              fixLeftEdge: true,
              fixRightEdge: true,
              lockVisibleTimeRangeOnResize: true,
            }}
          >
<HistogramSeries
  priceScaleId="right"
  priceFormat={{
    type: "volume",
  }}
  data={volumeData ?? []}
/>
<PriceScale
  id="right"
  scaleMargins={{
    top: 0.8,
    bottom: 0
  }}
/>
</Chart>
trash-and-fire commented 1 year ago

looks like a bug. I'll see what could be the problem.

trash-and-fire commented 1 year ago

What version of react and lightweight-charts are you using?

trash-and-fire commented 1 year ago

Try using as workaround:

<Chart
    rightPriceScale: {
        scaleMargins={
            top: 0.8,
            bottom: 0
        }
    }
>
cjkoepke commented 1 year ago

I would try using the top-level default settings, but I have two charts and need them to have independent scale margins. My example was just for brevity as it doesn't seem to matter how many there are.

React: 18.2.0 Lightweight Charts: 4.0.1

trash-and-fire commented 1 year ago

Try using 1.3.3. There should be a fix.

cjkoepke commented 1 year ago

Try using 1.3.3. There should be a fix.

This fixed the issue! Thanks for the quick response.