Pie Chart
Pie Chart
I need to create a pie chart with fairly complex requirements.
Basically I want to divide the pie into four equal quadrants. Each quadrant may then have between 2 to 7 slices added to it. I need to control to a high degree the specific slices within each quadrant. Can I do this with the pie chart?
Thanks
Basically I want to divide the pie into four equal quadrants. Each quadrant may then have between 2 to 7 slices added to it. I need to control to a high degree the specific slices within each quadrant. Can I do this with the pie chart?
Thanks
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Pie Chart
Hi rossmc,
Yes, I think so. You can use a combination of whats shown in the All Features\Welcome!\Chart Styles\Standard\Multiple Pies example and the All Features\Welcome!\Chart Styles\Standard\Semi-pie example in the features demo available at TeeChart's program group. I'd use 4 pie series located as in the multiple pies example and set their angle as in the semi-pie example.
Hope this helps!
Yes, I think so. You can use a combination of whats shown in the All Features\Welcome!\Chart Styles\Standard\Multiple Pies example and the All Features\Welcome!\Chart Styles\Standard\Semi-pie example in the features demo available at TeeChart's program group. I'd use 4 pie series located as in the multiple pies example and set their angle as in the semi-pie example.
Hope this helps!
Best Regards,
Narcís Calvet / 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: Pie Chart
Thanks Narcis
After a closer look at the spec I realised that although the slices per quadrant may vary between 2 and 7, for each individual chart instance every quadrant will have the same number of slices. This simplifies my task considerably as I can now do everything on a single chart - much easier!
What I would like to do now however is label each slice along the circumference of the pie. In other words, outside the enclosing circle of the pie, at the end of each slice I want to label the slice with a three character code. The labels need to go around the pie-the angle of the labels would need to change depending on their location along the circumference. Any ideas on this. Sorry to be a pain but this is a rush job and I have no experience using the pie series. Many thanks!
Sorry, something else. If I want to manually draw 'spokes' within a slice - a line originating in the exact centre of the pie and extending towards the circumference for a specified length. I have added a drawline tool with the idea of simply adding lines to it for each 'spoke'. If this will work, what are the coordinates in a pie chart? Unless I should be doing this some other way?
After a closer look at the spec I realised that although the slices per quadrant may vary between 2 and 7, for each individual chart instance every quadrant will have the same number of slices. This simplifies my task considerably as I can now do everything on a single chart - much easier!
What I would like to do now however is label each slice along the circumference of the pie. In other words, outside the enclosing circle of the pie, at the end of each slice I want to label the slice with a three character code. The labels need to go around the pie-the angle of the labels would need to change depending on their location along the circumference. Any ideas on this. Sorry to be a pain but this is a rush job and I have no experience using the pie series. Many thanks!
Sorry, something else. If I want to manually draw 'spokes' within a slice - a line originating in the exact centre of the pie and extending towards the circumference for a specified length. I have added a drawline tool with the idea of simply adding lines to it for each 'spoke'. If this will work, what are the coordinates in a pie chart? Unless I should be doing this some other way?
Re: Pie Chart
Hi again
Made a bit more progress on this task. The only thing I'm missing now is the ability to draw the text labels as previously indicated. I thought of using the .RotateLabel?
My real problem is I do not know how to obtain the actual dimensions of the pie? Since I'm drawing directly on the canvas I'm working with x and y coordinates in the canvas rectangle. It would help however if I knew how to obtain the radius of the pie?
Made a bit more progress on this task. The only thing I'm missing now is the ability to draw the text labels as previously indicated. I thought of using the .RotateLabel?
My real problem is I do not know how to obtain the actual dimensions of the pie? Since I'm drawing directly on the canvas I'm working with x and y coordinates in the canvas rectangle. It would help however if I knew how to obtain the radius of the pie?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Pie Chart
Hi rossmc,
Standard series marks don't do the job for you? You can easily fill them using the label parameter in the add method when populating them or use series' Labels ValueList. I think it would be much easier doing this with series marks with a little bit customization if necessary.Made a bit more progress on this task. The only thing I'm missing now is the ability to draw the text labels as previously indicated. I thought of using the .RotateLabel?
You can use CircleXCenter and CircleYCenter, for example:My real problem is I do not know how to obtain the actual dimensions of the pie? Since I'm drawing directly on the canvas I'm working with x and y coordinates in the canvas rectangle. It would help however if I knew how to obtain the radius of the pie?
Code: Select all
Point center = new Point(pie1.CircleXCenter, pie1.CircleYCenter);
Best Regards,
Narcís Calvet / 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: Pie Chart
Re the labels, the problem is the spec calls for the labels to align along the circumference of the chart. Each label is just three characters long. No matter where along the circumference the bottom of the text must always run along the edge of the circumference. Can I do something like this with series marks?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Pie Chart
Hi rossmc,
Yes, I think so even I'm not 100% sure about what you are trying to do exactly . You may need to set marks ArrowLength to zero. If this doesn't help could you please attach an image of what you are trying to do?
Thanks in advance.
Yes, I think so even I'm not 100% sure about what you are trying to do exactly . You may need to set marks ArrowLength to zero. If this doesn't help could you please attach an image of what you are trying to do?
Thanks in advance.
Best Regards,
Narcís Calvet / 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: Pie Chart
Hi Narcis
Uploaded a very quick paint drawing. You will see how the labels go around the circumference. Of course there will also be labels at intermediate points along the circumference but I couldn't get paint to rotate text by 45 degrees
Thanks
Uploaded a very quick paint drawing. You will see how the labels go around the circumference. Of course there will also be labels at intermediate points along the circumference but I couldn't get paint to rotate text by 45 degrees
Thanks
- Attachments
-
- pie.jpg (4.25 KiB) Viewed 11001 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Pie Chart
Hi rossmc,
Ok, you can rotate standard marks but you can't have a different angle for each mark so custom text drawing is the way to go, for example:
Hope this helps!
Ok, you can rotate standard marks but you can't have a different angle for each mark so custom text drawing is the way to go, for example:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Pie pie1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Legend.Visible = false;
pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
pie1.FillSampleValues();
pie1.Circled = true;
pie1.Marks.Visible = false;
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
for (int i = 0; i < pie1.Count; i++)
{
double pieAngle = pie1.Angles[i].MidAngle;
int x, y;
pie1.AngleToPos(pieAngle, pie1.XRadius + 20, pie1.YRadius + 20, out x, out y);
g.RotateLabel(x, y, pie1.Labels[i], Steema.TeeChart.Utils.Rad2Deg(pieAngle) - 90);
}
}
Best Regards,
Narcís Calvet / 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: Pie Chart
Wow, great answer! Exactly what I was trying to do. The only thing here is I do not have the .Rad2Deg method in my control. I am using version 3.5
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Pie Chart
Hi rossmc,
Excellent! I'm glad to hear that's what you were looking for.Wow, great answer! Exactly what I was trying to do.
I used TeeChart 2010 aka v4 for this example. Actually this method is pretty straightforward:The only thing here is I do not have the .Rad2Deg method in my control. I am using version 3.5
Code: Select all
/// <summary>
///Returns a degree value from a radian value.
/// </summary>
static public double Rad2Deg(double radian)
{
return radian * (180 / Math.PI);
}
Best Regards,
Narcís Calvet / 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 |