ScrollPager doesn't respect the margin of customaxis

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

ScrollPager doesn't respect the margin of customaxis

Post by acastro » Wed Mar 05, 2014 11:09 am

If I have a custom axis with a manually set margin and I add a page scroller it doesn respect the margin.

Please find the example, press button2, and the button1
http://193.145.251.126/pnp/files/rjiKjX ... croll2.zip

Thanks

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: ScrollPager doesn't respect the margin of customaxis

Post by Christopher » Thu Mar 06, 2014 10:30 am

wakeup wrote:If I have a custom axis with a manually set margin and I add a page scroller it doesn respect the margin.
As we've discussed before, I believe, the ScrollPagerTool uses sets TChart.Chart.CustomChartRect to TRUE every time it is painted, so making these margins non-functional. One workaround would be:

Code: Select all

        private void button2_Click(object sender, EventArgs e)
        {
          AddCustomAxis();
          tChart1.BeforeDraw += tChart1_BeforeDraw;
          tChart1.Invalidate();
        }

        private void AddCustomAxis()
        {
          Steema.TeeChart.Axis customAxis = new Steema.TeeChart.Axis(tChart1.Chart);
          customAxis.Title.Visible = false;
          customAxis.Visible = false;
          customAxis.Horizontal = false;
          customAxis.Automatic = true;

          customAxis.Ticks.Color = tChart1.Series[0].Color;
          customAxis.AxisPen.Color = tChart1.Series[0].Color;
          customAxis.Labels.Font.Color = tChart1.Series[0].Color;

          tChart1.Axes.Custom.Add(customAxis);
          tChart1.Series[0].CustomVertAxis = customAxis;
          tChart1.Series[0].CustomVertAxis.Visible = true;
        }


        void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
          double maxVal = tChart1.Series[0].YValues.Maximum;
          float width = tChart1.Graphics3D.TextWidth(maxVal.ToString(tChart1.Series[0].CustomVertAxis.Labels.ValueFormat));

          Rectangle rect = tChart1.Chart.ChartRect;
          rect.X = Steema.TeeChart.Utils.Round((width * 1) + 30);
          rect.Width = tChart1.Width - 80;
          tChart1.Chart.ChartRect = rect;
        }  
Best Regards,
Christopher Ireland / 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

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

Re: ScrollPager doesn't respect the margin of customaxis

Post by acastro » Thu Mar 06, 2014 10:40 am

Ok thanks, but with that code the scrollpager axis doesn't have any values...
Attachments
pagescrolleraxis.png
pagescrolleraxis.png (26.22 KiB) Viewed 25064 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: ScrollPager doesn't respect the margin of customaxis

Post by Christopher » Thu Mar 06, 2014 10:48 am

wakeup wrote:Ok thanks, but with that code the scrollpager axis doesn't have any values...
It does have values here.

This is the code for the entire form, which I'm using with TeeChart.dll version 4.1.2014.2062 (net40):

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestPageScroll2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void Form1_Load(object sender, EventArgs e)
        {
            Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line();

            tChart1.Series.Add(line);

            tChart1.Series[0].FillSampleValues();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            Steema.TeeChart.Tools.ScrollPager mt = new Steema.TeeChart.Tools.ScrollPager(tChart1.Chart);
            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                if (tChart1.Series[i].Count > 0)
                    mt.Series = tChart1.Series[i];
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
          AddCustomAxis();
          tChart1.BeforeDraw += tChart1_BeforeDraw;
          tChart1.Invalidate();
        }

        private void AddCustomAxis()
        {
          Steema.TeeChart.Axis customAxis = new Steema.TeeChart.Axis(tChart1.Chart);
          customAxis.Title.Visible = false;
          customAxis.Visible = false;
          customAxis.Horizontal = false;
          customAxis.Automatic = true;

          customAxis.Ticks.Color = tChart1.Series[0].Color;
          customAxis.AxisPen.Color = tChart1.Series[0].Color;
          customAxis.Labels.Font.Color = tChart1.Series[0].Color;

          tChart1.Axes.Custom.Add(customAxis);
          tChart1.Series[0].CustomVertAxis = customAxis;
          tChart1.Series[0].CustomVertAxis.Visible = true;
        }


        void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
          double maxVal = tChart1.Series[0].YValues.Maximum;
          float width = tChart1.Graphics3D.TextWidth(maxVal.ToString(tChart1.Series[0].CustomVertAxis.Labels.ValueFormat));

          Rectangle rect = tChart1.Chart.ChartRect;
          rect.X = Steema.TeeChart.Utils.Round((width * 1) + 30);
          rect.Width = tChart1.Width - 80;
          tChart1.Chart.ChartRect = rect;
        }        
    }
}
Best Regards,
Christopher Ireland / 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

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

