Page 1 of 1

ColorLines not cleared from chart

Posted: Thu Jan 14, 2010 8:58 pm
by 15654674
Using Teechart.WPF.dll 4.0.2009.35592, we are using ColorLines to act as cursors for our chart, letting the user know what value a particular series is at a given point. They work fairly well for the most part, but we are running into a problem when the user clears the chart. We do this by removing all custom axes, series and tools. Unfortunately, the cursors are NOT cleared out even though they no longer show up in the chart's tool collection - they are still drawn on the chart. I coded a very simple WPF application to demonstrate the problem:

Code: Select all

    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            Axis axis = new Axis(false, false, chart.Chart);
            axis.MinimumOffset = axis.MaximumOffset = 5;
            chart.Axes.Custom.Add(axis);

            chart.Series.Add(new Steema.TeeChart.WPF.Styles.Line());
            chart.Series[0].FillSampleValues();

            ColorLine cursor = new ColorLine();
            cursor.Value = 5;
            cursor.Axis = chart.Axes.Bottom;
            chart.Tools.Add(cursor);

            chart.MouseDoubleClick += DoubleClick;
        }

        void DoubleClick(object sender, MouseEventArgs e)
        {
            chart.Axes.Custom.Clear();
            chart.Series.Clear();
            chart.Tools.Clear();

            Axis axis = new Axis(false, false, chart.Chart);
            axis.MinimumOffset = axis.MaximumOffset = 5;
            chart.Axes.Custom.Add(axis);

            chart.Series.Add(new Steema.TeeChart.WPF.Styles.Line());
            chart.Series[0].FillSampleValues();
        }
    }
The window has a grid with a single TChart object in it called "chart". When the application starts up, you can see a ColorLine at position 5. If you double-click on the chart, I would expect the code in DoubleClick to clear the chart of everything, including the ColorLine, and then display the same sort of chart as before, without a ColorLine visible. (The data's random, but the layout's the same.) However, after double-clicking, the ColorLine is still visible at position 5.

We've found that the ColorLines remain drawn through Chart.Invalidate() and other methods that we would normally expect to force a redraw. However, resizing the window seems to do the trick of removing them. That seems like a rather poor way of getting rid of them though. Are we doing something wrong in the reset code or is this a bug that will be fixed soon?

Re: ColorLines not cleared from chart

Posted: Fri Jan 15, 2010 3:01 pm
by yeray
Hi Charles,

You are right, I could reproduce it. It seems that the function tChart1.Tools.Clear(); clears the tool list but for some reason the ColorLineTools are still drawn. I've added it to the defect list to be fixed as soon as possible (TW16014640).

Re: ColorLines not cleared from chart

Posted: Tue Apr 06, 2010 1:58 pm
by narcis
Hi Charles,

Please notice TW16014640 has been fixed for next maintenance release.