PDA

View Full Version : Changing size of pie chart



jkenyon
08-09-2007, 10:27 AM
In IMSL C#, is there any way to change the radius of a pie chart? I have more than enough room in the window, but I have a lot of slices and the labels are overlapping.

Thanks,
Jeff

brian
08-09-2007, 11:17 AM
Hello jkenyon,

You may want to try changing the viewport:



using Imsl.Chart2D;
using Imsl.Stat;
using System;
using System.Windows.Forms;

public class PieEx1 : FrameChart
{

public PieEx1()
{
Chart chart = this.Chart;
AxisXY axis = new AxisXY(chart);

// Create an instance of a Pie Chart
double[] y = new double[]{10.0, 20.0, 30.0, 40.0};
Pie pie = new Pie(chart, y);
pie.SetViewport(0.1, 0.9, 0.1, 0.9);

// Set the Pie Chart Title
chart.ChartTitle.SetTitle("A Simple Pie Chart");

// Set the colors of the Pie Slices
PieSlice[] slice = pie.GetPieSlice();
slice[0].FillColor = System.Drawing.Color.Red;
slice[1].FillColor = System.Drawing.Color.Blue;
slice[2].FillColor = System.Drawing.Color.Black;
slice[3].FillColor = System.Drawing.Color.Yellow;

// Set the Pie Slice Labels
pie.LabelType = Imsl.Chart2D.Pie.LABEL_TYPE_TITLE;
slice[0].SetTitle("Fish");
slice[1].SetTitle("Pork");
slice[2].SetTitle("Poultry");
slice[3].SetTitle("Beef");

// Explode a Pie Slice
slice[0].Explode = 0.2;
}

public static void Main(string[] argv)
{
System.Windows.Forms.Application.Run(new PieEx1());
}
}


Regards,

brian

jkenyon
08-09-2007, 01:31 PM
You were right...through messing about with the viewport size, I got things adjusted properly.

Thanks very much for the pointer!
Jeff