tradingview / lightweight-charts

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

Still showing price line label on price axis after removing it #1020

Closed shaohlalnyd closed 2 years ago

shaohlalnyd commented 2 years ago

Hi I have 3 price line in my chart .and update them after stream received When new data received from socket , first I remove the previous price line and then add new. Every thing is okay, but when user de active the page (Like go to another tab) price line removed but the label of that price line still showing.

WhatsApp Image 2022-02-16 at 8 04 38 PM

the above photo its what heppening. i coding in react .

if (priceLineSerie) candleSerie.removePriceLine(priceLineSerie); 
if (tp1LineSerie) candleSerie.removePriceLine(tp1LineSerie);
if (slLineSerie) candleSerie.removePriceLine(slLineSerie); 
if (candleSerie) candleSerie.setMarkers([]);

the above code when run a new event received and remove the price lines.

    //entry price line

    const priceLine = candleSerie.createPriceLine({
      price: chartData.entryPrice,
      color: "#0000ff",
      lineWidth: 2,
      // lineStyle: 'Solid',
      axisLabelVisible: true,
      title: "Price",
    });

    setPriceLineSerie(priceLine);

    candleSerie.createPriceLine(priceLine);

    //tp1 line

    const tp1Line = candleSerie.createPriceLine({
      price: chartData.tp1,
      color: "#00ff00",
      lineWidth: 2,
      // lineStyle: 'Solid',
      axisLabelVisible: true,
      title: "TP",
    });

    setTp1LineSerie(tp1Line);

    candleSerie.createPriceLine(tp1Line);

    //sl line

    const slLine = candleSerie.createPriceLine({
      price: chartData.sl,
      color: "#ff0000",
      lineWidth: 2,
      // lineStyle: 'Solid',
      axisLabelVisible: true,
      title: "SL",
    });

    setSlLineSerie(slLine);

    candleSerie.createPriceLine(slLine);

above code , add price line to candle serie.

Please help me how to fix it

timocov commented 2 years ago

Please help me how to fix it

Is there any chance to provide a repro for that? Otherwise I don't think that it is possible to help.

shaohlalnyd commented 2 years ago

Please help me how to fix it

Is there any chance to provide a repro for that? Otherwise I don't think that it is possible to help.

please open this issue

timocov commented 2 years ago

@shaohlalnyd thanks for you code samples, but this is not enough. What steps to reproduce the issue? Is it possible to create a jsfiddle example with your issue?

timocov commented 2 years ago

I'm going to close the issue. If you'll have any question or updates - feel free to ping me.