]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix polar area legends 1667/head
authoretimberg <evert.timberg@gmail.com>
Thu, 19 Nov 2015 02:30:16 +0000 (21:30 -0500)
committeretimberg <evert.timberg@gmail.com>
Thu, 19 Nov 2015 02:30:16 +0000 (21:30 -0500)
src/charts/Chart.PolarArea.js

index 20171f7f70e9a0c1127a636e3c1d01999894400b..2b44bb9aa859249806f49146d5d9560db7ad92d3 100644 (file)
@@ -7,7 +7,23 @@
 
        var defaultConfig = {
                aspectRatio: 1,
-               legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i = 0; i < data.datasets[0].data.length; i++){%><li><span style=\"background-color:<%=data.datasets[0].backgroundColor[i]%>\"><%if(data.labels && i < data.labels.length){%><%=data.labels[i]%><%}%></span></li><%}%></ul>",
+               legendCallback: function(chart) {
+                       var text = [];
+                       text.push('<ul class="' + chart.id + '-legend">');
+
+                       if (chart.data.datasets.length) {
+                               for (var i = 0; i < chart.data.datasets[0].data.length; ++i) {
+                                       text.push('<li><span style="background-color:' + chart.data.datasets[0].backgroundColor[i] + '">');
+                                       if (chart.data.labels[i]) {
+                                               text.push(chart.data.labels[i]);
+                                       }
+                                       text.push('</span></li>');
+                               }
+                       }
+
+                       text.push('</ul>');
+                       return text.join("");
+               }
        };
 
        Chart.PolarArea = function(context, config) {