Search code examples
c#asp.netmschartpie-chart

MS Chart control - pie chart transparency


I'm trying to get a pie chart to display as transparent. Ideally it should look like the 3rd chart from the left on this page (link).

So far I've tried setting the transparency on the chartArea:

<asp:ChartArea Name="ChartArea1" BackColor="64, 165, 191, 228" BackGradientStyle="TopBottom" 
            BackSecondaryColor="Transparent" BorderColor="64, 64, 64, 64"  
            ShadowColor="Transparent">

Also I tried setting it from codebehind:

    protected void pieChart_Customize(object sender, EventArgs e)
    {
        foreach (Series s in pieChart.Series)
        {
            s.Color = Color.FromArgb(128, s.Color);
        }
    }

However neither of these approaches work. Has anybody managed to set the transparency on this type of chart control?


Solution

  • I found the answer on the MSDN site: link

    Here's the exact code that ended up working for me:

        protected void Page_Load(object sender, EventArgs e)
        {
            pieChart.Series[0].Palette = ChartColorPalette.SemiTransparent;
        }