javascript - how to add legend in pie chart -


i use php codeigniter , create pie chart using javascript. , database data pass using json encode. problem how use legend. pie chart , title.

javascript

        var piedata = [             {                 value: sales_data[i].ans,                 color:"#ff0000"              },             {                 value : sales_data[i].noans,                 color : "#006400"             },             {                 value : sales_data[i].reans,                 color : "#191970"             }             ,             {                 value : sales_data[i].noreans,                 color : "#ffea88"             }         ];         // pie chart canvas         var countries=document.getelementbyid("countries").getcontext("2d");                            // draw pie chart         new chart(countries).pie(piedata, pieoptions);                      }         }         }); 

give shot -

 legendtemplate : "<ul class=\"<%=name.tolowercase()%>-legend\"><%  (var i=0; i<segments.length; i++){%><li><span style=\"background-color: <%=segments[i].fillcolor%>\"></span><%if(segments[i].label){%> <%=segments[i].label%><%}%></li><%}%></ul>" 

include part of pieoptions.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -