]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Improve configuration options
authorEvert Timberg <evert.timberg+github@gmail.com>
Thu, 19 May 2016 02:49:20 +0000 (22:49 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Wed, 25 May 2016 22:39:41 +0000 (18:39 -0400)
docs/00-Getting-Started.md
docs/01-Chart-Configuration.md [new file with mode: 0644]
docs/02-Scales.md [moved from docs/01-Scales.md with 100% similarity]
docs/03-Line-Chart.md [moved from docs/02-Line-Chart.md with 98% similarity]
docs/04-Bar-Chart.md [moved from docs/03-Bar-Chart.md with 98% similarity]
docs/05-Radar-Chart.md [moved from docs/04-Radar-Chart.md with 98% similarity]
docs/06-Polar-Area-Chart.md [moved from docs/05-Polar-Area-Chart.md with 97% similarity]
docs/07-Pie-Doughnut-Chart.md [moved from docs/06-Pie-Doughnut-Chart.md with 97% similarity]
docs/08-Bubble-Chart.md [moved from docs/07-Bubble-Chart.md with 100% similarity]
docs/09-Advanced.md [moved from docs/08-Advanced.md with 100% similarity]
docs/10-Notes.md [moved from docs/09-Notes.md with 100% similarity]

index 4547eeda5b2b85f3e3eb2c026a9c8e78e1ffb42f..2a11f9bff888f754b868997f3ad1544257b43f9a 100644 (file)
@@ -118,181 +118,3 @@ var myChart = new Chart(ctx, {
 ```
 
 It's that easy to get started using Chart.js! From here you can explore the many options that can help you customise your charts with scales, tooltips, labels, colors, custom actions, and much more.
-
-### Global Chart Configuration
-
-This concept was introduced in Chart.js 1.0 to keep configuration DRY, and allow for changing options globally across chart types, avoiding the need to specify options for each instance, or the default for a particular chart type.
-
-Chart.js merges configurations and options in a few places with the global defaults using chart type defaults and scales defaults. This way you can be as specific as you want in your individual chart configs, or change the defaults for Chart.js as a whole.
-
-The global options are defined in `Chart.defaults.global`.
-
-Name | Type | Default | Description
---- | --- | --- | ---
-responsive | Boolean | true | Resizes when the canvas container does.
-responsiveAnimationDuration | Number | 0 | Duration in milliseconds it takes to animate to new size after a resize event.
-maintainAspectRatio | Boolean | true | Maintain the original canvas aspect ratio `(width / height)` when resizing
-events | Array[String] | `["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"]` | Events that the chart should listen to for tooltips and hovering
-hover |Object|-|-
-*hover*.onHover | Function | null | Called when any of the events fire. Called in the context of the chart and passed an array of active elements (bars, points, etc)
-*hover*.mode | String | 'single' | Sets which elements hover. Acceptable options are `'single'`, `'label'`, or `'dataset'`. `single` highlights the closest element. `label` highlights elements in all datasets at the same `X` value. `dataset` highlights the closest dataset.
-*hover*.animationDuration | Number | 400 | Duration in milliseconds it takes to animate hover style changes
-onClick | Function | null | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed an array of active elements
-defaultColor | Color | 'rgba(0,0,0,0.1)' |
-defaultFontColor | Color | '#666' | Default font color for all text
-defaultFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Default font family for all text
-defaultFontSize | Number | 12 | Default font size (in px) for text. Does not apply to radialLinear scale point labels
-defaultFontStyle | String | 'normal' | Default font style. Does not apply to tooltip title or footer. Does not apply to chart title
-legendCallback | Function | ` function (chart) { }` | Function to generate a legend. Receives the chart object to generate a legend from. 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 | false | 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 | `function(event, legendItem) {}` | A callback that is called when a click is registered on top of a label item
-labels |Object|-|-
-*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*.generateLabels: | Function | `function(chart) {  }` | 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`.
-
-Name | Type | Default | Description
---- |:---:| --- | ---
-enabled | Boolean | true |
-custom | | null |
-mode | String | 'single' | Sets which elements appear in the tooltip. Acceptable options are `'single'` or `'label'`. `single` highlights the closest element. `label` highlights elements in all datasets at the same `X` value.
-backgroundColor | Color | 'rgba(0,0,0,0.8)' | Background color of the tooltip
- | | |
-Label | | | There are three labels you can control. `title`, `body`, `footer` the star (\*) represents one of these three. *(i.e. titleFontFamily, footerSpacing)*
-\*FontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" |
-\*FontSize | Number | 12 |
-\*FontStyle | String | title - "bold", body - "normal", footer - "bold" |
-\*Spacing | Number | 2 |
-\*Color | Color | "#fff" |
-\*Align | String | "left" | text alignment. See [MDN Canvas Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign)
-titleMarginBottom | Number | 6 | Margin to add on bottom of title section
-footerMarginTop | Number | 6 | Margin to add before drawing the footer
-xPadding | Number | 6 | Padding to add on left and right of tooltip
-yPadding | Number | 6 | Padding to add on top and bottom of tooltip
-caretSize | Number | 5 | Size, in px, of the tooltip arrow
-cornerRadius | Number | 6 | Radius of tooltip corner curves
-multiKeyBackground | Color | "#fff" | Color to draw behind the colored boxes when multiple items are in the tooltip
- | | |
-callbacks | Object | - |  V2.0 introduces callback functions as a replacement for the template engine in v1. The tooltip has the following callbacks for providing text. For all functions, 'this' will be the tooltip object create from the Chart.Tooltip constructor
-**Callback Functions** | | | All functions are called with the same arguments
-xLabel | String or Array[Strings] | | This is the xDataValue for each item to be displayed in the tooltip
-yLabel | String or Array[Strings] | | This is the yDataValue for each item to be displayed in the tooltip
-index | Number | | Data index.
-data | Object | | Data object passed to chart.
-`return`| String or Array[Strings] | | All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text.
- | | |
-*callbacks*.beforeTitle | Function | none | Text to render before the title
-*callbacks*.title | Function | `function(tooltipItems, data) { //Pick first xLabel }` | Text to render as the title
-*callbacks*.afterTitle | Function | none | Text to render after the ttiel
-*callbacks*.beforeBody | Function | none | Text to render before the body section
-*callbacks*.beforeLabel | Function | none | Text to render before an individual label
-*callbacks*.label | Function | `function(tooltipItem, data) { // Returns "datasetLabel: tooltipItem.yLabel" }` | Text to render as label
-*callbacks*.afterLabel | Function | none | Text to render after an individual label
-*callbacks*.afterBody | Function | none | Text to render after the body section
-*callbacks*.beforeFooter | Function | none | Text to render before the footer section
-*callbacks*.footer | Function | none | Text to render as the footer
-*callbacks*.afterFooter | Function | none | Text to render after the footer section
-
-The global options for animations are defined in `Chart.defaults.global.animation`.
-
-Name | Type | Default | Description
---- |:---:| --- | ---
-duration | Number | 1000 | The number of milliseconds an animation takes.
-easing | String | "easeOutQuart" | Easing function to use.
-onProgress | Function | none | Callback called on each step of an animation. Passed a single argument, an object, containing the chart instance and an object with details of the animation.
-onComplete | Function | none | Callback called at the end of an animation. Passed the same arguments as `onProgress`
-
-The global options for elements are defined in `Chart.defaults.global.elements`.
-
-Name | Type | Default | Description
---- |:---:| --- | ---
-arc | Object | - | -
-*arc*.backgroundColor | Color | `Chart.defaults.global.defaultColor` | Default fill color for arcs
-*arc*.borderColor | Color | "#fff" | Default stroke color for arcs
-*arc*.borderWidth | Number | 2 | Default stroke width for arcs
-line | Object | - | -
-*line*.tension | Number | 0.4 | Default bezier curve tension. Set to `0` for no bezier curves.
-*line*.backgroundColor | Color | `Chart.defaults.global.defaultColor` | Default line fill color
-*line*.borderWidth | Number | 3 | Default line stroke width
-*line*.borderColor | Color | `Chart.defaults.global.defaultColor` | Default line stroke color
-*line*.borderCapStyle | String | 'butt' | Default line cap style. See [MDN](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap)
-*line*.borderDash | Array | `[]` | Default line dash. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash)
-*line*.borderDashOffset | Number | 0.0 | Default line dash offset. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset)
-*line*.borderJoinStyle | String | 'miter' | Default line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin)
-*line*.fill | Boolean | true |
-point | Object | - | -
-*point*.radius | Number | 3 | Default point radius
-*point*.pointStyle | String | 'circle' | Default point style
-*point*.backgroundColor | Color | `Chart.defaults.global.defaultColor` | Default point fill color
-*point*.borderWidth | Number | 1 | Default point stroke width
-*point*.borderColor | Color | `Chart.defaults.global.defaultColor` | Default point stroke color
-*point*.hitRadius | Number | 1 | Extra radius added to point radius for hit detection
-*point*.hoverRadius | Number | 4 | Default point radius when hovered
-*point*.hoverBorderWidth | Number | 1 | Default stroke width when hovered
-rectangle | Object | - | -
-*rectangle*.backgroundColor | Color | `Chart.defaults.global.defaultColor` | Default bar fill color
-*rectangle*.borderWidth | Number | 0 | Default bar stroke width
-*rectangle*.borderColor | Color | `Chart.defaults.global.defaultColor` | Default bar stroke color
-*rectangle*.borderSkipped | String | 'bottom' | Default skipped (excluded) border for rectangle. Can be one of `bottom`, `left`, `top`, `right`
-
-If for example, you wanted all charts created to be responsive, and resize when the browser window does, the following setting can be changed:
-
-```javascript
-Chart.defaults.global.responsive = true;
-```
-
-Now, every time we create a chart, `options.responsive` will be `true`.
-
-### Colors
-When supplying colors to Chart options, you can use a number of formats. You can specify the color as a string in hexadecimal, RGB, or HSL notations. 
-
-You can also pass a [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient) object. You will need to create this before passing to the chart, but using it you can achieve some interesting effects.
-
-The final option is to pass a [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern) object. For example, if you wanted to fill a dataset with a pattern from an image you could do the following.
-
-```javascript
-var img = new Image();
-img.src = 'https://example.com/my_image.png';
-img.onload = function() {
-    var ctx = document.getElementById('canvas').getContext('2d');
-    var fillPattern = ctx.createPattern(img, 'repeat');
-
-    var chart = new Chart(ctx, {
-        data: {
-            labels: ['Item 1', 'Item 2', 'Item 3'],
-            datasets: [{
-                data: [10, 20, 30],
-                backgroundColor: fillPattern
-            }]
-        }
-    })
-}
-
-```
diff --git a/docs/01-Chart-Configuration.md b/docs/01-Chart-Configuration.md
new file mode 100644 (file)
index 0000000..80e079f
--- /dev/null
@@ -0,0 +1,408 @@
+---
+title: Chart Configuration
+anchor: chart-configuration
+---
+
+Chart.js provides a number of options for changing the behaviour of created charts. These configuration options can be changed on a per chart basis by passing in an options object when creating the chart. Alternatively, the global configuration can be changed which will be used by all charts created after that point.
+
+### Creating a Chart with Options
+
+To create a chart with configuration options, simply pass an object containing your configuration to the constructor. In the example below, a line chart is created and configured to not be responsive.
+
+```javascript
+var chartInstance = new Chart(ctx, {
+    type: 'line',
+    data: data,
+    options: {
+        responsive: false
+    }
+});
+```
+
+### Global Configuration
+
+This concept was introduced in Chart.js 1.0 to keep configuration DRY, and allow for changing options globally across chart types, avoiding the need to specify options for each instance, or the default for a particular chart type.
+
+Chart.js merges the options object passed to the chart with the global configuration using chart type defaults and scales defaults appropriately. This way you can be as specific as you would like in your individual chart configuration, while still changing the defaults for all chart types where applicable. The global general options are defined in `Chart.defaults.global`. The defaults for each chart type are discussed in the documentation for that chart type.
+
+The following example would set the hover mode to 'single' for all charts where this was not overridden by the chart type defaults or the options passed to the constructor on creation.
+
+```javascript
+Chart.defaults.global.hover.mode = 'single';
+
+// Hover mode is set to single because it was not overridden here
+var chartInstanceHoverModeSingle = new Chart(ctx, {
+    type: 'line',
+    data: data,
+});
+
+// This chart would have the hover mode that was passed in
+var chartInstanceDifferentHoverMode = new Chart(ctx, {
+    type: 'line',
+    data: data,
+    options: {
+        hover: {
+            // Overrides the global setting
+            mode: 'label'
+        }
+    }
+})
+```
+
+#### Global Font Settings
+
+There are 4 special global settings that can change all of the fonts on the chart. These options are in `Chart.defaults.global`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+defaultFontColor | Color | '#666' | Default font color for all text
+defaultFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Default font family for all text
+defaultFontSize | Number | 12 | Default font size (in px) for text. Does not apply to radialLinear scale point labels
+defaultFontStyle | String | 'normal' | Default font style. Does not apply to tooltip title or footer. Does not apply to chart title
+
+### Common Chart Configuration
+
+The following options are applicable to all charts. The can be set on the [global configuration](#chart-configuration-global-configuration), or they can be passed to the chart constructor.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+responsive | Boolean | true | Resizes when the canvas container does.
+responsiveAnimationDuration | Number | 0 | Duration in milliseconds it takes to animate to new size after a resize event.
+maintainAspectRatio | Boolean | true | Maintain the original canvas aspect ratio `(width / height)` when resizing
+events | Array[String] | `["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"]` | Events that the chart should listen to for tooltips and hovering
+onClick | Function | null | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed an array of active elements
+legendCallback | Function | ` function (chart) { }` | Function to generate a legend. Receives the chart object to generate a legend from. Default implementation returns an HTML string.
+
+### Title Configuration
+
+The title configuration is passed into the `options.title` namespace. The global options for the chart title is defined in `Chart.defaults.global.title`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+display | Boolean | false | Display the title block
+position | String | 'top' | Position of the title. Only 'top' or 'bottom' are currently allowed
+fullWidth | Boolean | true | Marks that this box should take the full width of the canvas (pushing down other boxes)
+fontSize | Number | 12 | Font size inherited from global configuration
+fontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family inherited from global configuration
+fontColor | Color | "#666" | Font color inherited from global configuration
+fontStyle | String | 'bold' | Font styling of the title. 
+padding | Number | 10 | Number of pixels to add above and below the title text
+text | String | '' | Title text
+
+#### Example Usage
+
+The example below would enable a title of 'Custom Chart Title' on the chart that is created.
+
+```javascript
+var chartInstance = new Chart(ctx, {
+    type: 'line',
+    data: data,
+    options: {
+        title: {
+            display: true,
+            text: 'Custom Chart Title'
+        }
+    }
+})
+```
+
+### Legend Configuration
+
+The legend configuration is passed into the `options.legend` namespace. 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 | `function(event, legendItem) {}` | A callback that is called when a click is registered on top of a label item
+labels |Object|-| See the [Legend Label Configuration](#chart-configuration-legend-label-configuration) section below.
+
+#### Legend Label Configuration
+
+The legend label configuration is nested below the legend configuration using the `labels` key.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+boxWidth | Number | 40 | Width of coloured box
+fontSize | Number | 12 | Font size inherited from global configuration
+fontStyle | String | "normal" | Font style inherited from global configuration
+fontColor | Color | "#666" | Font color inherited from global configuration
+fontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family inherited from global configuration
+padding | Number | 10 | Padding between rows of colored boxes
+generateLabels: | Function | `function(chart) {  }` | Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See [Legend Item](#chart-configuration-legend-item-interface) for details.
+
+#### Legend Item Interface
+
+Items passed to the legend `onClick` function are the ones returned from `labels.generateLabels`. These items must implement the following interface.
+
+```javascript
+{
+    // Label that will be displayed
+    text: String,
+
+    // Fill style of the legend box
+    fillStyle: Color,
+
+    // If true, this item represents a hidden dataset. Label will be rendered with a strike-through effect
+    hidden: Boolean,
+
+    // For box border. See https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap
+    lineCap: String,
+
+    // For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
+    lineDash: Array[Number],
+
+    // For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
+    lineDashOffset: Number,
+
+    // For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin
+    lineJoin: String,
+
+    // Width of box border 
+    lineWidth: Number,
+
+    // Stroke style of the legend box
+    strokeStyle: Color
+}
+```
+
+#### Example
+
+The following example will create a chart with the legend enabled and turn all of the text red in color.
+
+```javascript
+var chartInstance = new Chart(ctx, {
+    type: 'bar',
+    data: data,
+    options: {
+        legend: {
+            display: true,
+            labels: {
+                fontColor: 'rgb(255, 99, 132)'
+            }
+        }
+    }
+});
+```
+
+### Tooltip Configuration
+
+The title configuration is passed into the `options.tooltips` namespace. The global options for the chart tooltips is defined in `Chart.defaults.global.title`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+enabled | Boolean | true | Are tooltips 
+custom | Function | null | See [section](#chart-configuration-custom-tooltips) below
+mode | String | 'single' | Sets which elements appear in the tooltip. Acceptable options are `'single'` or `'label'`. `single` highlights the closest element. `label` highlights elements in all datasets at the same `X` value.
+backgroundColor | Color | 'rgba(0,0,0,0.8)' | Background color of the tooltip
+titleFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for tooltip title inherited from global font family
+titleFontSize | Number | 12 | Font size for tooltip title inherited from global font size
+titleFontStyle | String | "bold" |
+titleFontColor | Color | "#fff" | Font color for tooltip title
+titleSpacing | Number | 2 | Spacing to add to top and bottom of each title line.
+titleMarginBottom | Number | 6 | Margin to add on bottom of title section
+bodyFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for tooltip items inherited from global font family
+bodyFontSize | Number | 12 | Font size for tooltip items inherited from global font size
+bodyFontStyle | String | "normal" |
+bodyFontColor | Color | "#fff" | Font color for tooltip items.
+bodySpacing | Number | 2 | Spacing to add to top and bottom of each tooltip item
+footerFontFamily | String | "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif" | Font family for tooltip footer inherited from global font family.
+footerFontSize | Number | 12 | Font size for tooltip footer inherited from global font size.
+footerFontStyle | String | "bold" | Font style for tooltip footer.
+footerFontColor | Color | "#fff" | Font color for tooltip footer.
+footerSpacing | Number | 2 | Spacing to add to top and bottom of each footer line.
+footerMarginTop | Number | 6 | Margin to add before drawing the footer
+xPadding | Number | 6 | Padding to add on left and right of tooltip
+yPadding | Number | 6 | Padding to add on top and bottom of tooltip
+caretSize | Number | 5 | Size, in px, of the tooltip arrow
+cornerRadius | Number | 6 | Radius of tooltip corner curves
+multiKeyBackground | Color | "#fff" | Color to draw behind the colored boxes when multiple items are in the tooltip
+callbacks | Object | | See the [callbacks section](#chart-configuration-tooltip-callbacks) below
+
+#### Tooltip Callbacks
+
+The tooltip label configuration is nested below the tooltip configuration using the `callbacks` key. The tooltip has the following callbacks for providing text. For all functions, 'this' will be the tooltip object created from the Chart.Tooltip constructor. 
+
+All functions are called with the same arguments: a [tooltip item](#chart-configuration-tooltip-item-interface) and the data object passed to the chart. All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text.
+
+Callback | Arguments | Description
+--- | --- | ---
+beforeTitle | `Array[tooltipItem], data` | Text to render before the title
+title | `Array[tooltipItem], data` | Text to render as the title
+afterTitle | `Array[tooltipItem], data` | Text to render after the title
+beforeBody | `Array[tooltipItem], data` | Text to render before the body section
+beforeLabel | `tooltipItem, data` | Text to render before an individual label
+label | `tooltipItem, data` | Text to render for an individual item in the tooltip
+afterLabel | `tooltipItem, data` | Text to render after an individual label
+afterBody | `Array[tooltipItem], data` | Text to render after the body section
+beforeFooter | `Array[tooltipItem], data` | Text to render before the footer section
+footer | `Array[tooltipItem], data` | Text to render as the footer
+afterFooter | `Array[tooltipItem], data` | Text to render after the footer section
+
+#### Tooltip Item Interface
+
+The tooltip items passed to the tooltip callbacks implement the following interface.
+
+```javascript
+{
+    // X Value of the tooltip as a string
+    xLabel: String,
+
+    // Y value of the tooltip as a string
+    yLabel: String,
+
+    // Index of the dataset the item comes from
+    datasetIndex: Number,
+
+    // Index of this data item in the dataset
+    index: Number
+}
+```
+
+### Hover Configuration
+
+The hover configuration is passed into the `options.hover` namespace. The global hover configuration is at `Chart.defaults.global.hover`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+mode | String | 'single' | Sets which elements hover. Acceptable options are `'single'`, `'label'`, or `'dataset'`. `single` highlights the closest element. `label` highlights elements in all datasets at the same `X` value. `dataset` highlights the closest dataset.
+animationDuration | Number | 400 | Duration in milliseconds it takes to animate hover style changes
+onHover | Function | null | Called when any of the events fire. Called in the context of the chart and passed an array of active elements (bars, points, etc)
+
+### Animation Configuration
+
+The following animation options are available. The global options for are defined in `Chart.defaults.global.animation`.
+
+Name | Type | Default | Description
+--- |:---:| --- | ---
+duration | Number | 1000 | The number of milliseconds an animation takes.
+easing | String | "easeOutQuart" | Easing function to use.
+onProgress | Function | none | Callback called on each step of an animation. Passed a single argument, an object, containing the chart instance and an object with details of the animation.
+onComplete | Function | none | Callback called at the end of an animation. Passed the same arguments as `onProgress`
+
+#### Animation Callbacks
+
+The `onProgress` and `onComplete` callbacks are useful for synchronizing an external draw to the chart animation. The callback is passed an object that implements the following interface. An example usage of these callbacks can be found on [Github](https://github.com/chartjs/Chart.js/blob/master/samples/AnimationCallbacks/progress-bar.html). This sample displays a progress bar showing how far along the animation is.
+
+```javscript
+{
+    // Chart object
+    chartInstance,
+
+    // Contains details of the on-going animation
+    animationObject,
+}
+```
+
+#### Animation Object
+
+The animation object passed to the callbacks is of type `Chart.Animation`. The object has the following parameters.
+
+```javascript
+{
+    // Current Animation frame number
+    currentStep: Number,
+
+    // Number of animation frames
+    numSteps: Number,
+
+    // Animation easing to use
+    easing: String,
+
+    // Function that renders the chart
+    render: Function,
+
+    // User callback
+    onAnimationProgress: Function,
+
+    // User callback
+    onAnimationComplete: Function
+}
+```
+
+### Element Configuration
+
+The global options for elements are defined in `Chart.defaults.global.elements`.
+
+Options can be configured for four different types of elements; arc, lines, points, and rectangles. When set, these options apply to all objects of that type unless specifically overridden by the configuration attached to a dataset.
+
+#### Arc Configuration
+
+Arcs are used in the polar area, doughnut and pie charts. They can be configured with the following options. The global arc options are stored in `Chart.defaults.global.elements.arc`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default fill color for arcs. Inherited from the global default 
+borderColor | Color | '#fff' | Default stroke color for arcs
+borderWidth | Number | 2 | Default stroke width for arcs
+
+#### Line Configuration
+
+Line elements are used to represent the line in a line chart. The global line options are stored in `Chart.defaults.global.elements.line`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+tension | Number | 0.4 | Default bezier curve tension. Set to `0` for no bezier curves.
+backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default line fill color
+borderWidth | Number | 3 | Default line stroke width
+borderColor | Color | 'rgba(0,0,0,0.1)' | Default line stroke color
+borderCapStyle | String | 'butt' | Default line cap style. See [MDN](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap)
+borderDash | Array | `[]` | Default line dash. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash)
+borderDashOffset | Number | 0.0 | Default line dash offset. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset)
+borderJoinStyle | String | 'miter' | Default line join style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin)
+fill | Boolean | true | If true, the line is filled.
+
+#### Point Configuration
+
+Point elements are used to represent the points in a line chart or a bubble chart. The global point options are stored in `Chart.defaults.global.elements.point`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+radius | Number | 3 | Default point radius
+pointStyle | String | 'circle' | Default point style
+backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default point fill color
+borderWidth | Number | 1 | Default point stroke width
+borderColor | Color | 'rgba(0,0,0,0.1)' | Default point stroke color
+hitRadius | Number | 1 | Extra radius added to point radius for hit detection
+hoverRadius | Number | 4 | Default point radius when hovered
+hoverBorderWidth | Number | 1 | Default stroke width when hovered
+
+#### Rectangle Configuration
+
+Rectangle elements are used to represent the bars in a bar chart. The global rectangle options are stored in `Chart.defaults.global.elements.rectange`.
+
+Name | Type | Default | Description
+--- | --- | --- | ---
+backgroundColor | Color | 'rgba(0,0,0,0.1)' | Default bar fill color
+borderWidth | Number | 0 | Default bar stroke width
+borderColor | Color | 'rgba(0,0,0,0.1)' | Default bar stroke color
+borderSkipped | String | 'bottom' | Default skipped (excluded) border for rectangle. Can be one of `bottom`, `left`, `top`, `right`
+
+### Colors
+
+When supplying colors to Chart options, you can use a number of formats. You can specify the color as a string in hexadecimal, RGB, or HSL notations. If a color is needed, but not specified, Chart.js will use the global default color. This color is stored at `Chart.defaults.global.defaultColor`. It is initially set to 'rgb(0, 0, 0, 0.1)';
+
+You can also pass a [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient) object. You will need to create this before passing to the chart, but using it you can achieve some interesting effects.
+
+The final option is to pass a [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern) object. For example, if you wanted to fill a dataset with a pattern from an image you could do the following.
+
+```javascript
+var img = new Image();
+img.src = 'https://example.com/my_image.png';
+img.onload = function() {
+    var ctx = document.getElementById('canvas').getContext('2d');
+    var fillPattern = ctx.createPattern(img, 'repeat');
+
+    var chart = new Chart(ctx, {
+        data: {
+            labels: ['Item 1', 'Item 2', 'Item 3'],
+            datasets: [{
+                data: [10, 20, 30],
+                backgroundColor: fillPattern
+            }]
+        }
+    })
+}
+
+```
\ No newline at end of file
similarity index 100%
rename from docs/01-Scales.md
rename to docs/02-Scales.md
similarity index 98%
rename from docs/02-Line-Chart.md
rename to docs/03-Line-Chart.md
index 1aba0de903774fb31d4087e940401262d0d0559f..0c34f179db4e742528ce682543f3dfefef28e3bf 100644 (file)
@@ -96,7 +96,7 @@ The label key on each dataset is optional, and can be used when generating a sca
 
 ### Chart Options
 
-These are the customisation options specific to Line charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+These are the customisation options specific to Line charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart.
 
 The default options for line chart are defined in `Chart.defaults.line`.
 
similarity index 98%
rename from docs/03-Bar-Chart.md
rename to docs/04-Bar-Chart.md
index d8bf236bf83fc192a6c9664a3c19e6f016ac18d2..a0b1440c70970d5ba212251a6c76f5d649b460dc 100644 (file)
@@ -73,7 +73,7 @@ We have an array of labels too for display. In the example, we are showing the s
 
 ### Chart Options
 
-These are the customisation options specific to Bar charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+These are the customisation options specific to Bar charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart.
 
 The default options for bar chart are defined in `Chart.defaults.bar`.
 
similarity index 98%
rename from docs/04-Radar-Chart.md
rename to docs/05-Radar-Chart.md
index ad381d6c230dc0288f38fe5f0f738a412d95fe85..ce98dc4e973830927f1c55f01423c14c95a55bda 100644 (file)
@@ -88,7 +88,7 @@ The label key on each dataset is optional, and can be used when generating a sca
 
 ### Chart Options
 
-These are the customisation options specific to Radar charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+These are the customisation options specific to Radar charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart.
 
 The default options for radar chart are defined in `Chart.defaults.radar`.
 
similarity index 97%
rename from docs/05-Polar-Area-Chart.md
rename to docs/06-Polar-Area-Chart.md
index 224f0898a45d3c3e1f649ea7d6ef383e16cbd2e1..3b94b731837b78b0813ef48e50bb4dc505ee443b 100644 (file)
@@ -72,7 +72,7 @@ As you can see, for the chart data you pass in an array of objects, with a value
 
 ### Chart Options
 
-These are the customisation options specific to Polar Area charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+These are the customisation options specific to Polar Area charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart.
 
 Name | Type | Default | Description
 --- | --- | --- | ---
similarity index 97%
rename from docs/06-Pie-Doughnut-Chart.md
rename to docs/07-Pie-Doughnut-Chart.md
index de1fd3306567878e7cbd9494c24e1cbe518fdb4c..3347d730943f678417fe903dd6c6f460a3c55347 100644 (file)
@@ -83,7 +83,7 @@ For a pie chart, datasets need to contain an array of data points. The data poin
 
 ### Chart Options
 
-These are the customisation options specific to Pie & Doughnut charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+These are the customisation options specific to Pie & Doughnut charts. These options are merged with the [global chart configuration options](#global-chart-configuration), and form the options of the chart.
 
 Name | Type | Default | Description
 --- | --- | --- | ---
similarity index 100%
rename from docs/08-Advanced.md
rename to docs/09-Advanced.md
similarity index 100%
rename from docs/09-Notes.md
rename to docs/10-Notes.md