Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2008, 06:42 AM
Registered User
 
Join Date: Jul 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Different color for a piechart segment ???

hi :)
I had created the PieChart using set of values.
how can i use different color for each segement in the piechart.

Code:
for (int i = 0; i < size - 1; i++)
{
segment[i] = myPane.AddPieSlice(Convert.ToDouble(NetSalesAMT[i]), 
Color.FromArgb(153, 204, 204), Color.White, 50f, 0, BranchName[i] + "\n " + Convert.ToString((NetSalesAMT[i])));
}
i have to change the color dynamically can anyone help me!!!!!

Thanks in advance
N.Sheik Dawood
 
Old July 29th, 2008, 07:10 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well you presumably need an array of colours so you can just assign a new colour to each segment? I don't see where the problem lies?

Color[] colors = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Pink, Color.Yellow, Color.Brown };

for (int i = 0; i < size - 1; i++)
{
segment[i] = myPane.AddPieSlice(Convert.ToDouble(NetSalesAMT[i]),colors[i], 204), Color.White, 50f, 0, BranchName[i] + "\n " + Convert.ToString((NetSalesAMT[i])));
}

/- Sam Judson : Wrox Technical Editor -/
 
Old July 30th, 2008, 01:20 AM
Registered User
 
Join Date: Jul 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you sam,:)
the code which you gave me is working,

but, i dont know how many segment will appear in the piechart it will change according to the size variable. so i cant give the fixed amount of color in the color[] array.
there is any other way to give the color dyanmically

Thanks in advance
N.Sheik Dawood
 
Old July 30th, 2008, 02:40 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well you could use a random number generator to generate numbers, but I wouldn't recommend it.

A pie chart with more than 20 or 30 slices is going to be impossible to read anyway, so I would just make a really big array of colours.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I set ROLLBACK SEGMENT of Oracle in SSIS? Samuel Choi SQL Server DTS 1 August 14th, 2007 07:39 AM
How can I set ROLLBACK SEGMENT of Oracle in SSIS? Samuel Choi SQL Server 2005 0 March 8th, 2006 04:55 AM
Stack segment fuehrer C++ Programming 1 April 29th, 2005 01:59 AM
Excel 2003: How to remove line segment in chart James Peng Excel VBA 0 October 22nd, 2004 05:03 PM
Inserting just the time segment Trojan_uk SQL Server ASP 1 April 15th, 2004 10:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.