this is the code I am using now:
public void CreatePie(WebChartViewer Viewer, Int64 LinkId)
{
// The data for the pie chart
double[] data = { };
double[] dataPercent = { };
// The labels for the pie chart
string[] labels = { "low", "on target", "high", "very high" };
// The colors to use for the sectors
int[] colors = { 0x012c6d, 0x046d56, 0xc8cc06, 0xff0000 };
//get data
data = GetChartPiePoints(LinkId, out dataPercent);
// Create a PieChart object
PieChart c = new PieChart(370, 230, Chart.Transparent);
// Set the center of the pie (x,y) and the radius
c.setPieSize(250, 115, 110);
//legend
LegendBox legendBox = c.addLegend(130, 110, true, "Verdana Bold", 11);
legendBox.setBackground(Chart.Transparent, Chart.Transparent);
legendBox.setAlignment(Chart.Right);
// Set the legend box background and border
legendBox.setBackground(0xe8f0f8, 0x445566);
// Use rounded corners of 5 pixel radius for the legend box
legendBox.setRoundedCorners(5);
// Set the label position to -40 pixels from the perimeter of the pie
c.setLabelPos(-40);
c.setLabelStyle("Verdana bold", 12, 0x000000).setBackground(Chart.Transparent);
// Set the pie data and the pie labels
c.setData(dataPercent, labels);
c.setLabelFormat("{value}%");
// Set the sector colors
c.setColors2(Chart.DataColor, colors);
// Use local gradient shading, with a 1 pixel semi-transparent black (bb000000) border
c.setSectorStyle(0, 0x000000, 1);
// Output the chart
Viewer.Image = c.makeWebImage(Chart.PNG);
} |