ScrollPager doesn't respect the margin of customaxis
ScrollPager doesn't respect the margin of customaxis
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
Please find the example, press button2, and the button1
http://193.145.251.126/pnp/files/rjiKjX ... croll2.zip
Thanks
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: ScrollPager doesn't respect the margin of customaxis
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:wakeup wrote:If I have a custom axis with a manually set margin and I add a page scroller it doesn respect the margin.
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 |
Re: ScrollPager doesn't respect the margin of customaxis
Ok thanks, but with that code the scrollpager axis doesn't have any values...
- Attachments
-
- pagescrolleraxis.png (26.22 KiB) Viewed 24859 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: ScrollPager doesn't respect the margin of customaxis
It does have values here.wakeup wrote:Ok thanks, but with that code the scrollpager axis doesn't have any values...
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 |
Re: ScrollPager doesn't respect the margin of customaxis
Please press first the button2 to add the custom axis, and then button1 to add the scrollpager
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: ScrollPager doesn't respect the margin of customaxis
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.wakeup wrote:Please press first the button2 to add the custom axis, and then button1 to add the scrollpager
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 |
Re: ScrollPager doesn't respect the margin of customaxis
I don't understand you, the chart have the custom axis... what doesn't have the chart?Christopher wrote: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.wakeup wrote:Please press first the button2 to add the custom axis, and then button1 to add the scrollpager
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 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.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: ScrollPager doesn't respect the margin of customaxis
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 thinkwakeup wrote: I don't understand you, the chart have the custom axis... what doesn't have the chart?
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.
No, that's not what I'm saying. The order is: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...
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 |
Re: ScrollPager doesn't respect the margin of customaxis
So, do you mean Scrollpagertool doesn't support custom axis?Christopher wrote: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 thinkwakeup wrote: I don't understand you, the chart have the custom axis... what doesn't have the chart?
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.
Yes in that order it runs, but I'm saying it doesn't run in this order:Christopher wrote:No, that's not what I'm saying. The order is: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...
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
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
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: ScrollPager doesn't respect the margin of customaxis
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: So, do you mean Scrollpagertool doesn't support custom axis?
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.wakeup wrote: Yes in that order it runs, but I'm saying it doesn't run in this 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 |
Re: ScrollPager doesn't respect the margin of customaxis
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: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: So, do you mean Scrollpagertool doesn't support custom axis?
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 wrote: Yes, I know it doesn't run in that order
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: ScrollPager doesn't respect the margin of customaxis
Yes, you do, my mistake. I shall restate my position: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...
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.
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.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...
AFAIC, it's a bit like saying that this code:
Code: Select all
private void InitializeChart()
{
tChart1[0].FillSampleValues();
tChart1.Series.Add(typeof(Line));
}
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 |
Re: ScrollPager doesn't respect the margin of customaxis
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
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
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: ScrollPager doesn't respect the margin of customaxis
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: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?
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 |
Re: ScrollPager doesn't respect the margin of customaxis
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.Christopher wrote:
I'm not sure exactly what you're looking for here,
Thanks