I have an a chart control which measures customer satisfaction.
The possible values are Happy, Neutral and Sad. (e.g. a possible set of values might be: Happy (23), Neutral (12), Sad (19) )
I want Happy to always be Green, Neutral to always be Orange and Sad to always be Red (e.g. like a RAG status)
I set the colors thus:
fbChart.Palette = ChartColorPalette.None;
fbChart.PaletteCustomColors = new Color[] { Color.Green, Color.Orange, Color.Red };
This works fine if all three possible options have values, but if there is only one or two with values the colors screws up. (e.g. If I have Happy (12) and Sad (9) but no Neutral, the colors come out as Green for Happy and Orange for Sad.)
Is there a way I can tie down the colors to the name (e.g Happy / Neutral / Sad)?
EDIT:
The data is loaded into the chart from a datatable:
var fb = from f in db.tl_feedbacks
where f.timestamp >= new DateTime(fromYear, fromMonth, fromDay, 0, 0, 0) && f.timestamp <= new DateTime(toYear, toMonth, toDay, 23, 59, 59)
group f by f.tl_feedback_score.score into grp
select new
{
Score = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(grp.Key),
Count = grp.Select(x => x.tl_feedback_score.score).Count()
};
fbChart.Series["Feedback"].XValueMember = "Score";
fbChart.Series["Feedback"].YValueMembers = "Count";
fbChart.DataSource = fb;
fbChart.DataBind();