In my code I have a class-wide instance of CusorTool cursorTool1. In the code, each time (for example) I load some data I reset cursorTool1 to be 'new CursorTool(myChart.Chart).
But rather than updating the cursortool I seem to have an extra copy of the cursor on that chart after each time, that is I want to 'clear the cursor' from the chart. Should I do something like name it, iterate through the series list and remove it before do the 'new' on it?
Thanks
cursorTool redux issue
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi dunion,
Yes, you can do something like this:
Yes, you can do something like this:
Code: Select all
private Steema.TeeChart.Tools.CursorTool cursor1;
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
cursor1 = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
}
private void button1_Click(object sender, EventArgs e)
{
tChart1.Tools.Remove(cursor1);
cursor1 = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
doesn't seem to be working...
try { tChart1.Tools.Remove(cursorTool1);
} catch (Exception) { } // don't care if we don't find it.
cursorTool1 = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
Still seeing more tools on the screen even if I clear out the series list and replot the data.
} catch (Exception) { } // don't care if we don't find it.
cursorTool1 = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
Still seeing more tools on the screen even if I clear out the series list and replot the data.
Hello dunion,
I couldn't reproduce your issue here, with last version of TeeChartFor .NET version 3.
Please, you could say which version of TeeChartFor .NET you can use?
Also, I recomend dowload last version of TeechartFor .NET and check if this issue works fine or not.
Thank,
I couldn't reproduce your issue here, with last version of TeeChartFor .NET version 3.
Please, you could say which version of TeeChartFor .NET you can use?
Also, I recomend dowload last version of TeechartFor .NET and check if this issue works fine or not.
Thank,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
got it working
What I had wa (psedocode)
// method in class
private void DoStuff(CursorTool ct, Chart ch, ...) {
ch.Tools.Remove(ct)
ct = new CursorTool(ch.Chart);
... other stuff
}
// upper level method
private CursorTool ct1 = new..., ct2 = new...
private Chart c1, c2 ...
if (some condition) {
DoStuff(ct1, c1...)
} else {
DoStuff(ct2, c2...)
}
That wasn't working in the method but when I explicitly
do the
if (condition) {
c1.Tools.Remove(ct1)
// other stuff method call
} else {
c2.Tools.Remove(ct2)
// other stuff method call
}
That works, so I'm OK. Not sure why the general handler didn't work, I was automatically starting with refactored code by habit.
Thanks.
// method in class
private void DoStuff(CursorTool ct, Chart ch, ...) {
ch.Tools.Remove(ct)
ct = new CursorTool(ch.Chart);
... other stuff
}
// upper level method
private CursorTool ct1 = new..., ct2 = new...
private Chart c1, c2 ...
if (some condition) {
DoStuff(ct1, c1...)
} else {
DoStuff(ct2, c2...)
}
That wasn't working in the method but when I explicitly
do the
if (condition) {
c1.Tools.Remove(ct1)
// other stuff method call
} else {
c2.Tools.Remove(ct2)
// other stuff method call
}
That works, so I'm OK. Not sure why the general handler didn't work, I was automatically starting with refactored code by habit.
Thanks.
Another case where it's failing
If I have one line on the chart and I remove the line and the cursor I can get it to go away. But if I re-use a line and leave a line (.net v3 teechart) it doesn't go away.
So chart 1 for example has one line, I can search through the series on the chart object, if I find mine, I can clear the data and reload it and I can get the cursor to go away.
But on my chart2 test, I have that series and another series - that other series doesn't have a cursor attached. But on that one if I reload data on the series of interest (leave the other series the same) the cursor doesn't go away and I have two cursors pointing to the changed series - but the first cursor still thinks it's looking at the 'old values' (so it's off) while the new instance is correct.
Anything else to try?
So chart 1 for example has one line, I can search through the series on the chart object, if I find mine, I can clear the data and reload it and I can get the cursor to go away.
But on my chart2 test, I have that series and another series - that other series doesn't have a cursor attached. But on that one if I reload data on the series of interest (leave the other series the same) the cursor doesn't go away and I have two cursors pointing to the changed series - but the first cursor still thinks it's looking at the 'old values' (so it's off) while the new instance is correct.
Anything else to try?
More investigation
it's not really going away in the first case, in fact in the debugger, each time I load new curve data into the existing series if I look at chart.tools.base the count is incrementing each time, so basically all the 'cursor tools' are really just stacked on top of each other so it doesn't look like there are (for example) a lot of them. If I check the list of tools at runtime (foreach tool t in...) and then look for 'is a cursortool' I get this incremented each time despite using chart1.Tools.Remove(cursorTool1) and (just in case) chart1.Chart.Tools.Remove(cursorTool1).
So if you have something else to try let me know.
Thanks.
So if you have something else to try let me know.
Thanks.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi dunion,
Could you please send us a simple example project we can run "as-is" to reproduce the problem here and let us know the exact TeeChart for .NET v3 build you are using? Notice that last version available is build 3.5.3371.26404/5/6 from 25th March 2009.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Could you please send us a simple example project we can run "as-is" to reproduce the problem here and let us know the exact TeeChart for .NET v3 build you are using? Notice that last version available is build 3.5.3371.26404/5/6 from 25th March 2009.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
My teechart version
3.5.3274.30664
Figured out what was up and why....
Thanks.
Figured out what was up and why....
Thanks.