ColorLine and Move chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

ColorLine and Move chart

Post by acastro » Tue Nov 12, 2013 2:01 pm

Please find this example
http://193.145.251.126/pnp/files/ZQyAYs ... chart3.zip

Button1 adds a colorline in 150, if you move then the chart the color line goes out of the chart (in the screen shot you can see it below the x axis).
I see it only happnes if AllowDrop property is false

Is it a bug or can I avoid going out the chart?

Thanks
Attachments
colorline.png
colorline.png (23.22 KiB) Viewed 14619 times

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

Re: ColorLine and Move chart

Post by Sandra » Thu Nov 14, 2013 2:12 pm

Hello wakeup,

To solve your problem I recommend you taking a look in this link, where you find different methods to avoid ColorLine tool drag out of bounds of chart.

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: ColorLine and Move chart

Post by acastro » Thu Nov 14, 2013 3:34 pm

The first solution is not valid because I dont want it to be dragable.

And the second doesn't run well, sometime the tool is active and it is not shown, and somtimes it is not active and it is shown. It seems it is not well refreshed the active property.

Is this issue already reported as a bug?

Thanks

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

Re: ColorLine and Move chart

Post by Sandra » Fri Nov 15, 2013 2:25 pm

Hello wakeup,

I have modified the code and now it works in correct way:

Code: Select all

       public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      FastLine fastLine1 = new FastLine(tChart1.Chart);

      var line = new ColorLine(tChart1.Chart)
      {
        Axis = tChart1.Axes.Left,
        Pen = { Style = DashStyle.Solid, Color = Color.Red, Width = 1 },
        AllowDrag = false
      };
      tChart1.Aspect.View3D = false;
      tChart1.Header.Font.Bold = true;
      tChart1.Header.Font.Size = 15;
      fastLine1.FillSampleValues();
      line.Value = fastLine1.YValues.Minimum - 50;
      fastLine1.LinePen.Width = 1;
      tChart1.AfterDraw += tChart1_AfterDraw;
      tChart1.Draw();
    }

    void tChart1_AfterDraw(object sender, Graphics3D g)
    {
      for (int i = 0; i < tChart1.Tools.Count; i++)
      {
        Steema.TeeChart.Tools.Tool tool = tChart1.Tools[i];
        if (tool is Steema.TeeChart.Tools.ColorLine)
        {
          if ((tool as Steema.TeeChart.Tools.ColorLine).Value < tChart1.Axes.Left.Minimum || (tool as Steema.TeeChart.Tools.ColorLine).Value > tChart1.Axes.Left.Maximum)
          {
            tool.Active = false;
          }
          else
          {
            tool.Active = true;
          }
        }
      }
    }
Could you tell us if previous code works in your end?

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: ColorLine and Move chart

Post by acastro » Fri Nov 15, 2013 2:40 pm

I did change bottom to left axis in the previous code. That is not the reason because it didn't run. The reason was sometime the tool is active and it is not shown, and sometimes it is not active and it is shown. It seems it is not well refreshed the active property. It sometimes happens in general in teechart, but I use to solve it putting a chart.refresh() in the code, but in this case I can't because it would be a infinite loop.

Is this issue already reported as a bug?

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

Re: ColorLine and Move chart

Post by Sandra » Fri Nov 15, 2013 3:29 pm

Hello wakeup,

The line of code I have added to solve the problem is next:

Code: Select all

tChart1.AfterDraw += tChart1_AfterDraw;
      tChart1.Draw();
I realized is necessary repainting the chart after initialize AfterDraw event, so the ColorLine tool is drawing correctly and if I use tChart1.Draw() method, the active property is refreshed as I expect. Please, check my code and tell us if it help you.

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: ColorLine and Move chart

Post by acastro » Fri Nov 15, 2013 3:58 pm

I follow with the same problems with that code:

I already had the instrucction
this.chart.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(this.chart_AfterDraw);
which I think is similar.

and "chart.Draw();" in the initialization doesn't do anything especial, because the refreshing problem is not in the initialization, but in the "AfterDraw" function, and in that function I cannot put the chart.Draw() instruction because it would be a infinite loop.

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

Re: ColorLine and Move chart

Post by Sandra » Fri Nov 15, 2013 4:26 pm

Hello wakeup,

Ok. I couldn't reproduce the problem you there is with ColorLine Tool using my last code. Could you please, make a project, where your problem appears and I can reproduce it here?

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: ColorLine and Move chart

Post by acastro » Mon Nov 18, 2013 9:10 am

Here you have
http://193.145.251.126/pnp/files/QOQduc ... orline.zip

If you do zoom, and after that an uzoom, most of the times the color line is not shown.

Thanks

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

Re: ColorLine and Move chart

Post by Sandra » Mon Nov 18, 2013 1:03 pm

Hello wakeup,

Your code need refresh the chart when you add data and do Unzoom, if you want ColorLine draw correctly. I have modified your code and it works in my end:

Code: Select all

 public Form1()
        {
          InitializeComponent(); 
        }

        private void Form1_Load(object sender, EventArgs e)
        {
          tChart1.UndoneZoom += tChart1_UndoneZoom;
        }
        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
          tChart1.Draw();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            tChart1.Series[0].FillSampleValues();
            tChart1.Draw();
        }
        private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            for (int i = 0; i < tChart1.Tools.Count; i++)
            {
                Steema.TeeChart.Tools.Tool tool = tChart1.Tools[i];
                if (tool is Steema.TeeChart.Tools.ColorLine)
                {

                    if ((tool as Steema.TeeChart.Tools.ColorLine).Value < tChart1.Axes.Left.Minimum || (tool as Steema.TeeChart.Tools.ColorLine).Value > tChart1.Axes.Left.Maximum)
                    {
                        tool.Active = false;
                    }
                    else
                    {
                        tool.Active = true;
                    }

                }
            }
        }
Could you confirm us if the code works now in your end?

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: ColorLine and Move chart

Post by acastro » Mon Nov 18, 2013 1:54 pm

Ok thanks, now it seems to run. But anyway, I think it would be better to do all this automatically, as when allowDrop is true. Would not it?

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

Re: ColorLine and Move chart

Post by Sandra » Thu Nov 21, 2013 9:13 am

Hello wakeup,

Sorry for the delay. After do many test with ColorLine tool we consider your request as a bug and we have added it to bug list with number [id447]. We will try to fix it to upcoming versions of TeeChartFor.Net. Remember you can follow its status in this link. On the other hand, if you want you can sign up at bugzilla and submit and follow up issues yourself in our new bugzilla bug tracking system


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