ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Pie chart sector label colors
Posted by Massimo on Aug-03-2016 02:22
Attachments:
Hi Peter,

as the pie chart has diff rent colours I got the problem that a single font color for the label is not clear enough for the different backgrounds. Is it possible to have different label color for each pie sector? For example white for the blue the green and the red but black for the yellow? I am constraint to not to change background colors.
chartsectortext.png

  Re: Pie chart sector label colors
Posted by Massimo on Aug-03-2016 02:29
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);

}

  Re: Pie chart sector label colors
Posted by Peter Kwan on Aug-03-2016 22:19
Hi Massimo,

You may refer to the following example on how to configure the font style of a particular sector label.

http://www.advsofteng.com/doc/cdnet.htm#fontpie.htm

Hope this can help.

Regards
Peter Kwan

  Re: Pie chart sector label colors
Posted by Massimo on Aug-03-2016 22:33
What can I say Peter....

perfect!!  There is anything that this software cannot do?

great job.

Peter Kwan wrote:

Hi Massimo,

You may refer to the following example on how to configure the font style of a particular sector label.

http://www.advsofteng.com/doc/cdnet.htm#fontpie.htm

Hope this can help.

Regards
Peter Kwan