PieChart label DataField

6 posts, 0 answers
  1. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 07 Aug 2012 Link to this post

    Hello,
    we recently bought telerik controls, and wanted to use html pie chart. Everything look working properly. However to display legent properly I have to create Series manually from code. But then if series is created manually, how can I set label? I can set label when data is databound - then  legent is not wokring, or have legent but then I cannot set label.
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 09 Aug 2012 Link to this post

    Hello Marcin,

    Could you explain the problem in more detail, because I am not sure I can undestand you correctly?

    You can add a PieSeries in the markup and set its properties related to labels and tooltips appearance (e.g. the DataFormatString) and then create the items in the code-behind - loop through the datasource, create SeriesItem instances and set their Name property according to your data, then add each item to the series.

    You can find a simple example that shows this approach in action.


    Kind regards,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 09 Aug 2012 Link to this post

    I will try to explain:
    First of all thank you for answer, but this is what I already new:
    1. To have proper Legend for PieChar I have to create seriesitems in code behind.
    2. To have proper Label description I have to bind PieChar and use DataField on label description.

    I don't know how to have both.

    I have label column in result with description (not number) it is combination of both. So when I'm binding chart label is displayed properly. But I don't have Legend, because Legened uses Names and cannot be binded.

    When I'm not binding but creating SeriesItems in code I can have label only by formating e.g. Percentage, but not my descriptive label, because I cannot set label for SeriesItem.
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 13 Aug 2012 Link to this post

    Hello Marcin,

    I have added your idea to the PITS - a property that can be used for databinding the name of each series item in the same manner in which ColorField can be. You can monitor its progress and vote for it in this URL.

    Regarding your exact scenario - I am afraid I still cannot understand the limitation. The DataFormatString for labels or tooltips of the series can use the YValue of the item at present and whether this property is set in the code-behind or in the markup there is no difference. The idea that more columns from a datasource can be added to a tooltip/label is logged in this PITS item, so you may find it interesting as well.

    I believe my previous sample shows a relatively easy workaround for the time being that can enable you to use markup declaration for all common properties and only create items programmatically. Simply add the  DataField="color" property to the LabelsAppearance tag of the PieSeries declaration and you will see the strings around the pie.


    All the best,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 13 Aug 2012 Link to this post

    Hello

    How to explain it better.
    1. DataFormatString is working for Label when I want to use YValue for labels. But I DON'T want. Each part of PIeChar has it own description e,g, car type: Toyota, Honda, Mercedes. And this is NOT possible with manual series creation. How ever I can do that with data binding.

    2. Data binding however has different limitation. I cannot use Legend. Legend for PieChart can be only obtained by manual creation and using Name.

    3. I just would like to have both Legend and Label, working on both modes: manual creation in code behind or data binding. Currently I can have only 1 working.
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 14 Aug 2012 Link to this post

    Hello Marcin,

    It seems you are using the DataField property of the LabelsAppearance tag. Indeed, currently both cannot be achieved and this is why I logged the PITS item that will provide sufficient functionality. Please accept my apologies for the inconvenience this may cause.


    Greetings,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017