This is a migrated thread and some comments may be shown as answers.

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

6 Answers 151 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Atul Srivastav
Top achievements
Rank 1
Atul Srivastav asked on 19 Aug 2010, 06:38 PM
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

6 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 23 Aug 2010, 11:49 AM
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
0
Atul Srivastav
Top achievements
Rank 1
answered on 25 Aug 2010, 05:01 PM
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
0
Giuseppe
Telerik team
answered on 27 Aug 2010, 12:18 PM
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
0
Saravanan
Top achievements
Rank 1
answered on 25 Jul 2011, 09:49 AM

 



 
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

0
Evgenia
Telerik team
answered on 27 Jul 2011, 11:44 AM
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.

0
Saravanan
Top achievements
Rank 1
answered on 28 Jul 2011, 07:29 AM
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
Tags
Chart (Obsolete)
Asked by
Atul Srivastav
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Atul Srivastav
Top achievements
Rank 1
Saravanan
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or