Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After removing line form the chart getting issue . #1406

Closed
au190 opened this issue Aug 16, 2023 · 5 comments · Fixed by #1529
Closed

After removing line form the chart getting issue . #1406

au190 opened this issue Aug 16, 2023 · 5 comments · Fixed by #1529

Comments

@au190
Copy link

au190 commented Aug 16, 2023

Lightweight Charts™ Version:

Steps/code to reproduce:
`

<script type="text/javascript" src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"></script> <style> #myDiv { width: 400px; height: 400px; border: 2px solid black; } </style> <script type="text/javascript">

var chart = LightweightCharts.createChart(document.body, {
width: 900,
height: 600,
grid: {
vertLines: {
color: 'rgba(197, 203, 206, 0.5)',
},
horzLines: {
color: 'rgba(197, 203, 206, 0.5)',
},
},
crosshair: {
mode: LightweightCharts.CrosshairMode.Normal,
},
rightPriceScale: {
borderColor: 'rgba(197, 203, 206, 0.8)',
},
timeScale: {
borderColor: 'rgba(197, 203, 206, 0.8)',
},
localization: {
dateFormat: 'yyyy-MM-dd',
},
});

chart.subscribeClick(myClickHandler);
chart.subscribeCrosshairMove(myMouseMoveHandler);

var candleSeries = chart.addCandlestickSeries({
upColor: 'rgba(255, 144, 0, 1)',
downColor: '#000',
borderDownColor: 'rgba(255, 144, 0, 1)',
borderUpColor: 'rgba(255, 144, 0, 1)',
wickDownColor: 'rgba(255, 144, 0, 1)',
wickUpColor: 'rgba(255, 144, 0, 1)',
});

candleSeries.setData([

{ time: '2019-04-16', open: 205.25, high: 205.99, low: 204.29, close: 204.47 },
{ time: '2019-04-17', open: 205.34, high: 206.84, low: 205.32, close: 206.55 },
{ time: '2019-04-18', open: 206.02, high: 207.78, low: 205.10, close: 205.66 },
{ time: '2019-04-22', open: 204.11, high: 206.25, low: 204.00, close: 204.78 },
{ time: '2019-04-23', open: 205.14, high: 207.33, low: 203.43, close: 206.05 },
{ time: '2019-04-24', open: 206.16, high: 208.29, low: 205.54, close: 206.72 },
{ time: '2019-04-25', open: 206.01, high: 207.72, low: 205.06, close: 206.50 },
{ time: '2019-04-26', open: 205.88, high: 206.14, low: 203.34, close: 203.61 },
{ time: '2019-04-29', open: 203.31, high: 203.80, low: 200.34, close: 202.16 },
{ time: '2019-04-30', open: 201.55, high: 203.75, low: 200.79, close: 203.70 },
{ time: '2019-05-01', open: 203.20, high: 203.52, low: 198.66, close: 198.80 },
{ time: '2019-05-02', open: 199.30, high: 201.06, low: 198.80, close: 201.01 },
{ time: '2019-05-03', open: 202.00, high: 202.31, low: 200.32, close: 200.56 },
{ time: '2019-05-06', open: 198.74, high: 199.93, low: 198.31, close: 199.63 },
{ time: '2019-05-07', open: 196.75, high: 197.65, low: 192.96, close: 194.77 },
{ time: '2019-05-08', open: 194.49, high: 196.61, low: 193.68, close: 195.17 },
{ time: '2019-05-09', open: 193.31, high: 195.08, low: 191.59, close: 194.58 },
{ time: '2019-05-10', open: 193.21, high: 195.49, low: 190.01, close: 194.58 },
{ time: '2019-05-13', open: 191.00, high: 191.66, low: 189.14, close: 190.34 },
{ time: '2019-05-14', open: 190.50, high: 192.76, low: 190.01, close: 191.62 },
{ time: '2019-05-15', open: 190.81, high: 192.81, low: 190.27, close: 191.76 },
{ time: '2019-05-16', open: 192.47, high: 194.96, low: 192.20, close: 192.38 },
{ time: '2019-05-17', open: 190.86, high: 194.50, low: 190.75, close: 192.58 },
{ time: '2019-05-20', open: 191.13, high: 192.86, low: 190.61, close: 190.95 },
{ time: '2019-05-21', open: 187.13, high: 192.52, low: 186.34, close: 191.45 },
{ time: '2019-05-22', open: 190.49, high: 192.22, low: 188.05, close: 188.91 },
{ time: '2019-05-23', open: 188.45, high: 192.54, low: 186.27, close: 192.00 },
{ time: '2019-05-24', open: 192.54, high: 193.86, low: 190.41, close: 193.59 },

]);

let m_line = [];
let m_linemk = [];

let o1 = {
time: '2019-04-22',
value: 205,
};
m_line.push(o1);

let o2 = {
time: '2019-05-16',
value: 205,
};
m_line.push(o2);

// Add markers
let m1 = {
id: '123',
time: '2019-04-22',
position: 'inBar',
color: 'rgba(0, 0, 255, 1)',
shape: 'circle',
};
m_linemk.push(m1);

let m2 = {
id: '123',
time: '2019-05-16',
position: 'inBar',
color: 'rgba(0, 0, 255, 1)',
shape: 'circle',
};
m_linemk.push(m2);

line_1 = chart.addLineSeries({
color: 'rgba(0, 0, 255, 1)',
lineWidth: 2,
lastValueVisible: false, // hide value from y axis
priceLineVisible: false,
crosshairMarkerVisible: true,
});

line_1.setData(m_line);
line_1.setMarkers(m_linemk);

console.log(line_1);

function myClickHandler(e){

if(e.hoveredSeries !== undefined && e.hoveredObjectId !== undefined){//Del Line 

  let id = e.hoveredObjectId;
  console.log('myClickHandler: ' + id)
  chart.removeSeries(line_1);
  
}

}
function myMouseMoveHandler(e){

}

</script>

`

Actual behavior:

When I click on the dot to delete the line on the chart getting error in the console browser.
Iam getting this if I subscribed to : chart.subscribeCrosshairMove(myMouseMoveHandler);
If Iam moving the mouse on the chart getting error messages in the console.

Expected behavior:

Removing the line.

Screenshots:
2
1

@SlicedSilver
Copy link
Contributor

You could try use the development build of the library to get a more useful error message.
https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.development.js

@au190
Copy link
Author

au190 commented Aug 16, 2023

Thx, I will check.
Is this could be an issue ? or just configuration ?

Thx for your help.

@SlicedSilver
Copy link
Contributor

I'm closing this issue since there hasn't been any new messages.
If you've managed to use the development build to get a more helpful error message and you are still stuck then please post the error message here.

@au190
Copy link
Author

au190 commented Sep 4, 2023

Hi,

The issue is there in the API ver: TradingView Lightweight Charts™ v4.0.1. If you run my example you will see.
If you can you can please correct the in the API.

@NekitCorp
Copy link
Contributor

NekitCorp commented Feb 28, 2024

@SlicedSilver Hi, I think I'm facing a similar problem. Could you please take a look at a minimally reproducible example? The problem in the example is reproduced when subscribing to crosshair move in the chart and creating any series with the price line. If we are now focused on the price line and at the same time we delete the series, then we get an error. It seems that the link to the price line remains in the subscription and is not cleared until we move the cursor beyond the border of the chart.

The thickness of the price line is intentionally made 15 pixels to make it easier to aim at it, but with a thickness of 1 pixel the problem is also reproduced :)

lightweight-charts version: 4.1.3

Screen.Recording.2024-02-28.at.10.21.45.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants