Pie chart for ChartView

5 posts, 0 answers
  1. Chai
    Chai avatar
    4 posts
    Member since:
    Jul 2015

    Posted 16 Aug 2015 Link to this post

    Hi Telerik team,


    For the pie chart, I saw that Telerik tools that have smart labels(refer to the attachment with the red color box), there are few features like draw connecting line and labels border, sync labels border color and line color. But I can't find it in the property of visual studio for chartView, please advise. Is it need to write back end coding instead of using property to use those features?
    Apart from that, the label(refer to left red color box of attachment) show in my pie chart is by percentage(%) but the label show in Telerik is in character for each categories, may I know how to set it?


    Best regards,
    Nicholas
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 17 Aug 2015 Link to this post

    Hi Chai,

    Thank you for writing.

    You can use the properties of each series to enable the labels lines. You can use the Label property of each point to set the labels text. For example:
    this.radChartView1.AreaType = ChartAreaType.Pie;
    PieSeries series = new PieSeries();
    series.DataPoints.Add(new PieDataPoint(50, "Germany"));
    series.DataPoints.Add(new PieDataPoint(70, "United States"));
    series.DataPoints.Add(new PieDataPoint(40, "France"));
    series.DataPoints.Add(new PieDataPoint(25, "United Kingdom") { Label = "My Label" });
    series.ShowLabels = true;
    series.DrawLinesToLabels = true;
    series.SyncLinesToLabelsColor = true;
     
     
    this.radChartView1.ShowSmartLabels = true;  
    this.radChartView1.Series.Add(series);

    The borders and the labels text (in case you need to dynamically calculate a value used in the label) can be set in the LabelFormatting event. 

    In addition, the entire code of the SmartLabels example is available directly in the demo application (just click the tab with the desired language).

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. John
    John avatar
    2 posts
    Member since:
    Dec 2015

    Posted 05 Jan in reply to Dimitar Link to this post

    Dimitar, I've just tried to get the labels to display properly as you have described however I get the error attached?
  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 06 Jan Link to this post

    Hello Jonh,

    Thank for writing.

    I am using C# in my previous post. The code, converted to Visual Basic looks like this:
    Me.RadChartView1.AreaType = ChartAreaType.Pie
    Dim series As New PieSeries()
    series.DataPoints.Add(New PieDataPoint(50, "Germany"))
    series.DataPoints.Add(New PieDataPoint(70, "United States"))
    series.DataPoints.Add(New PieDataPoint(40, "France"))
    series.DataPoints.Add(New PieDataPoint(25, "United Kingdom") With {.Label = "My Label"})
    series.ShowLabels = True
    series.DrawLinesToLabels = True
    series.SyncLinesToLabelsColor = True
     
     
    Me.RadChartView1.ShowSmartLabels = True
    Me.RadChartView1.Series.Add(series)

    Let me know if I can assist you further.

    Regards,
    Dimitar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  6. John
    John avatar
    2 posts
    Member since:
    Dec 2015

    Posted 06 Jan in reply to Dimitar Link to this post

    Thank you Dimitar, I should really start using C# :/
Back to Top
UI for WinForms is Visual Studio 2017 Ready