我有一个基本的ASP.NET Charting控件设置为饼图,使用“Bright Pastel”调色板,我想将图表中使用的颜色链接到页面上其他位置的gridview(这是有效地扮演一个传奇,但是一旦我有了这个工作,也会有更多的领域。)
我无法在控件中找到它引用饼图每个部分中使用的实际颜色的任何地方,所有的BackgroundColor属性都是0.我可以手动分配颜色,但如果我真的会让事情变得复杂必须这样做。
屏幕截图,如果它有助于可视化我正在尝试做的事情:
答案 0 :(得分:3)
设置完系列后,可以调用方法chart1.ApplyPaletteColors(),然后检查系列[] .Color属性以确定颜色。
chart1.Series.Clear();
chart1.Series.Add(new Series());
chart1.Series.Add(new Series());
Color series1Color = chart1.Series[0].Color;
// Above (Series 1) currently holds {Color [Empty]} || {Name=0, ARGB={0,0,0,0}}
Color series2Color = chart1.Series[1].Color;
// Above (Series 2) currently holds {Color [Empty]} || {Name=0, ARGB={0,0,0,0}}
chart1.ApplyPaletteColors();
Color series1AfterColor = chart1.Series[0].Color;
// Above (Series 1) now holds {Color [A=255, R=65, G=140, B=240]}
Color series2AfterColor = chart1.Series[1].Color;
// Above (Series 2) now holds {Color [A=255, R=252, G=180, B=65]}
这些颜色会因您设置的调色板而异。
要查看您可以设置的调色板,您可以看到Alex Gorev的博客。
他在.NET图表上有非常有用的帖子,我经常咨询他的博客,通常是在Google上搜索图表问题的答案 http://blogs.msdn.com/b/alexgor/
如果这不足以完成您的任务,请告诉我,我会详细说明您认为我有能力的任何领域。