language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/08-Bubble-Chart.md | @@ -1,100 +0,0 @@
----
-title: Bubble Chart
-anchor: bubble-chart
----
-### Introduction
-A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles.
-
-<div class="canvas-holder">
- <canvas width="250" height="125"></canvas>
-</div>
-<br>
-
-### Example Usage
-
-```javascript
-// For a bubble chart
-var myBubbleChart = new Chart(ctx,{
- type: 'bubble',
- data: data,
- options: options
-});
-```
-
-### Dataset Structure
-
-Property | Type | Usage
---- | --- | ---
-data | `Array<BubbleDataObject>` | The data to plot as bubbles. See [Data format](#bubble-chart-data-format)
-label | `String` | The label for the dataset which appears in the legend and tooltips
-backgroundColor | `Color Array<Color>` | The fill color of the bubbles. See [Colors](#chart-configuration-colors)
-borderColor | `Color or Array<Color>` | The stroke color of the bubbles.
-borderWidth | `Number or Array<Number>` | The stroke width of bubble in pixels.
-hoverBackgroundColor | `Color or Array<Color>` | The fill color of the bubbles when hovered.
-hoverBorderColor | `Color or Array<Color>` | The stroke color of the bubbles when hovered.
-hoverBorderWidth | `Number or Array<Number>` | The stroke width of the bubbles when hovered.
-hoverRadius | `Number or Array<Number>` | Additional radius to add to data radius on hover.
-
-An example data object using these attributes is shown below. This example creates a single dataset with 2 different bubbles.
-
-```javascript
-var data = {
- datasets: [
- {
- label: 'First Dataset',
- data: [
- {
- x: 20,
- y: 30,
- r: 15
- },
- {
- x: 40,
- y: 10,
- r: 10
- }
- ],
- backgroundColor:"#FF6384",
- hoverBackgroundColor: "#FF6384",
- }]
-};
-```
-
-### Data Object
-
-Data for the bubble chart is passed in the form of an object. The object must implement the following interface. It is important to note that the radius property, `r` is **not** scaled by the chart. It is the raw radius in pixels of the bubble that is drawn on the canvas.
-
-```javascript
-{
- // X Value
- x: <Number>,
-
- // Y Value
- y: <Number>,
-
- // Radius of bubble. This is not scaled.
- r: <Number>
-}
-```
-
-### Chart Options
-
-The bubble chart has no unique configuration options. To configure options common to all of the bubbles, the point element options are used.
-
-For example, to give all bubbles a 1px wide black border, the following options would be used.
-
-```javascript
-new Chart(ctx,{
- type:"bubble",
- options: {
- elements: {
- points: {
- borderWidth: 1,
- borderColor: 'rgb(0, 0, 0)'
- }
- }
- }
-});
-```
-
-We can also change the default values for the Bubble chart type. Doing so will give all bubble charts created after this point the new defaults. The default configuration for the bubble chart can be accessed at `Chart.defaults.bubble`. | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/09-Advanced.md | @@ -1,467 +0,0 @@
----
-title: Advanced usage
-anchor: advanced-usage
----
-
-
-### Prototype Methods
-
-For each chart, there are a set of global prototype methods on the shared `ChartType` which you may find useful. These are available on all charts created with Chart.js, but for the examples, let's use a line chart we've made.
-
-```javascript
-// For example:
-var myLineChart = new Chart(ctx, config);
-```
-
-#### .destroy()
-
-Use this to destroy any chart instances that are created. This will clean up any references stored to the chart object within Chart.js, along with any associated event listeners attached by Chart.js.
-This must be called before the canvas is reused for a new chart.
-
-```javascript
-// Destroys a specific chart instance
-myLineChart.destroy();
-```
-
-#### .update(duration, lazy)
-
-Triggers an update of the chart. This can be safely called after updating the data object. This will update all scales, legends, and then re-render the chart.
-
-```javascript
-// duration is the time for the animation of the redraw in milliseconds
-// lazy is a boolean. if true, the animation can be interrupted by other animations
-myLineChart.data.datasets[0].data[2] = 50; // Would update the first dataset's value of 'March' to be 50
-myLineChart.update(); // Calling update now animates the position of March from 90 to 50.
-```
-
-> **Note:** replacing the data reference (e.g. `myLineChart.data = {datasets: [...]}` only works starting **version 2.6**. Prior that, replacing the entire data object could be achieved with the following workaround: `myLineChart.config.data = {datasets: [...]}`.
-
-#### .reset()
-
-Reset the chart to it's state before the initial animation. A new animation can then be triggered using `update`.
-
-```javascript
-myLineChart.reset();
-```
-
-#### .render(duration, lazy)
-
-Triggers a redraw of all chart elements. Note, this does not update elements for new data. Use `.update()` in that case.
-
-```javascript
-// duration is the time for the animation of the redraw in milliseconds
-// lazy is a boolean. if true, the animation can be interrupted by other animations
-myLineChart.render(duration, lazy);
-```
-
-#### .stop()
-
-Use this to stop any current animation loop. This will pause the chart during any current animation frame. Call `.render()` to re-animate.
-
-```javascript
-// Stops the charts animation loop at its current frame
-myLineChart.stop();
-// => returns 'this' for chainability
-```
-
-#### .resize()
-
-Use this to manually resize the canvas element. This is run each time the canvas container is resized, but you can call this method manually if you change the size of the canvas nodes container element.
-
-```javascript
-// Resizes & redraws to fill its container element
-myLineChart.resize();
-// => returns 'this' for chainability
-```
-
-#### .clear()
-
-Will clear the chart canvas. Used extensively internally between animation frames, but you might find it useful.
-
-```javascript
-// Will clear the canvas that myLineChart is drawn on
-myLineChart.clear();
-// => returns 'this' for chainability
-```
-
-#### .toBase64Image()
-
-This returns a base 64 encoded string of the chart in it's current state.
-
-```javascript
-myLineChart.toBase64Image();
-// => returns png data url of the image on the canvas
-```
-
-#### .generateLegend()
-
-Returns an HTML string of a legend for that chart. The legend is generated from the `legendCallback` in the options.
-
-```javascript
-myLineChart.generateLegend();
-// => returns HTML string of a legend for this chart
-```
-
-#### .getElementAtEvent(e)
-
-Calling `getElementAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the single element at the event position. If there are multiple items within range, only the first is returned
-
-```javascript
-myLineChart.getElementAtEvent(e);
-// => returns the first element at the event point.
-```
-
-#### .getElementsAtEvent(e)
-
-Looks for the element under the event point, then returns all elements at the same data index. This is used internally for 'label' mode highlighting.
-
-Calling `getElementsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the point elements that are at that the same position of that event.
-
-```javascript
-canvas.onclick = function(evt){
- var activePoints = myLineChart.getElementsAtEvent(evt);
- // => activePoints is an array of points on the canvas that are at the same position as the click event.
-};
-```
-
-This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.
-
-#### .getDatasetAtEvent(e)
-
-Looks for the element under the event point, then returns all elements from that dataset. This is used internally for 'dataset' mode highlighting
-
-```javascript
-myLineChart.getDatasetAtEvent(e);
-// => returns an array of elements
-```
-
-#### .getDatasetMeta(index)
-
-Looks for the dataset that matches the current index and returns that metadata. This returned data has all of the metadata that is used to construct the chart.
-
-The `data` property of the metadata will contain information about each point, rectangle, etc. depending on the chart type.
-
-Extensive examples of usage are available in the [Chart.js tests](https://github.com/chartjs/Chart.js/tree/master/test).
-
-```javascript
-var meta = myChart.getDatasetMeta(0);
-var x = meta.data[0]._model.x
-```
-
-### External Tooltips
-
-You can enable custom tooltips in the global or chart configuration like so:
-
-```javascript
-var myPieChart = new Chart(ctx, {
- type: 'pie',
- data: data,
- options: {
- tooltips: {
- custom: function(tooltip) {
- // tooltip will be false if tooltip is not visible or should be hidden
- if (!tooltip) {
- return;
- }
-
- // Otherwise, tooltip will be an object with all tooltip properties like:
-
- // tooltip.caretSize
- // tooltip.caretPadding
- // tooltip.chart
- // tooltip.cornerRadius
- // tooltip.fillColor
- // tooltip.font...
- // tooltip.text
- // tooltip.x
- // tooltip.y
- // tooltip.caretX
- // tooltip.caretY
- // etc...
- }
- }
- }
-});
-```
-
-See `samples/tooltips/line-customTooltips.html` for examples on how to get started.
-
-### Writing New Scale Types
-
-Starting with Chart.js 2.0 scales can be individually extended. Scales should always derive from Chart.Scale.
-
-```javascript
-var MyScale = Chart.Scale.extend({
- /* extensions ... */
-});
-
-// MyScale is now derived from Chart.Scale
-```
-
-Once you have created your scale class, you need to register it with the global chart object so that it can be used. A default config for the scale may be provided when registering the constructor. The first parameter to the register function is a string key that is used later to identify which scale type to use for a chart.
-
-```javascript
-Chart.scaleService.registerScaleType('myScale', MyScale, defaultConfigObject);
-```
-
-To use the new scale, simply pass in the string key to the config when creating a chart.
-
-```javascript
-var lineChart = new Chart(ctx, {
- data: data,
- type: 'line',
- options: {
- scales: {
- yAxes: [{
- type: 'myScale' // this is the same key that was passed to the registerScaleType function
- }]
- }
- }
-})
-```
-
-#### Scale Properties
-
-Scale instances are given the following properties during the fitting process.
-
-```javascript
-{
- left: Number, // left edge of the scale bounding box
- right: Number, // right edge of the bounding box'
- top: Number,
- bottom: Number,
- width: Number, // the same as right - left
- height: Number, // the same as bottom - top
-
- // Margin on each side. Like css, this is outside the bounding box.
- margins: {
- left: Number,
- right: Number,
- top: Number,
- bottom: Number,
- },
-
- // Amount of padding on the inside of the bounding box (like CSS)
- paddingLeft: Number,
- paddingRight: Number,
- paddingTop: Number,
- paddingBottom: Number,
-}
-```
-
-#### Scale Interface
-To work with Chart.js, custom scale types must implement the following interface.
-
-```javascript
-{
- // Determines the data limits. Should set this.min and this.max to be the data max/min
- determineDataLimits: function() {},
-
- // Generate tick marks. this.chart is the chart instance. The data object can be accessed as this.chart.data
- // buildTicks() should create a ticks array on the axis instance, if you intend to use any of the implementations from the base class
- buildTicks: function() {},
-
- // Get the value to show for the data at the given index of the the given dataset, ie this.chart.data.datasets[datasetIndex].data[index]
- getLabelForIndex: function(index, datasetIndex) {},
-
- // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value
- // @param index: index into the ticks array
- // @param includeOffset: if true, get the pixel halway between the given tick and the next
- getPixelForTick: function(index, includeOffset) {},
-
- // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value
- // @param value : the value to get the pixel for
- // @param index : index into the data array of the value
- // @param datasetIndex : index of the dataset the value comes from
- // @param includeOffset : if true, get the pixel halway between the given tick and the next
- getPixelForValue: function(value, index, datasetIndex, includeOffset) {}
-
- // Get the value for a given pixel (x coordinate for horizontal axis, y coordinate for vertical axis)
- // @param pixel : pixel value
- getValueForPixel: function(pixel) {}
-}
-```
-
-Optionally, the following methods may also be overwritten, but an implementation is already provided by the `Chart.Scale` base class.
-
-```javascript
- // Transform the ticks array of the scale instance into strings. The default implementation simply calls this.options.ticks.callback(numericalTick, index, ticks);
- convertTicksToLabels: function() {},
-
- // Determine how much the labels will rotate by. The default implementation will only rotate labels if the scale is horizontal.
- calculateTickRotation: function() {},
-
- // Fits the scale into the canvas.
- // this.maxWidth and this.maxHeight will tell you the maximum dimensions the scale instance can be. Scales should endeavour to be as efficient as possible with canvas space.
- // this.margins is the amount of space you have on either side of your scale that you may expand in to. This is used already for calculating the best label rotation
- // You must set this.minSize to be the size of your scale. It must be an object containing 2 properties: width and height.
- // You must set this.width to be the width and this.height to be the height of the scale
- fit: function() {},
-
- // Draws the scale onto the canvas. this.(left|right|top|bottom) will have been populated to tell you the area on the canvas to draw in
- // @param chartArea : an object containing four properties: left, right, top, bottom. This is the rectangle that lines, bars, etc will be drawn in. It may be used, for example, to draw grid lines.
- draw: function(chartArea) {},
-```
-
-The Core.Scale base class also has some utility functions that you may find useful.
-```javascript
-{
- // Returns true if the scale instance is horizontal
- isHorizontal: function() {},
-
- // Get the correct value from the value from this.chart.data.datasets[x].data[]
- // If dataValue is an object, returns .x or .y depending on the return of isHorizontal()
- // If the value is undefined, returns NaN
- // Otherwise returns the value.
- // Note that in all cases, the returned value is not guaranteed to be a Number
- getRightValue: function(dataValue) {},
-}
-```
-
-### Writing New Chart Types
-
-Chart.js 2.0 introduces the concept of controllers for each dataset. Like scales, new controllers can be written as needed.
-
-```javascript
-Chart.controllers.MyType = Chart.DatasetController.extend({
-
-});
-
-
-// Now we can create a new instance of our chart, using the Chart.js API
-new Chart(ctx, {
- // this is the string the constructor was registered at, ie Chart.controllers.MyType
- type: 'MyType',
- data: data,
- options: options
-});
-```
-
-#### Dataset Controller Interface
-
-Dataset controllers must implement the following interface.
-
-```javascript
-{
- // Create elements for each piece of data in the dataset. Store elements in an array on the dataset as dataset.metaData
- addElements: function() {},
-
- // Create a single element for the data at the given index and reset its state
- addElementAndReset: function(index) {},
-
- // Draw the representation of the dataset
- // @param ease : if specified, this number represents how far to transition elements. See the implementation of draw() in any of the provided controllers to see how this should be used
- draw: function(ease) {},
-
- // Remove hover styling from the given element
- removeHoverStyle: function(element) {},
-
- // Add hover styling to the given element
- setHoverStyle: function(element) {},
-
- // Update the elements in response to new data
- // @param reset : if true, put the elements into a reset state so they can animate to their final values
- update: function(reset) {},
-}
-```
-
-The following methods may optionally be overridden by derived dataset controllers
-```javascript
-{
- // Initializes the controller
- initialize: function(chart, datasetIndex) {},
-
- // Ensures that the dataset represented by this controller is linked to a scale. Overridden to helpers.noop in the polar area and doughnut controllers as these
- // chart types using a single scale
- linkScales: function() {},
-
- // Called by the main chart controller when an update is triggered. The default implementation handles the number of data points changing and creating elements appropriately.
- buildOrUpdateElements: function() {}
-}
-```
-
-### Extending Existing Chart Types
-
-Extending or replacing an existing controller type is easy. Simply replace the constructor for one of the built in types with your own.
-
-The built in controller types are:
-* `Chart.controllers.line`
-* `Chart.controllers.bar`
-* `Chart.controllers.radar`
-* `Chart.controllers.doughnut`
-* `Chart.controllers.polarArea`
-* `Chart.controllers.bubble`
-
-#### Bar Controller
-The bar controller has a special property that you should be aware of. To correctly calculate the width of a bar, the controller must determine the number of datasets that map to bars. To do this, the bar controller attaches a property `bar` to the dataset during initialization. If you are creating a replacement or updated bar controller, you should do the same. This will ensure that charts with regular bars and your new derived bars will work seamlessly.
-
-### Creating Plugins
-
-Starting with v2.1.0, you can create plugins for chart.js. To register your plugin, simply call `Chart.plugins.register` and pass your plugin in.
-Plugins will be called at the following times
-* Start of initialization
-* End of initialization
-* Start of update
-* After the chart scales have calculated
-* Start of datasets update
-* End of datasets update
-* End of update (before render occurs)
-* Start of draw
-* End of draw
-* Before datasets draw
-* After datasets draw
-* Resize
-* Before an animation is started
-* When an event occurs on the canvas (mousemove, click, etc). This requires the `options.events` property handled
-
-Plugins should implement the `IPlugin` interface:
-```javascript
-{
- beforeInit: function(chart) { },
- afterInit: function(chart) { },
-
- resize: function(chart, newChartSize) { },
-
- beforeUpdate: function(chart) { },
- afterScaleUpdate: function(chart) { }
- beforeDatasetsUpdate: function(chart) { }
- afterDatasetsUpdate: function(chart) { }
- afterUpdate: function(chart) { },
-
- // This is called at the start of a render. It is only called once, even if the animation will run for a number of frames. Use beforeDraw or afterDraw
- // to do something on each animation frame
- beforeRender: function(chart) { },
-
- // Easing is for animation
- beforeDraw: function(chart, easing) { },
- afterDraw: function(chart, easing) { },
- // Before the datasets are drawn but after scales are drawn
- beforeDatasetsDraw: function(chart, easing) { },
- afterDatasetsDraw: function(chart, easing) { },
-
- destroy: function(chart) { }
-
- // Called when an event occurs on the chart
- beforeEvent: function(chart, event) {}
- afterEvent: function(chart, event) {}
-}
-```
-
-### Building Chart.js
-
-Chart.js uses <a href="http://gulpjs.com/" target="_blank">gulp</a> to build the library into a single JavaScript file.
-
-Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:
-
-```bash
-npm install
-npm install -g gulp
-```
-
-This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner <a href="http://gulpjs.com/" target="_blank">gulp</a>.
-
-Now, we can run the `gulp build` task.
-
-```bash
-gulp build
-``` | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/10-Notes.md | @@ -1,115 +0,0 @@
----
-title: Notes
-anchor: notes
----
-### Previous versions
-
-Version 2 has a completely different API than earlier versions.
-
-Most earlier version options have current equivalents or are the same.
-
-Please use the documentation that is available on [chartjs.org](http://www.chartjs.org/docs/) for the current version of Chart.js.
-
-Please note - documentation for previous versions are available on the GitHub repo.
-
-- [1.x Documentation](https://github.com/chartjs/Chart.js/tree/v1.1.1/docs)
-
-### Browser support
-
-Chart.js offers support for all browsers where canvas is supported.
-
-Browser support for the canvas element is available in all modern & major mobile browsers <a href="http://caniuse.com/#feat=canvas" target="_blank">(http://caniuse.com/#feat=canvas)</a>.
-
-Thanks to <a href="https://browserstack.com" target="_blank">BrowserStack</a> for allowing our team to test on thousands of browsers.
-
-
-### Bugs & issues
-
-Please report these on the GitHub page - at <a href="https://github.com/chartjs/Chart.js" target="_blank">github.com/chartjs/Chart.js</a>. If you could include a link to a simple <a href="http://jsbin.com/" target="_blank">jsbin</a> or similar to demonstrate the issue, that'd be really helpful.
-
-
-### Contributing
-
-New contributions to the library are welcome, but we ask that you please follow these guidelines:
-
-- Use tabs for indentation, not spaces.
-- Only change the individual files in `/src`.
-- Check that your code will pass `eslint` code standards, `gulp lint` will run this for you.
-- Check that your code will pass tests, `gulp test` will run tests for you.
-- Keep pull requests concise, and document new functionality in the relevant `.md` file.
-- Consider whether your changes are useful for all users, or if creating a Chart.js plugin would be more appropriate.
-
-### License
-
-Chart.js is <a href="https://github.com/chartjs/Chart.js" target="_blank">open source</a> and available under the <a href="http://opensource.org/licenses/MIT" target="_blank">MIT license</a>.
-
-### Charting Library Comparison
-
-Library Features
-
-| Feature | Chart.js | D3 | HighCharts | Chartist |
-| ------- | -------- | --- | ---------- | -------- |
-| Completely Free | ✓ | ✓ | | ✓ |
-| Canvas | ✓ | | | |
-| SVG | | ✓ | ✓ | ✓ |
-| Built-in Charts | ✓ | | ✓ | ✓ |
-| 8+ Chart Types | ✓ | ✓ | ✓ | |
-| Extendable to Custom Charts | ✓ | ✓ | | |
-| Supports Modern Browsers | ✓ | ✓ | ✓ | ✓ |
-| Extensive Documentation | ✓ | ✓ | ✓ | ✓ |
-| Open Source | ✓ | ✓ | ✓ | ✓ |
-
-Built in Chart Types
-
-| Type | Chart.js | HighCharts | Chartist |
-| ---- | -------- | ---------- | -------- |
-| Combined Types | ✓ | ✓ | |
-| Line | ✓ | ✓ | ✓ |
-| Bar | ✓ | ✓ | ✓ |
-| Horizontal Bar | ✓ | ✓ | ✓ |
-| Pie/Doughnut | ✓ | ✓ | ✓ |
-| Polar Area | ✓ | ✓ | |
-| Radar | ✓ | | |
-| Scatter | ✓ | ✓ | ✓ |
-| Bubble | ✓ | | |
-| Gauges | | ✓ | |
-| Maps (Heat/Tree/etc.) | | ✓ | |
-
-### Popular Plugins
-
-There are many plugins that add additional functionality to Chart.js. Some particularly notable ones are listed here. In addition, many plugins can be found on the [Chart.js GitHub organization](https://github.com/chartjs).
-
- - <a href="https://github.com/chartjs/chartjs-plugin-annotation" target="_blank">chartjs-plugin-annotation.js</a> - Draw lines and boxes on chart area
- - <a href="https://github.com/chartjs/chartjs-plugin-deferred" target="_blank">chartjs-plugin-deferred.js</a> - Defer initial chart update until chart scrolls into viewport
- - <a href="https://github.com/compwright/chartjs-plugin-draggable" target="_blank">chartjs-plugin-draggable.js</a> - Makes select chart elements draggable with the mouse
- - <a href="https://github.com/chartjs/chartjs-plugin-zoom" target="_blank">chartjs-plugin-zoom.js</a> - Enable zooming and panning on charts
- - <a href="https://github.com/chartjs/Chart.BarFunnel.js" target="_blank">Chart.BarFunnel.js</a> - Adds a bar funnel chart type
- - <a href="https://github.com/chartjs/Chart.LinearGauge.js" target="_blank">Chart.LinearGauge.js</a> - Adds a linear gauge chart type
- - <a href="https://github.com/chartjs/Chart.smith.js" target="_blank">Chart.Smith.js</a> - Adds a smith chart type
-
-### Popular Extensions
-
-There are many extensions which are available for use with popular frameworks. Some particularly notable ones are listed here.
-
-#### Angular
- - <a href="https://github.com/jtblin/angular-chart.js" target="_blank">angular-chart.js</a>
- - <a href="https://github.com/carlcraig/tc-angular-chartjs" target="_blank">tc-angular-chartjs</a>
- - <a href="https://github.com/petermelias/angular-chartjs" target="_blank">angular-chartjs</a>
- - <a href="https://github.com/earlonrails/angular-chartjs-directive" target="_blank">Angular Chart-js Directive</a>
-
-#### React
- - <a href="https://github.com/topdmc/react-chartjs2" target="_blank">react-chartjs2</a>
- - <a href="https://github.com/gor181/react-chartjs-2" target="_blank">react-chartjs-2</a>
-
-#### Django
- - <a href="https://github.com/matthisk/django-jchart" target="_blank">Django JChart</a>
- - <a href="https://github.com/novafloss/django-chartjs" target="_blank">Django Chartjs</a>
-
-#### Ruby on Rails
- - <a href="https://github.com/airblade/chartjs-ror" target="_blank">chartjs-ror</a>
-
-#### Laravel
- - <a href="https://github.com/fxcosta/laravel-chartjs" target="_blank">laravel-chartjs</a>
-
-#### Vue.js
- - <a href="https://github.com/apertureless/vue-chartjs/" target="_blank">vue-chartjs</a> | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/README.md | @@ -0,0 +1,65 @@
+# Chart.js
+
+[](https://chart-js-automation.herokuapp.com/)
+
+## Installation
+
+You can download the latest version of Chart.js from the [GitHub releases](https://github.com/chartjs/Chart.js/releases/latest) or use a [Chart.js CDN](https://cdnjs.com/libraries/Chart.js). Detailed installation instructions can be found on the [installation](./getting-started/installation.md) page.
+
+## Creating a Chart
+
+It's easy to get started with Chart.js. All that's required is the script included in your page along with a single `<canvas>` node to render the chart.
+
+In this example, we create a bar chart for a single dataset and render that in our page. You can see all the ways to use Chart.js in the [usage documentation](./getting-started/usage.md)
+```html
+<canvas id="myChart" width="400" height="400"></canvas>
+<script>
+var ctx = document.getElementById("myChart").getContext('2d');
+var myChart = new Chart(ctx, {
+ type: 'bar',
+ data: {
+ labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
+ datasets: [{
+ label: '# of Votes',
+ data: [12, 19, 3, 5, 2, 3],
+ backgroundColor: [
+ 'rgba(255, 99, 132, 0.2)',
+ 'rgba(54, 162, 235, 0.2)',
+ 'rgba(255, 206, 86, 0.2)',
+ 'rgba(75, 192, 192, 0.2)',
+ 'rgba(153, 102, 255, 0.2)',
+ 'rgba(255, 159, 64, 0.2)'
+ ],
+ borderColor: [
+ 'rgba(255,99,132,1)',
+ 'rgba(54, 162, 235, 1)',
+ 'rgba(255, 206, 86, 1)',
+ 'rgba(75, 192, 192, 1)',
+ 'rgba(153, 102, 255, 1)',
+ 'rgba(255, 159, 64, 1)'
+ ],
+ borderWidth: 1
+ }]
+ },
+ options: {
+ scales: {
+ yAxes: [{
+ ticks: {
+ beginAtZero:true
+ }
+ }]
+ }
+ }
+});
+</script>
+```
+
+## Contributing
+
+Before submitting an issue or a pull request to the project, please take a moment to look over the [contributing guidelines](https://github.com/chartjs/Chart.js/blob/master/CONTRIBUTING.md) first.
+
+For support using Chart.js, please post questions with the [`chartjs` tag on Stack Overflow](http://stackoverflow.com/questions/tagged/chartjs).
+
+## License
+
+Chart.js is available under the [MIT license](http://opensource.org/licenses/MIT). | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/SUMMARY.md | @@ -0,0 +1,50 @@
+# Summary
+
+* [Chart.js](README.md)
+* [Getting Started](getting-started/README.md)
+ * [Installation](getting-started/installation.md)
+ * [Integration](getting-started/integration.md)
+ * [Usage](getting-started/usage.md)
+* [General](general/README.md)
+ * [Responsive](general/responsive.md)
+ * [Interactions](general/interactions/README.md)
+ * [Events](general/interactions/events.md)
+ * [Modes](general/interactions/modes.md)
+ * [Colors](general/colors.md)
+ * [Fonts](general/fonts.md)
+* [Configuration](configuration/README.md)
+ * [Animations](configuration/animations.md)
+ * [Layout](configuration/layout.md)
+ * [Legend](configuration/legend.md)
+ * [Title](configuration/title.md)
+ * [Tooltip](configuration/tooltip.md)
+ * [Elements](configuration/elements.md)
+* [Charts](charts/README.md)
+ * [Line](charts/line.md)
+ * [Bar](charts/bar.md)
+ * [Radar](charts/radar.md)
+ * [Doughnut & Pie](charts/doughnut.md)
+ * [Polar Area](charts/polar.md)
+ * [Bubble](charts/bubble.md)
+ * [Scatter](charts/scatter.md)
+ * [Mixed](charts/mixed.md)
+* [Axes](axes/README.md)
+ * [Cartesian](axes/cartesian/README.md)
+ * [Category](axes/cartesian/category.md)
+ * [Linear](axes/cartesian/linear.md)
+ * [Logarithmic](axes/cartesian/logarithmic.md)
+ * [Time](axes/cartesian/time.md)
+ * [Radial](axes/radial/README.md)
+ * [Linear](axes/radial/linear.md)
+ * [Labelling](axes/labelling.md)
+ * [Styling](axes/styling.md)
+* [Developers](developers/README.md)
+ * [Chart.js API](developers/api.md)
+ * [Plugins](developers/plugins.md)
+ * [New Charts](developers/charts.md)
+ * [New Axes](developers/axes.md)
+ * [Contributing](developers/contributing.md)
+* [Additional Notes](notes/README.md)
+ * [Comparison Table](notes/comparison.md)
+ * [Popular Extensions](notes/extensions.md)
+ * [License](notes/license.md) | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/README.md | @@ -0,0 +1,57 @@
+# Axes
+
+Axes are an integral part of a chart. They are used to determine how data maps to a pixel value on the chart. In a cartesian chart, there is 1 or more X axis and 1 or more Y axis to map points onto the 2 dimensional canvas. These axes are know as ['cartesian axes'](./cartesian/README.md#cartesian-axes).
+
+In a radial chart, such as a radar chart or a polar area chart, there is a single axis that maps points in the angular and radial directions. These are known as ['radial axes'](./radial/README.md#radial-axes).
+
+Scales in Chart.js >V2.0 are significantly more powerful, but also different than those of v1.0.
+* Multiple X & Y axes are supported.
+* A built-in label auto-skip feature detects would-be overlapping ticks and labels and removes every nth label to keep things displaying normally.
+* Scale titles are supported
+* New scale types can be extended without writing an entirely new chart type
+
+# Common Configuration
+
+The following properties are common to all axes provided by Chart.js
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `display` | `Boolean` | `true` | If set to `false` the axis is hidden from view. Overrides *gridLines.display*, *scaleLabel.display*, and *ticks.display*.
+| `callbacks` | `Object` | | Callback functions to hook into the axis lifecycle. [more...](#callbacks)
+
+## Callbacks
+There are a number of config callbacks that can be used to change parameters in the scale at different points in the update process.
+
+| Name | Arguments | Description
+| ---- | --------- | -----------
+| `beforeUpdate` | `axis` | Callback called before the update process starts.
+| `beforeSetDimensions` | `axis` | Callback that runs before dimensions are set.
+| `afterSetDimensions` | `axis` | Callback that runs after dimensions are set.
+| `beforeDataLimits` | `axis` | Callback that runs before data limits are determined.
+| `afterDataLimits` | `axis` | Callback that runs after data limits are determined.
+| `beforeBuildTicks` | `axis` | Callback that runs before ticks are created.
+| `afterBuildTicks` | `axis` | Callback that runs after ticks are created. Useful for filtering ticks.
+| `beforeTickToLabelConversion` | `axis` | Callback that runs before ticks are converted into strings.
+| `afterTickToLabelConversion` | `axis` | Callback that runs after ticks are converted into strings.
+| `beforeCalculateTickRotation` | `axis` | Callback that runs before tick rotation is determined.
+| `afterCalculateTickRotation` | `axis` | Callback that runs after tick rotation is determined.
+| `beforeFit` | `axis` | Callback that runs before the scale fits to the canvas.
+| `afterFit` | `axis` | Callback that runs after the scale fits to the canvas.
+| `afterUpdate` | `axis` | Callback that runs at the end of the update process.
+
+## Updating Axis Defaults
+
+The default configuration for a scale can be easily changed using the scale service. All you need to do is to pass in a partial configuration that will be merged with the current scale default configuration to form the new default.
+
+For example, to set the minimum value of 0 for all linear scales, you would do the following. Any linear scales created after this time would now have a minimum of 0.
+
+```javascript
+Chart.scaleService.updateScaleDefaults('linear', {
+ ticks: {
+ min: 0
+ }
+});
+```
+
+## Creating New Axes
+To create a new axis, see the [developer docs](../developers/axes.md). | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/cartesian/README.md | @@ -0,0 +1,104 @@
+# Cartesian Axes
+
+Axes that follow a cartesian grid are known as 'Cartesian Axes'. Cartesian axes are used for line, bar, and bubble charts. Four cartesian axes are included in Chart.js by default.
+
+* [linear](./linear.md#linear-cartesian-axis)
+* [logarithmic](./logarithmic.md#logarithmic-cartesian-axis)
+* [category](./category.md#category-cartesian-axis)
+* [time](./time.md#time-cartesian-axis)
+
+# Common Configuration
+
+All of the included cartesian axes support a number of common options.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `type` | `String` | | Type of scale being employed. Custom scales can be created and registered with a string key. This allows changing the type of an axis for a chart.
+| `position` | `String` | | Position of the axis in the chart. Possible values are: `'top'`, `'left'`, `'bottom'`, `'right'`
+| `id` | `String` | | The ID is used to link datasets and scale axes together. [more...](#axis-id)
+| `gridLines` | `Object` | | Grid line configuration. [more...](../styling.md#grid-line-configuration)
+| `scaleLabel` | `Object` | | Scale title configuration. [more...](../labelling.md#scale-title-configuration)
+| `ticks` | `Object` | | Tick configuration. [more...](#tick-configuration)
+
+## Tick Configuration
+The following options are common to all cartesian axes but do not apply to other axes.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `autoSkip` | `Boolean` | `true` | If true, automatically calculates how many labels that can be shown and hides labels accordingly. Turn it off to show all labels no matter what
+| `autoSkipPadding` | `Number` | `0` | Padding between the ticks on the horizontal axis when `autoSkip` is enabled. *Note: Only applicable to horizontal scales.*
+| `labelOffset` | `Number` | `0` | Distance in pixels to offset the label from the centre point of the tick (in the y direction for the x axis, and the x direction for the y axis). *Note: this can cause labels at the edges to be cropped by the edge of the canvas*
+| `maxRotation` | `Number` | `90` | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.*
+| `minRotation` | `Number` | `0` | Minimum rotation for tick labels. *Note: Only applicable to horizontal scales.*
+| `mirror` | `Boolean` | `false` | Flips tick labels around axis, displaying the labels inside the chart instead of outside. *Note: Only applicable to vertical scales.*
+| `padding` | `Number` | `10` | Padding between the tick label and the axis. *Note: Only applicable to horizontal scales.*
+
+## Axis ID
+The properties `dataset.xAxisID` or `dataset.yAxisID` have to match the scale properties `scales.xAxes.id` or `scales.yAxes.id`. This is especially needed if multi-axes charts are used.
+
+```javascript
+var myChart = new Chart(ctx, {
+ type: 'line',
+ data: {
+ datasets: [{
+ // This dataset appears on the first axis
+ yAxisID: 'first-y-axis'
+ }, {
+ // This dataset appears on the second axis
+ yAxisID: 'second-y-axis'
+ }]
+ },
+ options: {
+ scales: {
+ yAxes: [{
+ id: 'first-y-axis',
+ type: 'linear'
+ }, {
+ id: 'second-y-axis',
+ type: 'linear'
+ }]
+ }
+ }
+});
+```
+
+# Creating Multiple Axes
+
+With cartesian axes, it is possible to create multiple X and Y axes. To do so, you can add multiple configuration objects to the `xAxes` and `yAxes` properties. When adding new axes, it is important to ensure that you specify the type of the new axes as default types are **not** used in this case.
+
+In the example below, we are creating two Y axes. We then use the `yAxisID` property to map the datasets to their correct axes.
+
+```javascript
+var myChart = new Chart(ctx, {
+ type: 'line',
+ data: {
+ datasets: [{
+ data: [20, 50, 100, 75, 25, 0],
+ label: 'Left dataset'
+
+ // This binds the dataset to the left y axis
+ yAxisID: 'left-y-axis'
+ }, {
+ data: [0.1, 0.5, 1.0, 2.0, 1.5, 0]
+ label: 'Right dataset'
+
+ // This binds the dataset to the right y axis
+ yAxisID: 'right-y-axis',
+ }],
+ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
+ },
+ options: {
+ scales: {
+ yAxes: [{
+ id: 'left-y-axis',
+ type: 'linear',
+ position: 'left'
+ }, {
+ id: 'right-y-axis',
+ type: 'linear',
+ position: 'right'
+ }]
+ }
+ }
+});
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/cartesian/category.md | @@ -0,0 +1,36 @@
+# Category Cartesian Axis
+
+The category scale will be familiar to those who have used v1.0. Labels are drawn from one of the label arrays included in the chart data. If only `data.labels` is defined, this will be used. If `data.xLabels` is defined and the axis is horizontal, this will be used. Similarly, if `data.yLabels` is defined and the axis is vertical, this property will be used. Using both `xLabels` and `yLabels` together can create a chart that uses strings for both the X and Y axes.
+
+## Tick Configuration Options
+
+The category scale provides the following options for configuring tick marks. They are nested in the `ticks` sub object. These options extend the [common tick configuration](README.md#tick-configuration).
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `min` | `String` | | The minimum item to display. [more...](#min-max-configuration)
+| `max` | `String` | | The maximum item to display. [more...](#min-max-configuration)
+
+## Min Max Configuration
+For both the `min` and `max` properties, the value must be in the `labels` array. In the example below, the x axis would only display "March" through "June".
+
+```javascript
+let chart = new Chart(ctx, {
+ type: 'line',
+ data: {
+ datasets: [{
+ data: [10, 20, 30, 40, 50, 60]
+ }],
+ labels: ['January', 'February', 'March', 'April', 'May', 'June'],
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ ticks: {
+ min: 'March'
+ }
+ }]
+ }
+ }
+});
+``` | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/cartesian/linear.md | @@ -0,0 +1,74 @@
+# Linear Cartesian Axis
+
+The linear scale is use to chart numerical data. It can be placed on either the x or y axis. The scatter chart type automatically configures a line chart to use one of these scales for the x axis. As the name suggests, linear interpolation is used to determine where a value lies on the axis.
+
+## Tick Configuration Options
+
+The following options are provided by the linear scale. They are all located in the `ticks` sub options. These options extend the [common tick configuration](README.md#tick-configuration).
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `beginAtZero` | `Boolean` | | if true, scale will include 0 if it is not already included.
+| `min` | `Number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](#axis-range-settings)
+| `max` | `Number` | | User defined maximum number for the scale, overrides maximum value from data. [more...](#axis-range-settings)
+| `maxTicksLimit` | `Number` | `11` | Maximum number of ticks and gridlines to show.
+| `stepSize` | `Number` | | User defined fixed step size for the scale. [more...](#step-size)
+| `suggestedMax` | `Number` | | Adjustment used when calculating the maximum data value. [more...](#axis-range-settings)
+| `suggestedMin` | `Number` | | Adjustment used when calculating the minimum data value. [more...](#axis-range-settings)
+
+## Axis Range Settings
+
+Given the number of axis range settings, it is important to understand how they all interact with each other.
+
+The `suggestedMax` and `suggestedMin` settings only change the data values that are used to scale the axis. These are useful for extending the range of the axis while maintaing the auto fit behaviour.
+
+```javascript
+let minDataValue = Math.min(mostNegativeValue, options.ticks.suggestedMin);
+let maxDataValue = Math.max(mostPositiveValue, options.ticks.suggestedMax);
+```
+
+In this example, the largest positive value is 50, but the data maximum is expanded out to 100. However, because the lowest data value is below the `suggestedMin` setting, it is ignored.
+
+```javascript
+let chart = new Chart(ctx, {
+ type: 'line',
+ data: {
+ datasets: [{
+ label: 'First dataset',
+ data: [0, 20, 40, 50]
+ }],
+ labels: ['January', 'February', 'March', 'April']
+ },
+ options: {
+ scales: {
+ yAxes: [{
+ ticks: {
+ suggestedMin: 50
+ suggestedMax: 100
+ }
+ }]
+ }
+ }
+});
+```
+
+In contrast to the `suggested*` settings, the `min` and `max` settings set explicit ends to the axes. When these are set, some data points may not be visible.
+
+## Step Size
+ If set, the scale ticks will be enumerated by multiple of stepSize, having one tick per increment. If not set, the ticks are labeled automatically using the nice numbers algorithm.
+
+This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5`.
+
+```javascript
+let options = {
+ scales: {
+ yAxes: [{
+ ticks: {
+ max: 5,
+ min: 0,
+ stepSize: 0.5
+ }
+ }]
+ }
+};
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/cartesian/logarithmic.md | @@ -0,0 +1,12 @@
+# Logarithmic Cartesian Axis
+
+The logarithmic scale is use to chart numerical data. It can be placed on either the x or y axis. As the name suggests, logarithmic interpolation is used to determine where a value lies on the axis.
+
+## Tick Configuration Options
+
+The following options are provided by the logarithmic scale. They are all located in the `ticks` sub options. These options extend the [common tick configuration](README.md#tick-configuration).
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `min` | `Number` | | User defined minimum number for the scale, overrides minimum value from data.
+| `max` | `Number` | | User defined maximum number for the scale, overrides maximum value from data.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/cartesian/time.md | @@ -0,0 +1,97 @@
+# Time Cartesian Axis
+
+The time scale is used to display times and dates. When building its ticks, it will automatically calculate the most comfortable unit base on the size of the scale.
+
+## Configuration Options
+
+The following options are provided by the time scale. They are all located in the `time` sub options. These options extend the [common tick configuration](README.md#tick-configuration).
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `displayFormats` | `Object` | | Sets how different time units are displayed. [more...](#display-formats)
+| `isoWeekday` | `Boolean` | `false` | If true and the unit is set to 'week', iso weekdays will be used.
+| `max` | [Time](#date-formats) | | If defined, this will override the data maximum
+| `min` | [Time](#date-formats) | | If defined, this will override the data minimum
+| `parser` | `String` or `Function` | | Custom parser for dates. [more...](#parser)
+| `round` | `String` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#scales-time-units) below for the allowed units.
+| `tooltipFormat` | `String` | | The moment js format string to use for the tooltip.
+| `unit` | `String` | `false` | If defined, will force the unit to be a certain type. See [Time Units](#scales-time-units) section below for details.
+| `unitStepSize` | `Number` | `1` | The number of units between grid lines.
+| `minUnit` | `String` | `millisecond` | The minimum display format to be used for a time unit.
+
+## Date Formats
+
+When providing data for the time scale, Chart.js supports all of the formats that Moment.js accepts. See [Moment.js docs](http://momentjs.com/docs/#/parsing/) for details.
+
+## Time Units
+
+The following time measurements are supported. The names can be passed as strings to the `time.unit` config option to force a certain unit.
+
+* millisecond
+* second
+* minute
+* hour
+* day
+* week
+* month
+* quarter
+* year
+
+For example, to create a chart with a time scale that always displayed units per month, the following config could be used.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ scales: {
+ xAxes: [{
+ time: {
+ unit: 'month'
+ }
+ }]
+ }
+ }
+})
+```
+
+## Display Formats
+The following display formats are used to configure how different time units are formed into strings for the axis tick marks. See [moment.js](http://momentjs.com/docs/#/displaying/format/) for the allowable format strings.
+
+Name | Default
+--- | ---
+millisecond | 'SSS [ms]'
+second | 'h:mm:ss a'
+minute | 'h:mm:ss a'
+hour | 'MMM D, hA'
+day | 'll'
+week | 'll'
+month | 'MMM YYYY'
+quarter | '[Q]Q - YYYY'
+year | 'YYYY'
+
+For example, to set the display format for the 'quarter' unit to show the month and year, the following config would be passed to the chart constructor.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ scales: {
+ xAxes: [{
+ type: 'time',
+ time: {
+ displayFormats: {
+ quarter: 'MMM YYYY'
+ }
+ }
+ }]
+ }
+ }
+})
+```
+
+## Parser
+If this property is defined as a string, it is interpreted as a custom format to be used by moment to parse the date.
+
+If this is a function, it must return a moment.js object given the appropriate data value.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/labelling.md | @@ -0,0 +1,42 @@
+# Labeling Axes
+
+When creating a chart, you want to tell the viewer what data they are viewing. To do this, you need to label the axis.
+
+## Scale Title Configuration
+
+The scale label configuration is nested under the scale configuration in the `scaleLabel` key. It defines options for the scale title. Note that this only applies to cartesian axes.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `display` | `Boolean` | `false` | If true, display the axis title.
+| `labelString` | `String` | `''` | The text for the title. (i.e. "# of People" or "Respone Choices").
+| `fontColor` | Color | `'#666'` | Font color for scale title.
+| `fontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family for the scale title, follows CSS font-family options.
+| `fontSize` | `Number` | `12` | Font size for scale title.
+| `fontStyle` | `String` | `'normal'` | Font style for the scale title, follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit).
+
+## Creating Custom Tick Formats
+
+It is also common to want to change the tick marks to include information about the data type. For example, adding a dollar sign ('$'). To do this, you need to override the `ticks.callback` method in the axis configuration.
+In the following example, every label of the Y axis would be displayed with a dollar sign at the front..
+
+If the callback returns `null` or `undefined` the associated grid line will be hidden.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ scales: {
+ yAxes: [{
+ ticks: {
+ // Include a dollar sign in the ticks
+ callback: function(value, index, values) {
+ return '$' + value;
+ }
+ }
+ }]
+ }
+ }
+});
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/radial/README.md | @@ -0,0 +1,5 @@
+# Radial Axes
+
+Radial axes are used specifically for the radar and polar area chart types. These axes overlay the chart area, rather than being positioned on one of the edges. One radial axis is included by default in Chart.js.
+
+* [linear](./linear.md#linear-radial-axis)
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/radial/linear.md | @@ -0,0 +1,110 @@
+# Linear Radial Axis
+
+The linear scale is use to chart numerical data. As the name suggests, linear interpolation is used to determine where a value lies in relation the center of the axis.
+
+The following additional configuration options are provided by the radial linear scale.
+
+## Configuration Options
+
+The axis has configuration properties for ticks, angle lines (line that appear in a radar chart outward from the center), pointLabels (labels around the edge in a radar chart). The following sections define each of the properties in those sections.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `angleLines` | `Object` | Angle line configuration. [more...](#angle-line-options)
+| `gridLines` | `Object` | Grid line configuration. [more...](../styling.md#grid-line-configuration)
+| `pointLabels` | `Object` | Point label configuration. [more...](#point-label-options)
+| `ticks` | `Object` | Tick configuration. [more...](#tick-options)
+
+## Tick Options
+The following options are provided by the linear scale. They are all located in the `ticks` sub options. The [common tick configuration](../styling.md#tick-configuration) options are supported by this axis.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `backdropColor` | Color | `'rgba(255, 255, 255, 0.75)'` | Color of label backdrops
+| `backdropPaddingX` | `Number` | `2` | Horizontal padding of label backdrop.
+| `backdropPaddingY` | `Number` | `2` | Vertical padding of label backdrop.
+| `beginAtZero` | `Boolean` | `false` | if true, scale will include 0 if it is not already included.
+| `min` | `Number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](#axis-range-settings)
+| `max` | `Number` | | User defined maximum number for the scale, overrides maximum value from data. [more...](#axis-range-settings)
+| `maxTicksLimit` | `Number` | `11` | Maximum number of ticks and gridlines to show.
+| `stepSize` | `Number` | | User defined fixed step size for the scale. [more...](#step-size)
+| `suggestedMax` | `Number` | | Adjustment used when calculating the maximum data value. [more...](#axis-range-settings)
+| `suggestedMin` | `Number` | | Adjustment used when calculating the minimum data value. [more...](#axis-range-settings)
+| `showLabelBackdrop` | `Boolean` | `true` | If true, draw a background behind the tick labels
+
+## Axis Range Settings
+
+Given the number of axis range settings, it is important to understand how they all interact with each other.
+
+The `suggestedMax` and `suggestedMin` settings only change the data values that are used to scale the axis. These are useful for extending the range of the axis while maintaing the auto fit behaviour.
+
+```javascript
+let minDataValue = Math.min(mostNegativeValue, options.ticks.suggestedMin);
+let maxDataValue = Math.max(mostPositiveValue, options.ticks.suggestedMax);
+```
+
+In this example, the largest positive value is 50, but the data maximum is expanded out to 100. However, because the lowest data value is below the `suggestedMin` setting, it is ignored.
+
+```javascript
+let chart = new Chart(ctx, {
+ type: 'radar',
+ data: {
+ datasets: [{
+ label: 'First dataset',
+ data: [0, 20, 40, 50]
+ }],
+ labels: ['January', 'February', 'March', 'April']
+ },
+ options: {
+ scale: {
+ ticks: {
+ suggestedMin: 50
+ suggestedMax: 100
+ }
+ }
+ }
+});
+```
+
+In contrast to the `suggested*` settings, the `min` and `max` settings set explicit ends to the axes. When these are set, some data points may not be visible.
+
+## Step Size
+ If set, the scale ticks will be enumerated by multiple of stepSize, having one tick per increment. If not set, the ticks are labeled automatically using the nice numbers algorithm.
+
+This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5`.
+
+```javascript
+let options = {
+ scales: {
+ yAxes: [{
+ ticks: {
+ max: 5,
+ min: 0,
+ stepSize: 0.5
+ }
+ }]
+ }
+};
+```
+
+## Angle Line Options
+
+The following options are used to configure angled lines that radiate from the center of the chart to the point labels. They can be found in the `angleLines` sub options. Note that these options only apply if `angleLines.display` is true.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `display` | `Boolean` | `true` | if true, angle lines are shown
+| `color` | Color | `rgba(0, 0, 0, 0.1)` | Color of angled lines
+| `lineWidth` | `Number` | `1` | Width of angled lines
+
+## Point Label Options
+
+The following options are used to configure the point labels that are shown on the perimeter of the scale. They can be found in the `pointLabels` sub options. Note that these options only apply if `pointLabels.display` is true.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `callback` | `Function` | | Callback function to transform data labels to point labels. The default implementation simply returns the current string.
+| `fontColor` | Color | `'#666'` | Font color for point labels.
+| `fontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family to use when rendering labels.
+| `fontSize` | `Number` | 10 | font size in pixels
+| `fontStyle` | `String` | `'normal'` | Font style to use when rendering point labels.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/axes/styling.md | @@ -0,0 +1,35 @@
+# Styling
+
+There are a number of options to allow styling an axis. There are settings to control [grid lines](#grid-line-configuration) and [ticks](#tick-configuration).
+
+## Grid Line Configuration
+
+The grid line configuration is nested under the scale configuration in the `gridLines` key. It defines options for the grid lines that run perpendicular to the axis.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `display` | `Boolean` | `true` | If false, do not display grid lines for this axis.
+| `color` | Color or Color[] | `'rgba(0, 0, 0, 0.1)'` | The color of the grid lines. If specified as an array, the first color applies to the first grid line, the second to the second grid line and so on.
+| `borderDash` | `Number[]` | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash)
+| `borderDashOffset` | `Number` | `0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset)
+| `lineWidth` | `Number or Number[]` | `1` | Stroke width of grid lines.
+| `drawBorder` | `Boolean` | `true` | If true, draw border at the edge between the axis and the chart area.
+| `drawOnChartArea` | `Boolean` | `true` | If true, draw lines on the chart area inside the axis lines. This is useful when there are multiple axes and you need to control which grid lines are drawn.
+| `drawTicks` | `Boolean` | `true` | If true, draw lines beside the ticks in the axis area beside the chart.
+| `tickMarkLength` | `Number` | `10` | Length in pixels that the grid lines will draw into the axis area.
+| `zeroLineWidth` | `Number` | `1` | Stroke width of the grid line for the first index (index 0).
+| `zeroLineColor` | Color | `'rgba(0, 0, 0, 0.25)'` | Stroke color of the grid line for the first index (index 0).
+| `offsetGridLines` | `Boolean` | `false` | If true, labels are shifted to be between grid lines. This is used in the bar chart and should not generally be used.
+
+## Tick Configuration
+The tick configuration is nested under the scale configuration in the `ticks` key. It defines options for the tick marks that are generated by the axis.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `callback` | `Function` | | Returns the string representation of the tick value as it should be displayed on the chart. See [callback](../axes/labelling.md#creating-custom-tick-formats).
+| `display` | `Boolean` | `true` | If true, show tick marks
+| `fontColor` | Color | `'#666'` | Font color for tick labels.
+| `fontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family for the tick labels, follows CSS font-family options.
+| `fontSize` | `Number` | `12` | Font size for the tick labels.
+| `fontStyle` | `String` | `'normal'` | Font style for the tick labels, follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit).
+| `reverse` | `Boolean` | `false` | Reverses order of tick labels. | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/README.md | @@ -0,0 +1,11 @@
+# Charts
+
+Chart.js comes with built-in chart types:
+* [line](./line.md)
+* [bar](./bar.md)
+* [radar](./radar.md)
+* [polar area](./polar.md)
+* [doughnut and pie](./doughnut.md)
+* [bubble](./bubble.md)
+
+To create a new chart type, see the [developer notes](../developers/charts.md#new-charts)
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/bar.md | @@ -0,0 +1,149 @@
+# Bar
+A bar chart provides a way of showing data values represented as vertical bars. It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
+
+## Example Usage
+```javascript
+var myBarChart = new Chart(ctx, {
+ type: 'bar',
+ data: data,
+ options: options
+});
+```
+
+## Dataset Properties
+The bar chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of the bars is generally set this way.
+
+Some properties can be specified as an array. If these are set to an array value, the first value applies to the first bar, the second value to the second bar, and so on.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
+| `xAxisID` | `String` | The ID of the x axis to plot this dataset on. If not specified, this defaults to the ID of the first found x axis
+| `yAxisID` | `String` | The ID of the y axis to plot this dataset on. If not specified, this defaults to the ID of the first found y axis.
+| `backgroundColor` | `Color/Color[]` | The fill color of the bar. See [Colors](../general/colors.md#colors)
+| `borderColor` | `Color/Color[]` | The color of the bar border. See [Colors](../general/colors.md#colors)
+| `borderWidth` | `Number/Number[]` | The stroke width of the bar in pixels.
+| `borderSkipped` | `String` | Which edge to skip drawing the border for. [more...](#borderSkipped)
+| `hoverBackgroundColor` | `Color/Color[]` | The fill colour of the bars when hovered.
+| `hoverBorderColor` | `Color/Color[]` | The stroke colour of the bars when hovered.
+| `hoverBorderWidth` | `Number/Number[]` | The stroke width of the bars when hovered.
+
+### borderSkipped
+This setting is used to avoid drawing the bar stroke at the base of the fill. In general, this does not need to be changed except when creating chart types that derive from a bar chart.
+
+Options are:
+* 'bottom'
+* 'left'
+* 'top'
+* 'right'
+
+## Configuration Options
+
+The bar chart defines the following configuration options. These options are merged with the global chart configuration options, `Chart.defaults.global`, to form the options passed to the chart.
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `barPercentage` | `Number` | `0.9` | Percent (0-1) of the available width each bar should be within the category percentage. 1.0 will take the whole category width and put the bars right next to each other. [more...](#bar-chart-barpercentage-vs-categorypercentage)
+| `categoryPercentage` | `Number` | `0.8` | Percent (0-1) of the available width (the space between the gridlines for small datasets) for each data-point to use for the bars. [more...](#bar-chart-barpercentage-vs-categorypercentage)
+| `barThickness` | `Number` | | Manually set width of each bar in pixels. If not set, the bars are sized automatically using `barPercentage` and `categoryPercentage`;
+| `maxBarThickness` | `Number` | | Set this to ensure that the automatically sized bars are not sized thicker than this. Only works if barThickness is not set (automatic sizing is enabled).
+| `gridLines.offsetGridLines` | `Boolean` | `true` | If true, the bars for a particular data point fall between the grid lines. If false, the grid line will go right down the middle of the bars. [more...](#offsetGridLines)
+
+### offsetGridLines
+If true, the bars for a particular data point fall between the grid lines. If false, the grid line will go right down the middle of the bars. It is unlikely that this will ever need to be changed in practice. It exists more as a way to reuse the axis code by configuring the existing axis slightly differently.
+
+This setting applies to the axis configuration for a bar chart. If axes are added to the chart, this setting will need to be set for each new axis.
+
+```javascript
+options = {
+ scales: {
+ xAxes: [{
+ gridLines: {
+ offsetGridLines: true
+ }
+ }]
+ }
+}
+```
+
+## Default Options
+
+It is common to want to apply a configuration setting to all created bar charts. The global bar chart settings are stored in `Chart.defaults.bar`. Changing the global options only affects charts created after the change. Existing charts are not changed.
+
+## barPercentage vs categoryPercentage
+
+The following shows the relationship between the bar percentage option and the category percentage option.
+
+```text
+// categoryPercentage: 1.0
+// barPercentage: 1.0
+Bar: | 1.0 | 1.0 |
+Category: | 1.0 |
+Sample: |===========|
+
+// categoryPercentage: 1.0
+// barPercentage: 0.5
+Bar: |.5| |.5|
+Category: | 1.0 |
+Sample: |==============|
+
+// categoryPercentage: 0.5
+// barPercentage: 1.0
+Bar: |1.||1.|
+Category: | .5 |
+Sample: |==============|
+```
+
+## Data Structure
+
+The `data` property of a dataset for a bar chart is specified as a an array of numbers. Each point in the data array corresponds to the label at the same index on the x axis.
+
+```javascript
+data: [20, 10]
+```
+
+# Stacked Bar Chart
+
+Bar charts can be configured into stacked bar charts by changing the settings on the X and Y axes to enable stacking. Stacked bar charts can be used to show how one data series is made up of a number of smaller pieces.
+
+```javascript
+var stackedBar = new Chart(ctx, {
+ type: 'bar',
+ data: data,
+ options: {
+ scales: {
+ xAxes: [{
+ stacked: true
+ }],
+ yAxes: [{
+ stacked: true
+ }]
+ }
+ }
+});
+```
+
+## Dataset Properties
+
+The following dataset properties are specific to stacked bar charts.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `stack` | `String` | The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack)
+
+# Horizontal Bar Chart
+A horizontal bar chart is a variation on a vertical bar chart. It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
+
+## Example
+```javascript
+var myBarChart = new Chart(ctx, {
+ type: 'horizontalBar',
+ data: data,
+ options: options
+});
+```
+
+## Config Options
+The configuration options for the horizontal bar chart are the same as for the [bar chart](../bar/config-options.md#config-options). However, any options specified on the x axis in a bar chart, are applied to the y axis in a horizontal bar chart.
+
+The default horizontal bar configuration is specified in `Chart.defaults.horizontalBar`.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/bubble.md | @@ -0,0 +1,60 @@
+# Bubble Chart
+
+A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles.
+
+## Example Usage
+
+```javascript
+// For a bubble chart
+var myBubbleChart = new Chart(ctx,{
+ type: 'bubble',
+ data: data,
+ options: options
+});
+```
+
+## Dataset Properties
+
+The bubble chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of the bubbles is generally set this way.
+
+All properties, except `label` can be specified as an array. If these are set to an array value, the first value applies to the first bubble in the dataset, the second value to the second bubble, and so on.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
+| `backgroundColor` | `Color/Color[]` | The fill color for bubbles.
+| `borderColor` | `Color/Color[]` | The border color for bubbles.
+| `borderWidth` | `Number/Number[]` | The width of the point bubbles in pixels.
+| `hoverBackgroundColor` | `Color/Color[]` | Bubble background color when hovered.
+| `hoverBorderColor` | `Color/Color[]` | Bubble border color when hovered.
+| `hoverBorderWidth` | `Number/Number[]` | Border width of point when hovered.
+| `hoverRadius` | `Number/Number[]` | Additional radius to add to data radius on hover.
+
+## Config Options
+
+The bubble chart has no unique configuration options. To configure options common to all of the bubbles, the [point element options](../configuration/elements/point.md#point-configuration) are used.
+
+## Default Options
+
+We can also change the default values for the Bubble chart type. Doing so will give all bubble charts created after this point the new defaults. The default configuration for the bubble chart can be accessed at `Chart.defaults.bubble`.
+
+## Data Structure
+
+For a bubble chart, datasets need to contain an array of data points. Each point must implement the [bubble data object](#bubble-data-object) interface.
+
+### Bubble Data Object
+
+Data for the bubble chart is passed in the form of an object. The object must implement the following interface. It is important to note that the radius property, `r` is **not** scaled by the chart. It is the raw radius in pixels of the bubble that is drawn on the canvas.
+
+```javascript
+{
+ // X Value
+ x: <Number>,
+
+ // Y Value
+ y: <Number>,
+
+ // Radius of bubble. This is not scaled.
+ r: <Number>
+}
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/doughnut.md | @@ -0,0 +1,79 @@
+# Doughnut and Pie
+Pie and doughnut charts are probably the most commonly used charts. They are divided into segments, the arc of each segment shows the proportional value of each piece of data.
+
+They are excellent at showing the relational proportions between data.
+
+Pie and doughnut charts are effectively the same class in Chart.js, but have one different default value - their `cutoutPercentage`. This equates what percentage of the inner should be cut out. This defaults to `0` for pie charts, and `50` for doughnuts.
+
+They are also registered under two aliases in the `Chart` core. Other than their different default value, and different alias, they are exactly the same.
+
+## Example Usage
+
+```javascript
+// For a pie chart
+var myPieChart = new Chart(ctx,{
+ type: 'pie',
+ data: data,
+ options: options
+});
+```
+
+```javascript
+// And for a doughnut chart
+var myDoughnutChart = new Chart(ctx, {
+ type: 'doughnut',
+ data: data,
+ options: options
+});
+```
+
+## Dataset Properties
+
+The doughnut/pie chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of a the dataset's arc are generally set this way.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
+| `backgroundColor` | `Color[]` | The fill color of the arcs in the dataset. See [Colors](../general/colors.md#colors)
+| `borderColor` | `Color[]` | The border color of the arcs in the dataset. See [Colors](../general/colors.md#colors)
+| `borderWidth` | `Number[]` | The border width of the arcs in the dataset.
+| `hoverBackgroundColor` | `Color[]` | The fill colour of the arcs when hovered.
+| `hoverBorderColor` | `Color[]` | The stroke colour of the arcs when hovered.
+| `hoverBorderWidth` | `Number[]` | The stroke width of the arcs when hovered.
+
+## Config Options
+
+These are the customisation options specific to Pie & Doughnut charts. These options are merged with the global chart configuration options, and form the options of the chart.
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `cutoutPercentage` | `Number` | `50` - for doughnut, `0` - for pie | The percentage of the chart that is cut out of the middle.
+| `rotation` | `Number` | `-0.5 * Math.PI` | Starting angle to draw arcs from.
+| `circumference` | `Number` | `2 * Math.PI` | Sweep to allow arcs to cover
+| `animation.animateRotate` | `Boolean` | `true` | If true, the chart will animate in with a rotation animation. This property is in the `options.animation` object.
+| `animation.animateScale` | `Boolean` | `false` | If true, will animate scaling the chart from the center outwards.
+
+## Default Options
+
+We can also change these default values for each Doughnut type that is created, this object is available at `Chart.defaults.doughnut`. Pie charts also have a clone of these defaults available to change at `Chart.defaults.pie`, with the only difference being `cutoutPercentage` being set to 0.
+
+## Data Structure
+
+For a pie chart, datasets need to contain an array of data points. The data points should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each.
+
+You also need to specify an array of labels so that tooltips appear correctly
+
+```javascript
+data = {
+ datasets: [{
+ data: [10, 20, 30]
+ }],
+
+ // These labels appear in the legend and in the tooltips when hovering different arcs
+ labels: [
+ 'Red',
+ 'Yellow',
+ 'Blue'
+ ]
+};
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/line.md | @@ -0,0 +1,213 @@
+# Line
+A line chart is a way of plotting data points on a line. Often, it is used to show trend data, or the comparison of two data sets.
+
+## Example Usage
+```javascript
+var myLineChart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: options
+});
+```
+
+## Dataset Properties
+
+The line chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of a line is generally set this way.
+
+All point* properties can be specified as an array. If these are set to an array value, the first value applies to the first point, the second value to the second point, and so on.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
+| `xAxisID` | `String` | The ID of the x axis to plot this dataset on. If not specified, this defaults to the ID of the first found x axis
+| `yAxisID` | `String` | The ID of the y axis to plot this dataset on. If not specified, this defaults to the ID of the first found y axis.
+| `backgroundColor` | `Color/Color[]` | The fill color under the line. See [Colors](../general/colors.md#colors)
+| `borderColor` | `Color/Color[]` | The color of the line. See [Colors](../general/colors.md#colors)
+| `borderWidth` | `Number/Number[]` | The width of the line in pixels.
+| `borderDash` | `Number[]` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash)
+| `borderDashOffset` | `Number` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset)
+| `borderCapStyle` | `String` | Cap style of the line. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap)
+| `borderJoinStyle` | `String` | Line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin)
+| `cubicInterpolationMode` | `String` | Algorithm used to interpolate a smooth curve from the discrete data points. [more...](#cubicInterpolationMode)
+| `fill` | `Boolean/String` | How to fill the area under the line. [more...](#fill)
+| `lineTension` | `Number` | Bezier curve tension of the line. Set to 0 to draw straightlines. This option is ignored if monotone cubic interpolation is used.
+| `pointBackgroundColor` | `Color/Color[]` | The fill color for points.
+| `pointBorderColor` | `Color/Color[]` | The border color for points.
+| `pointBorderWidth` | `Number/Number[]` | The width of the point border in pixels.
+| `pointRadius` | `Number/Number[]` | The radius of the point shape. If set to 0, the point is not rendered.
+| `pointStyle` | `String/String[]/Image/Image[]` | Style of the point. [more...](#pointStyle)
+| `pointHitRadius` | `Number/Number[]` | The pixel size of the non-displayed point that reacts to mouse events.
+| `pointHoverBackgroundColor` | `Color/Color[]` | Point background color when hovered.
+| `pointHoverBorderColor` | `Color/Color[]` | Point border color when hovered.
+| `pointHoverBorderWidth` | `Number/Number[]` | Border width of point when hovered.
+| `pointHoverRadius` | `Number/Number[]` | The radius of the point when hovered.
+| `showLine` | `Boolean` | If false, the line is not drawn for this dataset.
+| `spanGaps` | `Boolean` | If true, lines will be drawn between points with no or null data. If false, points with `NaN` data will create a break in the line
+| `steppedLine` | `Boolean` | If true, the line is shown as a stepped line and 'lineTension' will be ignored.
+
+### cubicInterpolationMode
+The following interpolation modes are supported:
+* 'default'
+* 'monotone'.
+
+The 'default' algorithm uses a custom weighted cubic interpolation, which produces pleasant curves for all types of datasets.
+
+The 'monotone' algorithm is more suited to `y = f(x)` datasets : it preserves monotonicity (or piecewise monotonicity) of the dataset being interpolated, and ensures local extremums (if any) stay at input data points.
+
+If left untouched (`undefined`), the global `options.elements.line.cubicInterpolationMode` property is used.
+
+### fill
+If `true`, fill the area under the line. The line is filled to the baseline. If the y axis has a 0 value, the line is filled to that point. If the axis has only negative values, the line is filled to the highest value. If the axis has only positive values, it is filled to the lowest value.
+
+String values to fill to specific locations are:
+* `'zero'`
+* `'top'`
+* `'bottom'`
+
+### pointStyle
+The style of point. Options are:
+* 'circle'
+* 'cross'
+* 'crossRot'
+* 'dash'.
+* 'line'
+* 'rect'
+* 'rectRounded'
+* 'rectRot'
+* 'star'
+* 'triangle'
+
+If the option is an image, that image is drawn on the canvas using [drawImage](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/drawImage).
+
+## Configuration Options
+
+The line chart defines the following configuration options. These options are merged with the global chart configuration options, `Chart.defaults.global`, to form the options passed to the chart.
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `showLines` | `Boolean` | `true` | If false, the lines between points are not drawn.
+| `spanGaps` | `Boolean` | `false` | If false, NaN data causes a break in the line.
+
+## Default Options
+
+It is common to want to apply a configuration setting to all created line charts. The global line chart settings are stored in `Chart.defaults.line`. Changing the global options only affects charts created after the change. Existing charts are not changed.
+
+For example, to configure all line charts with `spanGaps = true` you would do:
+```javascript
+Chart.defaults.line.spanGaps = true;
+```
+
+## Data Structure
+
+The `data` property of a dataset for a line chart can be passed in two formats.
+
+### Number[]
+```javascript
+data: [20, 10]
+```
+
+When the `data` array is an array of numbers, the x axis is generally a [category](../axes/cartesian/category.md#Category Axis). The points are placed onto the axis using their position in the array.
+
+### Point[]
+
+```javascript
+data: [{
+ x: 10,
+ y: 20
+ }, {
+ x: 15,
+ y: 10
+ }]
+```
+
+This alternate is used for sparse datasets, such as those in [scatter charts](./scatter.md#scatter-chart). Each data point is specified using an object containing `x` and `y` properties.
+
+# Stacked Area Chart
+
+Line charts can be configured into stacked area charts by changing the settings on the y axis to enable stacking. Stacked area charts can be used to show how one data trend is made up of a number of smaller pieces.
+
+```javascript
+var stackedLine = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ scales: {
+ yAxes: [{
+ stacked: true
+ }]
+ }
+ }
+});
+```
+
+# High Performance Line Charts
+
+When charting a lot of data, the chart render time may start to get quite large. In that case, the following strategies can be used to improve performance.
+
+## Data Decimation
+
+Decimating your data will achieve the best results. When there is a lot of data to display on the graph, it doesn't make sense to show tens of thousands of data points on a graph that is only a few hundred pixels wide.
+
+There are many approaches to data decimation and selection of an algorithm will depend on your data and the results you want to achieve. For instance, [min/max](http://digital.ni.com/public.nsf/allkb/F694FFEEA0ACF282862576020075F784) decimation will preserve peaks in your data but could require up to 4 points for each pixel. This type of decimation would work well for a very noisy signal where you need to see data peaks.
+
+## Disable Bezier Curves
+
+If you are drawing lines on your chart, disabling bezier curves will improve render times since drawing a straight line is more performant than a bezier curve.
+
+To disable bezier curves for an entire chart:
+
+```javascript
+new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ elements: {
+ line: {
+ tension: 0, // disables bezier curves
+ }
+ }
+ }
+});
+```
+
+## Draw Line Drawing
+
+If you have a lot of data points, it can be more performant to disable rendering of the line for a dataset and only draw points. Doing this means that there is less to draw on the canvas which will improve render performance.
+
+To disable lines:
+
+```javascript
+new Chart(ctx, {
+ type: 'line',
+ data: {
+ datasets: [{
+ showLine: false, // disable for a single dataset
+ }]
+ },
+ options: {
+ showLines: false, // disable for all datasets
+ }
+});
+```
+
+## Disable Animations
+
+If your charts have long render times, it is a good idea to disable animations. Doing so will mean that the chart needs to only be rendered once during an update instead of multiple times. This will have the effect of reducing CPU usage and improving general page performance.
+
+To disable animations
+
+```javascript
+new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ animation: {
+ duration: 0, // general animation time
+ },
+ hover: {
+ animationDuration: 0, // duration of animations when hovering an item
+ },
+ responsiveAnimationDuration: 0, // animation duration after a resize
+ }
+});
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/mixed.md | @@ -0,0 +1,37 @@
+# Mixed Chart Types
+
+With Chart.js, it is possible to create mixed charts that are a combination of two or more different chart types. A common example is a bar chart that also includes a line dataset.
+
+Creating a mixed chart starts with the initialization of a basic chart.
+
+```javascript
+var myChart = new Chart(ctx, {
+ type: 'bar',
+ data: data,
+ options: options
+});
+```
+
+At this point we have a standard bar chart. Now we need to convert one of the datasets to a line dataset.
+
+```javascript
+var mixedChart = new Chart(ctx, {
+ type: 'bar',
+ data: {
+ datasets: [{
+ label: 'Bar Dataset',
+ data: [10, 20, 30, 40]
+ }, {
+ label: 'Line Dataset',
+ data: [50, 50, 50, 50],
+
+ // Changes this dataset to become a line
+ type: 'line'
+ }],
+ labels: ['January', 'February', 'March', 'April']
+ },
+ options: options
+});
+```
+
+At this point we have a chart rendering how we'd like. It's important to note that the default options for a line chart are not merged in this case. Only the options for the default type are merged in. In this case, that means that the default options for a bar chart are merged because that is the type specified by the `type` field.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/polar.md | @@ -0,0 +1,69 @@
+# Polar Area
+
+Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value.
+
+This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context.
+
+## Example Usage
+
+```javascript
+new Chart(ctx, {
+ data: data,
+ type: 'polarArea',
+ options: options
+});
+```
+
+## Dataset Properties
+
+The following options can be included in a polar area chart dataset to configure options for that specific dataset.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
+| `backgroundColor` | `Color[]` | The fill color of the arcs in the dataset. See [Colors](../general/colors.md#colors)
+| `borderColor` | `Color[]` | The border color of the arcs in the dataset. See [Colors](../general/colors.md#colors)
+| `borderWidth` | `Number[]` | The border width of the arcs in the dataset.
+| `hoverBackgroundColor` | `Color[]` | The fill colour of the arcs when hovered.
+| `hoverBorderColor` | `Color[]` | The stroke colour of the arcs when hovered.
+| `hoverBorderWidth` | `Number[]` | The stroke width of the arcs when hovered.
+
+## Config Options
+
+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
+| ---- | ---- | ------- | -----------
+| `startAngle` | `Number` | `-0.5 * Math.PI` | Starting angle to draw arcs for the first item in a dataset.
+| `animation.animateRotate` | `Boolean` | `true` | If true, the chart will animate in with a rotation animation. This property is in the `options.animation` object.
+| `animation.animateScale` | `Boolean` | `true` | If true, will animate scaling the chart from the center outwards.
+
+## Default Options
+
+We can also change these defaults values for each PolarArea type that is created, this object is available at `Chart.defaults.polarArea`. Changing the global options only affects charts created after the change. Existing charts are not changed.
+
+For example, to configure all new polar area charts with `animateScale = false` you would do:
+```javascript
+Chart.defaults.polarArea.animation.animateScale = false;
+```
+
+## Data Structure
+
+For a polar area chart, datasets need to contain an array of data points. The data points should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each.
+
+You also need to specify an array of labels so that tooltips appear correctly for each slice.
+
+```javascript
+data = {
+ datasets: [{
+ data: [10, 20, 30]
+ }],
+
+ // These labels appear in the legend and in the tooltips when hovering different arcs
+ labels: [
+ 'Red',
+ 'Yellow',
+ 'Blue'
+ ]
+};
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/radar.md | @@ -0,0 +1,97 @@
+# Radar
+A radar chart is a way of showing multiple data points and the variation between them.
+
+They are often useful for comparing the points of two or more different data sets.
+
+## Example Usage
+```javascript
+var myRadarChart = new Chart(ctx, {
+ type: 'radar',
+ data: data,
+ options: options
+});
+```
+
+## Dataset Properties
+
+The radar chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of a line is generally set this way.
+
+All point* properties can be specified as an array. If these are set to an array value, the first value applies to the first point, the second value to the second point, and so on.
+
+| Name | Type | Description
+| ---- | ---- | -----------
+| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
+| `backgroundColor` | `Color/Color[]` | The fill color under the line. See [Colors](../general/colors.md#colors)
+| `borderColor` | `Color/Color[]` | The color of the line. See [Colors](../general/colors.md#colors)
+| `borderWidth` | `Number/Number[]` | The width of the line in pixels.
+| `borderDash` | `Number[]` | Length and spacing of dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash)
+| `borderDashOffset` | `Number` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset)
+| `borderCapStyle` | `String` | Cap style of the line. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap)
+| `borderJoinStyle` | `String` | Line joint style. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin)
+| `fill` | `Boolean/String` | How to fill the area under the line. [more...](#fill)
+| `lineTension` | `Number` | Bezier curve tension of the line. Set to 0 to draw straightlines.
+| `pointBackgroundColor` | `Color/Color[]` | The fill color for points.
+| `pointBorderColor` | `Color/Color[]` | The border color for points.
+| `pointBorderWidth` | `Number/Number[]` | The width of the point border in pixels.
+| `pointRadius` | `Number/Number[]` | The radius of the point shape. If set to 0, the point is not rendered.
+| `pointStyle` | `String/String[]/Image/Image[]` | Style of the point. [more...](#pointStyle)
+| `pointHitRadius` | `Number/Number[]` | The pixel size of the non-displayed point that reacts to mouse events.
+| `pointHoverBackgroundColor` | `Color/Color[]` | Point background color when hovered.
+| `pointHoverBorderColor` | `Color/Color[]` | Point border color when hovered.
+| `pointHoverBorderWidth` | `Number/Number[]` | Border width of point when hovered.
+| `pointHoverRadius` | `Number/Number[]` | The radius of the point when hovered.
+
+### pointStyle
+The style of point. Options are:
+* 'circle'
+* 'cross'
+* 'crossRot'
+* 'dash'.
+* 'line'
+* 'rect'
+* 'rectRounded'
+* 'rectRot'
+* 'star'
+* 'triangle'
+
+If the option is an image, that image is drawn on the canvas using [drawImage](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/drawImage).
+
+## Configuration Options
+
+Unlike other charts, the radar chart has no chart specific options.
+
+## Scale Options
+
+The radar chart supports only a single scale. The options for this scale are defined in the `scale` property.
+
+```javascript
+options = {
+ scale: {
+ // Hides the scale
+ display: false
+ }
+};
+```
+
+## Default Options
+
+It is common to want to apply a configuration setting to all created radar charts. The global radar chart settings are stored in `Chart.defaults.radar`. Changing the global options only affects charts created after the change. Existing charts are not changed.
+
+## Data Structure
+
+The `data` property of a dataset for a radar chart is specified as a an array of numbers. Each point in the data array corresponds to the label at the same index on the x axis.
+
+```javascript
+data: [20, 10]
+```
+
+For a radar chart, to provide context of what each point means, we include an array of strings that show around each point in the chart.
+
+```javascript
+data: {
+ labels: ['Running', 'Swimming', 'Eating', 'Cycling'],
+ datasets: [{
+ data: [20, 10, 4, 2]
+ }]
+}
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/charts/scatter.md | @@ -0,0 +1,49 @@
+# Scatter Chart
+
+Scatter charts are based on basic line charts with the x axis changed to a linear axis. To use a scatter chart, data must be passed as objects containing X and Y properties. The example below creates a scatter chart with 3 points.
+
+```javascript
+var scatterChart = new Chart(ctx, {
+ type: 'scatter',
+ data: {
+ datasets: [{
+ label: 'Scatter Dataset',
+ data: [{
+ x: -10,
+ y: 0
+ }, {
+ x: 0,
+ y: 10
+ }, {
+ x: 10,
+ y: 5
+ }]
+ }]
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ type: 'linear',
+ position: 'bottom'
+ }]
+ }
+ }
+});
+```
+
+## Dataset Properties
+The scatter chart supports all of the same properties as the [line chart](./line.md#dataset-properties).
+
+## Data Structure
+
+Unlike the line chart where data can be supplied in two different formats, the scatter chart only accepts data in a point format.
+
+```javascript
+data: [{
+ x: 10,
+ y: 20
+ }, {
+ x: 15,
+ y: 10
+ }]
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/configuration/README.md | @@ -0,0 +1,34 @@
+# Configuration
+
+The configuration is used to change how the chart behaves. There are properties to control styling, fonts, the legend, etc.
+
+## Global Configuration
+
+This concept was introduced in Chart.js 1.0 to keep configuration [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself), 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 'nearest' 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 = 'nearest';
+
+// Hover mode is set to nearest because it was not overridden here
+var chartHoverModeNearest = new Chart(ctx, {
+ type: 'line',
+ data: data,
+});
+
+// This chart would have the hover mode that was passed in
+var chartDifferentHoverMode = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ hover: {
+ // Overrides the global setting
+ mode: 'index'
+ }
+ }
+})
+```
+ | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/configuration/animations.md | @@ -0,0 +1,96 @@
+# Animations
+
+Chart.js animates charts out of the box. A number of options are provided to configure how the animation looks and how long it takes
+
+## 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. [more...](#easing)
+| `onProgress` | `Function` | `null` | Callback called on each step of an animation. [more...](#animation-callbacks)
+| `onComplete` | `Function` | `null` | Callback called at the end of an animation. [more...](#animation-callbacks)
+
+## Easing
+ Available options are:
+* `'linear'`
+* `'easeInQuad'`
+* `'easeOutQuad'`
+* `'easeInOutQuad'`
+* `'easeInCubic'`
+* `'easeOutCubic'`
+* `'easeInOutCubic'`
+* `'easeInQuart'`
+* `'easeOutQuart'`
+* `'easeInOutQuart'`
+* `'easeInQuint'`
+* `'easeOutQuint'`
+* `'easeInOutQuint'`
+* `'easeInSine'`
+* `'easeOutSine'`
+* `'easeInOutSine'`
+* `'easeInExpo'`
+* `'easeOutExpo'`
+* `'easeInOutExpo'`
+* `'easeInCirc'`
+* `'easeOutCirc'`
+* `'easeInOutCirc'`
+* `'easeInElastic'`
+* `'easeOutElastic'`
+* `'easeInOutElastic'`
+* `'easeInBack'`
+* `'easeOutBack'`
+* `'easeInOutBack'`
+* `'easeInBounce'`
+* `'easeOutBounce'`
+* `'easeInOutBounce'`
+
+See [Robert Penner's easing equations](http://robertpenner.com/easing/).
+
+## Animation Callbacks
+
+The `onProgress` and `onComplete` callbacks are useful for synchronizing an external draw to the chart animation. The callback is passed a `Chart.Animation` instance:
+
+```javascript
+{
+ // Chart object
+ chart: Chart,
+
+ // 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
+}
+```
+
+The following example fills a progress bar during the chart animation.
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ animation: {
+ onProgress: function(animation) {
+ progress.value = animation.animationObject.currentStep / animation.animationObject.numSteps;
+ }
+ }
+ }
+});
+```
+
+Another example usage of these callbacks can be found on [Github](https://github.com/chartjs/Chart.js/blob/master/samples/animation/progress-bar.html): this sample displays a progress bar showing how far along the animation is. | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/configuration/elements.md | @@ -0,0 +1,69 @@
+# Elements
+
+While chart types provide settings to configure the styling of each dataset, you sometimes want to style **all datasets the same way**. A common example would be to stroke all of the bars in a bar chart with the same colour but change the fill per dataset. Options can be configured for four different types of elements: **[arc](#arc-configuration)**, **[lines](#line-configuration)**, **[points](#point-configuration)**, and **[rectangles](#rectangle-configuration)**. When set, these options apply to all objects of that type unless specifically overridden by the configuration attached to a dataset.
+
+## Global Configuration
+
+The element options can be specified per chart or globally. The global options for elements are defined in `Chart.defaults.global.elements`. For example, to set the border width of all bar charts globally you would do:
+
+```javascript
+Chart.defaults.global.elements.rectangle.borderWidth = 2;
+```
+
+## Point Configuration
+Point elements are used to represent the points in a line chart or a bubble chart.
+
+Global point options: `Chart.defaults.global.elements.point`
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `radius` | `Number` | `3` | Point radius.
+| `pointStyle` | `String` | `circle` | Point style.
+| `backgroundColor` | `Color` | `'rgba(0,0,0,0.1)'` | Point fill color.
+| `borderWidth` | `Number` | `1` | Point stroke width.
+| `borderColor` | `Color` | `'rgba(0,0,0,0.1)'` | Point stroke color.
+| `hitRadius` | `Number` | `1` | Extra radius added to point radius for hit detection.
+| `hoverRadius` | `Number` | `4` | Point radius when hovered.
+| `hoverBorderWidth` | `Number` | `1` | Stroke width when hovered.
+
+## Line Configuration
+Line elements are used to represent the line in a line chart.
+
+Global line options: `Chart.defaults.global.elements.line`
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `tension` | `Number` | `0.4` | Bézier curve tension (`0` for no Bézier curves).
+| `backgroundColor` | `Color` | `'rgba(0,0,0,0.1)'` | Line fill color.
+| `borderWidth` | `Number` | `3` | Line stroke width.
+| `borderColor` | `Color` | `'rgba(0,0,0,0.1)'` | Line stroke color.
+| `borderCapStyle` | `String` | `'butt'` | Line cap style (see [MDN](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap)).
+| `borderDash` | `Array` | `[]` | Line dash (see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash)).
+| `borderDashOffset` | `Number` | `0` | Line dash offset (see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset)).
+| `borderJoinStyle` | `String` | `'miter` | Line join style (see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin)).
+| `capBezierPoints` | `Boolean` | `true` | `true` to keep Bézier control inside the chart, `false` for no restriction.
+| `fill` | `Boolean/String` | `true` | Fill location: `'zero'`, `'top'`, `'bottom'`, `true` (eq. `'zero'`) or `false` (no fill).
+| `stepped` | `Boolean` | `false` | `true` to show the line as a stepped line (`tension` will be ignored).
+
+## Rectangle Configuration
+Rectangle elements are used to represent the bars in a bar chart.
+
+Global rectangle options: `Chart.defaults.global.elements.rectangle`
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `backgroundColor` | `Color` | `'rgba(0,0,0,0.1)'` | Bar fill color.
+| `borderWidth` | `Number` | `0` | Bar stroke width.
+| `borderColor` | `Color` | `'rgba(0,0,0,0.1)'` | Bar stroke color.
+| `borderSkipped` | `String` | `'bottom'` | Skipped (excluded) border: `'bottom'`, `'left'`, `'top'` or `'right'`.
+
+## Arc Configuration
+Arcs are used in the polar area, doughnut and pie charts.
+
+Global arc options: `Chart.defaults.global.elements.arc`.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `backgroundColor` | `Color` | `'rgba(0,0,0,0.1)'` | Arc fill color.
+| `borderColor` | `Color` | `'#fff'` | Arc stroke color.
+| `borderWidth`| `Number` | `2` | Arc stroke width. | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/configuration/layout.md | @@ -0,0 +1,29 @@
+# Layout Configuration
+
+The layout configuration is passed into the `options.layout` namespace. The global options for the chart layout is defined in `Chart.defaults.global.layout`.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `padding` | `Number` or `Object` | `0` | The padding to add inside the chart. [more...](#padding)
+
+## Padding
+If this value is a number, it is applied to all sides of the chart (left, top, right, bottom). If this value is an object, the `left` property defines the left padding. Similarly the `right`, `top`, and `bottom` properties can also be specified.
+
+Lets say you wanted to add 50px of padding to the left side of the chart canvas, you would do:
+
+```javascript
+let chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ layout: {
+ padding: {
+ left: 50,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }
+ }
+ }
+});
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/configuration/legend.md | @@ -0,0 +1,166 @@
+# Legend Configuration
+
+The chart legend displays data about the datasets that area appearing on the chart.
+
+## Configuration options
+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 shown
+| `position` | `String` | `'top'` | Position of the legend. [more...](#position)
+| `fullWidth` | `Boolean` | `true` | Marks that this box should take the full width of the canvas (pushing down other boxes). This is unlikely to need to be changed in day-to-day use.
+| `onClick` | `Function` | | A callback that is called when a click event is registered on a label item
+| `onHover` | `Function` | | A callback that is called when a 'mousemove' event is registered on top of a label item
+| `reverse` | `Boolean` | `false` | Legend will show datasets in reverse order.
+| `labels` | `Object` | | See the [Legend Label Configuration](#legend-label-configuration) section below.
+
+## Position
+Position of the legend. Options are:
+* `'top'`
+* `'left'`
+* `'bottom'`
+* `'right'`
+
+## 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 of text
+| `fontStyle` | `String` | `'normal'` | font style of text
+| `fontColor` | Color | `'#666'` | Color of text
+| `fontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family of legend text.
+| `padding` | `Number` | `10` | Padding between rows of colored boxes.
+| `generateLabels` | `Function` | | 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.
+| `filter` | `Function` | `null` | Filters legend items out of the legend. Receives 2 parameters, a [Legend Item](#chart-configuration-legend-item-interface) and the chart data.
+| `usePointStyle` | `Boolean` | `false` | Label style will match corresponding point style (size is based on fontSize, boxWidth is not used in this case).
+
+## 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
+
+ // Point style of the legend box (only used if usePointStyle is true)
+ pointStyle: String
+}
+```
+
+## Example
+
+The following example will create a chart with the legend enabled and turn all of the text red in color.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'bar',
+ data: data,
+ options: {
+ legend: {
+ display: true,
+ labels: {
+ fontColor: 'rgb(255, 99, 132)'
+ }
+ }
+}
+});
+```
+
+## Custom On Click Actions
+
+It can be common to want to trigger different behaviour when clicking an item in the legend. This can be easily achieved using a callback in the config object.
+
+The default legend click handler is:
+```javascript
+function(e, legendItem) {
+ var index = legendItem.datasetIndex;
+ var ci = this.chart;
+ var meta = ci.getDatasetMeta(index);
+
+ // See controller.isDatasetVisible comment
+ meta.hidden = meta.hidden === null? !ci.data.datasets[index].hidden : null;
+
+ // We hid a dataset ... rerender the chart
+ ci.update();
+}
+```
+
+Lets say we wanted instead to link the display of the first two datasets. We could change the click handler accordingly.
+
+```javascript
+var defaultLegendClickHandler = Chart.defaults.global.legend.onClick;
+var newLegendClickHandler = function (e, legendItem) {
+ var index = legendItem.datasetIndex;
+
+ if (index > 1) {
+ // Do the original logic
+ defaultLegendClickHandler(e, legendItem);
+ } else {
+ let ci = this.chart;
+ [ci.getDatasetMeta(0),
+ ci.getDatasetMeta(1)].forEach(function(meta) {
+ meta.hidden = meta.hidden === null? !ci.data.datasets[index].hidden : null;
+ });
+ ci.update();
+ }
+};
+
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ legend: {
+
+ }
+ }
+});
+```
+
+Now when you click the legend in this chart, the visibility of the first two datasets will be linked together.
+
+## HTML Legends
+
+Sometimes you need a very complex legend. In these cases, it makes sense to generate an HTML legend. Charts provide a `generateLegend()` method on their prototype that returns an HTML string for the legend.
+
+To configure how this legend is generated, you can change the `legendCallback` config property.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ legendCallback: function(chart) {
+ // Return the HTML string here.
+ }
+ }
+});
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/configuration/title.md | @@ -0,0 +1,41 @@
+# Title
+
+The chart title defines text to draw at the top of the chart.
+
+## 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` | is the title shown
+| `position` | `String` | `'top'` | Position of title. [more...](#position)
+| `fontSize` | `Number` | `12` | Font size
+| `fontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family for the title text.
+| `fontColor` | Color | `'#666'` | Font color
+| `fontStyle` | `String` | `'bold'` | Font style
+| `padding` | `Number` | `10` | Number of pixels to add above and below the title text.
+| `text` | `String` | `''` | Title text ti display
+
+### Position
+Possible title position values are:
+* `'top'`
+* `'left'`
+* `'bottom'`
+* `'right'`
+
+## Example Usage
+
+The example below would enable a title of 'Custom Chart Title' on the chart that is created.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ title: {
+ display: true,
+ text: 'Custom Chart Title'
+ }
+ }
+})
+``` | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/configuration/tooltip.md | @@ -0,0 +1,292 @@
+# Tooltips
+
+## Tooltip Configuration
+
+The tooltip configuration is passed into the `options.tooltips` namespace. The global options for the chart tooltips is defined in `Chart.defaults.global.tooltips`.
+
+| Name | Type | Default | Description
+| -----| ---- | --------| -----------
+| `enabled` | `Boolean` | `true` | Are tooltips enabled
+| `custom` | `Function` | `null` | See [custom tooltip](#custom-tooltips) section.
+| `mode` | `String` | `'nearest'` | Sets which elements appear in the tooltip. [more...](../general/interactions/modes.md#interaction-modes).
+| `intersect` | `Boolean` | `true` | if true, the tooltip mode applies only when the mouse position intersects with an element. If false, the mode will be applied at all times.
+| `position` | `String` | `'average'` | The mode for positioning the tooltip. [more...](#position-modes)
+| `callbacks` | `Object` | | See the [callbacks section](#tooltip-callbacks)
+| `itemSort` | `Function` | | Sort tooltip items. [more...](#sort-callback)
+| `filter` | `Function` | | Filter tooltip items. [more...](#filter-callback)
+| `backgroundColor` | Color | `'rgba(0,0,0,0.8)'` | Background color of the tooltip.
+| `titleFontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | title font
+| `titleFontSize` | `Number` | `12` | Title font size
+| `titleFontStyle` | `String` | `'bold'` | Title font style
+| `titleFontColor` | Color | `'#fff'` | Title font color
+| `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"` | body line font
+| `bodyFontSize` | `Number` | `12` | Body font size
+| `bodyFontStyle` | `String` | `'normal'` | Body font style
+| `bodyFontColor` | Color | `'#fff'` | Body font color
+| `bodySpacing` | `Number` | `2` | Spacing to add to top and bottom of each tooltip item.
+| `footerFontFamily` | `String` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | footer font
+| `footerFontSize` | `Number` | `12` | Footer font size
+| `footerFontStyle` | `String` | `'bold'` | Footer font style
+| `footerFontColor` | Color | `'#fff'` | Footer font color
+| `footerSpacing` | `Number` | `2` | Spacing to add to top and bottom of each fotter 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
+| `displayColors` | `Boolean` | `true` | if true, color boxes are shown in the tooltip
+| `borderColor` | Color | `'rgba(0,0,0,0)'` | Color of the border
+| `borderWidth` | `Number` | `0` | Size of the border
+
+### Position Modes
+ Possible modes are:
+* 'average'
+* 'nearest'
+
+'average' mode will place the tooltip at the average position of the items displayed in the tooltip. 'nearest' will place the tooltip at the position of the element closest to the event position.
+
+New modes can be defined by adding functions to the Chart.Tooltip.positioners map.
+
+### Sort Callback
+
+Allows sorting of [tooltip items](#chart-configuration-tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort). This function can also accept a third parameter that is the data object passed to the chart.
+
+### Filter Callback
+
+Allows filtering of [tooltip items](#chart-configuration-tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.filter](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). This function can also accept a second parameter that is the data object passed to the chart.
+
+## 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.
+
+| Name | Arguments | Description
+| ---- | --------- | -----------
+| `beforeTitle` | `Array[tooltipItem], data` | Returns the text to render before the title.
+| `title` | `Array[tooltipItem], data` | Returns text to render as the title of the tooltip.
+| `afterTitle` | `Array[tooltipItem], data` | Returns text to render after the title.
+| `beforeBody` | `Array[tooltipItem], data` | Returns text to render before the body section.
+| `beforeLabel` | `tooltipItem, data` | Returns text to render before an individual label. This will be called for each item in the tooltip.
+| `label` | `tooltipItem, data` | Returns text to render for an individual item in the tooltip.
+| `labelColor` | `tooltipItem, chart` | Returns the colors to render for the tooltip item. [more...](#label-color-callback)
+| `afterLabel` | `tooltipItem, data` | Returns text to render after an individual label.
+| `afterBody` | `Array[tooltipItem], data` | Returns text to render after the body section
+| `beforeFooter` | `Array[tooltipItem], data` | Returns text to render before the footer section.
+| `footer` | `Array[tooltipItem], data` | Returns text to render as the footer of the tooltip.
+| `afterFooter` | `Array[tooltipItem], data` | Text to render after the footer section
+
+### Label Color Callback
+
+For example, to return a red box for each item in the tooltip you could do:
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ tooltips: {
+ callbacks: {
+ labelColor: function(tooltipItem, chart) {
+ return {
+ borderColor: 'rgb(255, 0, 0)',
+ backgroundColor: 'rgb(255, 0, 0)'
+ }
+ }
+ }
+ }
+ }
+});
+```
+
+
+### 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,
+
+ // X position of matching point
+ x: Number,
+
+ // Y position of matching point
+ y: Number,
+}
+```
+
+## External (Custom) Tooltips
+
+Custom tooltips allow you to hook into the tooltip rendering process so that you can render the tooltip in your own custom way. Generally this is used to create an HTML tooltip instead of an oncanvas one. You can enable custom tooltips in the global or chart configuration like so:
+
+```javascript
+var myPieChart = new Chart(ctx, {
+ type: 'pie',
+ data: data,
+ options: {
+ tooltips: {
+ custom: function(tooltipModel) {
+ // Tooltip Element
+ var tooltipEl = document.getElementById('chartjs-tooltip');
+
+ // Create element on first render
+ if (!tooltipEl) {
+ tooltipEl = document.createElement('div');
+ tooltipEl.id = 'chartjs-tooltip';
+ tooltipEl.innerHTML = "<table></table>"
+ document.body.appendChild(tooltipEl);
+ }
+
+ // Hide if no tooltip
+ if (tooltipModel.opacity === 0) {
+ tooltipEl.style.opacity = 0;
+ return;
+ }
+
+ // Set caret Position
+ tooltipEl.classList.remove('above', 'below', 'no-transform');
+ if (tooltipModel.yAlign) {
+ tooltipEl.classList.add(tooltipModel.yAlign);
+ } else {
+ tooltipEl.classList.add('no-transform');
+ }
+
+ function getBody(bodyItem) {
+ return bodyItem.lines;
+ }
+
+ // Set Text
+ if (tooltipModel.body) {
+ var titleLines = tooltipModel.title || [];
+ var bodyLines = tooltipModel.body.map(getBody);
+
+ var innerHtml = '<thead>';
+
+ titleLines.forEach(function(title) {
+ innerHtml += '<tr><th>' + title + '</th></tr>';
+ });
+ innerHtml += '</thead><tbody>';
+
+ bodyLines.forEach(function(body, i) {
+ var colors = tooltipModel.labelColors[i];
+ var style = 'background:' + colors.backgroundColor;
+ style += '; border-color:' + colors.borderColor;
+ style += '; border-width: 2px';
+ var span = '<span class="chartjs-tooltip-key" style="' + style + '"></span>';
+ innerHtml += '<tr><td>' + span + body + '</td></tr>';
+ });
+ innerHtml += '</tbody>';
+
+ var tableRoot = tooltipEl.querySelector('table');
+ tableRoot.innerHTML = innerHtml;
+ }
+
+ // `this` will be the overall tooltip
+ var position = this._chart.canvas.getBoundingClientRect();
+
+ // Display, position, and set styles for font
+ tooltipEl.style.opacity = 1;
+ tooltipEl.style.left = position.left + tooltipModel.caretX + 'px';
+ tooltipEl.style.top = position.top + tooltipModel.caretY + 'px';
+ tooltipEl.style.fontFamily = tooltipModel._fontFamily;
+ tooltipEl.style.fontSize = tooltipModel.fontSize;
+ tooltipEl.style.fontStyle = tooltipModel._fontStyle;
+ tooltipEl.style.padding = tooltipModel.yPadding + 'px ' + tooltipModel.xPadding + 'px';
+ }
+ }
+ }
+});
+```
+
+See `samples/tooltips/line-customTooltips.html` for examples on how to get started.
+
+## Tooltip Model
+The tooltip model contains parameters that can be used to render the tooltip.
+
+```javascript
+{
+ // The items that we are rendering in the tooltip. See Tooltip Item Interface section
+ dataPoints: TooltipItem[],
+
+ // Positioning
+ xPadding: Number,
+ yPadding: Number,
+ xAlign: String,
+ yAlign: String,
+
+ // X and Y properties are the top left of the tooltip
+ x: Number,
+ y: Number,
+ width: Number,
+ height: Number,
+ // Where the tooltip points to
+ caretX: Number,
+ caretY: Number,
+
+ // Body
+ // The body lines that need to be rendered
+ // Each pbject contains 3 parameters
+ // before: String[] // lines of text before the line with the color square
+ // lines: String[], // lines of text to render as the main item with color square
+ // after: String[], // lines of text to render after the main lines
+ body: Object[],
+ // lines of text that appear after the title but before the body
+ beforeBody: String[],
+ // line of text that appear after the body and before the footer
+ afterBody: String[],
+ bodyFontColor: Color,
+ _bodyFontFamily: String,
+ _bodyFontStyle: String,
+ _bodyAlign: String,
+ bodyFontSize: Number,
+ bodySpacing: Number,
+
+ // Title
+ // lines of text that form the title
+ title: String[],
+ titleFontColor: Color,
+ _titleFontFamily: String,
+ _titleFontStyle: String,
+ titleFontSize: Number,
+ _titleAlign: String,
+ titleSpacing: Number,
+ titleMarginBottom: Number,
+
+ // Footer
+ // lines of text that form the footer
+ footer: String[],
+ footerFontColor: Color,
+ _footerFontFamily: String,
+ _footerFontStyle: String,
+ footerFontSize: Number,
+ _footerAlign: String,
+ footerSpacing: Number,
+ footerMarginTop: Number,
+
+ // Appearance
+ caretSize: Number,
+ cornerRadius: Number,
+ backgroundColor: Color,
+
+ // colors to render for each item in body[]. This is the color of the squares in the tooltip
+ labelColors: Color[],
+
+ // 0 opacity is a hidden tooltip
+ opacity: Number,
+ legendColorBackground: Color,
+ displayColors: Boolean,
+}
+``` | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/developers/README.md | @@ -0,0 +1,22 @@
+# Developers
+Developer features allow extending and enhancing Chart.js in many different ways.
+
+# Browser support
+
+Chart.js offers support for all browsers where canvas is supported.
+
+Browser support for the canvas element is available in all modern & major mobile browsers. [CanIUse](http://caniuse.com/#feat=canvas)
+
+Thanks to [BrowserStack](https://browserstack.com) for allowing our team to test on thousands of browsers.
+
+# Previous versions
+
+Version 2 has a completely different API than earlier versions.
+
+Most earlier version options have current equivalents or are the same.
+
+Please use the documentation that is available on [chartjs.org](http://www.chartjs.org/docs/) for the current version of Chart.js.
+
+Please note - documentation for previous versions are available on the GitHub repo.
+
+- [1.x Documentation](https://github.com/chartjs/Chart.js/tree/v1.1.1/docs)
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/developers/api.md | @@ -0,0 +1,143 @@
+# Chart Prototype Methods
+
+For each chart, there are a set of global prototype methods on the shared `ChartType` which you may find useful. These are available on all charts created with Chart.js, but for the examples, let's use a line chart we've made.
+
+```javascript
+// For example:
+var myLineChart = new Chart(ctx, config);
+```
+
+## .destroy()
+
+Use this to destroy any chart instances that are created. This will clean up any references stored to the chart object within Chart.js, along with any associated event listeners attached by Chart.js.
+This must be called before the canvas is reused for a new chart.
+
+```javascript
+// Destroys a specific chart instance
+myLineChart.destroy();
+```
+
+## .update(duration, lazy)
+
+Triggers an update of the chart. This can be safely called after updating the data object. This will update all scales, legends, and then re-render the chart.
+
+```javascript
+// duration is the time for the animation of the redraw in milliseconds
+// lazy is a boolean. if true, the animation can be interrupted by other animations
+myLineChart.data.datasets[0].data[2] = 50; // Would update the first dataset's value of 'March' to be 50
+myLineChart.update(); // Calling update now animates the position of March from 90 to 50.
+```
+
+> **Note:** replacing the data reference (e.g. `myLineChart.data = {datasets: [...]}` only works starting **version 2.6**. Prior that, replacing the entire data object could be achieved with the following workaround: `myLineChart.config.data = {datasets: [...]}`.
+
+## .reset()
+
+Reset the chart to it's state before the initial animation. A new animation can then be triggered using `update`.
+
+```javascript
+myLineChart.reset();
+```
+
+## .render(duration, lazy)
+
+Triggers a redraw of all chart elements. Note, this does not update elements for new data. Use `.update()` in that case.
+
+```javascript
+// duration is the time for the animation of the redraw in milliseconds
+// lazy is a boolean. if true, the animation can be interrupted by other animations
+myLineChart.render(duration, lazy);
+```
+
+## .stop()
+
+Use this to stop any current animation loop. This will pause the chart during any current animation frame. Call `.render()` to re-animate.
+
+```javascript
+// Stops the charts animation loop at its current frame
+myLineChart.stop();
+// => returns 'this' for chainability
+```
+
+## .resize()
+
+Use this to manually resize the canvas element. This is run each time the canvas container is resized, but you can call this method manually if you change the size of the canvas nodes container element.
+
+```javascript
+// Resizes & redraws to fill its container element
+myLineChart.resize();
+// => returns 'this' for chainability
+```
+
+## .clear()
+
+Will clear the chart canvas. Used extensively internally between animation frames, but you might find it useful.
+
+```javascript
+// Will clear the canvas that myLineChart is drawn on
+myLineChart.clear();
+// => returns 'this' for chainability
+```
+
+## .toBase64Image()
+
+This returns a base 64 encoded string of the chart in it's current state.
+
+```javascript
+myLineChart.toBase64Image();
+// => returns png data url of the image on the canvas
+```
+
+## .generateLegend()
+
+Returns an HTML string of a legend for that chart. The legend is generated from the `legendCallback` in the options.
+
+```javascript
+myLineChart.generateLegend();
+// => returns HTML string of a legend for this chart
+```
+
+## .getElementAtEvent(e)
+
+Calling `getElementAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the single element at the event position. If there are multiple items within range, only the first is returned. The value returned from this method is an array with a single parameter. An array is used to keep a consistent API between the `get*AtEvent` methods.
+
+```javascript
+myLineChart.getElementAtEvent(e);
+// => returns the first element at the event point.
+```
+
+## .getElementsAtEvent(e)
+
+Looks for the element under the event point, then returns all elements at the same data index. This is used internally for 'label' mode highlighting.
+
+Calling `getElementsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the point elements that are at that the same position of that event.
+
+```javascript
+canvas.onclick = function(evt){
+ var activePoints = myLineChart.getElementsAtEvent(evt);
+ // => activePoints is an array of points on the canvas that are at the same position as the click event.
+};
+```
+
+This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.
+
+## .getDatasetAtEvent(e)
+
+Looks for the element under the event point, then returns all elements from that dataset. This is used internally for 'dataset' mode highlighting
+
+```javascript
+myLineChart.getDatasetAtEvent(e);
+// => returns an array of elements
+```
+
+## .getDatasetMeta(index)
+
+Looks for the dataset that matches the current index and returns that metadata. This returned data has all of the metadata that is used to construct the chart.
+
+The `data` property of the metadata will contain information about each point, rectangle, etc. depending on the chart type.
+
+Extensive examples of usage are available in the [Chart.js tests](https://github.com/chartjs/Chart.js/tree/master/test).
+
+```javascript
+var meta = myChart.getDatasetMeta(0);
+var x = meta.data[0]._model.x
+``` | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/developers/axes.md | @@ -0,0 +1,131 @@
+# New Axes
+
+Axes in Chart.js can be individually extended. Axes should always derive from Chart.Scale but this is not a mandatory requirement.
+
+```javascript
+let MyScale = Chart.Scale.extend({
+ /* extensions ... */
+});
+
+// MyScale is now derived from Chart.Scale
+```
+
+Once you have created your scale class, you need to register it with the global chart object so that it can be used. A default config for the scale may be provided when registering the constructor. The first parameter to the register function is a string key that is used later to identify which scale type to use for a chart.
+
+```javascript
+Chart.scaleService.registerScaleType('myScale', MyScale, defaultConfigObject);
+```
+
+To use the new scale, simply pass in the string key to the config when creating a chart.
+
+```javascript
+var lineChart = new Chart(ctx, {
+ data: data,
+ type: 'line',
+ options: {
+ scales: {
+ yAxes: [{
+ type: 'myScale' // this is the same key that was passed to the registerScaleType function
+ }]
+ }
+ }
+})
+```
+
+## Scale Properties
+
+Scale instances are given the following properties during the fitting process.
+
+```javascript
+{
+ left: Number, // left edge of the scale bounding box
+ right: Number, // right edge of the bounding box'
+ top: Number,
+ bottom: Number,
+ width: Number, // the same as right - left
+ height: Number, // the same as bottom - top
+
+ // Margin on each side. Like css, this is outside the bounding box.
+ margins: {
+ left: Number,
+ right: Number,
+ top: Number,
+ bottom: Number,
+ },
+
+ // Amount of padding on the inside of the bounding box (like CSS)
+ paddingLeft: Number,
+ paddingRight: Number,
+ paddingTop: Number,
+ paddingBottom: Number,
+}
+```
+
+## Scale Interface
+To work with Chart.js, custom scale types must implement the following interface.
+
+```javascript
+{
+ // Determines the data limits. Should set this.min and this.max to be the data max/min
+ determineDataLimits: function() {},
+
+ // Generate tick marks. this.chart is the chart instance. The data object can be accessed as this.chart.data
+ // buildTicks() should create a ticks array on the axis instance, if you intend to use any of the implementations from the base class
+ buildTicks: function() {},
+
+ // Get the value to show for the data at the given index of the the given dataset, ie this.chart.data.datasets[datasetIndex].data[index]
+ getLabelForIndex: function(index, datasetIndex) {},
+
+ // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value
+ // @param index: index into the ticks array
+ // @param includeOffset: if true, get the pixel halway between the given tick and the next
+ getPixelForTick: function(index, includeOffset) {},
+
+ // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value
+ // @param value : the value to get the pixel for
+ // @param index : index into the data array of the value
+ // @param datasetIndex : index of the dataset the value comes from
+ // @param includeOffset : if true, get the pixel halway between the given tick and the next
+ getPixelForValue: function(value, index, datasetIndex, includeOffset) {}
+
+ // Get the value for a given pixel (x coordinate for horizontal axis, y coordinate for vertical axis)
+ // @param pixel : pixel value
+ getValueForPixel: function(pixel) {}
+}
+```
+
+Optionally, the following methods may also be overwritten, but an implementation is already provided by the `Chart.Scale` base class.
+
+```javascript
+ // Transform the ticks array of the scale instance into strings. The default implementation simply calls this.options.ticks.callback(numericalTick, index, ticks);
+ convertTicksToLabels: function() {},
+
+ // Determine how much the labels will rotate by. The default implementation will only rotate labels if the scale is horizontal.
+ calculateTickRotation: function() {},
+
+ // Fits the scale into the canvas.
+ // this.maxWidth and this.maxHeight will tell you the maximum dimensions the scale instance can be. Scales should endeavour to be as efficient as possible with canvas space.
+ // this.margins is the amount of space you have on either side of your scale that you may expand in to. This is used already for calculating the best label rotation
+ // You must set this.minSize to be the size of your scale. It must be an object containing 2 properties: width and height.
+ // You must set this.width to be the width and this.height to be the height of the scale
+ fit: function() {},
+
+ // Draws the scale onto the canvas. this.(left|right|top|bottom) will have been populated to tell you the area on the canvas to draw in
+ // @param chartArea : an object containing four properties: left, right, top, bottom. This is the rectangle that lines, bars, etc will be drawn in. It may be used, for example, to draw grid lines.
+ draw: function(chartArea) {},
+```
+
+The Core.Scale base class also has some utility functions that you may find useful.
+```javascript
+{
+ // Returns true if the scale instance is horizontal
+ isHorizontal: function() {},
+
+ // Get the correct value from the value from this.chart.data.datasets[x].data[]
+ // If dataValue is an object, returns .x or .y depending on the return of isHorizontal()
+ // If the value is undefined, returns NaN
+ // Otherwise returns the value.
+ // Note that in all cases, the returned value is not guaranteed to be a Number
+ getRightValue: function(dataValue) {},
+}
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/developers/charts.md | @@ -0,0 +1,116 @@
+# New Charts
+
+Chart.js 2.0 introduces the concept of controllers for each dataset. Like scales, new controllers can be written as needed.
+
+```javascript
+Chart.controllers.MyType = Chart.DatasetController.extend({
+
+});
+
+
+// Now we can create a new instance of our chart, using the Chart.js API
+new Chart(ctx, {
+ // this is the string the constructor was registered at, ie Chart.controllers.MyType
+ type: 'MyType',
+ data: data,
+ options: options
+});
+```
+
+## Dataset Controller Interface
+
+Dataset controllers must implement the following interface.
+
+```javascript
+{
+ // Create elements for each piece of data in the dataset. Store elements in an array on the dataset as dataset.metaData
+ addElements: function() {},
+
+ // Create a single element for the data at the given index and reset its state
+ addElementAndReset: function(index) {},
+
+ // Draw the representation of the dataset
+ // @param ease : if specified, this number represents how far to transition elements. See the implementation of draw() in any of the provided controllers to see how this should be used
+ draw: function(ease) {},
+
+ // Remove hover styling from the given element
+ removeHoverStyle: function(element) {},
+
+ // Add hover styling to the given element
+ setHoverStyle: function(element) {},
+
+ // Update the elements in response to new data
+ // @param reset : if true, put the elements into a reset state so they can animate to their final values
+ update: function(reset) {},
+}
+```
+
+The following methods may optionally be overridden by derived dataset controllers
+```javascript
+{
+ // Initializes the controller
+ initialize: function(chart, datasetIndex) {},
+
+ // Ensures that the dataset represented by this controller is linked to a scale. Overridden to helpers.noop in the polar area and doughnut controllers as these
+ // chart types using a single scale
+ linkScales: function() {},
+
+ // Called by the main chart controller when an update is triggered. The default implementation handles the number of data points changing and creating elements appropriately.
+ buildOrUpdateElements: function() {}
+}
+```
+
+## Extending Existing Chart Types
+
+Extending or replacing an existing controller type is easy. Simply replace the constructor for one of the built in types with your own.
+
+The built in controller types are:
+* `Chart.controllers.line`
+* `Chart.controllers.bar`
+* `Chart.controllers.radar`
+* `Chart.controllers.doughnut`
+* `Chart.controllers.polarArea`
+* `Chart.controllers.bubble`
+
+For example, to derive a new chart type that extends from a bubble chart, you would do the following.
+
+```javascript
+// Sets the default config for 'derivedBubble' to be the same as the bubble defaults.
+// We look for the defaults by doing Chart.defaults[chartType]
+// It looks like a bug exists when the defaults don't exist
+Chart.defaults.derivedBubble = Chart.defaults.bubble;
+
+// I think the recommend using Chart.controllers.bubble.extend({ extensions here });
+var custom = Chart.controllers.bubble.extend({
+ draw: function(ease) {
+ // Call super method first
+ Chart.controllers.bubble.prototype.draw.call(this, ease);
+
+ // Now we can do some custom drawing for this dataset. Here we'll draw a red box around the first point in each dataset
+ var meta = this.getMeta();
+ var pt0 = meta.data[0];
+ var radius = pt0._view.radius;
+
+ var ctx = this.chart.chart.ctx;
+ ctx.save();
+ ctx.strokeStyle = 'red';
+ ctx.lineWidth = 1;
+ ctx.strokeRect(pt0._view.x - radius, pt0._view.y - radius, 2 * radius, 2 * radius);
+ ctx.restore();
+ }
+});
+
+// Stores the controller so that the chart initialization routine can look it up with
+// Chart.controllers[type]
+Chart.controllers.derivedBubble = custom;
+
+// Now we can create and use our new chart type
+new Chart(ctx, {
+ type: 'derivedBubble',
+ data: data,
+ options: options,
+});
+```
+
+### Bar Controller
+The bar controller has a special property that you should be aware of. To correctly calculate the width of a bar, the controller must determine the number of datasets that map to bars. To do this, the bar controller attaches a property `bar` to the dataset during initialization. If you are creating a replacement or updated bar controller, you should do the same. This will ensure that charts with regular bars and your new derived bars will work seamlessly.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/developers/contributing.md | @@ -0,0 +1,34 @@
+# Contributing
+
+New contributions to the library are welcome, but we ask that you please follow these guidelines:
+
+- Use tabs for indentation, not spaces.
+- Only change the individual files in `/src`.
+- Check that your code will pass `eslint` code standards, `gulp lint` will run this for you.
+- Check that your code will pass tests, `gulp test` will run tests for you.
+- Keep pull requests concise, and document new functionality in the relevant `.md` file.
+- Consider whether your changes are useful for all users, or if creating a Chart.js plugin would be more appropriate.
+
+# Building Chart.js
+
+Chart.js uses <a href="http://gulpjs.com/" target="_blank">gulp</a> to build the library into a single JavaScript file.
+
+Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:
+
+```bash
+npm install
+npm install -g gulp
+```
+
+This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner <a href="http://gulpjs.com/" target="_blank">gulp</a>.
+
+Now, we can run the `gulp build` task.
+
+```bash
+gulp build
+```
+
+# Bugs & issues
+
+Please report these on the GitHub page - at <a href="https://github.com/chartjs/Chart.js" target="_blank">github.com/chartjs/Chart.js</a>. If you could include a link to a simple <a href="http://jsbin.com/" target="_blank">jsbin</a> or similar to demonstrate the issue, that'd be really helpful.
+ | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/developers/plugins.md | @@ -0,0 +1,140 @@
+# Plugins
+
+Plugins are the most efficient way to customize or change the default behavior of a chart. They have been introduced at [version 2.1.0](https://github.com/chartjs/Chart.js/releases/tag/2.1.0) (global plugins only) and extended at [version 2.5.0](https://github.com/chartjs/Chart.js/releases/tag/2.5.0) (per chart plugins and options).
+
+## Popular Plugins
+
+ - <a href="https://github.com/chartjs/chartjs-plugin-annotation" target="_blank">chartjs-plugin-annotation.js</a> - Draw lines and boxes on chart area.
+ - <a href="https://github.com/chartjs/chartjs-plugin-deferred" target="_blank">chartjs-plugin-deferred.js</a> - Defer initial chart update until chart scrolls into viewport.
+ - <a href="https://github.com/compwright/chartjs-plugin-draggable" target="_blank">chartjs-plugin-draggable.js</a> - Makes select chart elements draggable with the mouse.
+ - <a href="https://github.com/chartjs/chartjs-plugin-zoom" target="_blank">chartjs-plugin-zoom.js</a> - Enable zooming and panning on charts.
+ - <a href="https://github.com/chartjs/Chart.BarFunnel.js" target="_blank">Chart.BarFunnel.js</a> - Adds a bar funnel chart type.
+ - <a href="https://github.com/chartjs/Chart.LinearGauge.js" target="_blank">Chart.LinearGauge.js</a> - Adds a linear gauge chart type.
+ - <a href="https://github.com/chartjs/Chart.smith.js" target="_blank">Chart.Smith.js</a> - Adds a smith chart type.
+
+In addition, many plugins can be found on the [Chart.js GitHub organization](https://github.com/chartjs) or on the [npm registry](https://www.npmjs.com/search?q=chartjs-plugin-).
+
+## Using plugins
+
+Plugins can be shared between chart instances:
+
+```javascript
+var plugin = { /* plugin implementation */ };
+
+// chart1 and chart2 use "plugin"
+var chart1 = new Chart(ctx, {
+ plugins: [plugin]
+});
+
+var chart2 = new Chart(ctx, {
+ plugins: [plugin]
+});
+
+// chart3 doesn't use "plugin"
+var chart3 = new Chart(ctx, {});
+```
+
+Plugins can also be defined directly in the chart `plugins` config (a.k.a. *inline plugins*):
+
+```javascript
+var chart = new Chart(ctx, {
+ plugins: [{
+ beforeInit: function(chart, options) {
+ //..
+ }
+ }]
+});
+```
+
+However, this approach is not ideal when the customization needs to apply to many charts.
+
+## Global plugins
+
+Plugins can be registered globally to be applied on all charts (a.k.a. *global plugins*):
+
+```javascript
+Chart.plugins.register({
+ // plugin implementation
+});
+```
+
+> Note: *inline* plugins can't be registered globally.
+
+## Configuration
+
+### Plugin ID
+
+Plugins must define a unique id in order to be configurable.
+
+This id should follow the [npm package name convention](https://docs.npmjs.com/files/package.json#name):
+
+- can't start with a dot or an underscore
+- can't contain any non-URL-safe characters
+- can't contain uppercase letters
+- should be something short, but also reasonably descriptive
+
+If a plugin is intended to be released publicly, you may want to check the [registry](https://www.npmjs.com/search?q=chartjs-plugin-) to see if there's something by that name already. Note that in this case, the package name should be prefixed by `chartjs-plugin-` to appear in Chart.js plugin registry.
+
+### Plugin options
+
+Plugin options are located under the `options.plugins` config and are scoped by the plugin ID: `options.plugins.{plugin-id}`.
+
+```javascript
+var chart = new Chart(ctx, {
+ config: {
+ foo: { ... }, // chart 'foo' option
+ plugins: {
+ p1: {
+ foo: { ... }, // p1 plugin 'foo' option
+ bar: { ... }
+ },
+ p2: {
+ foo: { ... }, // p2 plugin 'foo' option
+ bla: { ... }
+ }
+ }
+ }
+});
+```
+
+#### Disable plugins
+
+To disable a global plugin for a specific chart instance, the plugin options must be set to `false`:
+
+```javascript
+Chart.plugins.register({
+ id: 'p1',
+ // ...
+});
+
+var chart = new Chart(ctx, {
+ config: {
+ plugins: {
+ p1: false // disable plugin 'p1' for this instance
+ }
+ }
+});
+```
+
+## Plugin Core API
+
+Available hooks (as of version 2.5):
+
+* beforeInit
+* afterInit
+* beforeUpdate *(cancellable)*
+* afterUpdate
+* beforeLayout *(cancellable)*
+* afterLayout
+* beforeDatasetsUpdate *(cancellable)*
+* afterDatasetsUpdate
+* beforeRender *(cancellable)*
+* afterRender
+* beforeDraw *(cancellable)*
+* afterDraw
+* beforeDatasetsDraw *(cancellable)*
+* afterDatasetsDraw
+* beforeEvent *(cancellable)*
+* afterEvent
+* resize
+* destroy | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/general/README.md | @@ -0,0 +1,8 @@
+# General Chart.js Configuration
+
+These sections describe general configuration options that can apply elsewhere in the documentation.
+
+* [Colors](./colors.md) defines acceptable color values
+* [Font](./fonts.md) defines various font options
+* [Interactions](./interactions/README.md) defines options that reflect how hovering chart elements works
+* [Responsive](./responsive.md) defines responsive chart options that apply to all charts.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/general/colors.md | @@ -0,0 +1,49 @@
+# 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 `'rgba(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.
+
+## Patterns and Gradients
+
+An alternative option is to pass a [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern) or [CanvasGradient](https://developer.mozilla.org/en/docs/Web/API/CanvasGradient) object instead of a string colour.
+
+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
+ }]
+ }
+ })
+}
+```
+
+Using pattern fills for data graphics can help viewers with vision deficiencies (e.g. color-blindness or partial sight) to [more easily understand your data](http://betweentwobrackets.com/data-graphics-and-colour-vision/).
+
+Using the [Patternomaly](https://github.com/ashiguruma/patternomaly) library you can generate patterns to fill datasets.
+
+```javascript
+var chartData = {
+ datasets: [{
+ data: [45, 25, 20, 10],
+ backgroundColor: [
+ pattern.draw('square', '#ff6384'),
+ pattern.draw('circle', '#36a2eb'),
+ pattern.draw('diamond', '#cc65fe'),
+ pattern.draw('triangle', '#ffce56'),
+ ]
+ }],
+ labels: ['Red', 'Blue', 'Purple', 'Yellow']
+};
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/general/fonts.md | @@ -0,0 +1,28 @@
+# Fonts
+
+There are 4 special global settings that can change all of the fonts on the chart. These options are in `Chart.defaults.global`. The global font settings only apply when more specific options are not included in the config.
+
+For example, in this chart the text will all be red except for the labels in the legend.
+
+```javascript
+Chart.defaults.global.defaultFontColor = 'red';
+let chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ legend: {
+ labels: {
+ // This more specific font property overrides the global property
+ fontColor: 'black'
+ }
+ }
+ }
+});
+```
+
+| 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. | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/general/interactions/README.md | @@ -0,0 +1,9 @@
+# Interactions
+
+The hover configuration is passed into the `options.hover` namespace. The global hover configuration is at `Chart.defaults.global.hover`. To configure which events trigger chart interactions, see [events](./events.md#events).
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `mode` | `String` | `'nearest'` | Sets which elements appear in the tooltip. See [Interaction Modes](./modes.md#interaction-modes) for details.
+| `intersect` | `Boolean` | `true` | if true, the hover mode only applies when the mouse position intersects an item on the chart.
+| `animationDuration` | `Number` | `400` | Duration in milliseconds it takes to animate hover style changes.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/general/interactions/events.md | @@ -0,0 +1,21 @@
+# Events
+The following properties define how the chart interacts with events.
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `events` | `String[]` | `["mousemove", "mouseout", "click", "touchstart", "touchmove", "touchend"]` | The `events` option defines the browser events that the chart should listen to for tooltips and hovering. [more...](#event-option)
+| `onHover` | `Function` | `null` | Called when any of the events fire. Called in the context of the chart and passed the event and an array of active elements (bars, points, etc).
+| `onClick` | `Function` | `null` | Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed the event and an array of active elements
+
+## Event Option
+For example, to have the chart only respond to click events, you could do
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ // This chart will not respond to mousemove, etc
+ events: ['click']
+ }
+});
+``` | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/general/interactions/modes.md | @@ -0,0 +1,104 @@
+# Interaction Modes
+
+When configuring interaction with the graph via hover or tooltips, a number of different modes are available.
+
+The modes are detailed below and how they behave in conjunction with the `intersect` setting.
+
+## point
+Finds all of the items that intersect the point.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ tooltips: {
+ mode: 'point'
+ }
+ }
+})
+```
+
+## nearest
+Gets the item that is nearest to the point. The nearest item is determined based on the distance to the center of the chart item (point, bar). If 2 or more items are at the same distance, the one with the smallest area is used. If `intersect` is true, this is only triggered when the mouse position intersects an item in the graph. This is very useful for combo charts where points are hidden behind bars.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ tooltips: {
+ mode: 'nearest'
+ }
+ }
+})
+```
+
+## single (deprecated)
+Finds the first item that intersects the point and returns it. Behaves like 'nearest' mode with intersect = true.
+
+## label (deprecated)
+See `'index'` mode
+
+## index
+Finds item at the same index. If the `intersect` setting is true, the first intersecting item is used to determine the index in the data. If `intersect` false the nearest item is used to determine the index.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ tooltips: {
+ mode: 'index'
+ }
+ }
+})
+```
+
+## x-axis (deprecated)
+Behaves like `'index'` mode with `intersect = false`.
+
+## dataset
+Finds items in the same dataset. If the `intersect` setting is true, the first intersecting item is used to determine the index in the data. If `intersect` false the nearest item is used to determine the index.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ tooltips: {
+ mode: 'dataset'
+ }
+ }
+})
+```
+
+## x
+Returns all items that would intersect based on the `X` coordinate of the position only. Would be useful for a vertical cursor implementation. Note that this only applies to cartesian charts
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ tooltips: {
+ mode: 'x'
+ }
+ }
+})
+```
+
+## y
+Returns all items that would intersect based on the `Y` coordinate of the position. This would be useful for a horizontal cursor implementation. Note that this only applies to cartesian charts.
+
+```javascript
+var chart = new Chart(ctx, {
+ type: 'line',
+ data: data,
+ options: {
+ tooltips: {
+ mode: 'y'
+ }
+ }
+})
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/general/responsive.md | @@ -0,0 +1,10 @@
+# Responsive Charts
+
+Chart.js provides a few options for controlling resizing behaviour of charts.
+
+| Name | Type | Default | Description
+| ---- | ---- | ------- | -----------
+| `responsive` | `Boolean` | `true` | Resizes the chart canvas when its 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.
+| `onResize` | `Function` | `null` | Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/getting-started/README.md | @@ -0,0 +1,43 @@
+# Getting Started
+
+Let's get started using Chart.js!
+
+First, we need to have a canvas in our page.
+
+```html
+<canvas id="myChart"></canvas>
+```
+
+Now that we have a canvas we can use, we need to include Chart.js in our page.
+
+```html
+<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js" />
+```
+
+Now, we can create a chart. We add a script to our page:
+
+```javascript
+var ctx = document.getElementById('myChart').getContext('2d');
+var chart = new Chart(ctx, {
+ // The type of chart we want to create
+ type: 'line',
+
+ // The data for our dataset
+ data: {
+ labels: ["January", "February", "March", "April", "May", "June", "July"],
+ datasets: [{
+ label: "My First dataset",
+ backgroundColor: 'rgb(255, 99, 132)',
+ borderColor: 'rgb(255, 99, 132)',
+ data: [0, 10, 5, 2, 20, 30, 45],
+ }]
+ },
+
+ // Configuration options go here
+ options: {}
+});
+```
+
+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.
+
+There are many examples of Chart.js that are available in the `/samples` folder of `Chart.js.zip` that is attatched to every [release](https://github.com/chartjs/Chart.js/releases).
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/getting-started/installation.md | @@ -0,0 +1,41 @@
+# Installation
+Chart.js can be installed via npm or bower. It is recommended to get Chart.js this way.
+
+## npm
+
+```bash
+npm install chart.js --save
+```
+
+## Bower
+
+```bash
+bower install chart.js --save
+```
+
+## CDN
+or just use these [Chart.js CDN](https://cdnjs.com/libraries/Chart.js) links.
+
+
+## Github
+You can download the latest version of [Chart.js on GitHub](https://github.com/chartjs/Chart.js/releases/latest).
+
+If you download or clone the repository, you must [build](../developers/contributing.md#building-chartjs) Chart.js to generate the dist files. Chart.js no longer comes with prebuilt release versions, so an alternative option to downloading the repo is **strongly** advised.
+
+# Selecting the Correct Build
+
+Chart.js provides two different builds that are available for your use.
+
+## Stand-Alone Build
+Files:
+* `dist/Chart.js`
+* `dist/Chart.min.js`
+
+This version only includes Chart.js. If this version is used and you require the use of the time axis, [Moment.js](http://momentjs.com/) will need to be included before Chart.js.
+
+## Bundled Build
+Files:
+* `dist/Chart.bundle.js`
+* `dist/Chart.bundle.min.js`
+
+The bundled version includes Moment.js built into the same file. This version should be used if you wish to use time axes and want a single file to include. Do not use this build if your application already includes Moment.js. If you do, Moment.js will be included twice, increasing the page load time and potentially introducing version issues.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/getting-started/integration.md | @@ -0,0 +1,34 @@
+# Integration
+
+Chart.js can be integrated with plain JavaScript or with different module loaders. The examples below show how to load Chart.js in different systems.
+
+## ES6 Modules
+
+```javascript
+import Chart from 'chart.js'
+var myChart = new Chart(ctx, {...})
+```
+
+## Script Tag
+
+```html
+<script src="path/to/Chartjs/dist/Chart.js"></script>
+<script>
+var myChart = new Chart(ctx, {...})
+</script>
+```
+
+## Common JS
+
+```javascript
+var Chart = require('chart.js')
+var myChart = new Chart(ctx, {...})
+```
+
+## Require JS
+
+```javascript
+require(['path/to/Chartjs/src/chartjs.js'], function(Chart){
+ var myChart = new Chart(ctx, {...})
+})
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/getting-started/usage.md | @@ -0,0 +1,65 @@
+# Usage
+Chart.js can be used with ES6 modules, plain JavaScript and module loaders.
+
+## Creating a Chart
+
+To create a chart, we need to instantiate the `Chart` class. To do this, we need to pass in the node, jQuery instance, or 2d context of the canvas of where we want to draw the chart. Here's an example.
+
+```html
+<canvas id="myChart" width="400" height="400"></canvas>
+```
+
+```javascript
+// Any of the following formats may be used
+var ctx = document.getElementById("myChart");
+var ctx = document.getElementById("myChart").getContext("2d");
+var ctx = $("#myChart");
+var ctx = "myChart";
+```
+
+Once you have the element or context, you're ready to instantiate a pre-defined chart-type or create your own!
+
+The following example instantiates a bar chart showing the number of votes for different colors and the y-axis starting at 0.
+
+```html
+<canvas id="myChart" width="400" height="400"></canvas>
+<script>
+var ctx = document.getElementById("myChart");
+var myChart = new Chart(ctx, {
+ type: 'bar',
+ data: {
+ labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
+ datasets: [{
+ label: '# of Votes',
+ data: [12, 19, 3, 5, 2, 3],
+ backgroundColor: [
+ 'rgba(255, 99, 132, 0.2)',
+ 'rgba(54, 162, 235, 0.2)',
+ 'rgba(255, 206, 86, 0.2)',
+ 'rgba(75, 192, 192, 0.2)',
+ 'rgba(153, 102, 255, 0.2)',
+ 'rgba(255, 159, 64, 0.2)'
+ ],
+ borderColor: [
+ 'rgba(255,99,132,1)',
+ 'rgba(54, 162, 235, 1)',
+ 'rgba(255, 206, 86, 1)',
+ 'rgba(75, 192, 192, 1)',
+ 'rgba(153, 102, 255, 1)',
+ 'rgba(255, 159, 64, 1)'
+ ],
+ borderWidth: 1
+ }]
+ },
+ options: {
+ scales: {
+ yAxes: [{
+ ticks: {
+ beginAtZero:true
+ }
+ }]
+ }
+ }
+});
+</script>
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/notes/README.md | @@ -0,0 +1 @@
+# Additional Notes
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/notes/comparison.md | @@ -0,0 +1,32 @@
+# Comparison with Other Charting Libraries
+
+Library Features
+
+| Feature | Chart.js | D3 | HighCharts | Chartist |
+| ------- | -------- | --- | ---------- | -------- |
+| Completely Free | ✓ | ✓ | | ✓ |
+| Canvas | ✓ | | | |
+| SVG | | ✓ | ✓ | ✓ |
+| Built-in Charts | ✓ | | ✓ | ✓ |
+| 8+ Chart Types | ✓ | ✓ | ✓ | |
+| Extendable to Custom Charts | ✓ | ✓ | | |
+| Supports Modern Browsers | ✓ | ✓ | ✓ | ✓ |
+| Extensive Documentation | ✓ | ✓ | ✓ | ✓ |
+| Open Source | ✓ | ✓ | ✓ | ✓ |
+
+Built in Chart Types
+
+| Type | Chart.js | HighCharts | Chartist |
+| ---- | -------- | ---------- | -------- |
+| Combined Types | ✓ | ✓ | |
+| Line | ✓ | ✓ | ✓ |
+| Bar | ✓ | ✓ | ✓ |
+| Horizontal Bar | ✓ | ✓ | ✓ |
+| Pie/Doughnut | ✓ | ✓ | ✓ |
+| Polar Area | ✓ | ✓ | |
+| Radar | ✓ | | |
+| Scatter | ✓ | ✓ | ✓ |
+| Bubble | ✓ | | |
+| Gauges | | ✓ | |
+| Maps (Heat/Tree/etc.) | | ✓ | |
+ | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/notes/extensions.md | @@ -0,0 +1,26 @@
+# Popular Extensions
+
+There are many extensions which are available for use with popular frameworks. Some particularly notable ones are listed here.
+
+## Angular
+ - <a href="https://github.com/jtblin/angular-chart.js" target="_blank">angular-chart.js</a>
+ - <a href="https://github.com/carlcraig/tc-angular-chartjs" target="_blank">tc-angular-chartjs</a>
+ - <a href="https://github.com/petermelias/angular-chartjs" target="_blank">angular-chartjs</a>
+ - <a href="https://github.com/earlonrails/angular-chartjs-directive" target="_blank">Angular Chart-js Directive</a>
+
+## React
+ - <a href="https://github.com/topdmc/react-chartjs2" target="_blank">react-chartjs2</a>
+ - <a href="https://github.com/gor181/react-chartjs-2" target="_blank">react-chartjs-2</a>
+
+## Django
+ - <a href="https://github.com/matthisk/django-jchart" target="_blank">Django JChart</a>
+ - <a href="https://github.com/novafloss/django-chartjs" target="_blank">Django Chartjs</a>
+
+## Ruby on Rails
+ - <a href="https://github.com/airblade/chartjs-ror" target="_blank">chartjs-ror</a>
+
+## Laravel
+ - <a href="https://github.com/fxcosta/laravel-chartjs" target="_blank">laravel-chartjs</a>
+
+#### Vue.js
+ - <a href="https://github.com/apertureless/vue-chartjs/" target="_blank">vue-chartjs</a> | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/notes/license.md | @@ -0,0 +1,3 @@
+# License
+
+Chart.js is <a href="https://github.com/chartjs/Chart.js" target="_blank">open source</a> and available under the <a href="http://opensource.org/licenses/MIT" target="_blank">MIT license</a>.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | docs/style.css | @@ -0,0 +1,11 @@
+a.anchorjs-link {
+ color: rgba(65, 131, 196, 0.1);
+ font-weight: 400;
+ text-decoration: none;
+ transition: color 100ms ease-out;
+ z-index: 999;
+}
+
+a.anchorjs-link:hover {
+ color: rgba(65, 131, 196, 1);
+} | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | gulpfile.js | @@ -11,7 +11,7 @@ var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var zip = require('gulp-zip');
-var exec = require('child_process').exec;
+var exec = require('child-process-promise').exec;
var karma = require('karma');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
@@ -41,6 +41,7 @@ gulp.task('package', packageTask);
gulp.task('coverage', coverageTask);
gulp.task('watch', watchTask);
gulp.task('lint', lintTask);
+gulp.task('docs', docsTask);
gulp.task('test', ['lint', 'validHTML', 'unittest']);
gulp.task('size', ['library-size', 'module-sizes']);
gulp.task('server', serverTask);
@@ -164,6 +165,19 @@ function lintTask() {
.pipe(eslint.failAfterError());
}
+function docsTask(done) {
+ const script = require.resolve('gitbook-cli/bin/gitbook.js');
+ const cmd = process.execPath;
+
+ exec([cmd, script, 'install', './'].join(' ')).then(() => {
+ return exec([cmd, script, 'build', './', './dist/docs'].join(' '));
+ }).catch((err) => {
+ console.error(err.stdout);
+ }).then(() => {
+ done();
+ });
+}
+
function validHTMLTask() {
return gulp.src('samples/*.html')
.pipe(htmlv()); | true |
Other | chartjs | Chart.js | 3e94b9431a5b3d6e4bfbfd6a2339a350999b3292.json | Update the docs structure/content to use GitBook (#3751)
Update the docs structure/content to use GitBook | package.json | @@ -13,7 +13,9 @@
"browserify": "^13.0.0",
"browserify-istanbul": "^0.2.1",
"bundle-collapser": "^1.2.1",
+ "child-process-promise": "^2.2.0",
"coveralls": "^2.11.6",
+ "gitbook-cli": "^2.3.0",
"gulp": "3.9.x",
"gulp-concat": "~2.1.x",
"gulp-connect": "~2.0.5", | true |
Other | chartjs | Chart.js | b92b256872e9d01ef56c9b8d4440cda784662fe0.json | Flatten animation object and fix callbacks
Animation callbacks now receives `animationObject` directly with a reference on the associated chart (`animation.chart`), which deprecates `animation.animationObject` and `animation.chartInstance`. Also fix missing `onComplete` animation argument and make sure that an animation object is passed even when animations are disabled. | docs/01-Chart-Configuration.md | @@ -339,29 +339,18 @@ Name | Type | Default | Description
--- |:---:| --- | ---
duration | Number | 1000 | The number of milliseconds an animation takes.
easing | String | "easeOutQuart" | Easing function to use. Available options are: `'linear'`, `'easeInQuad'`, `'easeOutQuad'`, `'easeInOutQuad'`, `'easeInCubic'`, `'easeOutCubic'`, `'easeInOutCubic'`, `'easeInQuart'`, `'easeOutQuart'`, `'easeInOutQuart'`, `'easeInQuint'`, `'easeOutQuint'`, `'easeInOutQuint'`, `'easeInSine'`, `'easeOutSine'`, `'easeInOutSine'`, `'easeInExpo'`, `'easeOutExpo'`, `'easeInOutExpo'`, `'easeInCirc'`, `'easeOutCirc'`, `'easeInOutCirc'`, `'easeInElastic'`, `'easeOutElastic'`, `'easeInOutElastic'`, `'easeInBack'`, `'easeOutBack'`, `'easeInOutBack'`, `'easeInBounce'`, `'easeOutBounce'`, `'easeInOutBounce'`. See [Robert Penner's easing equations](http://robertpenner.com/easing/).
-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`
+onProgress | Function | none | Callback called on each step of an animation. Passed a single argument, a `Chart.Animation` instance, see below.
+onComplete | Function | none | Callback called at the end of an animation. Passed a single argument, a `Chart.Animation` instance, see below.
#### 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/animation/progress-bar.html). This sample displays a progress bar showing how far along the animation is.
+The `onProgress` and `onComplete` callbacks are useful for synchronizing an external draw to the chart animation. The callback is passed a `Chart.Animation` instance:
```javascript
{
// Chart instance
chart,
- // 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,
@@ -382,6 +371,8 @@ The animation object passed to the callbacks is of type `Chart.Animation`. The o
}
```
+An example usage of these callbacks can be found on [Github](https://github.com/chartjs/Chart.js/blob/master/samples/animation/progress-bar.html): this sample displays a progress bar showing how far along the animation is.
+
### Element Configuration
The global options for elements are defined in `Chart.defaults.global.elements`. | true |
Other | chartjs | Chart.js | b92b256872e9d01ef56c9b8d4440cda784662fe0.json | Flatten animation object and fix callbacks
Animation callbacks now receives `animationObject` directly with a reference on the associated chart (`animation.chart`), which deprecates `animation.animationObject` and `animation.chartInstance`. Also fix missing `onComplete` animation argument and make sure that an animation object is passed even when animations are disabled. | samples/animation/progress-bar.html | @@ -33,12 +33,12 @@
borderColor: window.chartColors.red,
backgroundColor: window.chartColors.red,
data: [
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
randomScalingFactor()
]
}, {
@@ -47,12 +47,12 @@
borderColor: window.chartColors.blue,
backgroundColor: window.chartColors.blue,
data: [
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
- randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
+ randomScalingFactor(),
randomScalingFactor()
]
}]
@@ -65,7 +65,7 @@
animation: {
duration: 2000,
onProgress: function(animation) {
- progress.value = animation.animationObject.currentStep / animation.animationObject.numSteps;
+ progress.value = animation.currentStep / animation.numSteps;
},
onComplete: function(animation) {
window.setTimeout(function() { | true |
Other | chartjs | Chart.js | b92b256872e9d01ef56c9b8d4440cda784662fe0.json | Flatten animation object and fix callbacks
Animation callbacks now receives `animationObject` directly with a reference on the associated chart (`animation.chart`), which deprecates `animation.animationObject` and `animation.chartInstance`. Also fix missing `onComplete` animation argument and make sure that an animation object is passed even when animations are disabled. | src/core/core.animation.js | @@ -13,13 +13,14 @@ module.exports = function(Chart) {
};
Chart.Animation = Chart.Element.extend({
- currentStep: null, // the current animation step
+ chart: null, // the animation associated chart instance
+ currentStep: 0, // the current animation step
numSteps: 60, // default number of steps
easing: '', // the easing to use for this animation
render: null, // render function used by the animation service
onAnimationProgress: null, // user specified callback to fire on each step of the animation
- onAnimationComplete: null // user specified callback to fire when the animation finishes
+ onAnimationComplete: null, // user specified callback to fire when the animation finishes
});
Chart.animationService = {
@@ -29,49 +30,47 @@ module.exports = function(Chart) {
request: null,
/**
- * @function Chart.animationService.addAnimation
- * @param chart {ChartController} the chart to animate
- * @param animationObject {IAnimation} the animation that we will animate
- * @param duration {Number} length of animation in ms
- * @param lazy {Boolean} if true, the chart is not marked as animating to enable more responsive interactions
+ * @param {Chart} chart - The chart to animate.
+ * @param {Chart.Animation} animation - The animation that we will animate.
+ * @param {Number} duration - The animation duration in ms.
+ * @param {Boolean} lazy - if true, the chart is not marked as animating to enable more responsive interactions
*/
- addAnimation: function(chart, animationObject, duration, lazy) {
- var me = this;
+ addAnimation: function(chart, animation, duration, lazy) {
+ var animations = this.animations;
+ var i, ilen;
+
+ animation.chart = chart;
if (!lazy) {
chart.animating = true;
}
- for (var index = 0; index < me.animations.length; ++index) {
- if (me.animations[index].chart === chart) {
- // replacing an in progress animation
- me.animations[index].animationObject = animationObject;
+ for (i=0, ilen=animations.length; i < ilen; ++i) {
+ if (animations[i].chart === chart) {
+ animations[i] = animation;
return;
}
}
- me.animations.push({
- chart: chart,
- chartInstance: chart, // deprecated, backward compatibility
- animationObject: animationObject
- });
+ animations.push(animation);
// If there are no animations queued, manually kickstart a digest, for lack of a better word
- if (me.animations.length === 1) {
- me.requestAnimationFrame();
+ if (animations.length === 1) {
+ this.requestAnimationFrame();
}
},
- // Cancel the animation for a given chart instance
+
cancelAnimation: function(chart) {
- var index = helpers.findIndex(this.animations, function(animationWrapper) {
- return animationWrapper.chart === chart;
+ var index = helpers.findIndex(this.animations, function(animation) {
+ return animation.chart === chart;
});
if (index !== -1) {
this.animations.splice(index, 1);
chart.animating = false;
}
},
+
requestAnimationFrame: function() {
var me = this;
if (me.request === null) {
@@ -84,9 +83,12 @@ module.exports = function(Chart) {
});
}
},
+
+ /**
+ * @private
+ */
startDigest: function() {
var me = this;
-
var startTime = Date.now();
var framesToDrop = 0;
@@ -95,46 +97,72 @@ module.exports = function(Chart) {
me.dropFrames = me.dropFrames % 1;
}
- var i = 0;
- while (i < me.animations.length) {
- if (me.animations[i].animationObject.currentStep === null) {
- me.animations[i].animationObject.currentStep = 0;
- }
+ me.advance(1 + framesToDrop);
- me.animations[i].animationObject.currentStep += 1 + framesToDrop;
+ var endTime = Date.now();
- if (me.animations[i].animationObject.currentStep > me.animations[i].animationObject.numSteps) {
- me.animations[i].animationObject.currentStep = me.animations[i].animationObject.numSteps;
- }
+ me.dropFrames += (endTime - startTime) / me.frameDuration;
- me.animations[i].animationObject.render(me.animations[i].chart, me.animations[i].animationObject);
- if (me.animations[i].animationObject.onAnimationProgress && me.animations[i].animationObject.onAnimationProgress.call) {
- me.animations[i].animationObject.onAnimationProgress.call(me.animations[i].chart, me.animations[i]);
- }
+ // Do we have more stuff to animate?
+ if (me.animations.length > 0) {
+ me.requestAnimationFrame();
+ }
+ },
- if (me.animations[i].animationObject.currentStep === me.animations[i].animationObject.numSteps) {
- if (me.animations[i].animationObject.onAnimationComplete && me.animations[i].animationObject.onAnimationComplete.call) {
- me.animations[i].animationObject.onAnimationComplete.call(me.animations[i].chart, me.animations[i]);
- }
+ /**
+ * @private
+ */
+ advance: function(count) {
+ var animations = this.animations;
+ var animation, chart;
+ var i = 0;
+
+ while (i < animations.length) {
+ animation = animations[i];
+ chart = animation.chart;
+
+ animation.currentStep = (animation.currentStep || 0) + count;
+ animation.currentStep = Math.min(animation.currentStep, animation.numSteps);
- // executed the last frame. Remove the animation.
- me.animations[i].chart.animating = false;
+ helpers.callback(animation.render, [chart, animation], chart);
+ helpers.callback(animation.onAnimationProgress, [animation], chart);
- me.animations.splice(i, 1);
+ if (animation.currentStep >= animation.numSteps) {
+ helpers.callback(animation.onAnimationComplete, [animation], chart);
+ chart.animating = false;
+ animations.splice(i, 1);
} else {
++i;
}
}
+ }
+ };
- var endTime = Date.now();
- var dropFrames = (endTime - startTime) / me.frameDuration;
-
- me.dropFrames += dropFrames;
+ /**
+ * Provided for backward compatibility, use Chart.Animation instead
+ * @prop Chart.Animation#animationObject
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ */
+ Object.defineProperty(Chart.Animation.prototype, 'animationObject', {
+ get: function() {
+ return this;
+ }
+ });
- // Do we have more stuff to animate?
- if (me.animations.length > 0) {
- me.requestAnimationFrame();
- }
+ /**
+ * Provided for backward compatibility, use Chart.Animation#chart instead
+ * @prop Chart.Animation#chartInstance
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ */
+ Object.defineProperty(Chart.Animation.prototype, 'chartInstance', {
+ get: function() {
+ return this.chart;
+ },
+ set: function(value) {
+ this.chart = value;
}
- };
+ });
+
}; | true |
Other | chartjs | Chart.js | b92b256872e9d01ef56c9b8d4440cda784662fe0.json | Flatten animation object and fix callbacks
Animation callbacks now receives `animationObject` directly with a reference on the associated chart (`animation.chart`), which deprecates `animation.animationObject` and `animation.chartInstance`. Also fix missing `onComplete` animation argument and make sure that an animation object is passed even when animations are disabled. | src/core/core.controller.js | @@ -445,36 +445,34 @@ module.exports = function(Chart) {
}
var animationOptions = me.options.animation;
- var onComplete = function() {
+ var onComplete = function(animation) {
plugins.notify(me, 'afterRender');
- var callback = animationOptions && animationOptions.onComplete;
- if (callback && callback.call) {
- callback.call(me);
- }
+ helpers.callback(animationOptions && animationOptions.onComplete, [animation], me);
};
if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
- var animation = new Chart.Animation();
- animation.numSteps = (duration || animationOptions.duration) / 16.66; // 60 fps
- animation.easing = animationOptions.easing;
+ var animation = new Chart.Animation({
+ numSteps: (duration || animationOptions.duration) / 16.66, // 60 fps
+ easing: animationOptions.easing,
- // render function
- animation.render = function(chart, animationObject) {
- var easingFunction = helpers.easingEffects[animationObject.easing];
- var stepDecimal = animationObject.currentStep / animationObject.numSteps;
- var easeDecimal = easingFunction(stepDecimal);
+ render: function(chart, animationObject) {
+ var easingFunction = helpers.easingEffects[animationObject.easing];
+ var currentStep = animationObject.currentStep;
+ var stepDecimal = currentStep / animationObject.numSteps;
- chart.draw(easeDecimal, stepDecimal, animationObject.currentStep);
- };
+ chart.draw(easingFunction(stepDecimal), stepDecimal, currentStep);
+ },
- // user events
- animation.onAnimationProgress = animationOptions.onProgress;
- animation.onAnimationComplete = onComplete;
+ onAnimationProgress: animationOptions.onProgress,
+ onAnimationComplete: onComplete
+ });
Chart.animationService.addAnimation(me, animation, duration, lazy);
} else {
me.draw();
- onComplete();
+
+ // See https://github.com/chartjs/Chart.js/issues/3781
+ onComplete(new Chart.Animation({numSteps: 0, chart: me}));
}
return me; | true |
Other | chartjs | Chart.js | b92b256872e9d01ef56c9b8d4440cda784662fe0.json | Flatten animation object and fix callbacks
Animation callbacks now receives `animationObject` directly with a reference on the associated chart (`animation.chart`), which deprecates `animation.animationObject` and `animation.chartInstance`. Also fix missing `onComplete` animation argument and make sure that an animation object is passed even when animations are disabled. | src/core/core.helpers.js | @@ -957,9 +957,9 @@ module.exports = function(Chart) {
return true;
};
- helpers.callCallback = function(fn, args, _tArg) {
+ helpers.callback = function(fn, args, thisArg) {
if (fn && typeof fn.call === 'function') {
- fn.apply(_tArg, args);
+ fn.apply(thisArg, args);
}
};
helpers.getHoverColor = function(colorValue) {
@@ -968,4 +968,12 @@ module.exports = function(Chart) {
colorValue :
helpers.color(colorValue).saturate(0.5).darken(0.1).rgbString();
};
+
+ /**
+ * Provided for backward compatibility, use Chart.helpers#callback instead.
+ * @function Chart.helpers#callCallback
+ * @deprecated since version 2.6.0
+ * @todo remove at version 3
+ */
+ helpers.callCallback = helpers.callback;
}; | true |
Other | chartjs | Chart.js | b92b256872e9d01ef56c9b8d4440cda784662fe0.json | Flatten animation object and fix callbacks
Animation callbacks now receives `animationObject` directly with a reference on the associated chart (`animation.chart`), which deprecates `animation.animationObject` and `animation.chartInstance`. Also fix missing `onComplete` animation argument and make sure that an animation object is passed even when animations are disabled. | src/core/core.scale.js | @@ -93,7 +93,7 @@ module.exports = function(Chart) {
// Any function can be extended by the scale type
beforeUpdate: function() {
- helpers.callCallback(this.options.beforeUpdate, [this]);
+ helpers.callback(this.options.beforeUpdate, [this]);
},
update: function(maxWidth, maxHeight, margins) {
var me = this;
@@ -146,13 +146,13 @@ module.exports = function(Chart) {
},
afterUpdate: function() {
- helpers.callCallback(this.options.afterUpdate, [this]);
+ helpers.callback(this.options.afterUpdate, [this]);
},
//
beforeSetDimensions: function() {
- helpers.callCallback(this.options.beforeSetDimensions, [this]);
+ helpers.callback(this.options.beforeSetDimensions, [this]);
},
setDimensions: function() {
var me = this;
@@ -177,29 +177,29 @@ module.exports = function(Chart) {
me.paddingBottom = 0;
},
afterSetDimensions: function() {
- helpers.callCallback(this.options.afterSetDimensions, [this]);
+ helpers.callback(this.options.afterSetDimensions, [this]);
},
// Data limits
beforeDataLimits: function() {
- helpers.callCallback(this.options.beforeDataLimits, [this]);
+ helpers.callback(this.options.beforeDataLimits, [this]);
},
determineDataLimits: helpers.noop,
afterDataLimits: function() {
- helpers.callCallback(this.options.afterDataLimits, [this]);
+ helpers.callback(this.options.afterDataLimits, [this]);
},
//
beforeBuildTicks: function() {
- helpers.callCallback(this.options.beforeBuildTicks, [this]);
+ helpers.callback(this.options.beforeBuildTicks, [this]);
},
buildTicks: helpers.noop,
afterBuildTicks: function() {
- helpers.callCallback(this.options.afterBuildTicks, [this]);
+ helpers.callback(this.options.afterBuildTicks, [this]);
},
beforeTickToLabelConversion: function() {
- helpers.callCallback(this.options.beforeTickToLabelConversion, [this]);
+ helpers.callback(this.options.beforeTickToLabelConversion, [this]);
},
convertTicksToLabels: function() {
var me = this;
@@ -208,13 +208,13 @@ module.exports = function(Chart) {
me.ticks = me.ticks.map(tickOpts.userCallback || tickOpts.callback);
},
afterTickToLabelConversion: function() {
- helpers.callCallback(this.options.afterTickToLabelConversion, [this]);
+ helpers.callback(this.options.afterTickToLabelConversion, [this]);
},
//
beforeCalculateTickRotation: function() {
- helpers.callCallback(this.options.beforeCalculateTickRotation, [this]);
+ helpers.callback(this.options.beforeCalculateTickRotation, [this]);
},
calculateTickRotation: function() {
var me = this;
@@ -257,13 +257,13 @@ module.exports = function(Chart) {
me.labelRotation = labelRotation;
},
afterCalculateTickRotation: function() {
- helpers.callCallback(this.options.afterCalculateTickRotation, [this]);
+ helpers.callback(this.options.afterCalculateTickRotation, [this]);
},
//
beforeFit: function() {
- helpers.callCallback(this.options.beforeFit, [this]);
+ helpers.callback(this.options.beforeFit, [this]);
},
fit: function() {
var me = this;
@@ -381,7 +381,7 @@ module.exports = function(Chart) {
},
afterFit: function() {
- helpers.callCallback(this.options.afterFit, [this]);
+ helpers.callback(this.options.afterFit, [this]);
},
// Shared Methods | true |
Other | chartjs | Chart.js | b92b256872e9d01ef56c9b8d4440cda784662fe0.json | Flatten animation object and fix callbacks
Animation callbacks now receives `animationObject` directly with a reference on the associated chart (`animation.chart`), which deprecates `animation.animationObject` and `animation.chartInstance`. Also fix missing `onComplete` animation argument and make sure that an animation object is passed even when animations are disabled. | test/global.deprecations.tests.js | @@ -39,6 +39,53 @@ describe('Deprecations', function() {
expect(proxy.width).toBe(140);
});
});
+
+ describe('Chart.Animation.animationObject', function() {
+ it('should be defined and an alias of Chart.Animation', function(done) {
+ var animation = null;
+
+ acquireChart({
+ options: {
+ animation: {
+ duration: 50,
+ onComplete: function(arg) {
+ animation = arg;
+ }
+ }
+ }
+ });
+
+ setTimeout(function() {
+ expect(animation).not.toBeNull();
+ expect(animation.animationObject).toBeDefined();
+ expect(animation.animationObject).toBe(animation);
+ done();
+ }, 200);
+ });
+ });
+
+ describe('Chart.Animation.chartInstance', function() {
+ it('should be defined and an alias of Chart.Animation.chart', function(done) {
+ var animation = null;
+ var chart = acquireChart({
+ options: {
+ animation: {
+ duration: 50,
+ onComplete: function(arg) {
+ animation = arg;
+ }
+ }
+ }
+ });
+
+ setTimeout(function() {
+ expect(animation).not.toBeNull();
+ expect(animation.chartInstance).toBeDefined();
+ expect(animation.chartInstance).toBe(chart);
+ done();
+ }, 200);
+ });
+ });
});
describe('Version 2.5.0', function() { | true |
Other | chartjs | Chart.js | d25e7b1e1a250b225e6fb5a5fda3cf42153d3d93.json | Handle incoming model values on element transition
If a value is set on the model after `pivot()` has been called, the view wasn't initialized and the animation started from 0. Now, `_start` and incomplete `_view` are initialized to the model value during the transition (no initial implicit transition).
Also remove exception handling when animating a string (color), which is faster when string are not valid colors (e.g. tooltip position). It requires to update `chartjs-color` to version 2.1.0. | package.json | @@ -46,7 +46,7 @@
"main": "Chart.js"
},
"dependencies": {
- "chartjs-color": "~2.0.0",
+ "chartjs-color": "^2.1.0",
"moment": "^2.10.6"
}
} | true |
Other | chartjs | Chart.js | d25e7b1e1a250b225e6fb5a5fda3cf42153d3d93.json | Handle incoming model values on element transition
If a value is set on the model after `pivot()` has been called, the view wasn't initialized and the animation started from 0. Now, `_start` and incomplete `_view` are initialized to the model value during the transition (no initial implicit transition).
Also remove exception handling when animating a string (color), which is faster when string are not valid colors (e.g. tooltip position). It requires to update `chartjs-color` to version 2.1.0. | src/core/core.element.js | @@ -1,9 +1,60 @@
'use strict';
+var color = require('chartjs-color');
+
module.exports = function(Chart) {
var helpers = Chart.helpers;
+ function interpolate(start, view, model, ease) {
+ var keys = Object.keys(model);
+ var i, ilen, key, actual, origin, target, type, c0, c1;
+
+ for (i=0, ilen=keys.length; i<ilen; ++i) {
+ key = keys[i];
+
+ target = model[key];
+
+ // if a value is added to the model after pivot() has been called, the view
+ // doesn't contain it, so let's initialize the view to the target value.
+ if (!view.hasOwnProperty(key)) {
+ view[key] = target;
+ }
+
+ actual = view[key];
+
+ if (actual === target || key[0] === '_') {
+ continue;
+ }
+
+ if (!start.hasOwnProperty(key)) {
+ start[key] = actual;
+ }
+
+ origin = start[key];
+
+ type = typeof(target);
+
+ if (type === typeof(origin)) {
+ if (type === 'string') {
+ c0 = color(origin);
+ if (c0.valid) {
+ c1 = color(target);
+ if (c1.valid) {
+ view[key] = c1.mix(c0, ease).rgbString();
+ continue;
+ }
+ }
+ } else if (type === 'number' && isFinite(origin) && isFinite(target)) {
+ view[key] = origin + (target - origin) * ease;
+ continue;
+ }
+ }
+
+ view[key] = target;
+ }
+ }
+
Chart.elements = {};
Chart.Element = function(configuration) {
@@ -22,59 +73,32 @@ module.exports = function(Chart) {
if (!me._view) {
me._view = helpers.clone(me._model);
}
- me._start = helpers.clone(me._view);
+ me._start = {};
return me;
},
transition: function(ease) {
var me = this;
-
- if (!me._view) {
- me._view = helpers.clone(me._model);
- }
+ var model = me._model;
+ var start = me._start;
+ var view = me._view;
// No animation -> No Transition
- if (ease === 1) {
- me._view = me._model;
+ if (!model || ease === 1) {
+ me._view = model;
me._start = null;
return me;
}
- if (!me._start) {
- me.pivot();
+ if (!view) {
+ view = me._view = {};
}
- helpers.each(me._model, function(value, key) {
+ if (!start) {
+ start = me._start = {};
+ }
- if (key[0] === '_') {
- // Only non-underscored properties
- // Init if doesn't exist
- } else if (!me._view.hasOwnProperty(key)) {
- if (typeof value === 'number' && !isNaN(me._view[key])) {
- me._view[key] = value * ease;
- } else {
- me._view[key] = value;
- }
- // No unnecessary computations
- } else if (value === me._view[key]) {
- // It's the same! Woohoo!
- // Color transitions if possible
- } else if (typeof value === 'string') {
- try {
- var color = helpers.color(me._model[key]).mix(helpers.color(me._start[key]), ease);
- me._view[key] = color.rgbString();
- } catch (err) {
- me._view[key] = value;
- }
- // Number transitions
- } else if (typeof value === 'number') {
- var startVal = me._start[key] !== undefined && isNaN(me._start[key]) === false ? me._start[key] : 0;
- me._view[key] = ((me._model[key] - startVal) * ease) + startVal;
- // Everything else
- } else {
- me._view[key] = value;
- }
- }, me);
+ interpolate(start, view, model, ease);
return me;
},
@@ -92,5 +116,4 @@ module.exports = function(Chart) {
});
Chart.Element.extend = helpers.inherits;
-
}; | true |
Other | chartjs | Chart.js | d25e7b1e1a250b225e6fb5a5fda3cf42153d3d93.json | Handle incoming model values on element transition
If a value is set on the model after `pivot()` has been called, the view wasn't initialized and the animation started from 0. Now, `_start` and incomplete `_view` are initialized to the model value during the transition (no initial implicit transition).
Also remove exception handling when animating a string (color), which is faster when string are not valid colors (e.g. tooltip position). It requires to update `chartjs-color` to version 2.1.0. | src/core/core.helpers.js | @@ -911,19 +911,21 @@ module.exports = function(Chart) {
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
};
- helpers.color = function(c) {
- if (!color) {
+
+ helpers.color = !color?
+ function(value) {
console.error('Color.js not found!');
- return c;
- }
+ return value;
+ } :
+ function(value) {
+ /* global CanvasGradient */
+ if (value instanceof CanvasGradient) {
+ value = Chart.defaults.global.defaultColor;
+ }
- /* global CanvasGradient */
- if (c instanceof CanvasGradient) {
- return color(Chart.defaults.global.defaultColor);
- }
+ return color(value);
+ };
- return color(c);
- };
helpers.isArray = Array.isArray?
function(obj) {
return Array.isArray(obj); | true |
Other | chartjs | Chart.js | d25e7b1e1a250b225e6fb5a5fda3cf42153d3d93.json | Handle incoming model values on element transition
If a value is set on the model after `pivot()` has been called, the view wasn't initialized and the animation started from 0. Now, `_start` and incomplete `_view` are initialized to the model value during the transition (no initial implicit transition).
Also remove exception handling when animating a string (color), which is faster when string are not valid colors (e.g. tooltip position). It requires to update `chartjs-color` to version 2.1.0. | test/core.element.tests.js | @@ -16,11 +16,9 @@ describe('Core element tests', function() {
// First transition clones model into view
element.transition(0.25);
- expect(element._view).toEqual(element._model);
- expect(element._start).toEqual(element._model); // also cloned
+ expect(element._view).toEqual(element._model);
expect(element._view.objectProp).toBe(element._model.objectProp); // not cloned
- expect(element._start.objectProp).toEqual(element._model.objectProp); // not cloned
element._model.numberProp = 100;
element._model.numberProp2 = 250;
@@ -30,6 +28,7 @@ describe('Core element tests', function() {
element._model.colorProp = 'rgb(255, 255, 0)';
element.transition(0.25);
+
expect(element._view).toEqual({
numberProp: 25,
numberProp2: 137.5, | true |
Other | chartjs | Chart.js | b50eac366dbde8c376f9fddc104726936a720628.json | Add test for layout service weight ordering | test/core.layoutService.tests.js | @@ -390,4 +390,43 @@ describe('Test the layout service', function() {
expect(chart.chartArea.top).toBeCloseToPixel(0);
});
});
+
+ describe('ordering by weight', function() {
+ it('should keep higher weights outside', function() {
+ var chart = window.acquireChart({
+ type: 'bar',
+ data: {
+ datasets: [
+ {
+ data: [10, 5, 0, 25, 78, -10]
+ }
+ ],
+ labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5', 'tick6']
+ },
+ options: {
+ legend: {
+ display: true,
+ position: 'left',
+ },
+ title: {
+ display: true,
+ position: 'bottom',
+ },
+ },
+ }, {
+ canvas: {
+ height: 150,
+ width: 250
+ }
+ });
+
+ var xAxis = chart.scales['x-axis-0'];
+ var yAxis = chart.scales['y-axis-0'];
+ var legend = chart.legend;
+ var title = chart.titleBlock;
+
+ expect(yAxis.left).toBe(legend.right);
+ expect(xAxis.bottom).toBe(title.top);
+ });
+ });
}); | false |
Other | chartjs | Chart.js | 2ddd5ff88c041042826f45382623bf4fc94db320.json | Fix use of reserved keyword as a parameter name | src/platforms/platform.dom.js | @@ -92,11 +92,11 @@ module.exports = function(Chart) {
return canvas;
}
- function createEvent(type, chart, x, y, native) {
+ function createEvent(type, chart, x, y, nativeEvent) {
return {
type: type,
chart: chart,
- native: native || null,
+ native: nativeEvent || null,
x: x !== undefined? x : null,
y: y !== undefined? y : null,
}; | false |
Other | chartjs | Chart.js | dfcf874735cb2cd7ed3e395ce66a6a89172c6d1c.json | Update initial sample with colours | docs/00-Getting-Started.md | @@ -84,7 +84,24 @@ var myChart = new Chart(ctx, {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
- data: [12, 19, 3, 5, 2, 3]
+ data: [12, 19, 3, 5, 2, 3],
+ backgroundColor: [
+ 'rgba(255, 99, 132, 0.2)',
+ 'rgba(54, 162, 235, 0.2)',
+ 'rgba(255, 206, 86, 0.2)',
+ 'rgba(75, 192, 192, 0.2)',
+ 'rgba(153, 102, 255, 0.2)',
+ 'rgba(255, 159, 64, 0.2)'
+ ],
+ borderColor: [
+ 'rgba(255,99,132,1)',
+ 'rgba(54, 162, 235, 1)',
+ 'rgba(255, 206, 86, 1)',
+ 'rgba(75, 192, 192, 1)',
+ 'rgba(153, 102, 255, 1)',
+ 'rgba(255, 159, 64, 1)'
+ ],
+ borderWidth: 1
}]
},
options: { | false |
Other | chartjs | Chart.js | 966d7376171a6b398ae78812c89740af994c7417.json | Fix handling of moments by scale.getRightValue
When using {x: moment, y: value} datapoints | src/core/core.scale.js | @@ -396,7 +396,7 @@ module.exports = function(Chart) {
}
// If it is in fact an object, dive in one more level
if (typeof(rawValue) === "object") {
- if (rawValue instanceof Date) {
+ if ((rawValue instanceof Date) || (rawValue.isValid)) {
return rawValue;
} else {
return getRightValue(this.isHorizontal() ? rawValue.x : rawValue.y); | false |
Other | chartjs | Chart.js | 529ebedc906d33af9fba44d8b642c6491fa7c852.json | Add BrowserStack mention to readme and website | README.md | @@ -31,6 +31,8 @@ For support using Chart.js, please post questions with the [`chartjs` tag on Sta
## Building and Testing
`gulp build`, `gulp test`
+Thanks to [BrowserStack](https://browserstack.com) for allowing our team to test on thousands of browsers.
+
## License
Chart.js is available under the [MIT license](http://opensource.org/licenses/MIT). | true |
Other | chartjs | Chart.js | 529ebedc906d33af9fba44d8b642c6491fa7c852.json | Add BrowserStack mention to readme and website | docs/08-Notes.md | @@ -14,6 +14,8 @@ Chart.js offers support for all browsers where canvas is supported.
Browser support for the canvas element is available in all modern & major mobile browsers <a href="http://caniuse.com/#feat=canvas" target="_blank">(http://caniuse.com/#feat=canvas)</a>.
+Thanks to <a href="https://browserstack.com" target="_blank">BrowserStack</a> for allowing our team to test on thousands of browsers.
+
### Bugs & issues
| true |
Other | chartjs | Chart.js | 69521477a1f77c8c149c166c5c6b77a93bb3a009.json | Remove useless hasOwnProperty checks
The Chart.helpers.each method uses Object.keys() to iterates on the object *own enumerable properties*, meaning that checking if object.hasOwnProperty() is useless. | src/core/core.element.js | @@ -39,7 +39,7 @@ module.exports = function(Chart) {
helpers.each(this._model, function(value, key) {
- if (key[0] === '_' || !this._model.hasOwnProperty(key)) {
+ if (key[0] === '_') {
// Only non-underscored properties
}
| true |
Other | chartjs | Chart.js | 69521477a1f77c8c149c166c5c6b77a93bb3a009.json | Remove useless hasOwnProperty checks
The Chart.helpers.each method uses Object.keys() to iterates on the object *own enumerable properties*, meaning that checking if object.hasOwnProperty() is useless. | src/core/core.helpers.js | @@ -35,14 +35,12 @@ module.exports = function(Chart) {
helpers.clone = function(obj) {
var objClone = {};
helpers.each(obj, function(value, key) {
- if (obj.hasOwnProperty(key)) {
- if (helpers.isArray(value)) {
- objClone[key] = value.slice(0);
- } else if (typeof value === 'object' && value !== null) {
- objClone[key] = helpers.clone(value);
- } else {
- objClone[key] = value;
- }
+ if (helpers.isArray(value)) {
+ objClone[key] = value.slice(0);
+ } else if (typeof value === 'object' && value !== null) {
+ objClone[key] = helpers.clone(value);
+ } else {
+ objClone[key] = value;
}
});
return objClone;
@@ -55,9 +53,7 @@ module.exports = function(Chart) {
}
helpers.each(additionalArgs, function(extensionObject) {
helpers.each(extensionObject, function(value, key) {
- if (extensionObject.hasOwnProperty(key)) {
- base[key] = value;
- }
+ base[key] = value;
});
});
return base;
@@ -67,42 +63,40 @@ module.exports = function(Chart) {
var base = helpers.clone(_base);
helpers.each(Array.prototype.slice.call(arguments, 1), function(extension) {
helpers.each(extension, function(value, key) {
- if (extension.hasOwnProperty(key)) {
- if (key === 'scales') {
- // Scale config merging is complex. Add out own function here for that
- base[key] = helpers.scaleMerge(base.hasOwnProperty(key) ? base[key] : {}, value);
-
- } else if (key === 'scale') {
- // Used in polar area & radar charts since there is only one scale
- base[key] = helpers.configMerge(base.hasOwnProperty(key) ? base[key] : {}, Chart.scaleService.getScaleDefaults(value.type), value);
- } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) {
- // In this case we have an array of objects replacing another array. Rather than doing a strict replace,
- // merge. This allows easy scale option merging
- var baseArray = base[key];
-
- helpers.each(value, function(valueObj, index) {
-
- if (index < baseArray.length) {
- if (typeof baseArray[index] === 'object' && baseArray[index] !== null && typeof valueObj === 'object' && valueObj !== null) {
- // Two objects are coming together. Do a merge of them.
- baseArray[index] = helpers.configMerge(baseArray[index], valueObj);
- } else {
- // Just overwrite in this case since there is nothing to merge
- baseArray[index] = valueObj;
- }
+ if (key === 'scales') {
+ // Scale config merging is complex. Add out own function here for that
+ base[key] = helpers.scaleMerge(base.hasOwnProperty(key) ? base[key] : {}, value);
+
+ } else if (key === 'scale') {
+ // Used in polar area & radar charts since there is only one scale
+ base[key] = helpers.configMerge(base.hasOwnProperty(key) ? base[key] : {}, Chart.scaleService.getScaleDefaults(value.type), value);
+ } else if (base.hasOwnProperty(key) && helpers.isArray(base[key]) && helpers.isArray(value)) {
+ // In this case we have an array of objects replacing another array. Rather than doing a strict replace,
+ // merge. This allows easy scale option merging
+ var baseArray = base[key];
+
+ helpers.each(value, function(valueObj, index) {
+
+ if (index < baseArray.length) {
+ if (typeof baseArray[index] === 'object' && baseArray[index] !== null && typeof valueObj === 'object' && valueObj !== null) {
+ // Two objects are coming together. Do a merge of them.
+ baseArray[index] = helpers.configMerge(baseArray[index], valueObj);
} else {
- baseArray.push(valueObj); // nothing to merge
+ // Just overwrite in this case since there is nothing to merge
+ baseArray[index] = valueObj;
}
- });
+ } else {
+ baseArray.push(valueObj); // nothing to merge
+ }
+ });
- } else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
- // If we are overwriting an object with an object, do a merge of the properties.
- base[key] = helpers.configMerge(base[key], value);
+ } else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
+ // If we are overwriting an object with an object, do a merge of the properties.
+ base[key] = helpers.configMerge(base[key], value);
- } else {
- // can just overwrite the value in this case
- base[key] = value;
- }
+ } else {
+ // can just overwrite the value in this case
+ base[key] = value;
}
});
});
@@ -131,38 +125,36 @@ module.exports = function(Chart) {
var base = helpers.clone(_base);
helpers.each(extension, function(value, key) {
- if (extension.hasOwnProperty(key)) {
- if (key === 'xAxes' || key === 'yAxes') {
- // These properties are arrays of items
- if (base.hasOwnProperty(key)) {
- helpers.each(value, function(valueObj, index) {
- var axisType = helpers.getValueOrDefault(valueObj.type, key === 'xAxes' ? 'category' : 'linear');
- var axisDefaults = Chart.scaleService.getScaleDefaults(axisType);
- if (index >= base[key].length || !base[key][index].type) {
- base[key].push(helpers.configMerge(axisDefaults, valueObj));
- } else if (valueObj.type && valueObj.type !== base[key][index].type) {
- // Type changed. Bring in the new defaults before we bring in valueObj so that valueObj can override the correct scale defaults
- base[key][index] = helpers.configMerge(base[key][index], axisDefaults, valueObj);
- } else {
- // Type is the same
- base[key][index] = helpers.configMerge(base[key][index], valueObj);
- }
- });
- } else {
- base[key] = [];
- helpers.each(value, function(valueObj) {
- var axisType = helpers.getValueOrDefault(valueObj.type, key === 'xAxes' ? 'category' : 'linear');
- base[key].push(helpers.configMerge(Chart.scaleService.getScaleDefaults(axisType), valueObj));
- });
- }
- } else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
- // If we are overwriting an object with an object, do a merge of the properties.
- base[key] = helpers.configMerge(base[key], value);
-
+ if (key === 'xAxes' || key === 'yAxes') {
+ // These properties are arrays of items
+ if (base.hasOwnProperty(key)) {
+ helpers.each(value, function(valueObj, index) {
+ var axisType = helpers.getValueOrDefault(valueObj.type, key === 'xAxes' ? 'category' : 'linear');
+ var axisDefaults = Chart.scaleService.getScaleDefaults(axisType);
+ if (index >= base[key].length || !base[key][index].type) {
+ base[key].push(helpers.configMerge(axisDefaults, valueObj));
+ } else if (valueObj.type && valueObj.type !== base[key][index].type) {
+ // Type changed. Bring in the new defaults before we bring in valueObj so that valueObj can override the correct scale defaults
+ base[key][index] = helpers.configMerge(base[key][index], axisDefaults, valueObj);
+ } else {
+ // Type is the same
+ base[key][index] = helpers.configMerge(base[key][index], valueObj);
+ }
+ });
} else {
- // can just overwrite the value in this case
- base[key] = value;
+ base[key] = [];
+ helpers.each(value, function(valueObj) {
+ var axisType = helpers.getValueOrDefault(valueObj.type, key === 'xAxes' ? 'category' : 'linear');
+ base[key].push(helpers.configMerge(Chart.scaleService.getScaleDefaults(axisType), valueObj));
+ });
}
+ } else if (base.hasOwnProperty(key) && typeof base[key] === "object" && base[key] !== null && typeof value === "object") {
+ // If we are overwriting an object with an object, do a merge of the properties.
+ base[key] = helpers.configMerge(base[key], value);
+
+ } else {
+ // can just overwrite the value in this case
+ base[key] = value;
}
});
| true |
Other | chartjs | Chart.js | 974ff00464d7743182f842a2c7786c334b9ca82c.json | Fix syntax error in docs (#2572) | docs/00-Getting-Started.md | @@ -259,7 +259,7 @@ 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 fillPattern = ctx.createPattern(img, 'repeat');
var chart = new Chart(ctx, {
data: { | false |
Other | chartjs | Chart.js | 6bb6e5aa4b110bf4f084747691b145a1caefb63a.json | Improve tick width for vertical bars | src/controllers/controller.bar.js | @@ -120,7 +120,7 @@ module.exports = function(Chart) {
// Appearance
base: reset ? yScalePoint : this.calculateBarBase(this.index, index),
- width: this.calculateBarWidth(numBars),
+ width: this.calculateBarWidth(index),
backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.getValueAtIndexOrDefault(dataset.backgroundColor, index, rectangleElementOptions.backgroundColor),
borderSkipped: custom.borderSkipped ? custom.borderSkipped : rectangleElementOptions.borderSkipped,
borderColor: custom.borderColor ? custom.borderColor : helpers.getValueAtIndexOrDefault(dataset.borderColor, index, rectangleElementOptions.borderColor),
@@ -177,19 +177,20 @@ module.exports = function(Chart) {
},
- getRuler: function() {
+ getRuler: function(index) {
var meta = this.getMeta();
var xScale = this.getScaleForId(meta.xAxisID);
var yScale = this.getScaleForId(meta.yAxisID);
var datasetCount = this.getBarCount();
- var tickWidth = (function() {
- var min = xScale.getPixelForTick(1) - xScale.getPixelForTick(0);
- for (var i = 2; i < xScale.ticks.length; i++) {
- min = Math.min(xScale.getPixelForTick(i) - xScale.getPixelForTick(i - 1), min);
- }
- return min;
- }).call(this);
+ var tickWidth;
+
+ if (xScale.options.type === 'category') {
+ tickWidth = xScale.getPixelForTick(index + 1) - xScale.getPixelForTick(index);
+ } else {
+ // Average width
+ tickWidth = xScale.width / xScale.ticks.length;
+ }
var categoryWidth = tickWidth * xScale.options.categoryPercentage;
var categorySpacing = (tickWidth - (tickWidth * xScale.options.categoryPercentage)) / 2;
var fullBarWidth = categoryWidth / datasetCount;
@@ -213,9 +214,9 @@ module.exports = function(Chart) {
};
},
- calculateBarWidth: function() {
+ calculateBarWidth: function(index) {
var xScale = this.getScaleForId(this.getMeta().xAxisID);
- var ruler = this.getRuler();
+ var ruler = this.getRuler(index);
return xScale.options.stacked ? ruler.categoryWidth : ruler.barWidth;
},
@@ -240,7 +241,7 @@ module.exports = function(Chart) {
var xScale = this.getScaleForId(meta.xAxisID);
var barIndex = this.getBarIndex(datasetIndex);
- var ruler = this.getRuler();
+ var ruler = this.getRuler(index);
var leftTick = xScale.getPixelForValue(null, index, datasetIndex, this.chart.isCombo);
leftTick -= this.chart.isCombo ? (ruler.tickWidth / 2) : 0;
| false |
Other | chartjs | Chart.js | 568c61c56d733a5cc66fd128d1559b6b3cd075e9.json | fix docs for tension | docs/00-Getting-Started.md | @@ -215,7 +215,7 @@ arc | Object | - | -
*arc*.borderColor | Color | "#fff" | Default stroke color for arcs
*arc*.borderWidth | Number | 2 | Default stroke width for arcs
line | Object | - | -
-*line*.lineTension | Number | 0.4 | Default bezier curve tension. Set to `0` for no bezier curves.
+*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 | false |
Other | chartjs | Chart.js | 2575ed0c1c7229afe01cb966ff715a791934abe8.json | Add issue & pull request template files (#2534) | .github/ISSUE_TEMPLATE.md | @@ -0,0 +1,2 @@
+- [ ] I have read the [guidelines for contributing](https://github.com/chartjs/Chart.js/blob/master/CONTRIBUTING.md)
+- [ ] I have included an example of my issue on a website such as [JS Bin](http://jsbin.com/), [JS Fiddle](http://jsfiddle.net/), or [Codepen](http://codepen.io/pen/). ([Template](http://codepen.io/pen?template=JXVYzq))
\ No newline at end of file | true |
Other | chartjs | Chart.js | 2575ed0c1c7229afe01cb966ff715a791934abe8.json | Add issue & pull request template files (#2534) | .github/PULL_REQUEST_TEMPLATE.md | @@ -0,0 +1,2 @@
+- [ ] I have read the [guidelines for contributing](https://github.com/chartjs/Chart.js/blob/master/CONTRIBUTING.md)
+- [ ] I have included an example of my changes on a website such as [JS Bin](http://jsbin.com/), [JS Fiddle](http://jsfiddle.net/), or [Codepen](http://codepen.io/pen/). ([Template](http://codepen.io/pen?template=JXVYzq))
\ No newline at end of file | true |
Other | chartjs | Chart.js | 691a7c6a4bef0c6e0b8d1c82bafd4e2807239fac.json | Update doc files for ticks.minRotation | docs/01-Scales.md | @@ -53,6 +53,7 @@ afterUpdate | Function | undefined | Callback that runs at the end of the update
*ticks*.fontFamily | String | "Helvetica Neue" | Font family for the tick labels, follows CSS font-family options.
*ticks*.fontSize | Number | 12 | Font size for the tick labels.
*ticks*.fontStyle | String | "normal" | Font style for the tick labels, follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit).
+*ticks*.minRotation | Number | 0 | Minimum rotation for tick labels
*ticks*.maxRotation | Number | 90 | Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. *Note: Only applicable to horizontal scales.*
*ticks*.minRotation | Number | 20 | *currently not-implemented* Minimum rotation for tick labels when condensing is necessary. *Note: Only applicable to horizontal scales.*
*ticks*.maxTicksLimit | Number | 11 | Maximum number of ticks and gridlines to show. If not defined, it will limit to 11 ticks but will show all gridlines. | false |
Other | chartjs | Chart.js | e519ea399d7e05b96fcfa2d8cbd295ad66690b8a.json | Fix color dependency for builds | package.json | @@ -46,7 +46,7 @@
"main": "Chart.js"
},
"dependencies": {
- "chartjs-color": "^2.0.0",
+ "chartjs-color": "~2.0.0",
"moment": "^2.10.6"
}
} | false |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | .gitignore | @@ -9,4 +9,5 @@
.vscode
bower.json
+*.log
*.swp | true |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | src/controllers/controller.bar.js | @@ -248,19 +248,20 @@ module.exports = function(Chart) {
return yScale.getPixelForValue(value);
},
- draw: function(ease) {
+ draw: function() {
var me = this;
var chart = me.chart;
- var easingDecimal = ease || 1;
- var metaData = me.getMeta().data;
+ var elements = me.getMeta().data;
var dataset = me.getDataset();
- var i, len;
+ var ilen = elements.length;
+ var i = 0;
+ var d;
Chart.canvasHelpers.clipArea(chart.ctx, chart.chartArea);
- for (i = 0, len = metaData.length; i < len; ++i) {
- var d = dataset.data[i];
+ for (; i<ilen; ++i) {
+ d = dataset.data[i];
if (d !== null && d !== undefined && !isNaN(d)) {
- metaData[i].transition(easingDecimal).draw();
+ elements[i].draw();
}
}
Chart.canvasHelpers.unclipArea(chart.ctx); | true |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | src/controllers/controller.line.js | @@ -280,29 +280,26 @@ module.exports = function(Chart) {
}
},
- draw: function(ease) {
+ draw: function() {
var me = this;
var chart = me.chart;
var meta = me.getMeta();
var points = meta.data || [];
- var easingDecimal = ease || 1;
- var i, ilen;
+ var area = chart.chartArea;
+ var ilen = points.length;
+ var i = 0;
- // Transition Point Locations
- for (i=0, ilen=points.length; i<ilen; ++i) {
- points[i].transition(easingDecimal);
- }
+ Chart.canvasHelpers.clipArea(chart.ctx, area);
- Chart.canvasHelpers.clipArea(chart.ctx, chart.chartArea);
- // Transition and Draw the line
if (lineEnabled(me.getDataset(), chart.options)) {
- meta.dataset.transition(easingDecimal).draw();
+ meta.dataset.draw();
}
+
Chart.canvasHelpers.unclipArea(chart.ctx);
// Draw the points
- for (i=0, ilen=points.length; i<ilen; ++i) {
- points[i].draw(chart.chartArea);
+ for (; i<ilen; ++i) {
+ points[i].draw(area);
}
},
| true |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | src/controllers/controller.radar.js | @@ -134,24 +134,6 @@ module.exports = function(Chart) {
});
},
- draw: function(ease) {
- var meta = this.getMeta();
- var easingDecimal = ease || 1;
-
- // Transition Point Locations
- helpers.each(meta.data, function(point) {
- point.transition(easingDecimal);
- });
-
- // Transition and Draw the line
- meta.dataset.transition(easingDecimal).draw();
-
- // Draw the points
- helpers.each(meta.data, function(point) {
- point.draw();
- });
- },
-
setHoverStyle: function(point) {
// Point
var dataset = this.chart.data.datasets[point._datasetIndex]; | true |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | src/core/core.controller.js | @@ -409,12 +409,34 @@ module.exports = function(Chart) {
}
for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
- me.getDatasetMeta(i).controller.update();
+ me.updateDataset(i);
}
plugins.notify(me, 'afterDatasetsUpdate');
},
+ /**
+ * Updates dataset at index unless a plugin returns `false` to the `beforeDatasetUpdate`
+ * hook, in which case, plugins will not be called on `afterDatasetUpdate`.
+ * @private
+ */
+ updateDataset: function(index) {
+ var me = this;
+ var meta = me.getDatasetMeta(index);
+ var args = {
+ meta: meta,
+ index: index
+ };
+
+ if (plugins.notify(me, 'beforeDatasetUpdate', [args]) === false) {
+ return;
+ }
+
+ meta.controller.update();
+
+ plugins.notify(me, 'afterDatasetUpdate', [args]);
+ },
+
render: function(duration, lazy) {
var me = this;
@@ -467,6 +489,8 @@ module.exports = function(Chart) {
easingValue = 1;
}
+ me.transition(easingValue);
+
if (plugins.notify(me, 'beforeDraw', [easingValue]) === false) {
return;
}
@@ -483,11 +507,26 @@ module.exports = function(Chart) {
me.drawDatasets(easingValue);
// Finally draw the tooltip
- me.tooltip.transition(easingValue).draw();
+ me.tooltip.draw();
plugins.notify(me, 'afterDraw', [easingValue]);
},
+ /**
+ * @private
+ */
+ transition: function(easingValue) {
+ var me = this;
+
+ for (var i=0, ilen=(me.data.datasets || []).length; i<ilen; ++i) {
+ if (me.isDatasetVisible(i)) {
+ me.getDatasetMeta(i).controller.transition(easingValue);
+ }
+ }
+
+ me.tooltip.transition(easingValue);
+ },
+
/**
* Draws all datasets unless a plugin returns `false` to the `beforeDatasetsDraw`
* hook, in which case, plugins will not be called on `afterDatasetsDraw`.
@@ -500,16 +539,39 @@ module.exports = function(Chart) {
return;
}
- // Draw each dataset via its respective controller (reversed to support proper line stacking)
- helpers.each(me.data.datasets, function(dataset, datasetIndex) {
- if (me.isDatasetVisible(datasetIndex)) {
- me.getDatasetMeta(datasetIndex).controller.draw(easingValue);
+ // Draw datasets reversed to support proper line stacking
+ for (var i=(me.data.datasets || []).length - 1; i >= 0; --i) {
+ if (me.isDatasetVisible(i)) {
+ me.drawDataset(i, easingValue);
}
- }, me, true);
+ }
plugins.notify(me, 'afterDatasetsDraw', [easingValue]);
},
+ /**
+ * Draws dataset at index unless a plugin returns `false` to the `beforeDatasetDraw`
+ * hook, in which case, plugins will not be called on `afterDatasetDraw`.
+ * @private
+ */
+ drawDataset: function(index, easingValue) {
+ var me = this;
+ var meta = me.getDatasetMeta(index);
+ var args = {
+ meta: meta,
+ index: index,
+ easingValue: easingValue
+ };
+
+ if (plugins.notify(me, 'beforeDatasetDraw', [args]) === false) {
+ return;
+ }
+
+ meta.controller.draw(easingValue);
+
+ plugins.notify(me, 'afterDatasetDraw', [args]);
+ },
+
// Get the single element that was clicked on
// @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
getElementAtEvent: function(e) { | true |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | src/core/core.datasetController.js | @@ -208,12 +208,33 @@ module.exports = function(Chart) {
update: helpers.noop,
- draw: function(ease) {
- var easingDecimal = ease || 1;
- var i, len;
- var metaData = this.getMeta().data;
- for (i = 0, len = metaData.length; i < len; ++i) {
- metaData[i].transition(easingDecimal).draw();
+ transition: function(easingValue) {
+ var meta = this.getMeta();
+ var elements = meta.data || [];
+ var ilen = elements.length;
+ var i = 0;
+
+ for (; i<ilen; ++i) {
+ elements[i].transition(easingValue);
+ }
+
+ if (meta.dataset) {
+ meta.dataset.transition(easingValue);
+ }
+ },
+
+ draw: function() {
+ var meta = this.getMeta();
+ var elements = meta.data || [];
+ var ilen = elements.length;
+ var i = 0;
+
+ if (meta.dataset) {
+ meta.dataset.draw();
+ }
+
+ for (; i<ilen; ++i) {
+ elements[i].draw();
}
},
| true |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | src/core/core.plugin.js | @@ -209,6 +209,27 @@ module.exports = function(Chart) {
* @param {Object} options - The plugin options.
* @since version 2.1.5
*/
+ /**
+ * @method IPlugin#beforeDatasetUpdate
+ * @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
+ * returns `false`, the datasets update is cancelled until another `update` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.index - The dataset index.
+ * @param {Number} args.meta - The dataset metadata.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetUpdate
+ * @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
+ * that this hook will not be called if the datasets update has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.index - The dataset index.
+ * @param {Number} args.meta - The dataset metadata.
+ * @param {Object} options - The plugin options.
+ */
/**
* @method IPlugin#beforeLayout
* @desc Called before laying out `chart`. If any plugin returns `false`,
@@ -274,6 +295,31 @@ module.exports = function(Chart) {
* @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
* @param {Object} options - The plugin options.
*/
+ /**
+ * @method IPlugin#beforeDatasetDraw
+ * @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
+ * are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
+ * is cancelled until another `render` is triggered.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.index - The dataset index.
+ * @param {Number} args.meta - The dataset metadata.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ * @returns {Boolean} `false` to cancel the chart datasets drawing.
+ */
+ /**
+ * @method IPlugin#afterDatasetDraw
+ * @desc Called after the `chart` datasets at the given `args.index` have been drawn
+ * (datasets are drawn in the reverse order). Note that this hook will not be called
+ * if the datasets drawing has been previously cancelled.
+ * @param {Chart} chart - The chart instance.
+ * @param {Object} args - The call arguments.
+ * @param {Object} args.index - The dataset index.
+ * @param {Number} args.meta - The dataset metadata.
+ * @param {Number} args.easingValue - The current animation value, between 0.0 and 1.0.
+ * @param {Object} options - The plugin options.
+ */
/**
* @method IPlugin#beforeEvent
* @desc Called before processing the specified `event`. If any plugin returns `false`, | true |
Other | chartjs | Chart.js | 4741c6f09da431e75fa860b4e08417a4d961fadf.json | Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before. | test/core.controller.tests.js | @@ -635,7 +635,7 @@ describe('Chart', function() {
describe('plugin.extensions', function() {
it ('should notify plugin in correct order', function(done) {
- var plugin = this.plugin = {id: 'foobar'};
+ var plugin = this.plugin = {};
var sequence = [];
var hooks = {
init: [
@@ -647,13 +647,17 @@ describe('Chart', function() {
'beforeLayout',
'afterLayout',
'beforeDatasetsUpdate',
+ 'beforeDatasetUpdate',
+ 'afterDatasetUpdate',
'afterDatasetsUpdate',
'afterUpdate',
],
render: [
'beforeRender',
'beforeDraw',
'beforeDatasetsDraw',
+ 'beforeDatasetDraw',
+ 'afterDatasetDraw',
'afterDatasetsDraw',
'afterDraw',
'afterRender',
@@ -675,6 +679,8 @@ describe('Chart', function() {
});
var chart = window.acquireChart({
+ type: 'line',
+ data: {datasets: [{}]},
plugins: [plugin],
options: {
responsive: true
@@ -702,5 +708,28 @@ describe('Chart', function() {
done();
});
});
+
+ it('should not notify before/afterDatasetDraw if dataset is hidden', function() {
+ var sequence = [];
+ var plugin = this.plugin = {
+ beforeDatasetDraw: function(chart, args) {
+ sequence.push('before-' + args.index);
+ },
+ afterDatasetDraw: function(chart, args) {
+ sequence.push('after-' + args.index);
+ }
+ };
+
+ window.acquireChart({
+ type: 'line',
+ data: {datasets: [{}, {hidden: true}, {}]},
+ plugins: [plugin]
+ });
+
+ expect(sequence).toEqual([
+ 'before-2', 'after-2',
+ 'before-0', 'after-0'
+ ]);
+ });
});
}); | true |
Other | chartjs | Chart.js | 9f3b51a80ce96578718267711e8b65c1ec8c25c1.json | Reuse parsed results rather than redoing work
The input labels/data is converted into moments in `determineDataLimits`, reuse them instead of duplicating the work. | src/scales/scale.time.js | @@ -76,17 +76,6 @@ module.exports = function(Chart) {
Chart.Scale.prototype.initialize.call(this);
},
- getLabelMoment: function(datasetIndex, index) {
- if (datasetIndex === null || index === null) {
- return null;
- }
-
- if (typeof this.labelMoments[datasetIndex] !== 'undefined') {
- return this.labelMoments[datasetIndex][index];
- }
-
- return null;
- },
getLabelDiff: function(datasetIndex, index) {
var me = this;
if (datasetIndex === null || index === null) {
@@ -114,49 +103,46 @@ module.exports = function(Chart) {
var me = this;
me.labelMoments = [];
+ function appendLabel(array, label) {
+ var labelMoment = me.parseTime(label);
+ if (labelMoment.isValid()) {
+ if (me.options.time.round) {
+ labelMoment.startOf(me.options.time.round);
+ }
+ array.push(labelMoment);
+ }
+ }
+
// Only parse these once. If the dataset does not have data as x,y pairs, we will use
// these
var scaleLabelMoments = [];
if (me.chart.data.labels && me.chart.data.labels.length > 0) {
helpers.each(me.chart.data.labels, function(label) {
- var labelMoment = me.parseTime(label);
-
- if (labelMoment.isValid()) {
- if (me.options.time.round) {
- labelMoment.startOf(me.options.time.round);
- }
- scaleLabelMoments.push(labelMoment);
- }
+ appendLabel(scaleLabelMoments, label);
}, me);
- me.firstTick = moment.min.call(me, scaleLabelMoments);
- me.lastTick = moment.max.call(me, scaleLabelMoments);
+ me.firstTick = moment.min(scaleLabelMoments);
+ me.lastTick = moment.max(scaleLabelMoments);
} else {
me.firstTick = null;
me.lastTick = null;
}
helpers.each(me.chart.data.datasets, function(dataset, datasetIndex) {
var momentsForDataset = [];
- var datasetVisible = me.chart.isDatasetVisible(datasetIndex);
if (typeof dataset.data[0] === 'object' && dataset.data[0] !== null) {
helpers.each(dataset.data, function(value) {
- var labelMoment = me.parseTime(me.getRightValue(value));
-
- if (labelMoment.isValid()) {
- if (me.options.time.round) {
- labelMoment.startOf(me.options.time.round);
- }
- momentsForDataset.push(labelMoment);
-
- if (datasetVisible) {
- // May have gone outside the scale ranges, make sure we keep the first and last ticks updated
- me.firstTick = me.firstTick !== null ? moment.min(me.firstTick, labelMoment) : labelMoment;
- me.lastTick = me.lastTick !== null ? moment.max(me.lastTick, labelMoment) : labelMoment;
- }
- }
+ appendLabel(momentsForDataset, me.getRightValue(value));
}, me);
+
+ if (me.chart.isDatasetVisible(datasetIndex)) {
+ // May have gone outside the scale ranges, make sure we keep the first and last ticks updated
+ var min = moment.min(momentsForDataset);
+ var max = moment.max(momentsForDataset);
+ me.firstTick = me.firstTick !== null ? moment.min(me.firstTick, min) : min;
+ me.lastTick = me.lastTick !== null ? moment.max(me.lastTick, max) : max;
+ }
} else {
// We have no labels. Use the ones from the scale
momentsForDataset = scaleLabelMoments;
@@ -180,43 +166,12 @@ module.exports = function(Chart) {
},
buildLabelDiffs: function() {
var me = this;
- me.labelDiffs = [];
- var scaleLabelDiffs = [];
- // Parse common labels once
- if (me.chart.data.labels && me.chart.data.labels.length > 0) {
- helpers.each(me.chart.data.labels, function(label) {
- var labelMoment = me.parseTime(label);
-
- if (labelMoment.isValid()) {
- if (me.options.time.round) {
- labelMoment.startOf(me.options.time.round);
- }
- scaleLabelDiffs.push(labelMoment.diff(me.firstTick, me.tickUnit, true));
- }
- }, me);
- }
-
- helpers.each(me.chart.data.datasets, function(dataset) {
- var diffsForDataset = [];
- if (typeof dataset.data[0] === 'object' && dataset.data[0] !== null) {
- helpers.each(dataset.data, function(value) {
- var labelMoment = me.parseTime(me.getRightValue(value));
-
- if (labelMoment.isValid()) {
- if (me.options.time.round) {
- labelMoment.startOf(me.options.time.round);
- }
- diffsForDataset.push(labelMoment.diff(me.firstTick, me.tickUnit, true));
- }
- }, me);
- } else {
- // We have no labels. Use common ones
- diffsForDataset = scaleLabelDiffs;
- }
-
- me.labelDiffs.push(diffsForDataset);
- }, me);
+ me.labelDiffs = me.labelMoments.map(function(datasetLabels) {
+ return datasetLabels.map(function(label) {
+ return label.diff(me.firstTick, me.tickUnit, true);
+ });
+ });
},
buildTicks: function() {
var me = this; | true |
Other | chartjs | Chart.js | 9f3b51a80ce96578718267711e8b65c1ec8c25c1.json | Reuse parsed results rather than redoing work
The input labels/data is converted into moments in `determineDataLimits`, reuse them instead of duplicating the work. | test/scale.time.tests.js | @@ -485,68 +485,4 @@ describe('Time scale tests', function() {
threshold: 0.75
});
});
-
- it('should not throw an error if the datasetIndex is out of bounds', function() {
- var chart = window.acquireChart({
- type: 'line',
- data: {
- labels: ['2016-06-26'],
- datasets: [{
- xAxisID: 'xScale0',
- data: [5]
- }]
- },
- options: {
- scales: {
- xAxes: [{
- id: 'xScale0',
- display: true,
- type: 'time',
- }]
- }
- }
- });
-
- var xScale = chart.scales.xScale0;
- var getOutOfBoundLabelMoment = function() {
- xScale.getLabelMoment(12, 0);
- };
-
- expect(getOutOfBoundLabelMoment).not.toThrow();
- });
-
- it('should not throw an error if the datasetIndex or index are null', function() {
- var chart = window.acquireChart({
- type: 'line',
- data: {
- labels: ['2016-06-26'],
- datasets: [{
- xAxisID: 'xScale0',
- data: [5]
- }]
- },
- options: {
- scales: {
- xAxes: [{
- id: 'xScale0',
- display: true,
- type: 'time',
- }]
- }
- }
- });
-
- var xScale = chart.scales.xScale0;
-
- var getNullDatasetIndexLabelMoment = function() {
- xScale.getLabelMoment(null, 1);
- };
-
- var getNullIndexLabelMoment = function() {
- xScale.getLabelMoment(1, null);
- };
-
- expect(getNullDatasetIndexLabelMoment).not.toThrow();
- expect(getNullIndexLabelMoment).not.toThrow();
- });
}); | true |
Other | chartjs | Chart.js | 8c90b9f2de6863cca3051276648e363aa332d6a2.json | Fix issue with how Chart.PluginBase is defined | src/chart.js | @@ -6,8 +6,8 @@ var Chart = require('./core/core.js')();
require('./core/core.helpers')(Chart);
require('./platforms/platform.js')(Chart);
require('./core/core.canvasHelpers')(Chart);
-require('./core/core.plugin.js')(Chart);
require('./core/core.element')(Chart);
+require('./core/core.plugin.js')(Chart);
require('./core/core.animation')(Chart);
require('./core/core.controller')(Chart);
require('./core/core.datasetController')(Chart); | true |
Other | chartjs | Chart.js | 8c90b9f2de6863cca3051276648e363aa332d6a2.json | Fix issue with how Chart.PluginBase is defined | src/core/core.plugin.js | @@ -321,5 +321,5 @@ module.exports = function(Chart) {
* @todo remove at version 3
* @private
*/
- Chart.PluginBase = helpers.inherits({});
+ Chart.PluginBase = Chart.Element.extend({});
}; | true |
Other | chartjs | Chart.js | 7205ff5e2aa4515bae0c62bb9d8355745837270e.json | Replace `onEvent` by `before/afterEvent` | docs/09-Advanced.md | @@ -439,12 +439,9 @@ Plugins should implement the `IPlugin` interface:
destroy: function(chartInstance) { }
- /**
- * Called when an event occurs on the chart
- * @param e {Core.Event} the Chart.js wrapper around the native event. e.native is the original event
- * @return {Boolean} true if the chart is changed and needs to re-render
- */
- onEvent: function(chartInstance, e) {}
+ // Called when an event occurs on the chart
+ beforeEvent: function(chartInstance, event) {}
+ afterEvent: function(chartInstance, event) {}
}
```
| true |
Other | chartjs | Chart.js | 7205ff5e2aa4515bae0c62bb9d8355745837270e.json | Replace `onEvent` by `before/afterEvent` | src/core/core.controller.js | @@ -664,15 +664,19 @@ module.exports = function(Chart) {
eventHandler: function(e) {
var me = this;
var tooltip = me.tooltip;
- var hoverOptions = me.options.hover;
+
+ if (plugins.notify(me, 'beforeEvent', [e]) === false) {
+ return;
+ }
// Buffer any update calls so that renders do not occur
me._bufferedRender = true;
me._bufferedRequest = null;
var changed = me.handleEvent(e);
changed |= tooltip && tooltip.handleEvent(e);
- changed |= plugins.notify(me, 'onEvent', [e]);
+
+ plugins.notify(me, 'afterEvent', [e]);
var bufferedRequest = me._bufferedRequest;
if (bufferedRequest) {
@@ -684,7 +688,7 @@ module.exports = function(Chart) {
// We only need to render at this point. Updating will cause scales to be
// recomputed generating flicker & using more memory than necessary.
- me.render(hoverOptions.animationDuration, true);
+ me.render(me.options.hover.animationDuration, true);
}
me._bufferedRender = false; | true |
Other | chartjs | Chart.js | 7205ff5e2aa4515bae0c62bb9d8355745837270e.json | Replace `onEvent` by `before/afterEvent` | src/core/core.legend.js | @@ -526,7 +526,7 @@ module.exports = function(Chart) {
delete chartInstance.legend;
}
},
- onEvent: function(chartInstance, e) {
+ afterEvent: function(chartInstance, e) {
var legend = chartInstance.legend;
if (legend) {
legend.handleEvent(e); | true |
Other | chartjs | Chart.js | 7205ff5e2aa4515bae0c62bb9d8355745837270e.json | Replace `onEvent` by `before/afterEvent` | src/core/core.plugin.js | @@ -274,6 +274,22 @@ module.exports = function(Chart) {
* @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
* @param {Object} options - The plugin options.
*/
+ /**
+ * @method IPlugin#beforeEvent
+ * @desc Called before processing the specified `event`. If any plugin returns `false`,
+ * the event will be discarded.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {IEvent} event - The event object.
+ * @param {Object} options - The plugin options.
+ */
+ /**
+ * @method IPlugin#afterEvent
+ * @desc Called after the `event` has been consumed. Note that this hook
+ * will not be called if the `event` has been previously discarded.
+ * @param {Chart.Controller} chart - The chart instance.
+ * @param {IEvent} event - The event object.
+ * @param {Object} options - The plugin options.
+ */
/**
* @method IPlugin#resize
* @desc Called after the chart as been resized. | true |
Other | chartjs | Chart.js | 7205ff5e2aa4515bae0c62bb9d8355745837270e.json | Replace `onEvent` by `before/afterEvent` | test/platform.dom.tests.js | @@ -320,7 +320,7 @@ describe('Platform.dom', function() {
it('should notify plugins about events', function() {
var notifiedEvent;
var plugin = {
- onEvent: function(chart, e) {
+ afterEvent: function(chart, e) {
notifiedEvent = e;
}
}; | true |
Other | chartjs | Chart.js | 1934358663ad16773082a44974da91f0be78b4e3.json | remove unnecessary extra init steps | src/core/core.controller.js | @@ -121,13 +121,9 @@ module.exports = function(Chart) {
me.resize(true);
}
- // Make sure controllers are built first so that each dataset is bound to an axis before the scales
- // are built
+ // Make sure scales have IDs and are built before we build any controllers.
me.ensureScalesHaveIDs();
- me.buildOrUpdateControllers();
me.buildScales();
- me.updateLayout();
- me.resetElements();
me.initToolTip();
me.update();
@@ -256,10 +252,6 @@ module.exports = function(Chart) {
Chart.scaleService.addScalesToLayout(this);
},
- updateLayout: function() {
- Chart.layoutService.update(this, this.chart.width, this.chart.height);
- },
-
buildOrUpdateControllers: function() {
var me = this;
var types = []; | false |
Other | chartjs | Chart.js | ceec907bee33d39da68cb7af111400622aefee23.json | Ignore .gitignore (and more) from Bower packages | gulpfile.js | @@ -71,7 +71,15 @@ function bowerTask() {
homepage: package.homepage,
license: package.license,
version: package.version,
- main: outDir + "Chart.js"
+ main: outDir + "Chart.js",
+ ignore: [
+ '.github',
+ '.codeclimate.yml',
+ '.gitignore',
+ '.npmignore',
+ '.travis.yml',
+ 'scripts'
+ ]
}, null, 2);
return file('bower.json', json, { src: true }) | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.