How to draw four graphs and share an X-axis, and other related issues?
How to draw four graphs and share an X-axis, and other related issues?
Question1:How do I find the maximum distance to the left of four graphs and set this maximum distance for all graphs. Or is there a better way to do this, so that if y is not aligned, the points on the top and bottom graph are not aligned
Question2:The X-axis label in the last figure is too long. I hope it can be displayed as a line wrap if it is too long, and the spacing between X-axis points and points can be widened Question3:The X-axis names of the first five points in the red box are the same, I hope that each point can correspond to its own X-axis label, and then each point should have vertical lines, such as the gray line I hand-painted in the red box (it should be tchart.Axes.Bottom.Grid), I expect that each point has a corresponding X-axis. And they all have Axes.Bottom.Grid Hope to reply as soon as possible, thank you !
Question2:The X-axis label in the last figure is too long. I hope it can be displayed as a line wrap if it is too long, and the spacing between X-axis points and points can be widened Question3:The X-axis names of the first five points in the red box are the same, I hope that each point can correspond to its own X-axis label, and then each point should have vertical lines, such as the gray line I hand-painted in the red box (it should be tchart.Axes.Bottom.Grid), I expect that each point has a corresponding X-axis. And they all have Axes.Bottom.Grid Hope to reply as soon as possible, thank you !
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to draw four graphs and share an X-axis, and other related issues?
Hello,
A similar question is answered here.
Did you try Marc's suggestion here?
You can try using custom axes; a similar question was asked here.coldwind wrote: ↑Thu Aug 31, 2023 5:38 amQuestion3:The X-axis names of the first five points in the red box are the same, I hope that each point can correspond to its own X-axis label, and then each point should have vertical lines, such as the gray line I hand-painted in the red box (it should be tchart.Axes.Bottom.Grid), I expect that each point has a corresponding X-axis. And they all have Axes.Bottom.Grid
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: How to draw four graphs and share an X-axis, and other related issues?
I want the label to wrap after 15 characters, but because the label is so long, it may need to wrap more than once. Therefore, it is also hoped that the spacing between points will increase synchronously according to the current number of newlines. The label spacing on the top of the hand-drawn sketch is smaller, and the label spacing on the bottom is larger. I wonder if it can be achieved?
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to draw four graphs and share an X-axis, and other related issues?
Hello,
Before adding the labels to the Chart, I think it would be easy to parse the label string and add in a '\n' character every 15 characters. TeeChart will recognize these line breaks and will adjust the spacing accordingly.
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: How to draw four graphs and share an X-axis, and other related issues?
According to your suggestion, I have wrapped the X-axis label before adding the icon, but the label did not automatically separate and overlapped, as shown in the figure below
The present situation is still not like the hand-drawn picture. When the width of the label newline becomes larger, the spacing between points does not automatically open. Is there any solution?Re: How to draw four graphs and share an X-axis, and other related issues?
Question1:According to the example you gave, the following code is used. It is true that the four images can be aligned with the Y axis, but it does not seem to be set according to the maximum distance between the left and left borders of the maximum y axis.The Y-axis label is weighed down by the Y-axis title!Christopher wrote: ↑Thu Aug 31, 2023 7:58 amHello,
A similar question is answered here.
Did you try Marc's suggestion here?
You can try using custom axes; a similar question was asked here.coldwind wrote: ↑Thu Aug 31, 2023 5:38 amQuestion3:The X-axis names of the first five points in the red box are the same, I hope that each point can correspond to its own X-axis label, and then each point should have vertical lines, such as the gray line I hand-painted in the red box (it should be tchart.Axes.Bottom.Grid), I expect that each point has a corresponding X-axis. And they all have Axes.Bottom.Grid
Code: Select all
List<int> yLabelLen = new List<int>
{
avgChart.Axes.Left.MaxLabelsWidth(),
stddevChart.Axes.Left.MaxLabelsWidth(),
rangeChart.Axes.Left.MaxLabelsWidth(),
rawDataChart.Axes.Left.MaxLabelsWidth()
};
int yLabelLenMax = yLabelLen.Max();
avgChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
stddevChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
rangeChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
rawDataChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
The Axes.Left.MaxLabelsWidth() value for all four figures is 15,This is clearly not true!
The Y-axis label is weighed down by the Y-axis title! AnotherQuestion: x label try to attach the bottom border, which property can set this spacing?
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to draw four graphs and share an X-axis, and other related issues?
Hello,
I'm not sure quite what the question is here, but a couple of things:coldwind wrote: ↑Sat Sep 02, 2023 7:22 amQuestion1:According to the example you gave, the following code is used. It is true that the four images can be aligned with the Y axis, but it does not seem to be set according to the maximum distance between the left and left borders of the maximum y axis.The Y-axis label is weighed down by the Y-axis title!
- do you have FixedLabelSize set to false? e.g.
Code: Select all
tChart1.Axes.Left.FixedLabelSize = false;
- you might consider using the GetAxesChartRect event for finer control over the size of the rectangle defined by the four axes. A simple example of it's use is here.
This is the job of the Increment property, e.g.
Code: Select all
tChart1.Series.Add(typeof(Line)).FillSampleValues();
tChart1[0].XValues.DateTime = true;
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Utils.GetDateTimeStep(DateTimeSteps.OneWeek);
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: How to draw four graphs and share an X-axis, and other related issues?
Code: Select all
List<int> yLabelLen = new List<int>
{
avgChart.Axes.Left.MaxLabelsWidth(),
stddevChart.Axes.Left.MaxLabelsWidth(),
rangeChart.Axes.Left.MaxLabelsWidth(),
rawDataChart.Axes.Left.MaxLabelsWidth()
};
int yLabelLenMax = yLabelLen.Max();
avgChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
stddevChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
rangeChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
rawDataChart.Axes.Left.Labels.CustomSize = yLabelLenMax;
The Axes.Left.MaxLabelsWidth() value for all four figures is 15,This is clearly not true!
How do I get the width of the Y-axis from the leftmost part of the current graph?As shown below
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to draw four graphs and share an X-axis, and other related issues?
Hello,
We use 'tChart1.Axes.Bottom.IStartPos' because the Bottom axis is horizontal, therefore the IStartPos is a horizontal (X) value.
There are a couple of ways to do this, e.g.
Code: Select all
private void InitializeChart()
{
tChart1.Series.Add(typeof(Line)).FillSampleValues();
tChart1.Axes.Left.AxisPen.Visible = true;
tChart1.Axes.Left.AxisPen.Width = 3;
tChart1.Axes.Left.AxisPen.Color = Color.Red;
tChart1.GetAxesChartRect += TChart1_GetAxesChartRect;
tChart1.BeforeDrawAxes += TChart1_BeforeDrawAxes;
}
private void TChart1_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.IGraphics3D g)
{
MessageBox.Show($"IStartPos: {tChart1.Axes.Bottom.IStartPos}");
g.Pen.Width = 3;
g.Pen.Color = Color.Blue;
g.Line(new Point(0, g.ChartYCenter), new Point(tChart1.Axes.Bottom.IStartPos, g.ChartYCenter));
}
private void TChart1_GetAxesChartRect(object sender, Steema.TeeChart.GetAxesChartRectEventArgs e)
{
MessageBox.Show($"GetAxesChartRect: {e.AxesChartRect.Left}");
}
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 |