Kaktana / kaktana-react-lightweight-charts

A simple react wrapper for the tradingview lightweight charts module
MIT License
106 stars 55 forks source link

autoscaleInfoProvider doesn't take effect #23

Open dimitarangelkov opened 3 years ago

dimitarangelkov commented 3 years ago

https://github.com/tradingview/lightweight-charts/blob/v3.3.0/docs/series-basics.md#overriding-autoscale

Here is the context I am using it

  const options = {
    layout: {
      backgroundColor: '#fff',
      textColor: 'rgba(145, 150, 179, 1)',
      fontSize: 12,
    },
    grid: {
      vertLines: {
        color: 'rgba(223, 225, 233, 1)',
        style: 2,
        visible: true,
      },
      horzLines: {
        color: 'rgba(223, 225, 233, 1)',
        style: 2,
        visible: true,
      },
    },
    crosshair: {
        vertLine: {
            color: 'rgba(78, 84, 113, 1)',
            width: 0.5,
            style: 2,
            visible: true,
            labelVisible: false,
        },
        horzLine: {
            color: 'rgba(78, 84, 113, 1)',
            width: 0.5,
            style: 2,
            visible: true,
            labelVisible: true,
        },
        mode: 1,
    },
    handleScroll: false,
    handleScale: false,
    axisPressedMouseMove: false,
    priceScale: {
        borderVisible: false,
    },
    timeScale: {
      rightOffset: 0,
      fixLeftEdge: true,
      lockVisibleTimeRangeOnResize: true,
      shiftVisibleRangeOnNewBar: false,
      timeVisible: true,
      secondsVisible: true,
      borderVisible: false,
    },    
  };

  const lineSeries = [
    {
      options: {
        color: 'rgba(76, 194, 194, 1)',
        lineWidth: 3,
        crosshairMarkerVisible: true,
        crosshairMarkerRadius: 8,
        autoscaleInfoProvider: () => ({
          priceRange: {
            minValue: 0,
            maxValue: 500,
          },
        }),
      },
      data: chart ? chart.map((el) => {        
        return { time: el.time, value: el.price };
      }) : [],
    },
  ];

  return (
      <Chart
        options={options}
        lineSeries={lineSeries}
        autoWidth
        height={190}
      />
  );
billyjacoby commented 2 years ago

Hey I'm running into this exact issue, did you ever find a solution?