From: Evert Timberg Date: Tue, 8 Dec 2015 02:52:15 +0000 (-0500) Subject: Update docs + remove unused config option since we don't need 2 different callbacks. X-Git-Tag: 2.0.0-beta2~25^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2e1a97382ced84cd9ca7aff7cb2c1826166de8a;p=thirdparty%2FChart.js.git Update docs + remove unused config option since we don't need 2 different callbacks. --- diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index 05ecd666e..9198861fe 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -126,7 +126,7 @@ Name | Type | Default | Description display | Boolean | true | Is the legend displayed position | String | 'top' | Position of the legend. Options are 'top' or 'bottom' fullWidth | Boolean | true | Marks that this box should take the full width of the canvas (pushing down other boxes) -onClick | Function | false | A callback that will override the default behavior of toggling the datasets +onClick | Function | `function(event, legendItem) {}` | A callback that is called when a click is registered on top of a label item labels |-|-|- *labels*boxWidth | Number | 40 | Width of coloured box *labels*fontSize | Number | 12 | Font size @@ -134,7 +134,7 @@ labels |-|-|- *labels*fontColor | Color | "#666" | *labels*fontFamily | String | "Helvetica Neue" | *labels*padding | Number | 10 | Padding between rows of colored boxes -*labels*callback: | Function | `function(dataset) { return '' + value; } | Generate the text for a dataset in the label +*labels*generateLabels: | Function | `function(data) { } | Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. Styles that can be returned are `fillStyle`, `strokeStyle`, `lineCap`, `lineDash`, `lineDashOffset`, `lineWidth`, `lineJoin`. Return a `hidden` attribute to indicate that the label refers to something that is not visible. A strikethrough style will be given to the text in this case. The global options for tooltips are defined in `Chart.defaults.global.tooltips`. diff --git a/docs/05-Polar-Area-Chart.md b/docs/05-Polar-Area-Chart.md index 30e0d84ea..dd24c3305 100644 --- a/docs/05-Polar-Area-Chart.md +++ b/docs/05-Polar-Area-Chart.md @@ -67,6 +67,8 @@ scale | Array | [See Scales](#scales) and [Defaults for Radial Linear Scale](#ge *scale*.lineArc | Boolean | true | When true, lines are circular. *animation*.animateRotate | Boolean |true | If true, will animate the rotation of the chart. *animation*.animateScale | Boolean | true | If true, will animate scaling the chart. +*legend*.*labels*.generateLabels | Function | `function(data) {} ` | Returns labels for each the legend +*legend*.onClick | Function | function(event, legendItem) {} ` | Handles clicking an individual legend item You can override these for your `Chart` instance by passing a second argument into the `PolarArea` method as an object with the keys you want to override. diff --git a/docs/06-Pie-Doughnut-Chart.md b/docs/06-Pie-Doughnut-Chart.md index 9511112e2..9552d43e5 100644 --- a/docs/06-Pie-Doughnut-Chart.md +++ b/docs/06-Pie-Doughnut-Chart.md @@ -78,6 +78,8 @@ scale | Array | [See Scales](#scales) and [Defaults for Radial Linear Scale](#ge *scale*.lineArc | Boolean | true | When true, lines are arced compared to straight when false. *animation*.animateRotate | Boolean |true | If true, will animate the rotation of the chart. *animation*.animateScale | Boolean | false | If true, will animate scaling the Doughnut from the centre. +*legend*.*labels*.generateLabels | Function | `function(data) {} ` | Returns labels for each the legend +*legend*.onClick | Function | function(event, legendItem) {} ` | Handles clicking an individual legend item You can override these for your `Chart` instance by passing a second argument into the `Doughnut` method as an object with the keys you want to override. diff --git a/src/core/core.legend.js b/src/core/core.legend.js index b2594f726..1ad6c9535 100644 --- a/src/core/core.legend.js +++ b/src/core/core.legend.js @@ -27,10 +27,6 @@ fontColor: "#666", fontFamily: "Helvetica Neue", padding: 10, - callback: function(dataset) { - return '' + dataset.label; - }, - // Generates labels shown in the legend // Valid properties to return: // text : text to display @@ -45,7 +41,7 @@ generateLabels: function(data) { return data.datasets.map(function(dataset, i) { return { - text: this.options.labels.callback.call(this, dataset), + text: dataset.label, fillStyle: dataset.backgroundColor, hidden: dataset.hidden, lineCap: dataset.borderCapStyle,