Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My application requires 5 files[A,B,C,D,E] to be uploaded.

Initially, the pie chart should be in white color with regions named A,B,C,D,E.

As soon as each one is uploaded, a segment of the pie chart should be colored i.e 5 parts of a pie chart should be colored one by one as each file is uploaded.

When any one of the uploaded files is deleted, that particular part of the chart's color should revert back to white.

I am using the below code:

C#
Dictionary<string, int> chartData = new Dictionary<string, int>();
chartData.Add("A", 20);
chartData.Add("B", 20);
chartData.Add("C", 20);
chartData.Add("D", 20);
chartData.Add("E", 20);
this.Chart1.Series[0].Points.DataBindXY(chartData.Keys, chartData.Values);
this.Chart1.Series[0].Label = "#VALX (#PERCENT)";
Color[] myPalette = new Color[5]{
Color.FromKnownColor(KnownColor.Blue),
Color.FromKnownColor(KnownColor.Green),
Color.FromKnownColor(KnownColor.Red),
Color.FromKnownColor(KnownColor.Orange), 
Color.FromKnownColor(KnownColor.LightGreen),
};
this.Chart1.Palette = ChartColorPalette.None;
this.Chart1.PaletteCustomColors = myPalette;


I have set a flag to 1 when the file is uploaded so I can color the chart and set flag to 0 when the file is deleted so that color can be reverted back to white.

But how can I specify an IF condition for changing colors of the chart?

Am stuck with this! Please help!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900