]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Docs + move defaults to correct place.
authorEvert Timberg <evert.timberg@gmail.com>
Sun, 6 Dec 2015 16:19:55 +0000 (11:19 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Sun, 6 Dec 2015 16:19:55 +0000 (11:19 -0500)
docs/00-Getting-Started.md
src/core/core.legend.js
src/core/core.title.js

index cd0970bd471b1003f3a14eb0253a93aaefebd2b1..05ecd666e7ed38514326616517ebc561b997223b 100644 (file)
@@ -105,6 +105,37 @@ onClick | Function | null | Called if the event is of type 'mouseup' or 'click'.
 defaultColor | Color | 'rgba(0,0,0,0.1)' |
 legendCallback | Function | ` function (chart) { // the chart object to generate a legend from.  }` | Function to generate a legend. Default implementation returns an HTML string.
 
+The global options for the chart title is defined in `Chart.defaults.global.title`
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+display | Boolean | true | Show the title block
+position | String | 'top' | Position of the title. 'top' or 'bottom' are allowed
+fullWidth | Boolean | true | Marks that this box should take the full width of the canvas (pushing down other boxes)
+fontColor | Color  | '#666' | Text color
+fontFamily | String | 'Helvetica Neue' |
+fontSize | Number | 12 | 
+fontStyle | String | 'bold' |
+padding | Number | 10 | Number of pixels to add above and below the title text
+text | String | '' | Title text
+
+The global options for the chart legend is defined in `Chart.defaults.global.legend`
+
+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
+labels |-|-|-
+*labels*boxWidth | Number | 40 | Width of coloured box
+*labels*fontSize | Number | 12 | Font size
+*labels*fontStyle | String | "normal" |
+*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
+
 The global options for tooltips are defined in `Chart.defaults.global.tooltips`.
 
 Name | Type | Default | Description
index 14e1c6b4e62c85f12c64516a56a3e0d34b6e504f..5a5274622d4077edff8b6814f46197091519cc7d 100644 (file)
@@ -5,7 +5,7 @@
                Chart = root.Chart,
                helpers = Chart.helpers;
 
-       Chart.defaults.legend = {
+       Chart.defaults.global.legend = {
 
                display: true,
                position: 'top',
                        fontColor: "#666",
                        fontFamily: "Helvetica Neue",
                        padding: 10,
-                       reverse: false,
-                       display: true,
-                       callback: function(value) {
-                               return '' + value;
+                       callback: function(dataset) {
+                               return '' + dataset.label;
                        },
                },
        };
@@ -31,7 +29,7 @@
 
                initialize: function(config) {
                        helpers.extend(this, config);
-                       this.options = helpers.configMerge(Chart.defaults.legend, config.options);
+                       this.options = helpers.configMerge(Chart.defaults.global.legend, config.options);
 
                        // Contains hit boxes for each dataset (in dataset order)
                        this.legendHitBoxes = [];
                beforeBuildLabels: helpers.noop,
                buildLabels: function() {
                        this.labels = this.chart.data.datasets.map(function(dataset) {
-                               return this.options.labels.callback.call(this, dataset.label);
+                               return this.options.labels.callback.call(this, dataset);
                        }, this);
                },
                afterBuildLabels: helpers.noop,
index 7758fd3371a0dd855c297efa0a86c54ff114ccf5..42ed8b54f8665e0122520bf20a6b10127f739dda 100644 (file)
@@ -5,9 +5,8 @@
                Chart = root.Chart,
                helpers = Chart.helpers;
 
-       Chart.defaults.title = {
-
-               display: true,
+       Chart.defaults.global.title = {
+               display: false,
                position: 'top',
                fullWidth: true, // marks that this box should take the full width of the canvas (pushing down other boxes)
 
@@ -25,7 +24,7 @@
 
                initialize: function(config) {
                        helpers.extend(this, config);
-                       this.options = helpers.configMerge(Chart.defaults.title, config.options);
+                       this.options = helpers.configMerge(Chart.defaults.global.title, config.options);
 
                        // Contains hit boxes for each dataset (in dataset order)
                        this.legendHitBoxes = [];