I want to draw a pie chart with solid coloros. But i am getting gradient

Thread is closed for posting
7 posts, 0 answers
  1. Atul Srivastav
    Atul Srivastav avatar
    65 posts
    Member since:
    Jun 2007

    Posted 19 Aug 2010 Link to this post

    Hi

    I need your help in this. I want to draw a pie chart with solid coloros. But i am getting gradient. My code is this.

     protected void Page_Load(object sender, EventArgs e)
        {
            ChartSeries chartSeries = new ChartSeries();
            chartSeries.Name = "Fleat Composit";
            chartSeries.Type = ChartSeriesType.Pie;
            chartSeries.AddItem(60, "B", System.Drawing.Color.White);
            chartSeries.AddItem(300, "A", System.Drawing.Color.Red);
            RadChart1.Appearance.FillStyle.FillType = FillType.Solid;
            RadChart1.Series.Add(chartSeries);
    }

    Regards
    Atul Srivastav
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 23 Aug 2010 Link to this post

    Hi Atul Srivastav,

    You need to set the FillType on the specific series item like this:

    ChartSeries chartSeries = new ChartSeries();
    chartSeries.Name = "Fleat Composit";
    chartSeries.Type = ChartSeriesType.Pie;
     
    ChartSeriesItem seriesItem = new ChartSeriesItem();
    seriesItem.YValue = 60;
    seriesItem.Appearance.FillStyle.FillType = FillType.Solid;
    seriesItem.Appearance.FillStyle.MainColor = Color.White;
    seriesItem.Label.TextBlock.Text = "A";
    chartSeries.Items.Add(seriesItem);
     
    ChartSeriesItem seriesItem2 = new ChartSeriesItem();
    seriesItem2.YValue = 300;
    seriesItem2.Appearance.FillStyle.FillType = FillType.Solid;
    seriesItem2.Appearance.FillStyle.MainColor = Color.Red;
    seriesItem2.Label.TextBlock.Text = "B";
    chartSeries.Items.Add(seriesItem2);
     
    RadChart1.Series.Add(chartSeries);

    Hope this helps.


    Sincerely yours,
    Freddie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Atul Srivastav
    Atul Srivastav avatar
    65 posts
    Member since:
    Jun 2007

    Posted 25 Aug 2010 Link to this post

    Hi
    Thanks for response. Now I got a problem with ChartSeriesItem border. It not drawing border in one side for first element.
    You see my code output in attached image. In image you see that for item "C" it is drwaing red color border with item "B".
    But with same code it is not drawing green color border for item "A" with item "D"

    My code is

    protected void Page_Load(object sender, EventArgs e)
        {
            ChartSeries chartSeries = new ChartSeries();
            chartSeries.Name = "Fleat Composit";
            chartSeries.Type = ChartSeriesType.Pie;

            ChartSeriesItem seriesItem = new ChartSeriesItem();
            seriesItem.YValue = 40;
            seriesItem.Appearance.FillStyle.FillType = FillType.Solid;
            seriesItem.Appearance.FillStyle.MainColor = Color.White;
            seriesItem.Label.TextBlock.Text = "A";
            seriesItem.Appearance.Border.Color = Color.Green;
            seriesItem.Appearance.Border.Width = 3;
            seriesItem.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
            chartSeries.Items.Add(seriesItem);

            ChartSeriesItem seriesItem2 = new ChartSeriesItem();
            seriesItem2.YValue = 60;
            seriesItem2.Appearance.FillStyle.FillType = FillType.Solid;
            seriesItem2.Appearance.FillStyle.MainColor = Color.Green;
            seriesItem2.Label.TextBlock.Text = "B";
            seriesItem2.Appearance.Border.Color = Color.Green;
            seriesItem2.Appearance.Border.Width = 3;
            chartSeries.Items.Add(seriesItem2);

            ChartSeriesItem seriesItem3 = new ChartSeriesItem();
            seriesItem3.YValue = 50;
            seriesItem3.Appearance.FillStyle.FillType = FillType.Solid;
            seriesItem3.Appearance.FillStyle.MainColor = Color.White;
            seriesItem3.Label.TextBlock.Text = "c";
            seriesItem3.Appearance.Border.Color = Color.Red;
            seriesItem3.Appearance.Border.Width = 3;
            seriesItem3.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
            chartSeries.Items.Add(seriesItem3);

            ChartSeriesItem seriesItem4 = new ChartSeriesItem();
            seriesItem4.YValue = 60;
            seriesItem4.Appearance.FillStyle.FillType = FillType.Solid;
            seriesItem4.Appearance.FillStyle.MainColor = Color.Red;
            seriesItem4.Appearance.Border.Color = Color.Red;
            seriesItem4.Appearance.Border.Width = 3;
            seriesItem4.Label.TextBlock.Text = "D";
            chartSeries.Items.Add(seriesItem4);

            RadChart1.Series.Add(chartSeries);

        }

    Regards
    Atul Srivastav
  5. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 27 Aug 2010 Link to this post

    Hi Atul Srivastav,

    You can achieve the desired effect by removing the border for items B and D:

    protected void Page_Load(object sender, EventArgs e)
    {
        ChartSeries chartSeries = new ChartSeries();
        chartSeries.Name = "Fleat Composit";
        chartSeries.Type = ChartSeriesType.Pie;
     
        ChartSeriesItem seriesItem = new ChartSeriesItem();
        seriesItem.YValue = 40;
        seriesItem.Appearance.FillStyle.FillType = FillType.Solid;
        seriesItem.Appearance.FillStyle.MainColor = Color.White;
        seriesItem.Label.TextBlock.Text = "A";
        seriesItem.Appearance.Border.Color = Color.Green;
        seriesItem.Appearance.Border.Width = 3;
        seriesItem.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
        chartSeries.Items.Add(seriesItem);
     
        ChartSeriesItem seriesItem2 = new ChartSeriesItem();
        seriesItem2.YValue = 60;
        seriesItem2.Appearance.FillStyle.FillType = FillType.Solid;
        seriesItem2.Appearance.FillStyle.MainColor = Color.Green;
        seriesItem2.Label.TextBlock.Text = "B";
        seriesItem2.Appearance.Border.Color = Color.Green;
        seriesItem2.Appearance.Border.Width = 0;
        chartSeries.Items.Add(seriesItem2);
     
        ChartSeriesItem seriesItem3 = new ChartSeriesItem();
        seriesItem3.YValue = 50;
        seriesItem3.Appearance.FillStyle.FillType = FillType.Solid;
        seriesItem3.Appearance.FillStyle.MainColor = Color.White;
        seriesItem3.Label.TextBlock.Text = "c";
        seriesItem3.Appearance.Border.Color = Color.Red;
        seriesItem3.Appearance.Border.Width = 3;
        seriesItem3.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
        chartSeries.Items.Add(seriesItem3);
     
        ChartSeriesItem seriesItem4 = new ChartSeriesItem();
        seriesItem4.YValue = 60;
        seriesItem4.Appearance.FillStyle.FillType = FillType.Solid;
        seriesItem4.Appearance.FillStyle.MainColor = Color.Red;
        seriesItem4.Appearance.Border.Color = Color.Red;
        seriesItem4.Appearance.Border.Width = 0;
        seriesItem4.Label.TextBlock.Text = "D";
        chartSeries.Items.Add(seriesItem4);
     
        RadChart1.Series.Add(chartSeries);
    }



    Greetings,
    Freddie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Saravanan
    Saravanan avatar
    36 posts
    Member since:
    Jun 2011

    Posted 25 Jul 2011 Link to this post


     



     
    I am Getting this error.
      
    The type or namespace name 'ChartSeries' could not be found (are you missing a using directive or an assembly reference?)  
     
    How should i remove the series item border color. ?
     
    Is it possible to remove the border by applying code in xaml file itself..find the attachment here,i want to do this in xaml file itself not in code behind.
     
    Thanks
    Sara

  7. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 27 Jul 2011 Link to this post

    Hi Saravanan,

    Let me start with some notes:
    1. Could you please post your inquiries in the Product category they are aimed for? From the picture attached I can see that you have a Pie Chart made with Silverlight and this forum is intended for questions relating the ASP.NET AJAX Chart. Having the post in it's corresponding Product category will be easier for both sides to follow it as well as for those that may face similar issue and want to find the solution in our forums.

    2. Could you be more specific about what do you mean by "Is it possible to remove the border by applying code in xaml file itself"? Do you want to remove the border from the Pie Chart's slices?

    Greetings,
    Evgenia
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  8. Saravanan
    Saravanan avatar
    36 posts
    Member since:
    Jun 2011

    Posted 28 Jul 2011 Link to this post

    Hi Evgneia.
      
    Sorry for wrong forum ,i came to this forum while i was searching chart series.
      
    actually i want to chnage piechart slice colour by applying style or in XAML code..thats it,
      
    i found the solution for this problem
      
    Thanks
    Saravanan
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017