From: Evert Timberg Date: Sat, 5 Dec 2015 01:32:18 +0000 (-0500) Subject: Label polar area and doughnut datasets X-Git-Tag: 2.0.0-beta2~25^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=744e1429b90eb87ab5f52b431c6aa23f003d8b68;p=thirdparty%2FChart.js.git Label polar area and doughnut datasets --- diff --git a/samples/doughnut.html b/samples/doughnut.html index fa78edd8b..0a6be617a 100644 --- a/samples/doughnut.html +++ b/samples/doughnut.html @@ -60,6 +60,7 @@ "#949FB1", "#4D5360", ], + label: 'Dataset 1' }, { hidden: true, data: [ @@ -76,6 +77,7 @@ "#949FB1", "#4D5360", ], + label: 'Dataset 2' }, { data: [ randomScalingFactor(), @@ -91,6 +93,7 @@ "#949FB1", "#4D5360", ], + label: 'Dataset 3' }], labels: [ "Red", @@ -106,7 +109,7 @@ position: 'top', title: { display: true, - text: 'Our 2 Favorite Datasets' + text: 'Our Favorite Datasets' } }, } @@ -145,6 +148,7 @@ var newDataset = { backgroundColor: [], data: [], + label: 'New dataset ' + config.data.datasets.length, }; for (var index = 0; index < config.data.labels.length; ++index) { diff --git a/samples/polar-area.html b/samples/polar-area.html index 87de0ac09..58f9d57f1 100644 --- a/samples/polar-area.html +++ b/samples/polar-area.html @@ -48,6 +48,7 @@ "#949FB1", "#4D5360", ], + label: 'My dataset' // for legend }], labels: [ "Red", diff --git a/src/core/core.legend.js b/src/core/core.legend.js index f4d6fab4d..fb3776d27 100644 --- a/src/core/core.legend.js +++ b/src/core/core.legend.js @@ -124,7 +124,6 @@ beforeBuildLabels: helpers.noop, buildLabels: function() { - // Convert ticks to strings this.labels = this.chart.data.datasets.map(function(dataset) { return this.options.labels.callback.call(this, dataset.label); }, this); @@ -292,6 +291,7 @@ if (dataset.hidden) { // Strikethrough the text if hidden ctx.beginPath(); + ctx.lineWidth = 2; ctx.moveTo(this.options.labels.boxWidth + (this.options.labels.fontSize / 2) + cursor.x, cursor.y + (this.options.labels.fontSize / 2)); ctx.lineTo(this.options.labels.boxWidth + (this.options.labels.fontSize / 2) + cursor.x + textWidth, cursor.y + (this.options.labels.fontSize / 2)); ctx.stroke();