使用调色板时查找分配给 ASP.NET 饼图中的点的颜色

发布于 2024-10-22 03:57:19 字数 306 浏览 2 评论 0原文

我有一个基本的 ASP.NET 图表控件设置为饼图,使用“Bright Pastel”调色板,我想将图表中使用的颜色链接到页面上其他位置的网格视图(这实际上充当一个传奇,但一旦我开始工作,也会有更多的领域)。

我无法在控件中找到引用饼图每个部分中使用的实际颜色的任何位置,所有 BackgroundColor 属性均为 0。我可以手动分配颜色,但如果我必须这样做,事情真的会变得复杂那。

屏幕截图(如果它有助于可视化我正在尝试执行的操作):

I've got a basic ASP.NET Charting control set to a pie chart, using the "Bright Pastel" palette and I'd like to link the colours used in the chart to a gridview elsewhere on the page (which is effectively acting as a legend, but will have some more fields in too, once I've got this working).

I can't find anywhere in the control where it references the actual colours used in each section of the pie, all of the BackgroundColor properties are 0. I could manually assign the colours, but it'll really complicate things if I have to do that.

Screenshot if it helps visualise what I'm trying to do:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅一夜美梦 2024-10-29 03:57:19

设置系列后,您可以调用方法 Chart1.ApplyPaletteColors(),然后检查 series[].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 的博客。

来自 Alexs博客
(来源:msdn.com

来源 - Alex 的博客

他在 .NET 图表方面有非常有用的帖子,我经常查阅他的博客,通常是在 google 上搜索图表问题的答案
http://blogs.msdn.com/b/alexgor/

如果这不足以回答您的问题以完成您的任务,我将详细说明您询问的我有能力的任何领域。

Once you have set your series, you can call the method chart1.ApplyPaletteColors() and then check the series[].Color property to determine the 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]}

These colors will vary depending on the color palette you have set.

To see what color palettes you can set, you can see Alex Gorev's Weblog.

From Alexs Blog
(source: msdn.com)

Source - Alex's blog

He has very helpful posts on .NET charting and I have consulted his blog often, usually from searching for answers to charting questions on google
http://blogs.msdn.com/b/alexgor/

Let me know if this does not answer your question enough to complete your task and I will elaborate on any area you ask that I am capable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文