Page 1 of 1

ColorLine bug

Posted: Tue Sep 17, 2013 7:14 pm
by 15665264
ColorLineBug.png
ColorLineBug.png (57.11 KiB) Viewed 7008 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!

Re: ColorLine bug

Posted: Wed Sep 18, 2013 11:56 am
by 10050769
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,

Re: ColorLine bug

Posted: Thu Sep 19, 2013 6:46 pm
by 15665264
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.

Re: ColorLine bug

Posted: Fri Sep 20, 2013 11:59 am
by 10050769
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,