From: Evert Timberg Date: Sun, 6 Dec 2015 16:19:55 +0000 (-0500) Subject: Docs + move defaults to correct place. X-Git-Tag: 2.0.0-beta2~25^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eba2fce923df5237d2813398714cd5fde876c431;p=thirdparty%2FChart.js.git Docs + move defaults to correct place. --- diff --git a/docs/00-Getting-Started.md b/docs/00-Getting-Started.md index cd0970bd4..05ecd666e 100644 --- a/docs/00-Getting-Started.md +++ b/docs/00-Getting-Started.md @@ -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 diff --git a/src/core/core.legend.js b/src/core/core.legend.js index 14e1c6b4e..5a5274622 100644 --- a/src/core/core.legend.js +++ b/src/core/core.legend.js @@ -5,7 +5,7 @@ Chart = root.Chart, helpers = Chart.helpers; - Chart.defaults.legend = { + Chart.defaults.global.legend = { display: true, position: 'top', @@ -19,10 +19,8 @@ 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 = []; @@ -110,7 +108,7 @@ 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, diff --git a/src/core/core.title.js b/src/core/core.title.js index 7758fd337..42ed8b54f 100644 --- a/src/core/core.title.js +++ b/src/core/core.title.js @@ -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 = [];