Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6591815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:28:27+00:00 2026-05-25T17:28:27+00:00

I’m prototyping a chart using ASP.NET Chart Controls. I have the following code to

  • 0

I’m prototyping a chart using ASP.NET Chart Controls. I have the following code to generate my chart. I’m trying to get as close to the client’s brand guidelines as possible. The brand guidelines are using gradients in the pie chart segments. Is this possible when using custom colours?

    /// <summary>
    /// Create an image of a chart from the given data
    /// </summary>
    /// <param name="data">Dictionary of data, labels as key and value as value.</param>
    /// <returns>The bytes of an image</returns>
    private Byte[] CreatePieChart(Dictionary<string,string> data)
    {
        //Set up the chart
        var chart = new Chart
        {
            Width = 550,
            Height = 400,
            RenderType = RenderType.BinaryStreaming,
            AntiAliasing = AntiAliasingStyles.All,
            TextAntiAliasingQuality = TextAntiAliasingQuality.High
        };

        //Add the title
        chart.Titles.Add("Chart 1");
        chart.Titles[0].Font = new Font("Arial", 16f);

        //Set up labels etc
        chart.ChartAreas.Add("");
        chart.ChartAreas[0].AxisX.TitleFont = new Font("Arial", 12f);
        chart.ChartAreas[0].AxisY.TitleFont = new Font("Arial", 12f);
        chart.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Arial", 10f);
        chart.ChartAreas[0].AxisX.LabelStyle.Angle = -90;
        chart.ChartAreas[0].BackColor = Color.White;

        //Set up the series and specify Pie chart
        chart.Series.Add("");
        chart.Series[0].ChartType = SeriesChartType.Pie;
        chart.Series[0].SetCustomProperty("PieLabelStyle", "outside");
        chart.Series[0].IsValueShownAsLabel = true;
        chart.Series[0].BackGradientStyle = GradientStyle.Center;

        //MAke the chart 3D
        chart.ChartAreas[0].Area3DStyle.Enable3D = true;
        //chart.ChartAreas[0].Area3DStyle.Perspective = 75;
        chart.ChartAreas[0].Area3DStyle.Inclination = 0;

        //Loop over the data and add it to the series
        foreach (var item in data)
        {
            chart.Series[0].Points.AddXY(item.Key, Convert.ToDouble(item.Value));
        }

        //Add a legend
        chart.Legends.Add("");
        chart.Legends[0].InsideChartArea = "";

        Color[] myPalette = new Color[6]{ 
             Color.FromArgb(255,101,187,226), 
             Color.FromArgb(255,253,214,91), 
             Color.FromArgb(255,38,190,151), 
             Color.FromArgb(255,253,183,101),
             Color.FromArgb(255,218,143,183),
            Color.FromArgb(255,242,242,242)};

        chart.Palette = ChartColorPalette.None;
        chart.PaletteCustomColors = myPalette;

        byte[] chartBytes;

        //Write the chart image to a stream and get the bytes
        using (var chartimage = new MemoryStream())
        {
            chart.SaveImage(chartimage, ChartImageFormat.Png);
            chartBytes = chartimage.GetBuffer();
        }

        return chartBytes;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:28:27+00:00Added an answer on May 25, 2026 at 5:28 pm

    It is possible to get a gradient on a pie chart with ASP.NET charting.

    Here’s the relevant lines:

            Color[] myPalette = new Color[5]{ 
                 Color.FromArgb(255,101,187,226), 
                 Color.FromArgb(255,253,214,91), 
                 Color.FromArgb(255,38,190,151), 
                 Color.FromArgb(255,253,183,101),
                 Color.FromArgb(255,218,143,183)};
    
            chart.Palette = ChartColorPalette.None;
            chart.PaletteCustomColors = myPalette;
    
            //Loop over the data and add it to the series
            int i = 0;
            foreach (var item in data)
            {
                chart.Series[0].Points.AddXY(item.Key, Convert.ToDouble(item.Value));
                chart.Series[0].Points[i].BackGradientStyle = GradientStyle.Center;
                chart.Series[0].Points[i].Color = myPalette[i];
                chart.Series[0].Points[i].BackSecondaryColor = LightenColor(myPalette[i]);
                //chart.Series[0].Points[i].SetCustomProperty("Exploded","true");
    
                i++;
            }
    

    Prototype code. Produces a passable gradient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.