]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Update docs + remove unused config option since we don't need 2 different callbacks.
authorEvert Timberg <evert.timberg@gmail.com>
Tue, 8 Dec 2015 02:52:15 +0000 (21:52 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Tue, 8 Dec 2015 02:52:15 +0000 (21:52 -0500)
docs/00-Getting-Started.md
docs/05-Polar-Area-Chart.md
docs/06-Pie-Doughnut-Chart.md
src/core/core.legend.js

index 05ecd666e7ed38514326616517ebc561b997223b..9198861fe2256e9d511b559af5b674d41514afe1 100644 (file)
@@ -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`.
 
index 30e0d84eaa7c60fe4d66a6780dac39ea6a02c886..dd24c33051706814450724b0cae3bf5d171c3dd1 100644 (file)
@@ -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.
 
index 9511112e2f67fcb308d13a85c80cc98883ac63f4..9552d43e5628bd9825e0b8ff230c8c8d71aa41d2 100644 (file)
@@ -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.
 
index b2594f726f092c096906a034b86060675815390f..1ad6c95355a0429d0537678a040a551c86da2f89 100644 (file)
                        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,