Hi,
I am using a RadChart in my silvelight application, and I am using a 2-d pie-chart. I need to set the color of the item based in its value.
My current code is:
What I want is, if the value of the DataPoint is "ABC", I wnat its slice red in color, and if its valye is "XYZ" I wnat its slice to be green in color.
Can you please help me, how can I acheive this?
Regards,
Bhaskar
I am using a RadChart in my silvelight application, and I am using a 2-d pie-chart. I need to set the color of the item based in its value.
My current code is:
var series =
new
DataSeries();
var myDataSource = <my data source>;
var pointCount = 0;
DataPoint point =
null
;
RiskChartArea.PaletteBrushes.Add(
new
SolidBrushColor(Colors.Red));
RiskChartArea.PaletteBrushes.Add(
new
SolidBrushColor(Colors.Blue));
RiskChartArea.PaletteBrushes.Add(
new
SolidBrushColor(Colors.Green));
RiskChartArea.PaletteBrushes.Add(
new
SolidBrushColor(Colors.Black));
RiskChartArea.PaletteBrushes.Add(
new
SolidBrushColor(Colors.Yellow));
myCollection.ToList().ForEach(x =>
{
pointCount = openItem.Where(y => y[
"Status"
].GetString().Equals(x.Code, StringComparison.CurrentCultureIgnoreCase)).Count();
point =
new
DataPoint(pointCount);
point.LegendLabel = x.Code;
point.Tooltip = x.Code;
series.Add(point);
});
DataSeries doughnutSeries = series;
doughnutSeries.LegendLabel =
"Doughnut Series"
;
doughnutSeries.Definition =
new
DoughnutSeriesDefinition();
doughnutSeries.Definition.InteractivitySettings.HoverScope = InteractivityScope.Item;
doughnutSeries.Definition.InteractivitySettings.SelectionScope = InteractivityScope.Item;
doughnutSeries.Definition.InteractivitySettings.SelectionMode = ChartSelectionMode.Single;
((DoughnutSeriesDefinition)doughnutSeries.Definition).LabelSettings.LabelOffset = 0.7d;
//doughnutSeries.Definition.ItemLabelFormat = "#%{p0}";
MyChartArea.DataSeries.Clear();
MyChartArea.DataSeries.Add(doughnutSeries);
MyChartArea.SmartLabelsEnabled =
false
;
MyChartLegend.Header =
" "
;
What I want is, if the value of the DataPoint is "ABC", I wnat its slice red in color, and if its valye is "XYZ" I wnat its slice to be green in color.
Can you please help me, how can I acheive this?
Regards,
Bhaskar