Re: ScrollPager doesn't respect the margin of customaxis

Post by acastro » Thu Mar 06, 2014 10:55 am

Please press first the button2 to add the custom axis, and then button1 to add the scrollpager

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: ScrollPager doesn't respect the margin of customaxis

Post by Christopher » Thu Mar 06, 2014 11:11 am

wakeup wrote:Please press first the button2 to add the custom axis, and then button1 to add the scrollpager
Yes, that's because when the ScrollPagerTool clones the Series internally, it clones a series with a custom axes specified onto a chart that does not have one.

That is to say, if you wish to use a Custom Axis in a Chart with an associated ScrollPagerTool, please make sure you set the ScrollPagerTool.Series property before you do so, as one does by pressing button1 and then button2.
Best Regards,
Christopher Ireland / 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

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

Re: ScrollPager doesn't respect the margin of customaxis

Post by acastro » Thu Mar 06, 2014 11:30 am

Christopher wrote:
wakeup wrote:Please press first the button2 to add the custom axis, and then button1 to add the scrollpager
Yes, that's because when the ScrollPagerTool clones the Series internally, it clones a series with a custom axes specified onto a chart that does not have one.
I don't understand you, the chart have the custom axis... what doesn't have the chart?
Christopher wrote: That is to say, if you wish to use a Custom Axis in a Chart with an associated ScrollPagerTool, please make sure you set the ScrollPagerTool.Series property before you do so, as one does by pressing button1 and then button2.
Set the scrollPagerTool.series, before I do what? I cannot set the scrollpagertool.series before add the scrollepagertool. And I don't know when the user is going to be interested in add a scrollerpager or not...

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: ScrollPager doesn't respect the margin of customaxis

Post by Christopher » Thu Mar 06, 2014 11:40 am

wakeup wrote: I don't understand you, the chart have the custom axis... what doesn't have the chart?
No, I'm not surprised you don't understand me, as you don't have access to the TeeChart source code and I do. If you had access to it, you would understand me much easier, I think :D

The ScrollPagerTool is a very complex tool and uses several other TeeChart tools internally. One of these tools is the SubChartTool, and it is this tool that presents a *secondary* chart underneath the *primary* chart when you add in a ScrollPagerTool, and this *secondary* chart has a clone of the Series in the *primary* chart. If the series in the primary chart is cloned when it has a custom axis associated to it, when it is rendered in the secondary chart it does not appear, as the secondary chart does not actually contain a custom axes.
wakeup wrote: Set the scrollPagerTool.series, before I do what? I cannot set the scrollpagertool.series before add the scrollepagertool. And I don't know when the user is going to be interested in add a scrollerpager or not...
No, that's not what I'm saying. The order is:
1) Add a Chart to a Windows Form
2) Add a series to the chart
3) Add a SubChartTool to the chart
4) Set the SubChartTool.Series property to the series in the chart
5) Add the custom axis to the series ("primary") of the chart
Best Regards,
Christopher Ireland / 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

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

Re: ScrollPager doesn't respect the margin of customaxis

Post by acastro » Thu Mar 06, 2014 11:47 am

Christopher wrote:
wakeup wrote: I don't understand you, the chart have the custom axis... what doesn't have the chart?
No, I'm not surprised you don't understand me, as you don't have access to the TeeChart source code and I do. If you had access to it, you would understand me much easier, I think :D

The ScrollPagerTool is a very complex tool and uses several other TeeChart tools internally. One of these tools is the SubChartTool, and it is this tool that presents a *secondary* chart underneath the *primary* chart when you add in a ScrollPagerTool, and this *secondary* chart has a clone of the Series in the *primary* chart. If the series in the primary chart is cloned when it has a custom axis associated to it, when it is rendered in the secondary chart it does not appear, as the secondary chart does not actually contain a custom axes.
So, do you mean Scrollpagertool doesn't support custom axis?
Christopher wrote:
wakeup wrote: Set the scrollPagerTool.series, before I do what? I cannot set the scrollpagertool.series before add the scrollepagertool. And I don't know when the user is going to be interested in add a scrollerpager or not...
No, that's not what I'm saying. The order is:
1) Add a Chart to a Windows Form
2) Add a series to the chart
3) Add a SubChartTool to the chart
4) Set the SubChartTool.Series property to the series in the chart
5) Add the custom axis to the series ("primary") of the chart
Yes in that order it runs, but I'm saying it doesn't run in this order:
1) Add a Chart to a Windows Form
2) Add a series to the chart
3) Add the custom axis to the series ("primary") of the chart[/quote]
4) Add a SubChartTool to the chart
5) Set the SubChartTool.Series property to the series in the chart

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: ScrollPager doesn't respect the margin of customaxis

