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

PieChart label DataField

12 Answers 240 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Veteran
Marcin asked on 07 Aug 2012, 10:35 AM
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.

12 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 09 Aug 2012, 08:59 AM
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.
0
Marcin
Top achievements
Rank 1
Veteran
answered on 09 Aug 2012, 09:10 AM
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.
0
Marin Bratanov
Telerik team
answered on 13 Aug 2012, 10:30 AM
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.
0
Marcin
Top achievements
Rank 1
Veteran
answered on 13 Aug 2012, 10:44 AM
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.
0
Marin Bratanov
Telerik team
answered on 14 Aug 2012, 02:16 PM
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.
0
Ahmet
Top achievements
Rank 1
answered on 24 Feb 2018, 01:49 AM

Hello Marcin

I was wondering if there is any update about this solution. I realized the PITS you provided do not work anymore. I am also trying to figure out if there is any straightforward way to add custom text/data in Labels in PieChart. I know that we are able to do it by binding the chart to a custom data source (i.e DataTable ) rather than adding PieSeries / SeriesItems into chart object; but I was wondering if there is any other way.

Thanks

Ahmet.

0
Ahmet
Top achievements
Rank 1
answered on 26 Feb 2018, 06:31 PM

Hello Marin

I was wondering if there is any update about this solution. I realized the PITS you provided do not work anymore. I am also trying to figure out if there is any straightforward way to add custom text/data in Labels in PieChart. I know that we are able to do it by binding the chart to a custom data source (i.e DataTable ) rather than adding PieSeries / SeriesItems into chart object; but I was wondering if there is any other way.
Thanks
Ahmet.

0
Vessy
Telerik team
answered on 28 Feb 2018, 04:34 PM
Hi Ahmet,

Yes, the PieChart offers NameField property at this moment, you can see it in action in the following demo:
https://demos.telerik.com/aspnet-ajax/htmlchart/examples/clientsidedatabinding/defaultcs.aspx

Regards,
Vessy
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Chris
Top achievements
Rank 1
answered on 31 Aug 2018, 03:04 PM

Can that name field be accessed in jscript?  I want to draw custom legend label using the nameField values, neither of the following work.  The second option is close but not correct.  I have my piechart bound to a sqlDataSource.  In the attached photo, I want the legend to match the chart label, missing and leaked.  Is this possible?

 

var label = new drawing.Text(e.series.name, [0, 0], {
        fill: {
            color: legendLabelsColor
        }
    })

or 

var label = new drawing.Text(e.series.categoryName, [0, 0], {
        fill: {
            color: legendLabelsColor
        }
    })

 

0
Vessy
Telerik team
answered on 04 Sep 2018, 02:31 PM
Hi Chris,

I have just answered your other thread on the matter, you can refer my answer in it and continue our conversation there:
https://www.telerik.com/forums/pie-series-namefield-to-legend-label

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
priyanka
Top achievements
Rank 1
answered on 23 Mar 2019, 07:49 AM

Hello,

I added the chart in my code.after executing project no output is displyed

0
Vessy
Telerik team
answered on 27 Mar 2019, 01:03 PM
Hi priyanka,

I will need to examined the exact setup you have in order to be able to say what is causing the faced issue. Please, follow the steps listed here and send me a runnable sample in which I can reproduce the issue and debug the reason of it:
https://www.telerik.com/blogs/isolating-a-problem-in-a-sample-project

Regards,
Vessy
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Chart (HTML5)
Asked by
Marcin
Top achievements
Rank 1
Veteran
Answers by
Marin Bratanov
Telerik team
Marcin
Top achievements
Rank 1
Veteran
Ahmet
Top achievements
Rank 1
Vessy
Telerik team
Chris
Top achievements
Rank 1
priyanka
Top achievements
Rank 1
Share this question
or