ASP.NET Charting Control Transparency

亡梦爱人 提交于 2019-12-12 10:57:17

问题


I'm working with the ASP.NET Charting Library and I've got it generating a pie chart but I'm having a problem configuring it to generate the pie chart with semi-transparent slices. If you look at the image you'll see what I'm talking about. Of the 4 pie charts the top 2 and the bottom left chart have the pie slice transparency I'm talking about.


(source: scottgu.com)

What settings of the chart do I tweak to render the slices with a certain % of transparency?

Thanks!


回答1:


Try assigning the color of the series to a color with alpha transparency, like so:

Chart1.Series(0).Color = Color.FromArgb(128, 255, 0, 0) //transparent red

Taken from this thread.




回答2:


This the ultimate solution for both cases - one color per series or palette charts:

myChart.ApplyPaletteColors();

foreach (var series in myChart.Series)
{
    foreach (var point in series.Points)
    {
        point.Color = Color.FromArgb(220, point.Color);
    }
}



回答3:


Try this:

Series["SeriesName"].Color = Color.FromArgb(180, Color.Blue);

Where 180 defines the "transparency level", which must be between 0 to 255.

You can use semi transparent palettes.

Refer to:

https://blogs.msdn.microsoft.com/alexgor/2009/10/06/setting-microsoft-chart-series-colors/



来源:https://stackoverflow.com/questions/2465230/asp-net-charting-control-transparency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!