ColorLine bug

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Jeremy Johnson
Newbie
Newbie
Posts: 16
Joined: Wed Feb 27, 2013 12:00 am

ColorLine bug

Post by Jeremy Johnson » Tue Sep 17, 2013 7:14 pm

ColorLineBug.png
ColorLineBug.png (57.11 KiB) Viewed 6962 times
My WPF TeeChart has multiple ColorLines attached to the Bottom axis. Unfortunately, the lines that have values outside of the "series area" of my chart are still being drawn. In the image above, you can see the ColorLines drawing over my axis label area.

I'm adding the lines with code similar to the following:

Code: Select all

            var line= new ColorLine( chart)
            {
                Axis = chart.Axes.Bottom,
                Pen = { Style = DashStyles.Solid, Color = Colors.Red, Width = 1 },
                Value = Utils.DateTime(alarmEvent.Time),
                AllowDrag = false
            };
Any suggestions for how I can eliminate this issue?

Thanks!

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: ColorLine bug

Post by Sandra » Wed Sep 18, 2013 11:56 am

Jeremy Johnson,

I recommend you two solutions for solve your problem in your code.
First, you can set ColorLine AllowDrag property to true as do in next lines of code:

Code: Select all

  var line = new ColorLine(tChart1.Chart)
          {
            Axis = tChart1.Axes.Bottom,
            Pen = { Style = DashStyles.Solid, Color = Colors.Red, Width = 1 },
           Value = Utils.DateTime(DateTime.Now),
            AllowDrag = true
          };
Previous code do that ColorLine isn't drawn out of bounds of chart.

Second, you can define a limit for the ColorLines aren't drawn out of bounds of Chart.

Code: Select all

        public MainWindow()
        {
            InitializeComponent();
            InitializeChart();
        }
       
        private void InitializeChart()
        {
          FastLine fastLine1 = new FastLine(tChart1.Chart);
         
          var line = new ColorLine(tChart1.Chart)
          {
            Axis = tChart1.Axes.Bottom,
            Pen = { Style = DashStyles.Solid, Color = Colors.Red, Width = 1 },
            AllowDrag = false
          };
          tChart1.Aspect.View3D = false;
          tChart1.Header.Font.Bold = true;
          tChart1.Header.Font.Size = 15;
          fastLine1.FillSampleValues();
          fastLine1.LinePen.Width = 1;
          tChart1.AfterDraw += tChart1_AfterDraw;
        }

        void tChart1_AfterDraw(object sender, Graphics3D g)
        {
          for (int i = 0; i < tChart1.Tools.Count; i++)
          {
            Steema.TeeChart.WPF.Tools.Tool tool = tChart1.Tools[i];
            if (tool is Steema.TeeChart.WPF.Tools.ColorLine)
            {
              if ((tool as Steema.TeeChart.WPF.Tools.ColorLine).Value < tChart1.Axes.Bottom.Minimum || (tool as Steema.TeeChart.WPF.Tools.ColorLine).Value > tChart1.Axes.Bottom.Maximum)
              {
                tool.Active = false;
              }
              else
              {
                tool.Active = true;
              }
            }
          }
        }
Could you tell us if my suggestions help you to solve the problem?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Jeremy Johnson
Newbie
Newbie
Posts: 16
Joined: Wed Feb 27, 2013 12:00 am

Re: ColorLine bug

Post by Jeremy Johnson » Thu Sep 19, 2013 6:46 pm

I think that for now I can perhaps get away with just using a CursorTool, which can render the same effect yet stay within bounds.

Thanks.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: ColorLine bug

Post by Sandra » Fri Sep 20, 2013 11:59 am

Hello Jeremy Johnson,

I am glad that you have found an alternative solution :). On the other hand, could you confirm us if my code works in your end? If it doesn't work in your end could you explain exactly what do you want do ColorLineTool and why doesn't work for you my suggestion code?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply