Showing posts with label wrap legend text length in pie chart. Show all posts
Showing posts with label wrap legend text length in pie chart. Show all posts

Friday, 18 December 2015

Legend text length in Pie chart Using jQuery

      Legend text length in Pie chart Using jQuery



          Sometimes we may face a problem in displaying all types of chart in a constant size due to number of characters in a legend name.One solution to this is to wrap the legend text.



How to wrap the legend text in chart using jquery?

Here is the code for that

Legend{
                labelFormatter: function() {
                    var legendName = this.name;
                   
                    if(legendName!=""){
                    var match = legendName.match(/.{1,15}/g);

                return match.toString().replace(/\,/g,"<br/>");
                }
                }

According to the required length size of the legend text we can change the number like below.

         var match = legendName.match(/.{1,15}/g);


            You can have any number of characters in a line which you specified next to 1 here in this code for ex:15.


Happy Learning !!!

Learn it ! Love it ! Lead it !


To learn more just like our page in facebook Sharepoint Dev