Post by Christopher » Thu Mar 06, 2014 11:51 am

wakeup wrote: So, do you mean Scrollpagertool doesn't support custom axis?
No, I'm not saying that. What I'm saying is that if you want to use Chart with a ScrollPagerTool and have the Series in the primary (top) Chart associated to a custom axis, then you will have to associate the custom axis to the Series before associating the Series to the ScrollPagerTool.Series property.
wakeup wrote: Yes in that order it runs, but I'm saying it doesn't run in this order:
Yes, I know it doesn't run in that order, I have given you an explanation for why it doesn't run, I have just given you my best suggestion (above) for how to work in the case of having a Series associated with a custom axis in the primary (top) chart.
Best Regards,
Christopher Ireland / 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

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

Re: ScrollPager doesn't respect the margin of customaxis

Post by acastro » Thu Mar 06, 2014 12:25 pm

Christopher wrote:
wakeup wrote: So, do you mean Scrollpagertool doesn't support custom axis?
No, I'm not saying that. What I'm saying is that if you want to use Chart with a ScrollPagerTool and have the Series in the primary (top) Chart associated to a custom axis, then you will have to associate the custom axis to the Series before associating the Series to the ScrollPagerTool.Series property.
I think I do that. I associate the custom axis to the serie in button2, and then in Button1 I set the ScrollPagerTool.Series property...
Christopher wrote: Yes, I know it doesn't run in that order
So, is it not a bug? I need to do it in that order, because the normal behabiour of a user is to do it in that order...

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: ScrollPager doesn't respect the margin of customaxis

Post by Christopher » Thu Mar 06, 2014 1:52 pm

wakeup wrote:I think I do that. I associate the custom axis to the serie in button2, and then in Button1 I set the ScrollPagerTool.Series property...
Yes, you do, my mistake. I shall restate my position:
What I'm saying is that if you want to use Chart with a ScrollPagerTool and have the Series in the primary (top) Chart associated to a custom axis, then you will have to associate the custom axis to the Series *AFTER* associating the Series to the ScrollPagerTool.Series property.
Christopher wrote:So, is it not a bug? I need to do it in that order, because the normal behabiour of a user is to do it in that order...
I don't see neither associating the custom axis to the Series *AFTER* associating the Series to the ScrollPagerTool.Series property nor associating the custom axis to the Series *BEFORE* associating the Series to the ScrollPagerTool.Series property as "normal" user behaviour.

AFAIC, it's a bit like saying that this code:

Code: Select all

    private void InitializeChart()
    {
      tChart1[0].FillSampleValues();
      tChart1.Series.Add(typeof(Line));
    }
Is a bug as the code will only work if the two lines are in reverse order.
Best Regards,
Christopher Ireland / 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

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

Re: ScrollPager doesn't respect the margin of customaxis

Post by acastro » Thu Mar 06, 2014 3:16 pm

Ok, then I have another related question. Please try this example:
http://193.145.251.126/pnp/files/PVSpTe ... croll2.zip

Press button1, then button2. And finally what is missing in button4 in order to run sucessfully updating the data and having the axis in the scrollpager right?

Thanks

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: ScrollPager doesn't respect the margin of customaxis

Post by Christopher » Fri Mar 07, 2014 11:37 am

wakeup wrote:Press button1, then button2. And finally what is missing in button4 in order to run sucessfully updating the data and having the axis in the scrollpager right?
I'm not sure exactly what you're looking for here, but you can line up the primary and secondary charts with code such as:

Code: Select all

    void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      double maxVal = tChart1.Series[0].YValues.Maximum;
      float width = tChart1.Graphics3D.TextWidth(maxVal.ToString(tChart1.Series[0].CustomVertAxis.Labels.ValueFormat));

      Rectangle rect = tChart1.Chart.ChartRect;
      rect.X = Steema.TeeChart.Utils.Round((width * 1) + 30);
      rect.Width = tChart1.Width - 80;
      tChart1.Chart.ChartRect = rect;


      width *= 1.3f;

      mt.SubChartTChart.Chart.CustomChartRect = true;
      rect.X -= Steema.TeeChart.Utils.Round(width);
      rect.Width += Steema.TeeChart.Utils.Round(width);
      mt.SubChartTChart.Chart.ChartRect = rect;
    }
Best Regards,
Christopher Ireland / 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

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

Re: ScrollPager doesn't respect the margin of customaxis

Post by acastro » Fri Mar 07, 2014 12:16 pm

Christopher wrote:
I'm not sure exactly what you're looking for here,
What I'm asking is how is the right way to update the data of a serie in that case. Itried with the code in the button4 but it creates a lot of new series in the subchart.

Thanks

Post Reply