Remove FillType Gradient

Thread is closed for posting
2 posts, 0 answers
  1. vlad
    vlad avatar
    21 posts
    Member since:
    Aug 2007

    Posted 23 Jul 2013 Link to this post

    Hello everybody,

    I can't figure out how to remove gradient fill from code-behind generated charts. Here is my current code:

    //set default properties
    RadChart radChart = new RadChart();
    radChart.Appearance.TextQuality = Telerik.Charting.Styles.TextQuality.ClearTypeGridFit;
    radChart.ChartTitle.TextBlock.Text = "Test Chart";
    radChart.ChartTitle.TextBlock.Appearance.TextProperties.Font = new System.Drawing.Font("Tahoma", 13, System.Drawing.FontStyle.Bold);
    radChart.ChartTitle.TextBlock.Appearance.TextProperties.Color = System.Drawing.ColorTranslator.FromHtml("#252525");
    radChart.Skin = "Office2007";
    radChart.Appearance.Border.Color = System.Drawing.ColorTranslator.FromHtml("#7f7f7f");
     
    //create chart series
    ChartSeries chartSeries = new ChartSeries();
    chartSeries.Name = "Sales";
    chartSeries.Type = ChartSeriesType.Pie;
    chartSeries.Appearance.FillStyle.FillType = FillType.Solid;
     
    //add data
    chartSeries.AddItem(120, "Internet");
    chartSeries.AddItem(140, "Retail");
    chartSeries.AddItem(35, "Wholesale");
    radChart.AddChartSeries(chartSeries);

    The instruction
    chartSeries.Appearance.FillStyle.FillType = FillType.Solid;
    doesn't seem to produce effect.

    Thanks!


  2. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 23 Jul 2013 Link to this post

    Hello Vlad,

    Please Try the below code

    //Create a color array to hold different colors for each chart series item
       Color[] pieColors = new Color[8]{
              Color.Purple,
              Color.SteelBlue,
              Color.Aqua,
              Color.Yellow,
              Color.Navy,
              Color.Green,
              Color.Blue,
              Color.Red
          };
     
       RadChart radChart = new RadChart();
       radChart.Appearance.TextQuality = Telerik.Charting.Styles.TextQuality.ClearTypeGridFit;
       radChart.ChartTitle.TextBlock.Text = "Test Chart";
       radChart.ChartTitle.TextBlock.Appearance.TextProperties.Font = new System.Drawing.Font("Tahoma", 13, System.Drawing.FontStyle.Bold);
       radChart.ChartTitle.TextBlock.Appearance.TextProperties.Color = System.Drawing.ColorTranslator.FromHtml("#252525");
       radChart.Skin = "Office2007";
       radChart.SkinsOverrideStyles = false;
       radChart.Appearance.Border.Color = System.Drawing.ColorTranslator.FromHtml("#7f7f7f");
     
     
     
       //create chart series
       ChartSeries chartSeries = new ChartSeries();
       chartSeries.Name = "Sales";
       chartSeries.Type = ChartSeriesType.Pie;
     
     
       //add data
       chartSeries.AddItem(120, "Internet");
       chartSeries.AddItem(140, "Retail");
       chartSeries.AddItem(35, "Wholesale");
       radChart.AddChartSeries(chartSeries);
       int i = 0;
     
       //Assigning color to Each Chart series item
       foreach (ChartSeriesItem item in radChart.Series[0].Items)
       {
           Color color = pieColors[i++];
           item.Appearance.FillStyle.FillType = FillType.Gradient;
           item.Appearance.FillStyle.MainColor = color;
           item.Appearance.FillStyle.SecondColor = color;
       }
     
       this.Page.Controls.Add(radChart);


    Thanks,
    A2H
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top