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 | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | gulpfile.js | @@ -86,7 +86,7 @@ function buildTask() {
function packageTask() {
return merge(
// gather "regular" files landing in the package root
- gulp.src([outDir + '*.js', 'LICENSE.md']),
+ gulp.src([outDir + '*.js', outDir + '*.css', 'LICENSE.md']),
// since we moved the dist files one folder up (package root), we need to rewrite
// samples src="../dist/ to src="../ and then copy them in the /samples directory. | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | package.json | @@ -23,6 +23,7 @@
"url": "https://github.com/chartjs/Chart.js/issues"
},
"devDependencies": {
+ "clean-css": "^4.2.1",
"coveralls": "^3.0.0",
"eslint": "^5.9.0",
"eslint-config-chartjs": "^0.1.0", | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | rollup.config.js | @@ -4,6 +4,7 @@ const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve');
const terser = require('rollup-plugin-terser').terser;
const optional = require('./rollup.plugins').optional;
+const stylesheet = require('./rollup.plugins').stylesheet;
const pkg = require('./package.json');
const input = 'src/chart.js';
@@ -23,6 +24,9 @@ module.exports = [
plugins: [
resolve(),
commonjs(),
+ stylesheet({
+ extract: true
+ }),
optional({
include: ['moment']
})
@@ -49,6 +53,10 @@ module.exports = [
optional({
include: ['moment']
}),
+ stylesheet({
+ extract: true,
+ minify: true
+ }),
terser({
output: {
preamble: banner
@@ -76,7 +84,8 @@ module.exports = [
input: input,
plugins: [
resolve(),
- commonjs()
+ commonjs(),
+ stylesheet()
],
output: {
name: 'Chart',
@@ -91,6 +100,9 @@ module.exports = [
plugins: [
resolve(),
commonjs(),
+ stylesheet({
+ minify: true
+ }),
terser({
output: {
preamble: banner | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | rollup.plugins.js | @@ -1,4 +1,6 @@
/* eslint-env es6 */
+const cleancss = require('clean-css');
+const path = require('path');
const UMD_WRAPPER_RE = /(\(function \(global, factory\) \{)((?:\s.*?)*)(\}\(this,)/;
const CJS_FACTORY_RE = /(module.exports = )(factory\(.*?\))( :)/;
@@ -56,6 +58,51 @@ function optional(config = {}) {
};
}
+// https://github.com/chartjs/Chart.js/issues/5208
+function stylesheet(config = {}) {
+ const minifier = new cleancss();
+ const styles = [];
+
+ return {
+ name: 'stylesheet',
+ transform(code, id) {
+ // Note that 'id' can be mapped to a CJS proxy import, in which case
+ // 'id' will start with 'commonjs-proxy', so let's first check if we
+ // are importing an existing css file (i.e. startsWith()).
+ if (!id.startsWith(path.resolve('.')) || !id.endsWith('.css')) {
+ return;
+ }
+
+ if (config.minify) {
+ code = minifier.minify(code).styles;
+ }
+
+ // keep track of all imported stylesheets (already minified)
+ styles.push(code);
+
+ return {
+ code: 'export default ' + JSON.stringify(code)
+ };
+ },
+ generateBundle(opts, bundle) {
+ if (!config.extract) {
+ return;
+ }
+
+ const entry = Object.keys(bundle).find(v => bundle[v].isEntry);
+ const name = (entry || '').replace(/\.js$/i, '.css');
+ if (!name) {
+ this.error('failed to guess the output file name');
+ }
+
+ bundle[name] = {
+ code: styles.filter(v => !!v).join('')
+ };
+ }
+ };
+}
+
module.exports = {
- optional
+ optional,
+ stylesheet
}; | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | samples/advanced/content-security-policy.css | @@ -0,0 +1,20 @@
+.content {
+ max-width: 640px;
+ margin: auto;
+ padding: 1rem;
+}
+
+.note {
+ font-family: sans-serif;
+ color: #5050a0;
+ line-height: 1.4;
+ margin-bottom: 1rem;
+ padding: 1rem;
+}
+
+code {
+ background-color: #f5f5ff;
+ border: 1px solid #d0d0fa;
+ border-radius: 4px;
+ padding: 0.05rem 0.25rem;
+} | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | samples/advanced/content-security-policy.html | @@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html lang="en-US">
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta http-equiv="Content-Security-Policy" content="default-src 'self'">
+ <title>Scriptable > Bubble | Chart.js sample</title>
+ <link rel="stylesheet" type="text/css" href="../../dist/Chart.min.css">
+ <link rel="stylesheet" type="text/css" href="./content-security-policy.css">
+ <script src="../../dist/Chart.min.js"></script>
+ <script src="../utils.js"></script>
+ <script src="content-security-policy.js"></script>
+</head>
+<body>
+ <div class="content">
+ <div class="note">
+ In order to support a strict content security policy (<code>default-src 'self'</code>),
+ this page manually loads <code>Chart.min.css</code> and turns off the automatic style
+ injection by setting <code>Chart.platform.disableCSSInjection = true;</code>.
+ </div>
+ <div class="wrapper">
+ <canvas id="chart-0"></canvas>
+ </div>
+ </div>
+</body>
+</html> | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | samples/advanced/content-security-policy.js | @@ -0,0 +1,54 @@
+var utils = Samples.utils;
+
+// CSP: disable automatic style injection
+Chart.platform.disableCSSInjection = true;
+
+utils.srand(110);
+
+function generateData() {
+ var DATA_COUNT = 16;
+ var MIN_XY = -150;
+ var MAX_XY = 100;
+ var data = [];
+ var i;
+
+ for (i = 0; i < DATA_COUNT; ++i) {
+ data.push({
+ x: utils.rand(MIN_XY, MAX_XY),
+ y: utils.rand(MIN_XY, MAX_XY),
+ v: utils.rand(0, 1000)
+ });
+ }
+
+ return data;
+}
+
+window.addEventListener('load', function() {
+ new Chart('chart-0', {
+ type: 'bubble',
+ data: {
+ datasets: [{
+ backgroundColor: utils.color(0),
+ data: generateData()
+ }, {
+ backgroundColor: utils.color(1),
+ data: generateData()
+ }]
+ },
+ options: {
+ aspectRatio: 1,
+ legend: false,
+ tooltip: false,
+ elements: {
+ point: {
+ radius: function(context) {
+ var value = context.dataset.data[context.dataIndex];
+ var size = context.chart.width;
+ var base = Math.abs(value.v) / 1000;
+ return (size / 24) * base;
+ }
+ }
+ }
+ }
+ });
+}); | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | samples/samples.js | @@ -187,6 +187,9 @@
items: [{
title: 'Progress bar',
path: 'advanced/progress-bar.html'
+ }, {
+ title: 'Content Security Policy',
+ path: 'advanced/content-security-policy.html'
}]
}];
| true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | samples/style.css | @@ -1,4 +1,3 @@
-@import url('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
@import url('https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900');
body, html { | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | scripts/deploy.sh | @@ -41,7 +41,7 @@ cd $TARGET_DIR
git checkout $TARGET_BRANCH
# Copy dist files
-deploy_files '../dist/*.js' './dist'
+deploy_files '../dist/*.css ../dist/*.js' './dist'
# Copy generated documentation
deploy_files '../dist/docs/*' './docs' | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | scripts/release.sh | @@ -21,7 +21,7 @@ git remote add auth-origin https://$GITHUB_AUTH_TOKEN@github.com/$TRAVIS_REPO_SL
git config --global user.email "$GITHUB_AUTH_EMAIL"
git config --global user.name "Chart.js"
git checkout --detach --quiet
-git add -f dist/*.js bower.json
+git add -f dist/*.css dist/*.js bower.json
git commit -m "Release $VERSION"
git tag -a "v$VERSION" -m "Version $VERSION"
git push -q auth-origin refs/tags/v$VERSION 2>/dev/null | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | src/platforms/platform.dom.css | @@ -0,0 +1,46 @@
+/*
+ * DOM element rendering detection
+ * https://davidwalsh.name/detect-node-insertion
+ */
+@keyframes chartjs-render-animation {
+ from { opacity: 0.99; }
+ to { opacity: 1; }
+}
+
+.chartjs-render-monitor {
+ animation: chartjs-render-animation 0.001s;
+}
+
+/*
+ * DOM element resizing detection
+ * https://github.com/marcj/css-element-queries
+ */
+.chartjs-size-monitor,
+.chartjs-size-monitor-expand,
+.chartjs-size-monitor-shrink {
+ position: absolute;
+ left: 0;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ overflow: hidden;
+ pointer-events: none;
+ visibility: hidden;
+ z-index: -1;
+}
+
+.chartjs-size-monitor-expand > div {
+ position: absolute;
+ width: 1000000px;
+ height: 1000000px;
+ left: 0;
+ top: 0;
+}
+
+.chartjs-size-monitor-shrink > div {
+ position: absolute;
+ width: 200%;
+ height: 200%;
+ left: 0;
+ top: 0;
+} | true |
Other | chartjs | Chart.js | 55128f74c1518ac82189c0acba2a6b40f77bf698.json | Move CSS in a separate file to be CSP-compliant (#6048)
In order to be compatible with any CSP, we need to prevent the automatic creation of the DOM 'style' element and offer our CSS as a separate file that can be manually loaded (`Chart.js` or `Chart.min.js`). Users can now opt-out the style injection using `Chart.platform.disableCSSInjection = true` (note that the style sheet is now injected on the first chart creation).
To prevent duplicating and maintaining the same CSS code at different places, move all these rules in `platform.dom.css` and write a minimal rollup plugin to inject that style as string in `platform.dom.js`. Additionally, this plugin extract the imported style in `./dist/Chart.js` and `./dist/Chart.min.js`. | src/platforms/platform.dom.js | @@ -5,9 +5,11 @@
'use strict';
var helpers = require('../helpers/index');
+var stylesheet = require('./platform.dom.css');
var EXPANDO_KEY = '$chartjs';
var CSS_PREFIX = 'chartjs-';
+var CSS_SIZE_MONITOR = CSS_PREFIX + 'size-monitor';
var CSS_RENDER_MONITOR = CSS_PREFIX + 'render-monitor';
var CSS_RENDER_ANIMATION = CSS_PREFIX + 'render-animation';
var ANIMATION_START_EVENTS = ['animationstart', 'webkitAnimationStart'];
@@ -166,48 +168,24 @@ function throttled(fn, thisArg) {
};
}
-function createDiv(cls, style) {
+function createDiv(cls) {
var el = document.createElement('div');
- el.style.cssText = style || '';
el.className = cls || '';
return el;
}
// Implementation based on https://github.com/marcj/css-element-queries
function createResizer(handler) {
- var cls = CSS_PREFIX + 'size-monitor';
var maxSize = 1000000;
- var style =
- 'position:absolute;' +
- 'left:0;' +
- 'top:0;' +
- 'right:0;' +
- 'bottom:0;' +
- 'overflow:hidden;' +
- 'pointer-events:none;' +
- 'visibility:hidden;' +
- 'z-index:-1;';
// NOTE(SB) Don't use innerHTML because it could be considered unsafe.
// https://github.com/chartjs/Chart.js/issues/5902
- var resizer = createDiv(cls, style);
- var expand = createDiv(cls + '-expand', style);
- var shrink = createDiv(cls + '-shrink', style);
-
- expand.appendChild(createDiv('',
- 'position:absolute;' +
- 'height:' + maxSize + 'px;' +
- 'width:' + maxSize + 'px;' +
- 'left:0;' +
- 'top:0;'
- ));
- shrink.appendChild(createDiv('',
- 'position:absolute;' +
- 'height:200%;' +
- 'width:200%;' +
- 'left:0;' +
- 'top:0;'
- ));
+ var resizer = createDiv(CSS_SIZE_MONITOR);
+ var expand = createDiv(CSS_SIZE_MONITOR + '-expand');
+ var shrink = createDiv(CSS_SIZE_MONITOR + '-shrink');
+
+ expand.appendChild(createDiv());
+ shrink.appendChild(createDiv());
resizer.appendChild(expand);
resizer.appendChild(shrink);
@@ -330,26 +308,36 @@ function injectCSS(platform, css) {
}
module.exports = {
+ /**
+ * When `true`, prevents the automatic injection of the stylesheet required to
+ * correctly detect when the chart is added to the DOM and then resized. This
+ * switch has been added to allow external stylesheet (`dist/Chart(.min)?.js`)
+ * to be manually imported to make this library compatible with any CSP.
+ * See https://github.com/chartjs/Chart.js/issues/5208
+ */
+ disableCSSInjection: false,
+
/**
* This property holds whether this platform is enabled for the current environment.
* Currently used by platform.js to select the proper implementation.
* @private
*/
_enabled: typeof window !== 'undefined' && typeof document !== 'undefined',
- initialize: function() {
- var keyframes = 'from{opacity:0.99}to{opacity:1}';
-
- injectCSS(this,
- // DOM rendering detection
- // https://davidwalsh.name/detect-node-insertion
- '@-webkit-keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
- '@keyframes ' + CSS_RENDER_ANIMATION + '{' + keyframes + '}' +
- '.' + CSS_RENDER_MONITOR + '{' +
- '-webkit-animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
- 'animation:' + CSS_RENDER_ANIMATION + ' 0.001s;' +
- '}'
- );
+ /**
+ * @private
+ */
+ _ensureLoaded: function() {
+ if (this._loaded) {
+ return;
+ }
+
+ this._loaded = true;
+
+ // https://github.com/chartjs/Chart.js/issues/5208
+ if (!this.disableCSSInjection) {
+ injectCSS(this, stylesheet);
+ }
},
acquireContext: function(item, config) {
@@ -370,6 +358,10 @@ module.exports = {
// https://github.com/chartjs/Chart.js/issues/2807
var context = item && item.getContext && item.getContext('2d');
+ // Load platform resources on first chart creation, to make possible to change
+ // platform options after importing the library (e.g. `disableCSSInjection`).
+ this._ensureLoaded();
+
// `instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when the item is
// inside an iframe or when running in a protected environment. We could guess the
// types from their toString() value but let's keep things flexible and assume it's | true |
Other | chartjs | Chart.js | 7c11c81d961751db1499a35e3f163b56d4d65ab1.json | Fix broken markdown link in 'line' docs (#6053) | docs/charts/line.md | @@ -91,7 +91,7 @@ The style of each point can be controlled with the following properties:
| `pointHitRadius` | The pixel size of the non-displayed point that reacts to mouse events.
| `pointRadius` | The radius of the point shape. If set to 0, the point is not rendered.
| `pointRotation` | The rotation of the point in degrees.
-| `pointStyle` | Style of the point. [more...](../configuration/elements#point-styles)
+| `pointStyle` | Style of the point. [more...](../configuration/elements.md#point-styles)
All these values, if `undefined`, fallback first to the dataset options then to the associated [`elements.point.*`](../configuration/elements.md#point-configuration) options.
| false |
Other | chartjs | Chart.js | 765c432dfaa1c6472caf9d52926177c48761bd32.json | Fix duplicate anchor (#6038)
* Fix broken documentation anchors
* Revert changes to installation docs | docs/axes/README.md | @@ -10,7 +10,7 @@ Scales in Chart.js >v2.0 are significantly more powerful, but also different tha
* Scale titles are supported.
* New scale types can be extended without writing an entirely new chart type.
-# Common Configuration
+## Common Configuration
The following properties are common to all axes provided by Chart.js.
@@ -20,7 +20,7 @@ The following properties are common to all axes provided by Chart.js.
| `callbacks` | `object` | | Callback functions to hook into the axis lifecycle. [more...](#callbacks)
| `weight` | `number` | `0` | The weight used to sort the axis. Higher weights are further away from the chart area.
-## 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
@@ -40,7 +40,7 @@ There are a number of config callbacks that can be used to change parameters in
| `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
+### 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.
| true |
Other | chartjs | Chart.js | 765c432dfaa1c6472caf9d52926177c48761bd32.json | Fix duplicate anchor (#6038)
* Fix broken documentation anchors
* Revert changes to installation docs | docs/axes/cartesian/README.md | @@ -7,7 +7,7 @@ Axes that follow a cartesian grid are known as 'Cartesian Axes'. Cartesian axes
* [category](./category.md#category-cartesian-axis)
* [time](./time.md#time-cartesian-axis)
-# Common Configuration
+## Common Configuration
All of the included cartesian axes support a number of common options.
@@ -21,7 +21,7 @@ All of the included cartesian axes support a number of common options.
| `scaleLabel` | `object` | | Scale title configuration. [more...](../labelling.md#scale-title-configuration)
| `ticks` | `object` | | Tick configuration. [more...](#tick-configuration)
-## Tick Configuration
+### Tick Configuration
The following options are common to all cartesian axes but do not apply to other axes.
| Name | Type | Default | Description
@@ -34,7 +34,7 @@ The following options are common to all cartesian axes but do not apply to other
| `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. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
-## Axis ID
+### 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
@@ -63,7 +63,7 @@ var myChart = new Chart(ctx, {
});
```
-# Creating Multiple Axes
+## 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.
| true |
Other | chartjs | Chart.js | 765c432dfaa1c6472caf9d52926177c48761bd32.json | Fix duplicate anchor (#6038)
* Fix broken documentation anchors
* Revert changes to installation docs | docs/charts/bar.md | @@ -206,7 +206,7 @@ You can also specify the dataset as x/y coordinates when using the [time scale](
data: [{x:'2016-12-25', y:20}, {x:'2016-12-26', y:10}]
```
-# Stacked Bar Chart
+## 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.
@@ -227,15 +227,13 @@ var stackedBar = new Chart(ctx, {
});
```
-## 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
+## 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.
{% chartjs %}
{
@@ -288,7 +286,7 @@ var myBarChart = new Chart(ctx, {
});
```
-## Config Options
+### Config Options
The configuration options for the horizontal bar chart are the same as for the [bar chart](#scale-configuration). 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`. | true |
Other | chartjs | Chart.js | 765c432dfaa1c6472caf9d52926177c48761bd32.json | Fix duplicate anchor (#6038)
* Fix broken documentation anchors
* Revert changes to installation docs | docs/charts/line.md | @@ -190,7 +190,7 @@ data: [{
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
+## 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.
@@ -208,17 +208,17 @@ var stackedLine = new Chart(ctx, {
});
```
-# High Performance Line Charts
+## 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
+### 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](https://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
+### 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.
@@ -238,7 +238,7 @@ new Chart(ctx, {
});
```
-## Disable Line Drawing
+### Disable 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.
@@ -258,7 +258,7 @@ new Chart(ctx, {
});
```
-## Disable Animations
+### 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.
| true |
Other | chartjs | Chart.js | 765c432dfaa1c6472caf9d52926177c48761bd32.json | Fix duplicate anchor (#6038)
* Fix broken documentation anchors
* Revert changes to installation docs | docs/developers/README.md | @@ -2,14 +2,14 @@
Developer features allow extending and enhancing Chart.js in many different ways.
-# Latest resources
+## Latest resources
Latest documentation and samples, including unreleased features, are available at:
- https://www.chartjs.org/docs/master/
- https://www.chartjs.org/samples/master/
-# Development releases
+## Development releases
Latest builds are available for testing at:
@@ -20,7 +20,7 @@ Latest builds are available for testing at:
**WARNING: Development builds MUST not be used for production purposes or as replacement for CDN.**
-# Browser support
+## Browser support
Chart.js offers support for the following browsers:
* Chrome 50+
@@ -33,7 +33,7 @@ Browser support for the canvas element is available in all modern & major mobile
Thanks to [BrowserStack](https://browserstack.com) for allowing our team to test on thousands of browsers.
-# Previous versions
+## Previous versions
Version 2 has a completely different API than earlier versions.
| true |
Other | chartjs | Chart.js | 765c432dfaa1c6472caf9d52926177c48761bd32.json | Fix duplicate anchor (#6038)
* Fix broken documentation anchors
* Revert changes to installation docs | docs/developers/contributing.md | @@ -9,11 +9,11 @@ New contributions to the library are welcome, but we ask that you please follow
- Avoid breaking changes unless there is an upcoming major release, which are infrequent. We encourage people to write plugins for most new advanced features, and care a lot about backwards compatibility.
- We strongly prefer new methods to be added as private whenever possible. A method can be made private either by making a top-level `function` outside of a class or by prefixing it with `_` and adding `@private` JSDoc if inside a class. Public APIs take considerable time to review and become locked once implemented as we have limited ability to change them without breaking backwards compatibility. Private APIs allow the flexibility to address unforeseen cases.
-# Joining the project
+## Joining the project
Active committers and contributors are invited to introduce yourself and request commit access to this project. We have a very active Slack community that you can join [here](https://chartjs-slack.herokuapp.com/). If you think you can help, we'd love to have you!
-# Building and Testing
+## Building and Testing
Chart.js uses <a href="https://gulpjs.com/" target="_blank">gulp</a> to build the library into a single JavaScript file.
@@ -42,7 +42,7 @@ The following commands are now available from the repository root:
More information can be found in [gulpfile.js](https://github.com/chartjs/Chart.js/blob/master/gulpfile.js).
-# Bugs and Issues
+## Bugs and 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>. Please do not use issues for support requests. For help using Chart.js, please take a look at the [`chartjs`](https://stackoverflow.com/questions/tagged/chartjs) tag on Stack Overflow.
| true |
Other | chartjs | Chart.js | 765c432dfaa1c6472caf9d52926177c48761bd32.json | Fix duplicate anchor (#6038)
* Fix broken documentation anchors
* Revert changes to installation docs | docs/getting-started/installation.md | @@ -17,6 +17,7 @@ bower install chart.js --save
```
## CDN
+
### CDNJS
[](https://cdnjs.com/libraries/Chart.js)
@@ -38,18 +39,18 @@ You can download the latest version of [Chart.js on GitHub](https://github.com/c
If you download or clone the repository, you must [build](../developers/contributing.md#building-and-testing) 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
+## Selecting the Correct Build
Chart.js provides two different builds for you to choose: **Stand-Alone Build**, **Bundled Build**.
-## Stand-Alone Build
+### Stand-Alone Build
Files:
* `dist/Chart.js`
* `dist/Chart.min.js`
The stand-alone build includes Chart.js as well as the color parsing library. If this version is used, you are required to include [Moment.js](https://momentjs.com/) before Chart.js for the functionality of the time axis.
-## Bundled Build
+### Bundled Build
Files:
* `dist/Chart.bundle.js`
* `dist/Chart.bundle.min.js` | true |
Other | chartjs | Chart.js | 93d5ac9a311282517a03b47ca9b54be7847aef0f.json | Remove unused eslint directive (#6040) | src/scales/scale.time.js | @@ -1,4 +1,3 @@
-/* global window: false */
'use strict';
var adapter = require('../core/core.adapters')._date; | false |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/README.md | @@ -14,11 +14,11 @@ In this example, we create a bar chart for a single dataset and render that in o
```html
<canvas id="myChart" width="400" height="400"></canvas>
<script>
-var ctx = document.getElementById("myChart").getContext('2d');
+var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
- labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
+ labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
@@ -31,7 +31,7 @@ var myChart = new Chart(ctx, {
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
- 'rgba(255,99,132,1)',
+ 'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
@@ -45,7 +45,7 @@ var myChart = new Chart(ctx, {
scales: {
yAxes: [{
ticks: {
- beginAtZero:true
+ beginAtZero: true
}
}]
} | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/README.md | @@ -16,9 +16,9 @@ The following properties are common to all axes provided by Chart.js.
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
-| `display` | `Boolean`/`String` | `true` | Controls the axis global visibility (visible when `true`, hidden when `false`). When `display: 'auto'`, the axis is visible only if at least one associated dataset is visible.
-| `callbacks` | `Object` | | Callback functions to hook into the axis lifecycle. [more...](#callbacks)
-| `weight` | `Number` | `0` | The weight used to sort the axis. Higher weights are further away from the chart area.
+| `display` | <code>boolean|string</code> | `true` | Controls the axis global visibility (visible when `true`, hidden when `false`). When `display: 'auto'`, the axis is visible only if at least one associated dataset is visible.
+| `callbacks` | `object` | | Callback functions to hook into the axis lifecycle. [more...](#callbacks)
+| `weight` | `number` | `0` | The weight used to sort the axis. Higher weights are further away from the chart area.
## 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. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/cartesian/README.md | @@ -12,27 +12,27 @@ Axes that follow a cartesian grid are known as 'Cartesian Axes'. Cartesian axes
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'`
-| `offset` | `Boolean` | `false` | If true, extra space is added to the both edges and the axis is scaled to fit into the chart area. This is set to `true` for a category scale in a bar chart by default.
-| `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)
+| ---- | ---- | ------- | -----------
+| `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'`
+| `offset` | `boolean` | `false` | If true, extra space is added to the both edges and the axis is scaled to fit into the chart area. This is set to `true` for a category scale in a bar chart by default.
+| `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 x direction for the x axis, and the y 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. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
+| ---- | ---- | ------- | -----------
+| `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 x direction for the x axis, and the y 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. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
## 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.
@@ -84,7 +84,7 @@ var myChart = new Chart(ctx, {
label: 'Right dataset',
// This binds the dataset to the right y axis
- yAxisID: 'right-y-axis',
+ yAxisID: 'right-y-axis'
}],
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
}, | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/cartesian/category.md | @@ -2,7 +2,7 @@
If global configuration is used, 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.
-Specifying any of the settings above defines the x axis as `type: category` if not defined otherwise. For more fine-grained control of category labels it is also possible to add `labels` as part of the category axis definition. Doing so does not apply the global defaults.
+Specifying any of the settings above defines the x axis as `type: 'category'` if not defined otherwise. For more fine-grained control of category labels it is also possible to add `labels` as part of the category axis definition. Doing so does not apply the global defaults.
## Category Axis Definition
@@ -14,7 +14,7 @@ let chart = new Chart(ctx, {
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
datasets: ...
- },
+ }
});
```
As part of axis definition:
@@ -27,7 +27,7 @@ let chart = new Chart(ctx, {
scales: {
xAxes: [{
type: 'category',
- labels: ['January', 'February', 'March', 'April', 'May', 'June'],
+ labels: ['January', 'February', 'March', 'April', 'May', 'June']
}]
}
}
@@ -39,10 +39,10 @@ let chart = new Chart(ctx, {
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
-| -----| ---- | --------| -----------
-| `labels` | `Array[String]` | - | An array of labels to display.
-| `min` | `String` | | The minimum item to display. [more...](#min-max-configuration)
-| `max` | `String` | | The maximum item to display. [more...](#min-max-configuration)
+| ---- | ---- | ------- | -----------
+| `labels` | `string[]` | - | An array of labels to display.
+| `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".
@@ -54,7 +54,7 @@ let chart = new Chart(ctx, {
datasets: [{
data: [10, 20, 30, 40, 50, 60]
}],
- labels: ['January', 'February', 'March', 'April', 'May', 'June'],
+ labels: ['January', 'February', 'March', 'April', 'May', 'June']
},
options: {
scales: { | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/cartesian/linear.md | @@ -7,15 +7,15 @@ The linear scale is use to chart numerical data. It can be placed on either the
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.
-| `precision` | `Number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
-| `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)
+| ---- | ---- | ------- | -----------
+| `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.
+| `precision` | `number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
+| `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
@@ -56,7 +56,7 @@ let chart = new Chart(ctx, {
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.
+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`.
@@ -72,4 +72,4 @@ let options = {
}]
}
};
-```
\ No newline at end of file
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/cartesian/logarithmic.md | @@ -7,6 +7,6 @@ The logarithmic scale is use to chart numerical data. It can be placed on either
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
+| ---- | ---- | ------- | -----------
+| `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. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/cartesian/time.md | @@ -8,14 +8,15 @@ The time scale is used to display times and dates. When building its ticks, it w
The x-axis data points may additionally be specified via the `t` or `x` attribute when using the time scale.
- data: [{
- x: new Date(),
- y: 1
- }, {
- t: new Date(),
- y: 10
- }]
-
+```javascript
+data: [{
+ x: new Date(),
+ y: 1
+}, {
+ t: new Date(),
+ y: 10
+}]
+```
### Date Formats
@@ -26,34 +27,34 @@ When providing data for the time scale, Chart.js supports all of the formats tha
The following options are provided by the time scale. You may also set options provided by the [common tick configuration](README.md#tick-configuration).
| Name | Type | Default | Description
-| -----| ---- | --------| -----------
-| `distribution` | `String` | `linear` | How data is plotted. [more...](#scale-distribution)
-| `bounds` | `String` | `data` | Determines the scale bounds. [more...](#scale-bounds)
-| `ticks.source` | `String` | `auto` | How ticks are generated. [more...](#ticks-source)
-| `time.displayFormats` | `Object` | | Sets how different time units are displayed. [more...](#display-formats)
-| `time.isoWeekday` | `Boolean` | `false` | If true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
+| ---- | ---- | ------- | -----------
+| `distribution` | `string` | `'linear'` | How data is plotted. [more...](#scale-distribution)
+| `bounds` | `string` | `'data'` | Determines the scale bounds. [more...](#scale-bounds)
+| `ticks.source` | `string` | `'auto'` | How ticks are generated. [more...](#ticks-source)
+| `time.displayFormats` | `object` | | Sets how different time units are displayed. [more...](#display-formats)
+| `time.isoWeekday` | `boolean` | `false` | If true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
| `time.max` | [Time](#date-formats) | | If defined, this will override the data maximum.
| `time.min` | [Time](#date-formats) | | If defined, this will override the data minimum.
-| `time.parser` | `String/Function` | | Custom parser for dates. [more...](#parser)
-| `time.round` | `String` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#time-units) below for the allowed units.
-| `time.tooltipFormat` | `String` | | The moment js format string to use for the tooltip.
-| `time.unit` | `String` | `false` | If defined, will force the unit to be a certain type. See [Time Units](#time-units) section below for details.
-| `time.stepSize` | `Number` | `1` | The number of units between grid lines.
-| `time.minUnit` | `String` | `'millisecond'` | The minimum display format to be used for a time unit.
+| `time.parser` | <code>string|function</code> | | Custom parser for dates. [more...](#parser)
+| `time.round` | `string` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#time-units) below for the allowed units.
+| `time.tooltipFormat` | `string` | | The Moment.js format string to use for the tooltip.
+| `time.unit` | `string` | `false` | If defined, will force the unit to be a certain type. See [Time Units](#time-units) section below for details.
+| `time.stepSize` | `number` | `1` | The number of units between grid lines.
+| `time.minUnit` | `string` | `'millisecond'` | The minimum display format to be used for a time unit.
### 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
+* `'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.
@@ -71,25 +72,25 @@ var chart = new Chart(ctx, {
}]
}
}
-})
+});
```
### 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](https://momentjs.com/docs/#/displaying/format/) for the allowable format strings.
+The following display formats are used to configure how different time units are formed into strings for the axis tick marks. See [Moment.js](https://momentjs.com/docs/#/displaying/format/) for the allowable format strings.
Name | Default | Example
--- | --- | ---
-millisecond | 'h:mm:ss.SSS a' | 11:20:01.123 AM
-second | 'h:mm:ss a' | 11:20:01 AM
-minute | 'h:mm a' | 11:20 AM
-hour | 'hA' | 11AM
-day | 'MMM D' | Sep 4
-week | 'll' | Sep 4 2015
-month | 'MMM YYYY' | Sep 2015
-quarter | '[Q]Q - YYYY' | Q3 - 2015
-year | 'YYYY' | 2015
-
-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.
+`millisecond` | `'h:mm:ss.SSS a'` | `'11:20:01.123 AM'`
+`second` | `'h:mm:ss a'` | `'11:20:01 AM'`
+`minute` | `'h:mm a'` | `'11:20 AM'`
+`hour` | `'hA'` | `'11AM'`
+`day` | `'MMM D'` | `'Sep 4'`
+`week` | `'ll'` | `'Sep 4 2015'`
+`month` | `'MMM YYYY'` | `'Sep 2015'`
+`quarter` | `'[Q]Q - YYYY'` | `'Q3 - 2015'`
+`year` | `'YYYY'` | `'2015'`
+
+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, {
@@ -107,15 +108,15 @@ var chart = new Chart(ctx, {
}]
}
}
-})
+});
```
### Scale Distribution
The `distribution` property controls the data distribution along the scale:
- * `'linear'`: data are spread according to their time (distances can vary)
- * `'series'`: data are spread at the same distance from each other
+* `'linear'`: data are spread according to their time (distances can vary)
+* `'series'`: data are spread at the same distance from each other
```javascript
var chart = new Chart(ctx, {
@@ -129,15 +130,15 @@ var chart = new Chart(ctx, {
}]
}
}
-})
+});
```
### Scale Bounds
-The `bounds` property controls the scale boundary strategy (bypassed by min/max time options).
+The `bounds` property controls the scale boundary strategy (bypassed by `min`/`max` time options).
-* `'data'`: make sure data are fully visible, labels outside are removed
-* `'ticks'`: make sure ticks are fully visible, data outside are truncated
+* `'data'`: makes sure data are fully visible, labels outside are removed
+* `'ticks'`: makes sure ticks are fully visible, data outside are truncated
### Ticks Source
@@ -148,6 +149,6 @@ The `ticks.source` property controls the ticks generation.
* `'labels'`: generates ticks from user given `data.labels` values ONLY
### 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 property is defined as a string, it is interpreted as a custom format to be used by Moment.js to parse the date.
-If this is a function, it must return a moment.js object given the appropriate data value.
+If this is a function, it must return a Moment.js object given the appropriate data value. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/labelling.md | @@ -7,15 +7,15 @@ When creating a chart, you want to tell the viewer what data they are viewing. T
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 "Response Choices").
-| `lineHeight` | `Number/String` | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
+| ---- | ---- | ------- | -----------
+| `display` | `boolean` | `false` | If true, display the axis title.
+| `labelString` | `string` | `''` | The text for the title. (i.e. "# of People" or "Response Choices").
+| `lineHeight` | <code>number|string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
| `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).
-| `padding` | `Number/Object` | `4` | Padding to apply around scale labels. Only `top` and `bottom` are implemented.
+| `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).
+| `padding` | <code>number|object</code> | `4` | Padding to apply around scale labels. Only `top` and `bottom` are implemented.
## Creating Custom Tick Formats
| true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/radial/README.md | @@ -2,4 +2,4 @@
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
+* [linear](./linear.md#linear-radial-axis) | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/radial/linear.md | @@ -10,28 +10,28 @@ The axis has configuration properties for ticks, angle lines (line that appear i
| 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)
+| `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.
-| `precision` | `Number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
-| `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.
+| `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.
+| `precision` | `number` | | if defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
+| `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
@@ -70,7 +70,7 @@ let chart = new Chart(ctx, {
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.
+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`.
@@ -91,22 +91,22 @@ let 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.
-| `borderDash` | `Number[]` | `[]` | Length and spacing of dashes on angled lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
-| `borderDashOffset` | `Number` | `0.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
+| ---- | ---- | ------- | -----------
+| `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.
+| `borderDash` | `number[]` | `[]` | Length and spacing of dashes on angled lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
+| `borderDashOffset` | `number` | `0.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
## 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/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.
-| `lineHeight` | `Number/String` | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
+| ---- | ---- | ------- | -----------
+| `callback` | `function` | | Callback function to transform data labels to point labels. The default implementation simply returns the current string.
+| `fontColor` | <code>Color|Color[]</code> | `'#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.
+| `lineHeight` | <code>number|string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)). | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/axes/styling.md | @@ -7,60 +7,60 @@ There are a number of options to allow styling an axis. There are settings to co
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.
-| `circular` | `Boolean` | `false` | If true, gridlines are circular (on radar chart only).
-| `color` | `Color/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.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
-| `lineWidth` | `Number/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).
-| `zeroLineBorderDash` | `Number[]` | `[]` | Length and spacing of dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
-| `zeroLineBorderDashOffset` | `Number` | `0.0` | Offset for line dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
-| `offsetGridLines` | `Boolean` | `false` | If true, grid lines will be shifted to be between labels. This is set to `true` for a category scale in a bar chart by default.
+| ---- | ---- | ------- | -----------
+| `display` | `boolean` | `true` | If false, do not display grid lines for this axis.
+| `circular` | `boolean` | `false` | If true, gridlines are circular (on radar chart only).
+| `color` | <code>Color|Color[]</code> | `'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.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
+| `lineWidth` | <code>number|number[]</code> | `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).
+| `zeroLineBorderDash` | `number[]` | `[]` | Length and spacing of dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
+| `zeroLineBorderDashOffset` | `number` | `0.0` | Offset for line dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
+| `offsetGridLines` | `boolean` | `false` | If true, grid lines will be shifted to be between labels. This is set to `true` for a category scale in a bar chart by default.
## 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.
+| ---- | ---- | ------- | -----------
+| `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).
-| `lineHeight` | `Number/String` | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
-| `reverse` | `Boolean` | `false` | Reverses order of 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).
+| `lineHeight` | <code>number|string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
+| `reverse` | `boolean` | `false` | Reverses order of tick labels.
| `minor` | `object` | `{}` | Minor ticks configuration. Omitted options are inherited from options above.
| `major` | `object` | `{}` | Major ticks configuration. Omitted options are inherited from options above.
-| `padding` | `Number` | `0` | Sets the offset of the tick labels from the axis
+| `padding` | `number` | `0` | Sets the offset of the tick labels from the axis
## Minor Tick Configuration
The minorTick configuration is nested under the ticks configuration in the `minor` key. It defines options for the minor tick marks that are generated by the axis. Omitted options are inherited from `ticks` configuration.
| 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).
+| ---- | ---- | ------- | -----------
+| `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).
| `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).
-| `lineHeight` | `Number/String` | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
+| `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).
+| `lineHeight` | <code>number|string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
## Major Tick Configuration
The majorTick configuration is nested under the ticks configuration in the `major` key. It defines options for the major tick marks that are generated by the axis. Omitted options are inherited from `ticks` configuration.
| 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).
+| ---- | ---- | ------- | -----------
+| `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).
| `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).
-| `lineHeight` | `Number/String` | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
+| `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).
+| `lineHeight` | <code>number|string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)). | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/area.md | @@ -8,10 +8,10 @@ Both [line](line.md) and [radar](radar.md) charts support a `fill` option on the
| Mode | Type | Values |
| :--- | :--- | :--- |
-| Absolute dataset index <sup>1</sup> | `Number` | `1`, `2`, `3`, ... |
-| Relative dataset index <sup>1</sup> | `String` | `'-1'`, `'-2'`, `'+1'`, ... |
-| Boundary <sup>2</sup> | `String` | `'start'`, `'end'`, `'origin'` |
-| Disabled <sup>3</sup> | `Boolean` | `false` |
+| Absolute dataset index <sup>1</sup> | `number` | `1`, `2`, `3`, ... |
+| Relative dataset index <sup>1</sup> | `string` | `'-1'`, `'-2'`, `'+1'`, ... |
+| Boundary <sup>2</sup> | `string` | `'start'`, `'end'`, `'origin'` |
+| Disabled <sup>3</sup> | `boolean` | `false` |
> <sup>1</sup> dataset filling modes have been introduced in version 2.6.0<br>
> <sup>2</sup> prior version 2.6.0, boundary values was `'zero'`, `'top'`, `'bottom'` (deprecated)<br>
@@ -29,16 +29,16 @@ new Chart(ctx, {
{fill: '-2'} // 4: fill to dataset 2
]
}
-})
+});
```
## Configuration
| Option | Type | Default | Description |
| :--- | :--- | :--- | :--- |
-| [`plugins.filler.propagate`](#propagate) | `Boolean` | `true` | Fill propagation when target is hidden.
+| [`plugins.filler.propagate`](#propagate) | `boolean` | `true` | Fill propagation when target is hidden.
### propagate
-Boolean (default: `true`)
+`propagate` takes a `boolean` value (default: `true`).
If `true`, the fill area will be recursively extended to the visible target defined by the `fill` value of hidden dataset targets:
@@ -61,7 +61,7 @@ new Chart(ctx, {
}
}
}
-})
+});
```
`propagate: true`: | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/bar.md | @@ -66,19 +66,19 @@ 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 color of the bars is generally set this way.
-| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
+| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
| ---- | ---- | :----: | :----: | ----
-| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`borderSkipped`](#borderskipped) | `String` | Yes | Yes | `'bottom'`
-| [`borderWidth`](#styling) | `Number` | Yes | Yes | `0`
-| [`data`](#data-structure) | `Object[]` | - | - | **required**
+| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`borderSkipped`](#borderskipped) | `string` | Yes | Yes | `'bottom'`
+| [`borderWidth`](#styling) | `number` | Yes | Yes | `0`
+| [`data`](#data-structure) | `object[]` | - | - | **required**
| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | - | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | - | Yes | `undefined`
-| [`hoverBorderWidth`](#interactions) | `Number` | - | Yes | `1`
-| [`label`](#general) | `String` | - | - | `''`
-| [`xAxisID`](#general) | `String` | - | - | first x axis
-| [`yAxisID`](#general) | `String` | - | - | first y axis
+| [`hoverBorderWidth`](#interactions) | `number` | - | Yes | `1`
+| [`label`](#general) | `string` | - | - | `''`
+| [`xAxisID`](#general) | `string` | - | - | first x axis
+| [`yAxisID`](#general) | `string` | - | - | first y axis
### General
@@ -130,12 +130,12 @@ The bar chart accepts the following configuration from the associated `scale` op
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
-| `barPercentage` | `Number` | `0.9` | Percent (0-1) of the available width each bar should be within the category width. 1.0 will take the whole category width and put the bars right next to each other. [more...](#barpercentage-vs-categorypercentage)
-| `categoryPercentage` | `Number` | `0.8` | Percent (0-1) of the available width each category should be within the sample width. [more...](#barpercentage-vs-categorypercentage)
-| `barThickness` | `Number/String` | | Manually set width of each bar in pixels. If set to `'flex'`, it computes "optimal" sample widths that globally arrange bars side by side. If not set (default), bars are equally sized based on the smallest interval. [more...](#barthickness)
-| `maxBarThickness` | `Number` | | Set this to ensure that bars are not sized thicker than this.
-| `minBarLength` | `Number` | | Set this to ensure that bars have a minimum length in pixels.
-| `gridLines.offsetGridLines` | `Boolean` | `true` | If true, the bars for a particular data point fall between the grid lines. The grid line will move to the left by one half of the tick interval. If false, the grid line will go right down the middle of the bars. [more...](#offsetgridlines)
+| `barPercentage` | `number` | `0.9` | Percent (0-1) of the available width each bar should be within the category width. 1.0 will take the whole category width and put the bars right next to each other. [more...](#barpercentage-vs-categorypercentage)
+| `categoryPercentage` | `number` | `0.8` | Percent (0-1) of the available width each category should be within the sample width. [more...](#barpercentage-vs-categorypercentage)
+| `barThickness` | <code>number|string</code> | | Manually set width of each bar in pixels. If set to `'flex'`, it computes "optimal" sample widths that globally arrange bars side by side. If not set (default), bars are equally sized based on the smallest interval. [more...](#barthickness)
+| `maxBarThickness` | `number` | | Set this to ensure that bars are not sized thicker than this.
+| `minBarLength` | `number` | | Set this to ensure that bars have a minimum length in pixels.
+| `gridLines.offsetGridLines` | `boolean` | `true` | If true, the bars for a particular data point fall between the grid lines. The grid line will move to the left by one half of the tick interval. If false, the grid line will go right down the middle of the bars. [more...](#offsetgridlines)
### Example Usage
@@ -152,7 +152,7 @@ options = {
}
}]
}
-}
+};
```
### barThickness
If this value is a number, it is applied to the width of each bar, in pixels. When this is enforced, `barPercentage` and `categoryPercentage` are ignored.
@@ -194,7 +194,7 @@ 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.
+The `data` property of a dataset for a bar chart is specified as 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]
@@ -233,7 +233,7 @@ 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).
+| `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. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/bubble.md | @@ -19,15 +19,15 @@ A bubble chart is used to display three dimensions of data at the same time. The
}],
"backgroundColor": "rgb(255, 99, 132)"
}]
- },
+ }
}
{% endchartjs %}
## Example Usage
```javascript
// For a bubble chart
-var myBubbleChart = new Chart(ctx,{
+var myBubbleChart = new Chart(ctx, {
type: 'bubble',
data: data,
options: options
@@ -38,21 +38,21 @@ var myBubbleChart = new Chart(ctx,{
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.
-| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
+| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
| ---- | ---- | :----: | :----: | ----
-| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`borderWidth`](#styling) | `Number` | Yes | Yes | `3`
-| [`data`](#data-structure) | `Object[]` | - | - | **required**
+| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`borderWidth`](#styling) | `number` | Yes | Yes | `3`
+| [`data`](#data-structure) | `object[]` | - | - | **required**
| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
-| [`hoverBorderWidth`](#interactions) | `Number` | Yes | Yes | `1`
-| [`hoverRadius`](#interactions) | `Number` | Yes | Yes | `4`
-| [`hitRadius`](#interactions) | `Number` | Yes | Yes | `1`
-| [`label`](#labeling) | `String` | - | - | `undefined`
-| [`pointStyle`](#styling) | `String` | Yes | Yes | `circle`
-| [`rotation`](#styling) | `Number` | Yes | Yes | `0`
-| [`radius`](#styling) | `Number` | Yes | Yes | `3`
+| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `1`
+| [`hoverRadius`](#interactions) | `number` | Yes | Yes | `4`
+| [`hitRadius`](#interactions) | `number` | Yes | Yes | `1`
+| [`label`](#labeling) | `string` | - | - | `undefined`
+| [`pointStyle`](#styling) | `string` | Yes | Yes | `'circle'`
+| [`rotation`](#styling) | `number` | Yes | Yes | `0`
+| [`radius`](#styling) | `number` | Yes | Yes | `3`
### Labeling
@@ -98,13 +98,13 @@ Bubble chart datasets need to contain a `data` array of points, each points repr
```javascript
{
// X Value
- x: <Number>,
+ x: number,
// Y Value
- y: <Number>,
+ y: number,
// Bubble radius in pixels (not scaled).
- r: <Number>
+ r: number
}
```
| true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/doughnut.md | @@ -14,26 +14,26 @@ They are also registered under two aliases in the `Chart` core. Other than their
"labels": [
"Red",
"Blue",
- "Yellow",
+ "Yellow"
],
"datasets": [{
"label": "My First Dataset",
"data": [300, 50, 100],
"backgroundColor": [
"rgb(255, 99, 132)",
"rgb(54, 162, 235)",
- "rgb(255, 205, 86)",
+ "rgb(255, 205, 86)"
]
}]
- },
+ }
}
{% endchartjs %}
## Example Usage
```javascript
// For a pie chart
-var myPieChart = new Chart(ctx,{
+var myPieChart = new Chart(ctx, {
type: 'pie',
data: data,
options: options
@@ -55,14 +55,14 @@ The doughnut/pie chart allows a number of properties to be specified for each da
| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
| ---- | ---- | :----: | :----: | ----
-| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`borderAlign`](#border-alignment) | `String` | Yes | Yes | `'center'`
+| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`borderAlign`](#border-alignment) | `string` | Yes | Yes | `'center'`
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'#fff'`
-| [`borderWidth`](#styling) | `Number` | Yes | Yes | `2`
-| [`data`](#data-structure) | `Number[]` | - | - | **required**
+| [`borderWidth`](#styling) | `number` | Yes | Yes | `2`
+| [`data`](#data-structure) | `number[]` | - | - | **required**
| [`hoverBackgroundColor`](#interations) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
-| [`hoverBorderWidth`](#interactions) | `Number` | Yes | Yes | `undefined`
+| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `undefined`
### Styling
@@ -102,11 +102,11 @@ These are the customisation options specific to Pie & Doughnut charts. These opt
| 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.
+| `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
@@ -131,4 +131,4 @@ data = {
'Blue'
]
};
-```
\ No newline at end of file
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/line.md | @@ -41,35 +41,35 @@ var myLineChart = new Chart(ctx, {
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.
-| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
+| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
| ---- | ---- | :----: | :----: | ----
-| [`backgroundColor`](#line-styling) | [`Color`](../general/colors.md) | - | - | `'rgba(0,0,0,0.1)'`
-| [`borderCapStyle`](#line-styling) | `String` | - | - | `'butt'`
-| [`borderColor`](#line-styling) | [`Color`](../general/colors.md) | - | - | `'rgba(0,0,0,0.1)'`
-| [`borderDash`](#line-styling) | `Number[]` | - | - | `[]`
-| [`borderDashOffset`](#line-styling) | `Number` | - | - | `0`
-| [`borderJoinStyle`](#line-styling) | `String` | - | - | `'miter'`
-| [`borderWidth`](#line-styling) | `Number` | - | - | `0`
-| [`cubicInterpolationMode`](#cubicInterpolationMode) | `String` | - | - | `''`
-| [`fill`](#line-styling) | `Boolean/String` | - | - | `true`
-| [`label`](#general) | `String` | - | - | `''`
-| [`lineTension`](#line-styling) | `Number` | - | - | `0.4`
-| [`pointBackgroundColor`](#point-styling) | `Color` | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`pointBorderColor`](#point-styling) | `Color` | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`pointBorderWidth`](#point-styling) | `Number` | Yes | Yes | `1`
-| [`pointHitRadius`](#point-styling) | `Number` | Yes | Yes | `1`
+| [`backgroundColor`](#line-styling) | [`Color`](../general/colors.md) | - | - | `'rgba(0, 0, 0, 0.1)'`
+| [`borderCapStyle`](#line-styling) | `string` | - | - | `'butt'`
+| [`borderColor`](#line-styling) | [`Color`](../general/colors.md) | - | - | `'rgba(0, 0, 0, 0.1)'`
+| [`borderDash`](#line-styling) | `number[]` | - | - | `[]`
+| [`borderDashOffset`](#line-styling) | `number` | - | - | `0.0`
+| [`borderJoinStyle`](#line-styling) | `string` | - | - | `'miter'`
+| [`borderWidth`](#line-styling) | `number` | - | - | `3`
+| [`cubicInterpolationMode`](#cubicinterpolationmode) | `string` | - | - | `''`
+| [`fill`](#line-styling) | <code>boolean|string</code> | - | - | `true`
+| [`label`](#general) | `string` | - | - | `''`
+| [`lineTension`](#line-styling) | `number` | - | - | `0.4`
+| [`pointBackgroundColor`](#point-styling) | `Color` | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`pointBorderColor`](#point-styling) | `Color` | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`pointBorderWidth`](#point-styling) | `number` | Yes | Yes | `1`
+| [`pointHitRadius`](#point-styling) | `number` | Yes | Yes | `1`
| [`pointHoverBackgroundColor`](#interactions) | `Color` | Yes | Yes | `undefined`
| [`pointHoverBorderColor`](#interactions) | `Color` | Yes | Yes | `undefined`
-| [`pointHoverBorderWidth`](#interactions) | `Number` | Yes | Yes | `undefined`
-| [`pointHoverRadius`](#interactions) | `Number` | Yes | Yes | `undefined`
-| [`pointRadius`](#point-styling) | `Number` | Yes | Yes | `3`
-| [`pointRotation`](#point-styling) | `Number` | Yes | Yes | `1`
-| [`pointStyle`](#point-styling) | `String/Image` | Yes | Yes | `'circle'`
-| [`showLine`](#general) | `Boolean` | - | - | `undefined`
-| [`spanGaps`](#general) | `Boolean` | - | - | `false`
-| [`steppedLine`](#stepped-line) | `Boolean/String` | - | - | `false`
-| [`xAxisID`](#general) | `String` | - | - | first x axis
-| [`yAxisID`](#general) | `String` | - | - | first y axis
+| [`pointHoverBorderWidth`](#interactions) | `number` | Yes | Yes | `1`
+| [`pointHoverRadius`](#interactions) | `number` | Yes | Yes | `4`
+| [`pointRadius`](#point-styling) | `number` | Yes | Yes | `3`
+| [`pointRotation`](#point-styling) | `number` | Yes | Yes | `0`
+| [`pointStyle`](#point-styling) | <code>string|Image</code> | Yes | Yes | `'circle'`
+| [`showLine`](#line-styling) | `boolean` | - | - | `undefined`
+| [`spanGaps`](#line-styling) | `boolean` | - | - | `undefined`
+| [`steppedLine`](#stepped-line) | <code>boolean|string</code> | - | - | `false`
+| [`xAxisID`](#general) | `string` | - | - | first x axis
+| [`yAxisID`](#general) | `string` | - | - | first y axis
### General
@@ -93,7 +93,7 @@ The style of each point can be controlled with the following properties:
| `pointRotation` | The rotation of the point in degrees.
| `pointStyle` | Style of the point. [more...](../configuration/elements#point-styles)
-All these values, if `undefined`, fallback first to the dataset options then to the associated [`elements.point.*`](../configuration/elements.md#point-configuration) options.
+All these values, if `undefined`, fallback first to the dataset options then to the associated [`elements.point.*`](../configuration/elements.md#point-configuration) options.
### Line Styling
@@ -113,7 +113,7 @@ The style of the line can be controlled with the following properties:
| `showLine` | If false, the line is not drawn for this dataset.
| `spanGaps` | 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.
-All these values, if `undefined`, fallback to the associated [`elements.line.*`](../configuration/elements.md#line-configuration) options.
+If the value is `undefined`, `showLine` and `spanGaps` fallback to the associated [chart configuration options](#configuration-options). The rest of the values fallback to the associated [`elements.line.*`](../configuration/elements.md#line-configuration) options.
### Interactions
@@ -128,19 +128,19 @@ The interaction with each point can be controlled with the following properties:
### cubicInterpolationMode
The following interpolation modes are supported.
-* 'default'
-* 'monotone'
+* `'default'`
+* `'monotone'`
-The 'default' algorithm uses a custom weighted cubic interpolation, which produces pleasant curves for all types of datasets.
+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.
+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.
### Stepped Line
The following values are supported for `steppedLine`.
-* `false`: No Step Interpolation (default)
-* `true`: Step-before Interpolation (eq. 'before')
+* `false`: No Step Interpolation (default)
+* `true`: Step-before Interpolation (eq. `'before'`)
* `'before'`: Step-before Interpolation
* `'after'`: Step-after Interpolation
* `'middle'`: Step-middle Interpolation
@@ -153,8 +153,8 @@ The line chart defines the following configuration options. These options are me
| 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.
+| `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
@@ -169,7 +169,7 @@ Chart.defaults.line.spanGaps = true;
The `data` property of a dataset for a line chart can be passed in two formats.
-### Number[]
+### number[]
```javascript
data: [20, 10]
```
@@ -180,12 +180,12 @@ When the `data` array is an array of numbers, the x axis is generally a [categor
```javascript
data: [{
- x: 10,
- y: 20
- }, {
- x: 15,
- y: 10
- }]
+ 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.
@@ -231,7 +231,7 @@ new Chart(ctx, {
options: {
elements: {
line: {
- tension: 0, // disables bezier curves
+ tension: 0 // disables bezier curves
}
}
}
@@ -249,11 +249,11 @@ new Chart(ctx, {
type: 'line',
data: {
datasets: [{
- showLine: false, // disable for a single dataset
+ showLine: false // disable for a single dataset
}]
},
options: {
- showLines: false, // disable for all datasets
+ showLines: false // disable for all datasets
}
});
```
@@ -270,12 +270,12 @@ new Chart(ctx, {
data: data,
options: {
animation: {
- duration: 0, // general animation time
+ duration: 0 // general animation time
},
hover: {
- animationDuration: 0, // duration of animations when hovering an item
+ animationDuration: 0 // duration of animations when hovering an item
},
- responsiveAnimationDuration: 0, // animation duration after a resize
+ responsiveAnimationDuration: 0 // animation duration after a resize
}
});
``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/mixed.md | @@ -6,67 +6,67 @@ Creating a mixed chart starts with the initialization of a basic chart.
```javascript
var myChart = new Chart(ctx, {
- type: 'bar',
- data: data,
- options: options
+ 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]
+ type: 'bar',
+ data: {
+ datasets: [{
+ label: 'Bar Dataset',
+ data: [10, 20, 30, 40]
}, {
- label: 'Line Dataset',
- data: [50, 50, 50, 50],
+ label: 'Line Dataset',
+ data: [50, 50, 50, 50],
- // Changes this dataset to become a line
- type: 'line'
+ // Changes this dataset to become a line
+ type: 'line'
}],
- labels: ['January', 'February', 'March', 'April']
- },
- options: options
+ 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.
{% chartjs %}
{
- "type": "bar",
- "data": {
- "labels": [
- "January",
- "February",
- "March",
- "April"
- ],
- "datasets": [{
- "label": "Bar Dataset",
- "data": [10, 20, 30, 40],
- "borderColor": "rgb(255, 99, 132)",
- "backgroundColor": "rgba(255, 99, 132, 0.2)"
- }, {
- "label": "Line Dataset",
- "data": [50, 50, 50, 50],
- "type": "line",
- "fill": false,
- "borderColor": "rgb(54, 162, 235)"
- }]
- },
- "options": {
- "scales": {
- "yAxes": [{
- "ticks": {
- "beginAtZero": true
+ "type": "bar",
+ "data": {
+ "labels": [
+ "January",
+ "February",
+ "March",
+ "April"
+ ],
+ "datasets": [{
+ "label": "Bar Dataset",
+ "data": [10, 20, 30, 40],
+ "borderColor": "rgb(255, 99, 132)",
+ "backgroundColor": "rgba(255, 99, 132, 0.2)"
+ }, {
+ "label": "Line Dataset",
+ "data": [50, 50, 50, 50],
+ "type": "line",
+ "fill": false,
+ "borderColor": "rgb(54, 162, 235)"
+ }]
+ },
+ "options": {
+ "scales": {
+ "yAxes": [{
+ "ticks": {
+ "beginAtZero": true
+ }
+ }]
}
- }]
}
- }
}
{% endchartjs %} | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/polar.md | @@ -26,7 +26,7 @@ This type of chart is often useful when we want to show a comparison data simila
"rgb(54, 162, 235)"
]
}]
- },
+ }
}
{% endchartjs %}
@@ -46,14 +46,14 @@ The following options can be included in a polar area chart dataset to configure
| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
| ---- | ---- | :----: | :----: | ----
-| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
-| [`borderAlign`](#border-alignment) | `String` | Yes | Yes | `'center'`
+| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
+| [`borderAlign`](#border-alignment) | `string` | Yes | Yes | `'center'`
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'#fff'`
-| [`borderWidth`](#styling) | `Number` | Yes | Yes | `2`
-| [`data`](#data-structure) | `Number[]` | - | - | **required**
+| [`borderWidth`](#styling) | `number` | Yes | Yes | `2`
+| [`data`](#data-structure) | `number[]` | - | - | **required**
| [`hoverBackgroundColor`](#interations) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
-| [`hoverBorderWidth`](#interactions) | `Number` | Yes | Yes | `undefined`
+| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `undefined`
### Styling
@@ -93,9 +93,9 @@ These are the customisation options specific to Polar Area charts. These options
| 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.
+| `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
| true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/radar.md | @@ -64,44 +64,44 @@ var myRadarChart = new Chart(ctx, {
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.
+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.
+| `label` | `string` | The label for the dataset which appears in the legend and tooltips.
| `backgroundColor` | `Color` | The fill color under the line. See [Colors](../general/colors.md#colors).
| `borderColor` | `Color` | The color of the line. See [Colors](../general/colors.md#colors).
-| `borderWidth` | `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. See [area charts](area.md).
-| `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.
-| `pointRotation` | `Number/Number[]` | The rotation of the point in degrees.
-| `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.
+| `borderWidth` | `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` | <code>boolean|string</code> | How to fill the area under the line. See [area charts](area.md).
+| `lineTension` | `number` | Bezier curve tension of the line. Set to 0 to draw straightlines.
+| `pointBackgroundColor` | <code>Color|Color[]</code> | The fill color for points.
+| `pointBorderColor` | <code>Color|Color[]</code> | The border color for points.
+| `pointBorderWidth` | <code>number|number[]</code> | The width of the point border in pixels.
+| `pointRadius` | <code>number|number[]</code> | The radius of the point shape. If set to 0, the point is not rendered.
+| `pointRotation` | <code>number|number[]</code> | The rotation of the point in degrees.
+| `pointStyle` | <code>string|string[]|Image|Image[]</code> | Style of the point. [more...](#pointstyle)
+| `pointHitRadius` | <code>number|number[]</code> | The pixel size of the non-displayed point that reacts to mouse events.
+| `pointHoverBackgroundColor` | <code>Color|Color[]</code> | Point background color when hovered.
+| `pointHoverBorderColor` | <code>Color|Color[]</code> | Point border color when hovered.
+| `pointHoverBorderWidth` | <code>number|number[]</code> | Border width of point when hovered.
+| `pointHoverRadius` | <code>number|number[]</code> | The radius of the point when hovered.
### pointStyle
The style of point. Options are:
-* 'circle'
-* 'cross'
-* 'crossRot'
-* 'dash'.
-* 'line'
-* 'rect'
-* 'rectRounded'
-* 'rectRot'
-* 'star'
-* 'triangle'
+* `'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).
@@ -128,7 +128,7 @@ It is common to want to apply a configuration setting to all created radar chart
## 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.
+The `data` property of a dataset for a radar chart is specified as 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] | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/charts/scatter.md | @@ -46,4 +46,4 @@ data: [{
x: 15,
y: 10
}]
-```
\ No newline at end of file
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/configuration/README.md | @@ -14,9 +14,9 @@ The following example would set the hover mode to 'nearest' for all charts where
Chart.defaults.global.hover.mode = 'nearest';
// Hover mode is set to nearest because it was not overridden here
-var chartHoverModeNearest = new Chart(ctx, {
+var chartHoverModeNearest = new Chart(ctx, {
type: 'line',
- data: data,
+ data: data
});
// This chart would have the hover mode that was passed in
@@ -29,5 +29,5 @@ var chartDifferentHoverMode = new Chart(ctx, {
mode: 'index'
}
}
-})
+});
``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/configuration/animations.md | @@ -7,14 +7,15 @@ Chart.js animates charts out of the box. A number of options are provided to con
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)
+| ---- | ---- | ------- | -----------
+| `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:
+
+Available options are:
* `'linear'`
* `'easeInQuad'`
* `'easeOutQuad'`
@@ -59,22 +60,22 @@ The `onProgress` and `onComplete` callbacks are useful for synchronizing an exte
chart: Chart,
// Current Animation frame number
- currentStep: Number,
+ currentStep: number,
// Number of animation frames
- numSteps: Number,
+ numSteps: number,
// Animation easing to use
- easing: String,
+ easing: string,
// Function that renders the chart
- render: Function,
+ render: function,
// User callback
- onAnimationProgress: Function,
+ onAnimationProgress: function,
// User callback
- onAnimationComplete: Function
+ onAnimationComplete: function
}
```
| true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/configuration/elements.md | @@ -11,21 +11,21 @@ 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.
+Point elements are used to represent the points in a line, radar or bubble chart.
Global point options: `Chart.defaults.global.elements.point`.
| Name | Type | Default | Description
-| -----| ---- | --------| -----------
-| `radius` | `Number` | `3` | Point radius.
-| [`pointStyle`](#point-styles) | `String` | `circle` | Point style.
-| `rotation` | `Number` | `0` | Point rotation (in degrees).
-| `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.
+| ---- | ---- | ------- | -----------
+| `radius` | `number` | `3` | Point radius.
+| [`pointStyle`](#point-styles) | <code>string|Image</code> | `'circle'` | Point style.
+| `rotation` | `number` | `0` | Point rotation (in degrees).
+| `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.
### Point Styles
@@ -49,38 +49,39 @@ 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).
+| ---- | ---- | ------- | -----------
+| `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` | `number[]` | `[]` | Line dash. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
+| `borderDashOffset` | `number` | `0.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` | <code>boolean|string</code> | `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'`.
+| ---- | ---- | ------- | -----------
+| `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.
+| ---- | ---- | ------- | -----------
+| `backgroundColor` | `Color` | `'rgba(0, 0, 0, 0.1)'` | Arc fill color.
+| `borderAlign` | `string` | `'center'` | Arc stroke alignment.
| `borderColor` | `Color` | `'#fff'` | Arc stroke color.
-| `borderWidth`| `Number` | `2` | Arc stroke width.
+| `borderWidth`| `number` | `2` | Arc stroke width. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/configuration/layout.md | @@ -3,11 +3,11 @@
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` | <code>number|object</code> | `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.
+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:
@@ -26,4 +26,4 @@ let chart = new Chart(ctx, {
}
}
});
-```
\ No newline at end of file
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/configuration/legend.md | @@ -6,14 +6,14 @@ The chart legend displays data about the datasets that are appearing on the char
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.
+| ---- | ---- | ------- | -----------
+| `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:
@@ -27,16 +27,16 @@ Position of the legend. Options are:
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.
+| ---- | ---- | ------- | -----------
+| `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](#legend-item-interface) for details.
-| `filter` | `Function` | `null` | Filters legend items out of the legend. Receives 2 parameters, a [Legend Item](#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).
+| `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](#legend-item-interface) for details.
+| `filter` | `function` | `null` | Filters legend items out of the legend. Receives 2 parameters, a [Legend Item](#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
@@ -45,34 +45,34 @@ Items passed to the legend `onClick` function are the ones returned from `labels
```javascript
{
// Label that will be displayed
- text: String,
+ 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,
+ hidden: boolean,
// For box border. See https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap
- lineCap: String,
+ lineCap: string,
// For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
- lineDash: Array[Number],
+ lineDash: number[],
// For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
- lineDashOffset: Number,
+ lineDashOffset: number,
// For box border. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin
- lineJoin: String,
+ lineJoin: string,
// Width of box border
- lineWidth: Number,
+ lineWidth: number,
// Stroke style of the legend box
- strokeStyle: Color
+ strokeStyle: Color,
// Point style of the legend box (only used if usePointStyle is true)
- pointStyle: String
+ pointStyle: string
}
```
@@ -91,7 +91,7 @@ var chart = new Chart(ctx, {
fontColor: 'rgb(255, 99, 132)'
}
}
-}
+ }
});
```
@@ -107,7 +107,7 @@ function(e, legendItem) {
var meta = ci.getDatasetMeta(index);
// See controller.isDatasetVisible comment
- meta.hidden = meta.hidden === null? !ci.data.datasets[index].hidden : null;
+ meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
// We hid a dataset ... rerender the chart
ci.update();
@@ -126,9 +126,11 @@ var newLegendClickHandler = function (e, legendItem) {
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.getDatasetMeta(0),
+ ci.getDatasetMeta(1)
+ ].forEach(function(meta) {
+ meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
});
ci.update();
}
@@ -139,7 +141,7 @@ var chart = new Chart(ctx, {
data: data,
options: {
legend: {
-
+ onClick: newLegendClickHandler
}
}
}); | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/configuration/title.md | @@ -6,16 +6,16 @@ The chart title defines text to draw at the top of the chart.
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.
+| ---- | ---- | ------- | -----------
+| `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.
-| `lineHeight` | `Number/String` | `1.2` | Height of an individual line of text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height).
-| `text` | `String/String[]` | `''` | Title text to display. If specified as an array, text is rendered on multiple lines.
+| `fontStyle` | `string` | `'bold'` | Font style.
+| `padding` | `number` | `10` | Number of pixels to add above and below the title text.
+| `lineHeight` | <code>number|string</code> | `1.2` | Height of an individual line of text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height).
+| `text` | <code>string|string[]</code> | `''` | Title text to display. If specified as an array, text is rendered on multiple lines.
### Position
Possible title position values are:
@@ -38,5 +38,5 @@ var chart = new Chart(ctx, {
text: 'Custom Chart Title'
}
}
-})
+});
``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/configuration/tooltip.md | @@ -5,51 +5,52 @@
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 on-canvas tooltips enabled?
-| `custom` | `Function` | `null` | See [custom tooltip](#external-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.
+| ---- | ---- | ------- | -----------
+| `enabled` | `boolean` | `true` | Are on-canvas tooltips enabled?
+| `custom` | `function` | `null` | See [custom tooltip](#external-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.
+| `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.
+| `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 footer line.
-| `footerMarginTop` | `Number` | `6` | Margin to add before drawing the footer.
-| `xPadding` | `Number` | `6` | Padding to add on left and right of tooltip.
-| `yPadding` | `Number` | `6` | Padding to add on top and bottom of tooltip.
-| `caretPadding` | `Number` | `2` | Extra distance to move the end of the tooltip arrow away from the tooltip point.
-| `caretSize` | `Number` | `5` | Size, in px, of the tooltip arrow.
-| `cornerRadius` | `Number` | `6` | Radius of tooltip corner curves.
+| `footerSpacing` | `number` | `2` | Spacing to add to top and bottom of each footer line.
+| `footerMarginTop` | `number` | `6` | Margin to add before drawing the footer.
+| `xPadding` | `number` | `6` | Padding to add on left and right of tooltip.
+| `yPadding` | `number` | `6` | Padding to add on top and bottom of tooltip.
+| `caretPadding` | `number` | `2` | Extra distance to move the end of the tooltip arrow away from the tooltip point.
+| `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.
+| `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.
+Possible modes are:
+* `'average'`
+* `'nearest'`
-New modes can be defined by adding functions to the Chart.Tooltip.positioners map.
+`'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.
Example:
```javascript
@@ -70,7 +71,7 @@ Chart.Tooltip.positioners.custom = function(elements, eventPosition) {
x: 0,
y: 0
};
-}
+};
```
### Sort Callback
@@ -83,29 +84,29 @@ Allows filtering of [tooltip items](#tooltip-item-interface). Must implement at
## 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.
+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](#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.
+All functions are called with the same arguments: a [tooltip item](#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)
-| `labelTextColor` | `tooltipItem, chart` | Returns the colors for the text of the label for the tooltip item.
-| `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.
+| `beforeTitle` | `TooltipItem[], object` | Returns the text to render before the title.
+| `title` | `TooltipItem[], object` | Returns text to render as the title of the tooltip.
+| `afterTitle` | `TooltipItem[], object` | Returns text to render after the title.
+| `beforeBody` | `TooltipItem[], object` | Returns text to render before the body section.
+| `beforeLabel` | `TooltipItem, object` | Returns text to render before an individual label. This will be called for each item in the tooltip.
+| `label` | `TooltipItem, object` | Returns text to render for an individual item in the tooltip. [more...](#label-callback)
+| `labelColor` | `TooltipItem, Chart` | Returns the colors to render for the tooltip item. [more...](#label-color-callback)
+| `labelTextColor` | `TooltipItem, Chart` | Returns the colors for the text of the label for the tooltip item.
+| `afterLabel` | `TooltipItem, object` | Returns text to render after an individual label.
+| `afterBody` | `TooltipItem[], object` | Returns text to render after the body section.
+| `beforeFooter` | `TooltipItem[], object` | Returns text to render before the footer section.
+| `footer` | `TooltipItem[], object` | Returns text to render as the footer of the tooltip.
+| `afterFooter` | `TooltipItem[], object` | Text to render after the footer section.
### Label Callback
-The label callback can change the text that displays for a given data point. A common example to round data values; the following example rounds the data to two decimal places.
+The `label` callback can change the text that displays for a given data point. A common example to round data values; the following example rounds the data to two decimal places.
```javascript
var chart = new Chart(ctx, {
@@ -143,9 +144,9 @@ var chart = new Chart(ctx, {
return {
borderColor: 'rgb(255, 0, 0)',
backgroundColor: 'rgb(255, 0, 0)'
- }
+ };
},
- labelTextColor:function(tooltipItem, chart){
+ labelTextColor: function(tooltipItem, chart) {
return '#543453';
}
}
@@ -162,22 +163,22 @@ The tooltip items passed to the tooltip callbacks implement the following interf
```javascript
{
// X Value of the tooltip as a string
- xLabel: String,
+ xLabel: string,
// Y value of the tooltip as a string
- yLabel: String,
+ yLabel: string,
// Index of the dataset the item comes from
- datasetIndex: Number,
+ datasetIndex: number,
// Index of this data item in the dataset
- index: Number,
+ index: number,
// X position of matching point
- x: Number,
+ x: number,
// Y position of matching point
- y: Number,
+ y: number
}
```
@@ -202,7 +203,7 @@ var myPieChart = new Chart(ctx, {
if (!tooltipEl) {
tooltipEl = document.createElement('div');
tooltipEl.id = 'chartjs-tooltip';
- tooltipEl.innerHTML = "<table></table>";
+ tooltipEl.innerHTML = '<table></table>';
document.body.appendChild(tooltipEl);
}
@@ -280,71 +281,75 @@ The tooltip model contains parameters that can be used to render the tooltip.
dataPoints: TooltipItem[],
// Positioning
- xPadding: Number,
- yPadding: Number,
- xAlign: String,
- yAlign: String,
+ 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,
+ x: number,
+ y: number,
+ width: number,
+ height: number,
// Where the tooltip points to
- caretX: Number,
- caretY: Number,
+ caretX: number,
+ caretY: number,
// Body
// The body lines that need to be rendered
// Each object 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[],
+ // 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[],
+ beforeBody: string[],
// line of text that appear after the body and before the footer
- afterBody: String[],
+ afterBody: string[],
bodyFontColor: Color,
- _bodyFontFamily: String,
- _bodyFontStyle: String,
- _bodyAlign: String,
- bodyFontSize: Number,
- bodySpacing: Number,
+ _bodyFontFamily: string,
+ _bodyFontStyle: string,
+ _bodyAlign: string,
+ bodyFontSize: number,
+ bodySpacing: number,
// Title
// lines of text that form the title
- title: String[],
+ title: string[],
titleFontColor: Color,
- _titleFontFamily: String,
- _titleFontStyle: String,
- titleFontSize: Number,
- _titleAlign: String,
- titleSpacing: Number,
- titleMarginBottom: Number,
+ _titleFontFamily: string,
+ _titleFontStyle: string,
+ titleFontSize: number,
+ _titleAlign: string,
+ titleSpacing: number,
+ titleMarginBottom: number,
// Footer
// lines of text that form the footer
- footer: String[],
+ footer: string[],
footerFontColor: Color,
- _footerFontFamily: String,
- _footerFontStyle: String,
- footerFontSize: Number,
- _footerAlign: String,
- footerSpacing: Number,
- footerMarginTop: Number,
+ _footerFontFamily: string,
+ _footerFontStyle: string,
+ footerFontSize: number,
+ _footerAlign: string,
+ footerSpacing: number,
+ footerMarginTop: number,
// Appearance
- caretSize: Number,
- cornerRadius: Number,
+ caretSize: number,
+ caretPadding: 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[],
+ labelTextColors: Color[],
// 0 opacity is a hidden tooltip
- opacity: Number,
+ opacity: number,
legendColorBackground: Color,
- displayColors: Boolean,
+ displayColors: boolean,
+ borderColor: Color,
+ borderWidth: number
}
``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/developers/api.md | @@ -1,6 +1,6 @@
# 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.
+For each chart, there are a set of global prototype methods on the shared chart type 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:
@@ -42,7 +42,7 @@ Example:
myChart.update({
duration: 800,
easing: 'easeOutBounce'
-})
+});
```
See [Updating Charts](updates.md) for more details.
@@ -65,9 +65,9 @@ See `.update(config)` for more details on the config object.
// 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: 800,
- lazy: false,
- easing: 'easeOutBounce'
+ duration: 800,
+ lazy: false,
+ easing: 'easeOutBounce'
});
```
@@ -148,7 +148,7 @@ Looks for the element under the event point, then returns all elements at the sa
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){
+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.
};
@@ -175,5 +175,5 @@ Extensive examples of usage are available in the [Chart.js tests](https://github
```javascript
var meta = myChart.getDatasetMeta(0);
-var x = meta.data[0]._model.x
+var x = meta.data[0]._model.x;
``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/developers/axes.md | @@ -1,6 +1,6 @@
# New Axes
-Axes in Chart.js can be individually extended. Axes should always derive from Chart.Scale but this is not a mandatory requirement.
+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({
@@ -29,7 +29,7 @@ var lineChart = new Chart(ctx, {
}]
}
}
-})
+});
```
## Scale Properties
@@ -38,26 +38,26 @@ 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
+ 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,
+ 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,
+ paddingLeft: number,
+ paddingRight: number,
+ paddingTop: number,
+ paddingBottom: number
}
```
@@ -78,15 +78,13 @@ To work with Chart.js, custom scale types must implement the following interface
// 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 halfway between the given tick and the next
- getPixelForTick: function(index, includeOffset) {},
+ getPixelForTick: function(index) {},
// 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 halfway between the given tick and the next
- getPixelForValue: function(value, index, datasetIndex, includeOffset) {}
+ getPixelForValue: function(value, index, datasetIndex) {},
// Get the value for a given pixel (x coordinate for horizontal axis, y coordinate for vertical axis)
// @param pixel : pixel value
@@ -97,6 +95,7 @@ To work with Chart.js, custom scale types must implement the following interface
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() {},
@@ -112,7 +111,8 @@ Optionally, the following methods may also be overwritten, but an implementation
// 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) {},
+ draw: function(chartArea) {}
+}
```
The Core.Scale base class also has some utility functions that you may find useful.
@@ -125,7 +125,10 @@ The Core.Scale base class also has some utility functions that you may find usef
// 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
+ // Note that in all cases, the returned value is not guaranteed to be a number
getRightValue: function(dataValue) {},
+
+ // Returns the scale tick objects ({label, major})
+ getTicks: function() {}
}
-```
\ No newline at end of file
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/developers/charts.md | @@ -41,7 +41,7 @@ Dataset controllers must implement the following interface.
// 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) {},
+ update: function(reset) {}
}
```
@@ -108,9 +108,9 @@ Chart.controllers.derivedBubble = custom;
new Chart(ctx, {
type: 'derivedBubble',
data: data,
- options: options,
+ 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
+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. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/developers/contributing.md | @@ -11,7 +11,7 @@ New contributions to the library are welcome, but we ask that you please follow
# Joining the project
- Active committers and contributors are invited to introduce yourself and request commit access to this project. We have a very active Slack community that you can join [here](https://chartjs-slack.herokuapp.com/). If you think you can help, we'd love to have you!
+Active committers and contributors are invited to introduce yourself and request commit access to this project. We have a very active Slack community that you can join [here](https://chartjs-slack.herokuapp.com/). If you think you can help, we'd love to have you!
# Building and Testing
| true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/developers/plugins.md | @@ -69,7 +69,7 @@ Plugin options are located under the `options.plugins` config and are scoped by
```javascript
var chart = new Chart(ctx, {
- config: {
+ options: {
foo: { ... }, // chart 'foo' option
plugins: {
p1: {
@@ -96,7 +96,7 @@ Chart.plugins.register({
});
var chart = new Chart(ctx, {
- config: {
+ options: {
plugins: {
p1: false // disable plugin 'p1' for this instance
}
@@ -106,27 +106,27 @@ var chart = new Chart(ctx, {
## Plugin Core API
-Available hooks (as of version 2.6):
-
-* beforeInit
-* afterInit
-* beforeUpdate *(cancellable)*
-* afterUpdate
-* beforeLayout *(cancellable)*
-* afterLayout
-* beforeDatasetsUpdate *(cancellable)*
-* afterDatasetsUpdate
-* beforeDatasetUpdate *(cancellable)*
-* afterDatasetUpdate
-* beforeRender *(cancellable)*
-* afterRender
-* beforeDraw *(cancellable)*
-* afterDraw
-* beforeDatasetsDraw *(cancellable)*
-* afterDatasetsDraw
-* beforeDatasetDraw *(cancellable)*
-* afterDatasetDraw
-* beforeEvent *(cancellable)*
-* afterEvent
-* resize
-* destroy
+Available hooks (as of version 2.7):
+
+* `beforeInit`
+* `afterInit`
+* `beforeUpdate` *(cancellable)*
+* `afterUpdate`
+* `beforeLayout` *(cancellable)*
+* `afterLayout`
+* `beforeDatasetsUpdate` *(cancellable)*
+* `afterDatasetsUpdate`
+* `beforeDatasetUpdate` *(cancellable)*
+* `afterDatasetUpdate`
+* `beforeRender` *(cancellable)*
+* `afterRender`
+* `beforeDraw` *(cancellable)*
+* `afterDraw`
+* `beforeDatasetsDraw` *(cancellable)*
+* `afterDatasetsDraw`
+* `beforeDatasetDraw` *(cancellable)*
+* `afterDatasetDraw`
+* `beforeEvent` *(cancellable)*
+* `afterEvent`
+* `resize`
+* `destroy` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/developers/updates.md | @@ -40,8 +40,8 @@ function updateConfigByMutating(chart) {
function updateConfigAsNewObject(chart) {
chart.options = {
responsive: true,
- title:{
- display:true,
+ title: {
+ display: true,
text: 'Chart.js'
},
scales: {
@@ -52,7 +52,7 @@ function updateConfigAsNewObject(chart) {
display: true
}]
}
- }
+ };
chart.update();
}
```
@@ -75,7 +75,7 @@ function updateScales(chart) {
display: true,
type: 'logarithmic'
}]
- }
+ };
chart.update();
// need to update the reference
xScale = chart.scales['newId'];
@@ -89,7 +89,7 @@ You can also update a specific scale either by specifying its index or id.
function updateScale(chart) {
chart.options.scales.yAxes[0] = {
type: 'logarithmic'
- }
+ };
chart.update();
}
```
@@ -98,4 +98,4 @@ Code sample for updating options can be found in [toggle-scale-type.html](../../
## Preventing Animations
-Sometimes when a chart updates, you may not want an animation. To achieve this you can call `update` with a duration of `0`. This will render the chart synchronously and without an animation.
\ No newline at end of file
+Sometimes when a chart updates, you may not want an animation. To achieve this you can call `update` with a duration of `0`. This will render the chart synchronously and without an animation. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/accessibility.md | @@ -2,7 +2,7 @@
Chart.js charts are rendered on user provided `canvas` elements. Thus, it is up to the user to create the `canvas` element in a way that is accessible. The `canvas` element has support in all browsers and will render on screen but the `canvas` content will not be accessible to screen readers.
-With `canvas`, the accessibility has to be added with `ARIA` attributes on the `canvas` element or added using internal fallback content placed within the opening and closing canvas tags.
+With `canvas`, the accessibility has to be added with ARIA attributes on the `canvas` element or added using internal fallback content placed within the opening and closing canvas tags.
This [website](http://pauljadam.com/demos/canvas.html) has a more detailed explanation of `canvas` accessibility as well as in depth examples.
@@ -20,7 +20,7 @@ This `canvas` element has a text alternative via fallback content.
```html
<canvas id="okCanvas2" width="400" height="100">
- <p>Hello Fallback World</p>
+ <p>Hello Fallback World</p>
</canvas>
```
| true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/colors.md | @@ -25,8 +25,8 @@ img.onload = function() {
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/).
@@ -41,9 +41,9 @@ var chartData = {
pattern.draw('square', '#ff6384'),
pattern.draw('circle', '#36a2eb'),
pattern.draw('diamond', '#cc65fe'),
- pattern.draw('triangle', '#ffce56'),
+ pattern.draw('triangle', '#ffce56')
]
}],
labels: ['Red', 'Blue', 'Purple', 'Yellow']
};
-```
\ No newline at end of file
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/device-pixel-ratio.md | @@ -10,4 +10,4 @@ Setting `devicePixelRatio` to a value other than 1 will force the canvas size to
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
-| `devicePixelRatio` | `Number` | window.devicePixelRatio | Override the window's default devicePixelRatio.
+| `devicePixelRatio` | `number` | `window.devicePixelRatio` | Override the window's default devicePixelRatio. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/fonts.md | @@ -23,9 +23,9 @@ let chart = new Chart(ctx, {
| 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.
+| `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.
## Missing Fonts
| true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/interactions/README.md | @@ -4,7 +4,7 @@ The hover configuration is passed into the `options.hover` namespace. The global
| 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.
-| `axis` | `String` | `'x'` | Can be set to `'x'`, `'y'`, or `'xy'` to define which directions are used in calculating distances. Defaults to `'x'` for `index` mode and `'xy'` in `dataset` and `nearest` modes.
-| `animationDuration` | `Number` | `400` | Duration in milliseconds it takes to animate hover style changes.
+| `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.
+| `axis` | `string` | `'x'` | Can be set to `'x'`, `'y'`, or `'xy'` to define which directions are used in calculating distances. Defaults to `'x'` for `'index'` mode and `'xy'` in `dataset` and `'nearest'` modes.
+| `animationDuration` | `number` | `400` | Duration in milliseconds it takes to animate hover style changes. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/interactions/events.md | @@ -3,9 +3,9 @@ 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.
+| `events` | `string[]` | `['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']` | 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: | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/interactions/modes.md | @@ -16,7 +16,7 @@ var chart = new Chart(ctx, {
mode: 'point'
}
}
-})
+});
```
## nearest
@@ -31,11 +31,11 @@ var chart = new Chart(ctx, {
mode: 'nearest'
}
}
-})
+});
```
## single (deprecated)
-Finds the first item that intersects the point and returns it. Behaves like 'nearest' mode with intersect = true.
+Finds the first item that intersects the point and returns it. Behaves like `'nearest'` mode with `intersect = true`.
## label (deprecated)
See `'index'` mode.
@@ -52,7 +52,7 @@ var chart = new Chart(ctx, {
mode: 'index'
}
}
-})
+});
```
To use index mode in a chart like the horizontal bar chart, where we search along the y direction, you can use the `axis` setting introduced in v2.7.0. By setting this value to `'y'` on the y direction is used.
@@ -67,7 +67,7 @@ var chart = new Chart(ctx, {
axis: 'y'
}
}
-})
+});
```
## x-axis (deprecated)
@@ -85,7 +85,7 @@ var chart = new Chart(ctx, {
mode: 'dataset'
}
}
-})
+});
```
## x
@@ -100,7 +100,7 @@ var chart = new Chart(ctx, {
mode: 'x'
}
}
-})
+});
```
## y
@@ -115,5 +115,5 @@ var chart = new Chart(ctx, {
mode: 'y'
}
}
-})
-```
\ No newline at end of file
+});
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/general/responsive.md | @@ -13,15 +13,15 @@ Chart.js provides a [few options](#configuration-options) to enable responsivene
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
-| `responsive` | `Boolean` | `true` | Resizes the chart canvas when its container does ([important note...](#important-note)).
-| `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.
-| `aspectRatio` | `Number` | `2` | Canvas aspect ratio (i.e. `width / height`, a value of 1 representing a square canvas). Note that this option is ignored if the height is explicitly defined either as attribute or via the style.
-| `onResize` | `Function` | `null` | Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.
+| `responsive` | `boolean` | `true` | Resizes the chart canvas when its container does ([important note...](#important-note)).
+| `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.
+| `aspectRatio` | `number` | `2` | Canvas aspect ratio (i.e. `width / height`, a value of 1 representing a square canvas). Note that this option is ignored if the height is explicitly defined either as attribute or via the style.
+| `onResize` | `function` | `null` | Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.
## Important Note
-Detecting when the canvas size changes can not be done directly from the `CANVAS` element. Chart.js uses its parent container to update the canvas *render* and *display* sizes. However, this method requires the container to be **relatively positioned** and **dedicated to the chart canvas only**. Responsiveness can then be achieved by setting relative values for the container size ([example](https://codepen.io/chartjs/pen/YVWZbz)):
+Detecting when the canvas size changes can not be done directly from the `canvas` element. Chart.js uses its parent container to update the canvas *render* and *display* sizes. However, this method requires the container to be **relatively positioned** and **dedicated to the chart canvas only**. Responsiveness can then be achieved by setting relative values for the container size ([example](https://codepen.io/chartjs/pen/YVWZbz)):
```html
<div class="chart-container" style="position: relative; height:40vh; width:80vw">
@@ -44,8 +44,8 @@ CSS media queries allow changing styles when printing a page. The CSS applied fr
```javascript
function beforePrintHandler () {
- for (var id in Chart.instances) {
- Chart.instances[id].resize()
- }
+ for (var id in Chart.instances) {
+ Chart.instances[id].resize();
+ }
}
``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/getting-started/README.md | @@ -11,7 +11,7 @@ First, we need to have a canvas in our page.
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"></script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
```
Now, we can create a chart. We add a script to our page:
@@ -24,12 +24,12 @@ var chart = new Chart(ctx, {
// The data for our dataset
data: {
- labels: ["January", "February", "March", "April", "May", "June", "July"],
+ labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
- label: "My First dataset",
+ label: 'My First dataset',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
- data: [0, 10, 5, 2, 20, 30, 45],
+ data: [0, 10, 5, 2, 20, 30, 45]
}]
},
@@ -40,4 +40,4 @@ var chart = new Chart(ctx, {
It's that easy to get started using Chart.js! From here you can explore the many options that can help you customise your charts with scales, tooltips, labels, colors, custom actions, and much more.
-There are many examples of Chart.js that are available in the `/samples` folder of `Chart.js.zip` that is attached to every [release](https://github.com/chartjs/Chart.js/releases).
\ No newline at end of file
+All our examples are [available online](https://www.chartjs.org/samples/latest/) but you can also download the `Chart.js.zip` archive attached to every [release](https://github.com/chartjs/Chart.js/releases) to experiment with our samples locally from the `/samples` folder. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/getting-started/installation.md | @@ -40,7 +40,7 @@ If you download or clone the repository, you must [build](../developers/contribu
# Selecting the Correct Build
-Chart.js provides two different builds for you to choose: `Stand-Alone Build`, `Bundled Build`.
+Chart.js provides two different builds for you to choose: **Stand-Alone Build**, **Bundled Build**.
## Stand-Alone Build
Files:
@@ -54,4 +54,4 @@ Files:
* `dist/Chart.bundle.js`
* `dist/Chart.bundle.min.js`
-The bundled build includes Moment.js in a single file. You should use this version if you require time axes and want to include a single file. You should not use this build if your application already included Moment.js. Otherwise, Moment.js will be included twice which results in increasing page load time and possible version compatability issues. The Moment.js version in the bundled build is private to Chart.js so if you want to use Moment.js yourself, it's better to use Chart.js (non bundled) and import Moment.js manually.
+The bundled build includes Moment.js in a single file. You should use this version if you require time axes and want to include a single file. You should not use this build if your application already included Moment.js. Otherwise, Moment.js will be included twice which results in increasing page load time and possible version compatibility issues. The Moment.js version in the bundled build is private to Chart.js so if you want to use Moment.js yourself, it's better to use Chart.js (non bundled) and import Moment.js manually. | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/getting-started/integration.md | @@ -28,9 +28,9 @@ var myChart = new Chart(ctx, {...});
## Require JS
```javascript
-require(['path/to/chartjs/dist/Chart.js'], function(Chart){
+require(['path/to/chartjs/dist/Chart.js'], function(Chart) {
var myChart = new Chart(ctx, {...});
});
```
-> **Important:** RequireJS [can **not** load CommonJS module as is](http://www.requirejs.org/docs/commonjs.html#intro), so be sure to require one of the built UMD files instead (i.e. `dist/Chart.js`, `dist/Chart.min.js`, etc.).
+> **Important:** RequireJS [can **not** load CommonJS module as is](https://requirejs.org/docs/commonjs.html#intro), so be sure to require one of the built UMD files instead (i.e. `dist/Chart.js`, `dist/Chart.min.js`, etc.). | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/getting-started/usage.md | @@ -11,10 +11,10 @@ To create a chart, we need to instantiate the `Chart` class. To do this, we need
```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";
+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!
@@ -24,11 +24,11 @@ The following example instantiates a bar chart showing the number of votes for d
```html
<canvas id="myChart" width="400" height="400"></canvas>
<script>
-var ctx = document.getElementById("myChart");
+var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
- labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
+ labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
@@ -41,7 +41,7 @@ var myChart = new Chart(ctx, {
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
- 'rgba(255,99,132,1)',
+ 'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
@@ -55,11 +55,11 @@ var myChart = new Chart(ctx, {
scales: {
yAxes: [{
ticks: {
- beginAtZero:true
+ beginAtZero: true
}
}]
}
}
});
</script>
-```
\ No newline at end of file
+``` | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/notes/README.md | @@ -1 +1 @@
-# Additional Notes
\ No newline at end of file
+# Additional Notes | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/notes/comparison.md | @@ -9,7 +9,7 @@ Library Features
| SVG | | ✓ | ✓ | ✓ |
| Built-in Charts | ✓ | | ✓ | ✓ |
| 8+ Chart Types | ✓ | ✓ | ✓ | |
-| Extendable to Custom Charts | ✓ | ✓ | | |
+| Extendable to Custom Charts | ✓ | ✓ | | |
| Supports Modern Browsers | ✓ | ✓ | ✓ | ✓ |
| Extensive Documentation | ✓ | ✓ | ✓ | ✓ |
| Open Source | ✓ | ✓ | | ✓ |
@@ -24,9 +24,8 @@ Built in Chart Types
| Horizontal Bar | ✓ | ✓ | ✓ |
| Pie/Doughnut | ✓ | ✓ | ✓ |
| Polar Area | ✓ | ✓ | |
-| Radar | ✓ | | |
+| Radar | ✓ | | |
| Scatter | ✓ | ✓ | ✓ |
| Bubble | ✓ | | |
| Gauges | | ✓ | |
| Maps (Heat/Tree/etc.) | | ✓ | |
- | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/notes/extensions.md | @@ -65,6 +65,6 @@ In addition, many plugins can be found on the [npm registry](https://www.npmjs.c
### Ember.js
- <a href="https://github.com/aomran/ember-cli-chart" target="_blank">ember-cli-chart</a>
-
+
### Omi (v5+)
- <a href="https://github.com/Tencent/omi/tree/master/packages/omi-chart" target="_blank">omi-chart</a> | true |
Other | chartjs | Chart.js | 0d01bcf5cca3a85c97305ad44925113cdead9c74.json | Fix typos and make the docs consistent (#6020) | docs/notes/license.md | @@ -1,3 +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="https://opensource.org/licenses/MIT" target="_blank">MIT license</a>.
\ No newline at end of file
+Chart.js is <a href="https://github.com/chartjs/Chart.js" target="_blank">open source</a> and available under the <a href="https://opensource.org/licenses/MIT" target="_blank">MIT license</a>. | true |
Other | chartjs | Chart.js | e6a0c8690981de60d789f74e605f6d6b4557e3f6.json | Fix pointBackgroundColor in radar sample (#6013) | samples/charts/radar.html | @@ -102,7 +102,7 @@
label: 'Dataset ' + config.data.datasets.length,
borderColor: newColor,
backgroundColor: color(newColor).alpha(0.2).rgbString(),
- pointBorderColor: newColor,
+ pointBackgroundColor: newColor,
data: [],
};
| false |
Other | chartjs | Chart.js | 8b110fdc513141e99848ae236860741e48cc31ff.json | Handle any element in triggerMouseEvent in tests (#5994) | test/specs/controller.polarArea.tests.js | @@ -281,12 +281,12 @@ describe('Chart.controllers.polarArea', function() {
var chart = this.chart;
var arc = chart.getDatasetMeta(0).data[0];
- jasmine.triggerMouseEvent(chart, 'mousemove', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mousemove', arc);
expect(arc._model.backgroundColor).toBe('rgb(49, 135, 221)');
expect(arc._model.borderColor).toBe('rgb(22, 89, 156)');
expect(arc._model.borderWidth).toBe(2);
- jasmine.triggerMouseEvent(chart, 'mouseout', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mouseout', arc);
expect(arc._model.backgroundColor).toBe('rgb(100, 150, 200)');
expect(arc._model.borderColor).toBe('rgb(50, 100, 150)');
expect(arc._model.borderWidth).toBe(2);
@@ -304,12 +304,12 @@ describe('Chart.controllers.polarArea', function() {
chart.update();
- jasmine.triggerMouseEvent(chart, 'mousemove', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mousemove', arc);
expect(arc._model.backgroundColor).toBe('rgb(200, 100, 150)');
expect(arc._model.borderColor).toBe('rgb(150, 50, 100)');
expect(arc._model.borderWidth).toBe(8.4);
- jasmine.triggerMouseEvent(chart, 'mouseout', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mouseout', arc);
expect(arc._model.backgroundColor).toBe('rgb(100, 150, 200)');
expect(arc._model.borderColor).toBe('rgb(50, 100, 150)');
expect(arc._model.borderWidth).toBe(2);
@@ -327,12 +327,12 @@ describe('Chart.controllers.polarArea', function() {
chart.update();
- jasmine.triggerMouseEvent(chart, 'mousemove', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mousemove', arc);
expect(arc._model.backgroundColor).toBe('rgb(200, 100, 150)');
expect(arc._model.borderColor).toBe('rgb(150, 50, 100)');
expect(arc._model.borderWidth).toBe(8.4);
- jasmine.triggerMouseEvent(chart, 'mouseout', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mouseout', arc);
expect(arc._model.backgroundColor).toBe('rgb(100, 150, 200)');
expect(arc._model.borderColor).toBe('rgb(50, 100, 150)');
expect(arc._model.borderWidth).toBe(2);
@@ -350,12 +350,12 @@ describe('Chart.controllers.polarArea', function() {
chart.update();
- jasmine.triggerMouseEvent(chart, 'mousemove', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mousemove', arc);
expect(arc._model.backgroundColor).toBe('rgb(200, 100, 150)');
expect(arc._model.borderColor).toBe('rgb(150, 50, 100)');
expect(arc._model.borderWidth).toBe(8.4);
- jasmine.triggerMouseEvent(chart, 'mouseout', {_model: arc.getCenterPoint()});
+ jasmine.triggerMouseEvent(chart, 'mouseout', arc);
expect(arc._model.backgroundColor).toBe('rgb(100, 150, 200)');
expect(arc._model.borderColor).toBe('rgb(50, 100, 150)');
expect(arc._model.borderWidth).toBe(2); | true |
Other | chartjs | Chart.js | 8b110fdc513141e99848ae236860741e48cc31ff.json | Handle any element in triggerMouseEvent in tests (#5994) | test/utils.js | @@ -106,12 +106,27 @@ function waitForResize(chart, callback) {
};
}
+function _resolveElementPoint(el) {
+ var point = {x: 0, y: 0};
+ if (el) {
+ if (typeof el.getCenterPoint === 'function') {
+ point = el.getCenterPoint();
+ } else if (el.x !== undefined && el.y !== undefined) {
+ point = el;
+ } else if (el._model && el._model.x !== undefined && el._model.y !== undefined) {
+ point = el._model;
+ }
+ }
+ return point;
+}
+
function triggerMouseEvent(chart, type, el) {
var node = chart.canvas;
var rect = node.getBoundingClientRect();
+ var point = _resolveElementPoint(el);
var event = new MouseEvent(type, {
- clientX: rect.left + el._model.x,
- clientY: rect.top + el._model.y,
+ clientX: rect.left + point.x,
+ clientY: rect.top + point.y,
cancelable: true,
bubbles: true,
view: window | true |
Other | chartjs | Chart.js | 7bbf3cab5bb8f2c561d0a81f6408e017d815e54e.json | Return correct label for value type axis (#5920) | src/controllers/controller.bar.js | @@ -173,7 +173,7 @@ module.exports = DatasetController.extend({
_updateElementGeometry: function(rectangle, index, reset) {
var me = this;
var model = rectangle._model;
- var vscale = me.getValueScale();
+ var vscale = me._getValueScale();
var base = vscale.getBasePixel();
var horizontal = vscale.isHorizontal();
var ruler = me._ruler || me.getRuler();
@@ -188,34 +188,6 @@ module.exports = DatasetController.extend({
model.width = horizontal ? undefined : ipixels.size;
},
- /**
- * @private
- */
- getValueScaleId: function() {
- return this.getMeta().yAxisID;
- },
-
- /**
- * @private
- */
- getIndexScaleId: function() {
- return this.getMeta().xAxisID;
- },
-
- /**
- * @private
- */
- getValueScale: function() {
- return this.getScaleForId(this.getValueScaleId());
- },
-
- /**
- * @private
- */
- getIndexScale: function() {
- return this.getScaleForId(this.getIndexScaleId());
- },
-
/**
* Returns the stacks based on groups and bar visibility.
* @param {Number} [last] - The dataset index
@@ -225,7 +197,7 @@ module.exports = DatasetController.extend({
_getStacks: function(last) {
var me = this;
var chart = me.chart;
- var scale = me.getIndexScale();
+ var scale = me._getIndexScale();
var stacked = scale.options.stacked;
var ilen = last === undefined ? chart.data.datasets.length : last + 1;
var stacks = [];
@@ -275,7 +247,7 @@ module.exports = DatasetController.extend({
*/
getRuler: function() {
var me = this;
- var scale = me.getIndexScale();
+ var scale = me._getIndexScale();
var stackCount = me.getStackCount();
var datasetIndex = me.index;
var isHorizontal = scale.isHorizontal();
@@ -310,7 +282,7 @@ module.exports = DatasetController.extend({
var me = this;
var chart = me.chart;
var meta = me.getMeta();
- var scale = me.getValueScale();
+ var scale = me._getValueScale();
var isHorizontal = scale.isHorizontal();
var datasets = chart.data.datasets;
var value = +scale.getRightValue(datasets[datasetIndex].data[index]);
@@ -326,7 +298,7 @@ module.exports = DatasetController.extend({
if (imeta.bar &&
imeta.stack === stack &&
- imeta.controller.getValueScaleId() === scale.id &&
+ imeta.controller._getValueScaleId() === scale.id &&
chart.isDatasetVisible(i)) {
ivalue = +scale.getRightValue(datasets[i].data[index]);
@@ -385,7 +357,7 @@ module.exports = DatasetController.extend({
draw: function() {
var me = this;
var chart = me.chart;
- var scale = me.getValueScale();
+ var scale = me._getValueScale();
var rects = me.getMeta().data;
var dataset = me.getDataset();
var ilen = rects.length; | true |
Other | chartjs | Chart.js | 7bbf3cab5bb8f2c561d0a81f6408e017d815e54e.json | Return correct label for value type axis (#5920) | src/controllers/controller.horizontalBar.js | @@ -65,14 +65,14 @@ module.exports = BarController.extend({
/**
* @private
*/
- getValueScaleId: function() {
+ _getValueScaleId: function() {
return this.getMeta().xAxisID;
},
/**
* @private
*/
- getIndexScaleId: function() {
+ _getIndexScaleId: function() {
return this.getMeta().yAxisID;
}
}); | true |
Other | chartjs | Chart.js | 7bbf3cab5bb8f2c561d0a81f6408e017d815e54e.json | Return correct label for value type axis (#5920) | src/core/core.datasetController.js | @@ -131,6 +131,34 @@ helpers.extend(DatasetController.prototype, {
return this.chart.scales[scaleID];
},
+ /**
+ * @private
+ */
+ _getValueScaleId: function() {
+ return this.getMeta().yAxisID;
+ },
+
+ /**
+ * @private
+ */
+ _getIndexScaleId: function() {
+ return this.getMeta().xAxisID;
+ },
+
+ /**
+ * @private
+ */
+ _getValueScale: function() {
+ return this.getScaleForId(this._getValueScaleId());
+ },
+
+ /**
+ * @private
+ */
+ _getIndexScale: function() {
+ return this.getScaleForId(this._getIndexScaleId());
+ },
+
reset: function() {
this.update(true);
}, | true |
Other | chartjs | Chart.js | 7bbf3cab5bb8f2c561d0a81f6408e017d815e54e.json | Return correct label for value type axis (#5920) | src/scales/scale.category.js | @@ -49,12 +49,12 @@ module.exports = Scale.extend({
getLabelForIndex: function(index, datasetIndex) {
var me = this;
- var data = me.chart.data;
- var isHorizontal = me.isHorizontal();
+ var chart = me.chart;
- if (data.yLabels && !isHorizontal) {
- return me.getRightValue(data.datasets[datasetIndex].data[index]);
+ if (chart.getDatasetMeta(datasetIndex).controller._getValueScaleId() === me.id) {
+ return me.getRightValue(chart.data.datasets[datasetIndex].data[index]);
}
+
return me.ticks[index - me.minIndex];
},
| true |
Other | chartjs | Chart.js | 7bbf3cab5bb8f2c561d0a81f6408e017d815e54e.json | Return correct label for value type axis (#5920) | test/specs/scale.category.tests.js | @@ -156,35 +156,38 @@ describe('Category scale tests', function() {
expect(scale.ticks).toEqual(labels);
});
- it ('should get the correct label for the index', function() {
- var scaleID = 'myScale';
-
- var mockData = {
- datasets: [{
- yAxisID: scaleID,
- data: [10, 5, 0, 25, 78]
- }],
- labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5']
- };
-
- var config = Chart.helpers.clone(Chart.scaleService.getScaleDefaults('category'));
- var Constructor = Chart.scaleService.getScaleConstructor('category');
- var scale = new Constructor({
- ctx: {},
- options: config,
- chart: {
- data: mockData
+ it('should get the correct label for the index', function() {
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ xAxisID: 'xScale0',
+ yAxisID: 'yScale0',
+ data: [10, 5, 0, 25, 78]
+ }],
+ labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5']
},
- id: scaleID
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'xScale0',
+ type: 'category',
+ position: 'bottom'
+ }],
+ yAxes: [{
+ id: 'yScale0',
+ type: 'linear'
+ }]
+ }
+ }
});
- scale.determineDataLimits();
- scale.buildTicks();
+ var scale = chart.scales.xScale0;
- expect(scale.getLabelForIndex(1)).toBe('tick2');
+ expect(scale.getLabelForIndex(1, 0)).toBe('tick2');
});
- it ('Should get the correct pixel for a value when horizontal', function() {
+ it('Should get the correct pixel for a value when horizontal', function() {
var chart = window.acquireChart({
type: 'line',
data: {
@@ -227,7 +230,7 @@ describe('Category scale tests', function() {
expect(xScale.getValueForPixel(417)).toBe(4);
});
- it ('Should get the correct pixel for a value when there are repeated labels', function() {
+ it('Should get the correct pixel for a value when there are repeated labels', function() {
var chart = window.acquireChart({
type: 'line',
data: {
@@ -258,7 +261,7 @@ describe('Category scale tests', function() {
expect(xScale.getPixelForValue('tick_1', 1, 0)).toBeCloseToPixel(143);
});
- it ('Should get the correct pixel for a value when horizontal and zoomed', function() {
+ it('Should get the correct pixel for a value when horizontal and zoomed', function() {
var chart = window.acquireChart({
type: 'line',
data: {
@@ -299,7 +302,7 @@ describe('Category scale tests', function() {
expect(xScale.getPixelForValue(0, 3, 0)).toBeCloseToPixel(429);
});
- it ('should get the correct pixel for a value when vertical', function() {
+ it('should get the correct pixel for a value when vertical', function() {
var chart = window.acquireChart({
type: 'line',
data: {
@@ -344,7 +347,7 @@ describe('Category scale tests', function() {
expect(yScale.getValueForPixel(437)).toBe(4);
});
- it ('should get the correct pixel for a value when vertical and zoomed', function() {
+ it('should get the correct pixel for a value when vertical and zoomed', function() {
var chart = window.acquireChart({
type: 'line',
data: { | true |
Other | chartjs | Chart.js | 8a3eb8592892965eb6e99750d74ef8000a409976.json | Implement adapter to abstract date/time features (#5960) | src/adapters/adapter.moment.js | @@ -0,0 +1,82 @@
+// TODO v3 - make this adapter external (chartjs-adapter-moment)
+
+'use strict';
+
+var moment = require('moment');
+var adapter = require('../core/core.adapters')._date;
+var helpers = require('../helpers/helpers.core');
+
+var FORMATS = {
+ millisecond: 'h:mm:ss.SSS a',
+ second: 'h:mm:ss a',
+ minute: 'h:mm a',
+ hour: 'hA',
+ day: 'MMM D',
+ week: 'll',
+ month: 'MMM YYYY',
+ quarter: '[Q]Q - YYYY',
+ year: 'YYYY'
+};
+
+var PRESETS = {
+ full: 'MMM D, YYYY h:mm:ss.SSS a',
+ time: 'MMM D, YYYY h:mm:ss a',
+ date: 'MMM D, YYYY'
+};
+
+helpers.merge(adapter, moment ? {
+ _id: 'moment', // DEBUG ONLY
+
+ formats: function() {
+ return FORMATS;
+ },
+
+ presets: function() {
+ return PRESETS;
+ },
+
+ parse: function(value, format) {
+ if (typeof value === 'string' && typeof format === 'string') {
+ value = moment(value, format);
+ } else if (!(value instanceof moment)) {
+ value = moment(value);
+ }
+ return value.isValid() ? +value : null;
+ },
+
+ format: function(time, format) {
+ return moment(time).format(format);
+ },
+
+ add: function(time, amount, unit) {
+ return +moment(time).add(amount, unit);
+ },
+
+ diff: function(max, min, unit) {
+ return moment.duration(moment(max).diff(moment(min))).as(unit);
+ },
+
+ startOf: function(time, unit, weekday) {
+ time = moment(time);
+ if (unit === 'isoWeek') {
+ return +time.isoWeekday(weekday);
+ }
+ return +time.startOf(unit);
+ },
+
+ endOf: function(time, unit) {
+ return +moment(time).endOf(unit);
+ },
+
+ // DEPRECATIONS
+
+ /**
+ * Provided for backward compatibility with scale.getValueForPixel().
+ * @deprecated since version 2.8.0
+ * @todo remove at version 3
+ * @private
+ */
+ _create: function(time) {
+ return moment(time);
+ },
+} : {}); | true |
Other | chartjs | Chart.js | 8a3eb8592892965eb6e99750d74ef8000a409976.json | Implement adapter to abstract date/time features (#5960) | src/adapters/index.js | @@ -0,0 +1,10 @@
+'use strict';
+
+// -----------------------------------------------------------------------------
+// IMPORTANT: do NOT submit new adapters to this repository, instead
+// create an external library named `chartjs-adapter-{lib-name}`
+// -----------------------------------------------------------------------------
+
+// Built-in moment adapter that we need to keep for backward compatibility
+// https://github.com/chartjs/Chart.js/issues/5542
+require('./adapter.moment'); | true |
Other | chartjs | Chart.js | 8a3eb8592892965eb6e99750d74ef8000a409976.json | Implement adapter to abstract date/time features (#5960) | src/chart.js | @@ -8,6 +8,7 @@ Chart.helpers = require('./helpers/index');
// @todo dispatch these helpers into appropriated helpers/helpers.* file and write unit tests!
require('./core/core.helpers')(Chart);
+Chart._adapters = require('./core/core.adapters');
Chart.Animation = require('./core/core.animation');
Chart.animationService = require('./core/core.animations');
Chart.controllers = require('./controllers/index');
@@ -30,6 +31,9 @@ Chart.helpers.each(scales, function(scale, type) {
Chart.scaleService.registerScaleType(type, scale, scale._defaults);
});
+// Load to register built-in adapters (as side effects)
+require('./adapters');
+
// Loading built-in plugins
var plugins = require('./plugins');
for (var k in plugins) { | true |
Other | chartjs | Chart.js | 8a3eb8592892965eb6e99750d74ef8000a409976.json | Implement adapter to abstract date/time features (#5960) | src/core/core.adapters.js | @@ -0,0 +1,115 @@
+/**
+ * @namespace Chart._adapters
+ * @since 2.8.0
+ * @private
+ */
+
+'use strict';
+
+function abstract() {
+ throw new Error(
+ 'This method is not implemented: either no adapter can ' +
+ 'be found or an incomplete integration was provided.'
+ );
+}
+
+/**
+ * Date adapter (current used by the time scale)
+ * @namespace Chart._adapters._date
+ * @memberof Chart._adapters
+ * @private
+ */
+
+/**
+ * Currently supported unit string values.
+ * @typedef {('millisecond'|'second'|'minute'|'hour'|'day'|'week'|'month'|'quarter'|'year')}
+ * @memberof Chart._adapters._date
+ * @name Unit
+ */
+
+/** @lends Chart._adapters._date */
+module.exports._date = {
+ /**
+ * Returns a map of time formats for the supported units.
+ * @returns {{string: string}}
+ */
+ formats: abstract,
+
+ /**
+ * Returns a map of date/time formats for the following presets:
+ * 'full': date + time + millisecond
+ * 'time': date + time
+ * 'date': date
+ * @returns {{string: string}}
+ */
+ presets: abstract,
+
+ /**
+ * Parses the given `value` and return the associated timestamp.
+ * @param {any} value - the value to parse (usually comes from the data)
+ * @param {string} [format] - the expected data format
+ * @returns {(number|null)}
+ * @function
+ */
+ parse: abstract,
+
+ /**
+ * Returns the formatted date in the specified `format` for a given `timestamp`.
+ * @param {number} timestamp - the timestamp to format
+ * @param {string} format - the date/time token
+ * @return {string}
+ * @function
+ */
+ format: abstract,
+
+ /**
+ * Adds the specified `amount` of `unit` to the given `timestamp`.
+ * @param {number} timestamp - the input timestamp
+ * @param {number} amount - the amount to add
+ * @param {Unit} unit - the unit as string
+ * @return {number}
+ * @function
+ */
+ add: abstract,
+
+ /**
+ * Returns the number of `unit` between the given timestamps.
+ * @param {number} max - the input timestamp (reference)
+ * @param {number} min - the timestamp to substract
+ * @param {Unit} unit - the unit as string
+ * @return {number}
+ * @function
+ */
+ diff: abstract,
+
+ /**
+ * Returns start of `unit` for the given `timestamp`.
+ * @param {number} timestamp - the input timestamp
+ * @param {Unit} unit - the unit as string
+ * @param {number} [weekday] - the ISO day of the week with 1 being Monday
+ * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
+ * @function
+ */
+ startOf: abstract,
+
+ /**
+ * Returns end of `unit` for the given `timestamp`.
+ * @param {number} timestamp - the input timestamp
+ * @param {Unit} unit - the unit as string
+ * @function
+ */
+ endOf: abstract,
+
+ // DEPRECATIONS
+
+ /**
+ * Provided for backward compatibility for scale.getValueForPixel(),
+ * this method should be overridden only by the moment adapter.
+ * @deprecated since version 2.8.0
+ * @todo remove at version 3
+ * @private
+ */
+ _create: function(value) {
+ return value;
+ }
+}; | true |
Other | chartjs | Chart.js | 8a3eb8592892965eb6e99750d74ef8000a409976.json | Implement adapter to abstract date/time features (#5960) | src/scales/scale.time.js | @@ -1,7 +1,7 @@
/* global window: false */
'use strict';
-var moment = require('moment');
+var adapter = require('../core/core.adapters')._date;
var defaults = require('../core/core.defaults');
var helpers = require('../helpers/index');
var Scale = require('../core/core.scale');
@@ -178,34 +178,35 @@ function interpolate(table, skey, sval, tkey) {
return prev[tkey] + offset;
}
-/**
- * Convert the given value to a moment object using the given time options.
- * @see https://momentjs.com/docs/#/parsing/
- */
-function momentify(value, options) {
+function toTimestamp(input, options) {
var parser = options.parser;
- var format = options.parser || options.format;
+ var format = parser || options.format;
+ var value = input;
if (typeof parser === 'function') {
- return parser(value);
+ value = parser(value);
}
- if (typeof value === 'string' && typeof format === 'string') {
- return moment(value, format);
+ // Only parse if its not a timestamp already
+ if (!helpers.isFinite(value)) {
+ value = typeof format === 'string'
+ ? adapter.parse(value, format)
+ : adapter.parse(value);
}
- if (!(value instanceof moment)) {
- value = moment(value);
+ if (value !== null) {
+ return +value;
}
- if (value.isValid()) {
- return value;
- }
+ // Labels are in an incompatible format and no `parser` has been provided.
+ // The user might still use the deprecated `format` option for parsing.
+ if (!parser && typeof format === 'function') {
+ value = format(input);
- // Labels are in an incompatible moment format and no `parser` has been provided.
- // The user might still use the deprecated `format` option to convert his inputs.
- if (typeof format === 'function') {
- return format(value);
+ // `format` could return something else than a timestamp, if so, parse it
+ if (!helpers.isFinite(value)) {
+ value = adapter.parse(value);
+ }
}
return value;
@@ -217,16 +218,16 @@ function parse(input, scale) {
}
var options = scale.options.time;
- var value = momentify(scale.getRightValue(input), options);
- if (!value.isValid()) {
- return null;
+ var value = toTimestamp(scale.getRightValue(input), options);
+ if (value === null) {
+ return value;
}
if (options.round) {
- value.startOf(options.round);
+ value = +adapter.startOf(value, options.round);
}
- return value.valueOf();
+ return value;
}
/**
@@ -277,13 +278,12 @@ function determineUnitForAutoTicks(minUnit, min, max, capacity) {
* Figures out what unit to format a set of ticks with
*/
function determineUnitForFormatting(ticks, minUnit, min, max) {
- var duration = moment.duration(moment(max).diff(moment(min)));
var ilen = UNITS.length;
var i, unit;
for (i = ilen - 1; i >= UNITS.indexOf(minUnit); i--) {
unit = UNITS[i];
- if (INTERVALS[unit].common && duration.as(unit) >= ticks.length) {
+ if (INTERVALS[unit].common && adapter.diff(max, min, unit) >= ticks.length) {
return unit;
}
}
@@ -313,8 +313,8 @@ function generate(min, max, capacity, options) {
var weekday = minor === 'week' ? timeOpts.isoWeekday : false;
var majorTicksEnabled = options.ticks.major.enabled;
var interval = INTERVALS[minor];
- var first = moment(min);
- var last = moment(max);
+ var first = min;
+ var last = max;
var ticks = [];
var time;
@@ -324,30 +324,30 @@ function generate(min, max, capacity, options) {
// For 'week' unit, handle the first day of week option
if (weekday) {
- first = first.isoWeekday(weekday);
- last = last.isoWeekday(weekday);
+ first = +adapter.startOf(first, 'isoWeek', weekday);
+ last = +adapter.startOf(last, 'isoWeek', weekday);
}
// Align first/last ticks on unit
- first = first.startOf(weekday ? 'day' : minor);
- last = last.startOf(weekday ? 'day' : minor);
+ first = +adapter.startOf(first, weekday ? 'day' : minor);
+ last = +adapter.startOf(last, weekday ? 'day' : minor);
// Make sure that the last tick include max
if (last < max) {
- last.add(1, minor);
+ last = +adapter.add(last, 1, minor);
}
- time = moment(first);
+ time = first;
if (majorTicksEnabled && major && !weekday && !timeOpts.round) {
// Align the first tick on the previous `minor` unit aligned on the `major` unit:
// we first aligned time on the previous `major` unit then add the number of full
// stepSize there is between first and the previous major time.
- time.startOf(major);
- time.add(~~((first - time) / (interval.size * stepSize)) * stepSize, minor);
+ time = +adapter.startOf(time, major);
+ time = +adapter.add(time, ~~((first - time) / (interval.size * stepSize)) * stepSize, minor);
}
- for (; time < last; time.add(stepSize, minor)) {
+ for (; time < last; time = +adapter.add(time, stepSize, minor)) {
ticks.push(+time);
}
@@ -395,7 +395,7 @@ function ticksFromTimestamps(values, majorUnit) {
for (i = 0, ilen = values.length; i < ilen; ++i) {
value = values[i];
- major = majorUnit ? value === +moment(value).startOf(majorUnit) : false;
+ major = majorUnit ? value === +adapter.startOf(value, majorUnit) : false;
ticks.push({
value: value,
@@ -406,25 +406,27 @@ function ticksFromTimestamps(values, majorUnit) {
return ticks;
}
-function determineLabelFormat(data, timeOpts) {
- var i, momentDate, hasTime;
- var ilen = data.length;
+/**
+ * Return the time format for the label with the most parts (milliseconds, second, etc.)
+ */
+function determineLabelFormat(timestamps) {
+ var presets = adapter.presets();
+ var ilen = timestamps.length;
+ var i, ts, hasTime;
- // find the label with the most parts (milliseconds, minutes, etc.)
- // format all labels with the same level of detail as the most specific label
for (i = 0; i < ilen; i++) {
- momentDate = momentify(data[i], timeOpts);
- if (momentDate.millisecond() !== 0) {
- return 'MMM D, YYYY h:mm:ss.SSS a';
+ ts = timestamps[i];
+ if (ts % INTERVALS.second.size !== 0) {
+ return presets.full;
}
- if (momentDate.second() !== 0 || momentDate.minute() !== 0 || momentDate.hour() !== 0) {
+ if (!hasTime && adapter.startOf(ts, 'day') !== ts) {
hasTime = true;
}
}
if (hasTime) {
- return 'MMM D, YYYY h:mm:ss a';
+ return presets.time;
}
- return 'MMM D, YYYY';
+ return presets.date;
}
var defaultConfig = {
@@ -456,19 +458,7 @@ var defaultConfig = {
displayFormat: false, // DEPRECATED
isoWeekday: false, // override week start day - see https://momentjs.com/docs/#/get-set/iso-weekday/
minUnit: 'millisecond',
-
- // defaults to unit's corresponding unitFormat below or override using pattern string from https://momentjs.com/docs/#/displaying/format/
- displayFormats: {
- millisecond: 'h:mm:ss.SSS a', // 11:20:01.123 AM,
- second: 'h:mm:ss a', // 11:20:01 AM
- minute: 'h:mm a', // 11:20 AM
- hour: 'hA', // 5PM
- day: 'MMM D', // Sep 4
- week: 'll', // Week 46, or maybe "[W]WW - YYYY" ?
- month: 'MMM YYYY', // Sept 2015
- quarter: '[Q]Q - YYYY', // Q3
- year: 'YYYY' // 2015
- },
+ displayFormats: {}
},
ticks: {
autoSkip: false,
@@ -491,24 +481,26 @@ var defaultConfig = {
module.exports = Scale.extend({
initialize: function() {
- if (!moment) {
- throw new Error('Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com');
- }
-
this.mergeTicksOptions();
-
Scale.prototype.initialize.call(this);
},
update: function() {
var me = this;
var options = me.options;
+ var time = options.time || (options.time = {});
// DEPRECATIONS: output a message only one time per update
- if (options.time && options.time.format) {
+ if (time.format) {
console.warn('options.time.format is deprecated and replaced by options.time.parser.');
}
+ // Backward compatibility: before introducing adapter, `displayFormats` was
+ // supposed to contain *all* unit/string pairs but this can't be resolved
+ // when loading the scale (adapters are loaded afterward), so let's populate
+ // missing formats on update
+ helpers.mergeIf(time.displayFormats, adapter.formats());
+
return Scale.prototype.update.apply(me, arguments);
},
@@ -582,8 +574,8 @@ module.exports = Scale.extend({
max = parse(timeOpts.max, me) || max;
// In case there is no valid min/max, set limits based on unit time option
- min = min === MAX_INTEGER ? +moment().startOf(unit) : min;
- max = max === MIN_INTEGER ? +moment().endOf(unit) + 1 : max;
+ min = min === MAX_INTEGER ? +adapter.startOf(+new Date(), unit) : min;
+ max = max === MIN_INTEGER ? +adapter.endOf(+new Date(), unit) + 1 : max;
// Make sure that max is strictly higher than min (required by the lookup table)
me.min = Math.min(min, max);
@@ -646,7 +638,7 @@ module.exports = Scale.extend({
me._majorUnit = determineMajorUnit(me._unit);
me._table = buildLookupTable(me._timestamps.data, min, max, options.distribution);
me._offsets = computeOffsets(me._table, ticks, min, max, options);
- me._labelFormat = determineLabelFormat(me._timestamps.data, timeOpts);
+ me._labelFormat = determineLabelFormat(me._timestamps.data);
if (options.ticks.reverse) {
ticks.reverse();
@@ -666,31 +658,30 @@ module.exports = Scale.extend({
label = me.getRightValue(value);
}
if (timeOpts.tooltipFormat) {
- return momentify(label, timeOpts).format(timeOpts.tooltipFormat);
+ return adapter.format(toTimestamp(label, timeOpts), timeOpts.tooltipFormat);
}
if (typeof label === 'string') {
return label;
}
- return momentify(label, timeOpts).format(me._labelFormat);
+ return adapter.format(toTimestamp(label, timeOpts), me._labelFormat);
},
/**
* Function to format an individual tick mark
* @private
*/
- tickFormatFunction: function(tick, index, ticks, formatOverride) {
+ tickFormatFunction: function(time, index, ticks, format) {
var me = this;
var options = me.options;
- var time = tick.valueOf();
var formats = options.time.displayFormats;
var minorFormat = formats[me._unit];
var majorUnit = me._majorUnit;
var majorFormat = formats[majorUnit];
- var majorTime = tick.clone().startOf(majorUnit).valueOf();
+ var majorTime = +adapter.startOf(time, majorUnit);
var majorTickOpts = options.ticks.major;
var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
- var label = tick.format(formatOverride ? formatOverride : major ? majorFormat : minorFormat);
+ var label = adapter.format(time, format ? format : major ? majorFormat : minorFormat);
var tickOpts = major ? majorTickOpts : options.ticks.minor;
var formatter = valueOrDefault(tickOpts.callback, tickOpts.userCallback);
@@ -702,7 +693,7 @@ module.exports = Scale.extend({
var i, ilen;
for (i = 0, ilen = ticks.length; i < ilen; ++i) {
- labels.push(this.tickFormatFunction(moment(ticks[i].value), i, ticks));
+ labels.push(this.tickFormatFunction(ticks[i].value, i, ticks));
}
return labels;
@@ -753,7 +744,8 @@ module.exports = Scale.extend({
var pos = (size ? (pixel - start) / size : 0) * (me._offsets.start + 1 + me._offsets.start) - me._offsets.end;
var time = interpolate(me._table, 'pos', pos, 'time');
- return moment(time);
+ // DEPRECATION, we should return time directly
+ return adapter._create(time);
},
/**
@@ -778,13 +770,13 @@ module.exports = Scale.extend({
getLabelCapacity: function(exampleTime) {
var me = this;
- var formatOverride = me.options.time.displayFormats.millisecond; // Pick the longest format for guestimation
-
- var exampleLabel = me.tickFormatFunction(moment(exampleTime), 0, [], formatOverride);
+ // pick the longest format (milliseconds) for guestimation
+ var format = me.options.time.displayFormats.millisecond;
+ var exampleLabel = me.tickFormatFunction(exampleTime, 0, [], format);
var tickLabelWidth = me.getLabelWidth(exampleLabel);
var innerWidth = me.isHorizontal() ? me.width : me.height;
-
var capacity = Math.floor(innerWidth / tickLabelWidth);
+
return capacity > 0 ? capacity : 1;
}
}); | true |
Other | chartjs | Chart.js | 8a3eb8592892965eb6e99750d74ef8000a409976.json | Implement adapter to abstract date/time features (#5960) | test/specs/scale.time.tests.js | @@ -102,17 +102,7 @@ describe('Time scale tests', function() {
isoWeekday: false,
displayFormat: false,
minUnit: 'millisecond',
- displayFormats: {
- millisecond: 'h:mm:ss.SSS a', // 11:20:01.123 AM
- second: 'h:mm:ss a', // 11:20:01 AM
- minute: 'h:mm a', // 11:20 AM
- hour: 'hA', // 5PM
- day: 'MMM D', // Sep 4
- week: 'll', // Week 46, or maybe "[W]WW - YYYY" ?
- month: 'MMM YYYY', // Sept 2015
- quarter: '[Q]Q - YYYY', // Q3
- year: 'YYYY' // 2015
- },
+ displayFormats: {}
}
});
@@ -1523,4 +1513,77 @@ describe('Time scale tests', function() {
});
});
});
+
+ describe('Deprecations', function() {
+ describe('options.time.displayFormats', function() {
+ it('should generate defaults from adapter presets', function() {
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {},
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'x',
+ type: 'time'
+ }]
+ }
+ }
+ });
+
+ // NOTE: built-in adapter uses moment
+ var expected = {
+ millisecond: 'h:mm:ss.SSS a',
+ second: 'h:mm:ss a',
+ minute: 'h:mm a',
+ hour: 'hA',
+ day: 'MMM D',
+ week: 'll',
+ month: 'MMM YYYY',
+ quarter: '[Q]Q - YYYY',
+ year: 'YYYY'
+ };
+
+ expect(chart.scales.x.options.time.displayFormats).toEqual(expected);
+ expect(chart.options.scales.xAxes[0].time.displayFormats).toEqual(expected);
+ });
+
+ it('should merge user formats with adapter presets', function() {
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {},
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'x',
+ type: 'time',
+ time: {
+ displayFormats: {
+ millisecond: 'foo',
+ hour: 'bar',
+ month: 'bla'
+ }
+ }
+ }]
+ }
+ }
+ });
+
+ // NOTE: built-in adapter uses moment
+ var expected = {
+ millisecond: 'foo',
+ second: 'h:mm:ss a',
+ minute: 'h:mm a',
+ hour: 'bar',
+ day: 'MMM D',
+ week: 'll',
+ month: 'bla',
+ quarter: '[Q]Q - YYYY',
+ year: 'YYYY'
+ };
+
+ expect(chart.scales.x.options.time.displayFormats).toEqual(expected);
+ expect(chart.options.scales.xAxes[0].time.displayFormats).toEqual(expected);
+ });
+ });
+ });
}); | true |
Other | chartjs | Chart.js | b50a1c21f2509f54a49347eeb73970a66b3c2013.json | Fix typo / grammar in the responsive docs (#5975) | docs/general/responsive.md | @@ -1,6 +1,6 @@
# Responsive Charts
-When it comes to change the chart size based on the window size, a major limitation is that the canvas *render* size (`canvas.width` and `.height`) can **not** be expressed with relative values, contrary to the *display* size (`canvas.style.width` and `.height`). Furthermore, these sizes are independent from each other and thus the canvas *render* size does not adjust automatically based on the *display* size, making the rendering inaccurate.
+When it comes to changing the chart size based on the window size, a major limitation is that the canvas *render* size (`canvas.width` and `.height`) can **not** be expressed with relative values, contrary to the *display* size (`canvas.style.width` and `.height`). Furthermore, these sizes are independent from each other and thus the canvas *render* size does not adjust automatically based on the *display* size, making the rendering inaccurate.
The following examples **do not work**:
| false |
Other | chartjs | Chart.js | 20c748f90b80c7c1969a9e805a7c0876a19b270b.json | Fix modifying ticks in afterBuildTicks (#5913) | docs/axes/README.md | @@ -31,7 +31,7 @@ There are a number of config callbacks that can be used to change parameters in
| `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.
+| `afterBuildTicks` | `axis`, `ticks` | Callback that runs after ticks are created. Useful for filtering ticks. Should return the filtered 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. | true |
Other | chartjs | Chart.js | 20c748f90b80c7c1969a9e805a7c0876a19b270b.json | Fix modifying ticks in afterBuildTicks (#5913) | src/core/core.scale.js | @@ -196,7 +196,8 @@ module.exports = Element.extend({
// we still support no return (`this.ticks` internally set by calling this method).
ticks = me.buildTicks() || [];
- me.afterBuildTicks();
+ // Allow modification of ticks in callback.
+ ticks = me.afterBuildTicks(ticks) || ticks;
me.beforeTickToLabelConversion();
@@ -290,8 +291,15 @@ module.exports = Element.extend({
helpers.callback(this.options.beforeBuildTicks, [this]);
},
buildTicks: helpers.noop,
- afterBuildTicks: function() {
- helpers.callback(this.options.afterBuildTicks, [this]);
+ afterBuildTicks: function(ticks) {
+ var me = this;
+ // ticks is empty for old axis implementations here
+ if (helpers.isArray(ticks) && ticks.length) {
+ return helpers.callback(me.options.afterBuildTicks, [me, ticks]);
+ }
+ // Support old implementations (that modified `this.ticks` directly in buildTicks)
+ me.ticks = helpers.callback(me.options.afterBuildTicks, [me, me.ticks]) || me.ticks;
+ return ticks;
},
beforeTickToLabelConversion: function() { | true |
Other | chartjs | Chart.js | 20c748f90b80c7c1969a9e805a7c0876a19b270b.json | Fix modifying ticks in afterBuildTicks (#5913) | test/specs/core.scale.tests.js | @@ -341,4 +341,99 @@ describe('Core.scale', function() {
});
});
});
+
+ describe('afterBuildTicks', function() {
+ it('should allow filtering of ticks', function() {
+ var labels = ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'];
+ var chart = window.acquireChart({
+ type: 'line',
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'x',
+ type: 'category',
+ labels: labels,
+ afterBuildTicks: function(axis, ticks) {
+ return ticks.slice(1);
+ }
+ }]
+ }
+ }
+ });
+
+ var scale = chart.scales.x;
+ expect(scale.ticks).toEqual(labels.slice(1));
+ });
+
+ it('should allow filtering of ticks (for new implementation of buildTicks)', function() {
+ var chart = window.acquireChart({
+ type: 'line',
+ data: {
+ labels: ['2016', '2017', '2018']
+ },
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'x',
+ type: 'time',
+ time: {
+ parser: 'YYYY'
+ },
+ ticks: {
+ source: 'labels'
+ },
+ afterBuildTicks: function(axis, ticks) {
+ return ticks.slice(1);
+ }
+ }]
+ }
+ }
+ });
+
+ var scale = chart.scales.x;
+ expect(scale.ticks.length).toEqual(2);
+ });
+
+ it('should allow no return value from callback', function() {
+ var labels = ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'];
+ var chart = window.acquireChart({
+ type: 'line',
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'x',
+ type: 'category',
+ labels: labels,
+ afterBuildTicks: function() { }
+ }]
+ }
+ }
+ });
+
+ var scale = chart.scales.x;
+ expect(scale.ticks).toEqual(labels);
+ });
+
+ it('should allow empty ticks', function() {
+ var labels = ['tick1', 'tick2', 'tick3', 'tick4', 'tick5'];
+ var chart = window.acquireChart({
+ type: 'line',
+ options: {
+ scales: {
+ xAxes: [{
+ id: 'x',
+ type: 'category',
+ labels: labels,
+ afterBuildTicks: function() {
+ return [];
+ }
+ }]
+ }
+ }
+ });
+
+ var scale = chart.scales.x;
+ expect(scale.ticks.length).toBe(0);
+ });
+ });
}); | true |
Other | chartjs | Chart.js | f342299845678819c7629e1a569629a8c87ed01a.json | Fix contribution docs about gulp-cli (#5968)
Update the docs so that only gulp-cli is installed globally | docs/developers/contributing.md | @@ -22,7 +22,7 @@ Firstly, we need to ensure development dependencies are installed. With node and
```bash
> npm install
-> npm install -g gulp
+> npm install -g gulp-cli
```
This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner <a href="https://gulpjs.com/" target="_blank">gulp</a>. | false |
Other | chartjs | Chart.js | c51ac8a64ae743377a594f152cdf50e425d68ac0.json | Make animation duration consistent across browsers (#5331) | src/core/core.animations.js | @@ -14,9 +14,7 @@ defaults._set('global', {
});
module.exports = {
- frameDuration: 17,
animations: [],
- dropFrames: 0,
request: null,
/**
@@ -30,6 +28,8 @@ module.exports = {
var i, ilen;
animation.chart = chart;
+ animation.startTime = Date.now();
+ animation.duration = duration;
if (!lazy) {
chart.animating = true;
@@ -79,19 +79,8 @@ module.exports = {
*/
startDigest: function() {
var me = this;
- var startTime = Date.now();
- var framesToDrop = 0;
- if (me.dropFrames > 1) {
- framesToDrop = Math.floor(me.dropFrames);
- me.dropFrames = me.dropFrames % 1;
- }
-
- me.advance(1 + framesToDrop);
-
- var endTime = Date.now();
-
- me.dropFrames += (endTime - startTime) / me.frameDuration;
+ me.advance();
// Do we have more stuff to animate?
if (me.animations.length > 0) {
@@ -102,7 +91,7 @@ module.exports = {
/**
* @private
*/
- advance: function(count) {
+ advance: function() {
var animations = this.animations;
var animation, chart;
var i = 0;
@@ -111,7 +100,7 @@ module.exports = {
animation = animations[i];
chart = animation.chart;
- animation.currentStep = (animation.currentStep || 0) + count;
+ animation.currentStep = Math.floor((Date.now() - animation.startTime) / animation.duration * animation.numSteps);
animation.currentStep = Math.min(animation.currentStep, animation.numSteps);
helpers.callback(animation.render, [chart, animation], chart); | true |
Other | chartjs | Chart.js | c51ac8a64ae743377a594f152cdf50e425d68ac0.json | Make animation duration consistent across browsers (#5331) | src/core/core.controller.js | @@ -509,22 +509,24 @@ module.exports = function(Chart) {
};
}
- var duration = config.duration;
+ var animationOptions = me.options.animation;
+ var duration = typeof config.duration !== 'undefined'
+ ? config.duration
+ : animationOptions && animationOptions.duration;
var lazy = config.lazy;
if (plugins.notify(me, 'beforeRender') === false) {
return;
}
- var animationOptions = me.options.animation;
var onComplete = function(animation) {
plugins.notify(me, 'afterRender');
helpers.callback(animationOptions && animationOptions.onComplete, [animation], me);
};
- if (animationOptions && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && animationOptions.duration !== 0))) {
+ if (animationOptions && duration) {
var animation = new Animation({
- numSteps: (duration || animationOptions.duration) / 16.66, // 60 fps
+ numSteps: duration / 16.66, // 60 fps
easing: config.easing || animationOptions.easing,
render: function(chart, animationObject) { | true |
Other | chartjs | Chart.js | c51ac8a64ae743377a594f152cdf50e425d68ac0.json | Make animation duration consistent across browsers (#5331) | test/specs/core.controller.tests.js | @@ -1122,7 +1122,7 @@ describe('Chart', function() {
expect(this.addAnimationSpy).toHaveBeenCalledWith(
this.chart,
jasmine.objectContaining({easing: 'linear'}),
- undefined,
+ 500,
undefined
);
}); | true |
Other | chartjs | Chart.js | aae05a08da0e216371caafa17228b3bff97d9fa9.json | Improve tick generation for linear scales (#5938)
* Improve tick generation for linear scales
* Simplify the tick generation code
* Refactor getTickLimit | src/scales/scale.linear.js | @@ -1,6 +1,5 @@
'use strict';
-var defaults = require('../core/core.defaults');
var helpers = require('../helpers/index');
var scaleService = require('../core/core.scaleService');
var Ticks = require('../core/core.ticks');
@@ -133,20 +132,16 @@ module.exports = function(Chart) {
// Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
this.handleTickRangeOptions();
},
- getTickLimit: function() {
- var maxTicks;
+ // Returns the maximum number of ticks based on the scale dimension
+ _computeTickLimit: function() {
var me = this;
- var tickOpts = me.options.ticks;
+ var tickFont;
if (me.isHorizontal()) {
- maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.width / 50));
- } else {
- // The factor of 2 used to scale the font size has been experimentally determined.
- var tickFontSize = helpers.valueOrDefault(tickOpts.fontSize, defaults.global.defaultFontSize);
- maxTicks = Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(me.height / (2 * tickFontSize)));
+ return Math.ceil(me.width / 40);
}
-
- return maxTicks;
+ tickFont = helpers.options._parseFont(me.options.ticks);
+ return Math.ceil(me.height / tickFont.lineHeight);
},
// Called after the ticks are built. We need
handleDirectionalChanges: function() { | true |
Other | chartjs | Chart.js | aae05a08da0e216371caafa17228b3bff97d9fa9.json | Improve tick generation for linear scales (#5938)
* Improve tick generation for linear scales
* Simplify the tick generation code
* Refactor getTickLimit | src/scales/scale.linearbase.js | @@ -16,35 +16,41 @@ function generateTicks(generationOptions, dataRange) {
// for details.
var stepSize = generationOptions.stepSize;
+ var unit = stepSize || 1;
+ var maxNumSpaces = generationOptions.maxTicks - 1;
var min = generationOptions.min;
var max = generationOptions.max;
- var spacing, precision, factor, niceRange, niceMin, niceMax, numSpaces;
-
- if (stepSize && stepSize > 0) {
- spacing = stepSize;
- } else {
- niceRange = helpers.niceNum(dataRange.max - dataRange.min, false);
- spacing = helpers.niceNum(niceRange / (generationOptions.maxTicks - 1), true);
-
- precision = generationOptions.precision;
- if (!helpers.isNullOrUndef(precision)) {
- // If the user specified a precision, round to that number of decimal places
- factor = Math.pow(10, precision);
- spacing = Math.ceil(spacing * factor) / factor;
- }
+ var precision = generationOptions.precision;
+ var spacing, factor, niceMin, niceMax, numSpaces;
+
+ // spacing is set to a nice number of the dataRange divided by maxNumSpaces.
+ // stepSize is used as a minimum unit if it is specified.
+ spacing = helpers.niceNum((dataRange.max - dataRange.min) / maxNumSpaces / unit) * unit;
+ numSpaces = Math.ceil(dataRange.max / spacing) - Math.floor(dataRange.min / spacing);
+ if (numSpaces > maxNumSpaces) {
+ // If the calculated num of spaces exceeds maxNumSpaces, recalculate it
+ spacing = helpers.niceNum(numSpaces * spacing / maxNumSpaces / unit) * unit;
}
- // If a precision is not specified, calculate factor based on spacing
- if (!factor) {
+
+ if (stepSize || helpers.isNullOrUndef(precision)) {
+ // If a precision is not specified, calculate factor based on spacing
factor = Math.pow(10, helpers.decimalPlaces(spacing));
+ } else {
+ // If the user specified a precision, round to that number of decimal places
+ factor = Math.pow(10, precision);
+ spacing = Math.ceil(spacing * factor) / factor;
}
+
niceMin = Math.floor(dataRange.min / spacing) * spacing;
niceMax = Math.ceil(dataRange.max / spacing) * spacing;
// If min, max and stepSize is set and they make an evenly spaced scale use it.
- if (!helpers.isNullOrUndef(min) && !helpers.isNullOrUndef(max) && stepSize) {
+ if (stepSize) {
// If very close to our whole number, use it.
- if (helpers.almostWhole((max - min) / stepSize, spacing / 1000)) {
+ if (!helpers.isNullOrUndef(min) && helpers.almostWhole(min / spacing, spacing / 1000)) {
niceMin = min;
+ }
+ if (!helpers.isNullOrUndef(max) && helpers.almostWhole(max / spacing, spacing / 1000)) {
niceMax = max;
}
}
@@ -146,7 +152,32 @@ module.exports = function(Chart) {
}
}
},
- getTickLimit: noop,
+
+ getTickLimit: function() {
+ var me = this;
+ var tickOpts = me.options.ticks;
+ var stepSize = tickOpts.stepSize;
+ var maxTicksLimit = tickOpts.maxTicksLimit;
+ var maxTicks;
+
+ if (stepSize) {
+ maxTicks = Math.ceil(me.max / stepSize) - Math.floor(me.min / stepSize) + 1;
+ } else {
+ maxTicks = me._computeTickLimit();
+ maxTicksLimit = maxTicksLimit || 11;
+ }
+
+ if (maxTicksLimit) {
+ maxTicks = Math.min(maxTicksLimit, maxTicks);
+ }
+
+ return maxTicks;
+ },
+
+ _computeTickLimit: function() {
+ return Number.POSITIVE_INFINITY;
+ },
+
handleDirectionalChanges: noop,
buildTicks: function() {
@@ -155,7 +186,7 @@ module.exports = function(Chart) {
var tickOpts = opts.ticks;
// Figure out what the max number of ticks we can support it is based on the size of
- // the axis area. For now, we say that the minimum tick spacing in pixels must be 50
+ // the axis area. For now, we say that the minimum tick spacing in pixels must be 40
// We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
// the graph. Make sure we always have at least 2 ticks
var maxTicks = me.getTickLimit(); | true |
Other | chartjs | Chart.js | aae05a08da0e216371caafa17228b3bff97d9fa9.json | Improve tick generation for linear scales (#5938)
* Improve tick generation for linear scales
* Simplify the tick generation code
* Refactor getTickLimit | src/scales/scale.logarithmic.js | @@ -15,10 +15,6 @@ function generateTicks(generationOptions, dataRange) {
var ticks = [];
var valueOrDefault = helpers.valueOrDefault;
- // Figure out what the max number of ticks we can support it is based on the size of
- // the axis area. For now, we say that the minimum tick spacing in pixels must be 50
- // We also limit the maximum number of ticks to 11 which gives a nice 10 squares on
- // the graph
var tickVal = valueOrDefault(generationOptions.min, Math.pow(10, Math.floor(helpers.log10(dataRange.min))));
var endExp = Math.floor(helpers.log10(dataRange.max)); | true |
Other | chartjs | Chart.js | aae05a08da0e216371caafa17228b3bff97d9fa9.json | Improve tick generation for linear scales (#5938)
* Improve tick generation for linear scales
* Simplify the tick generation code
* Refactor getTickLimit | src/scales/scale.radialLinear.js | @@ -357,11 +357,9 @@ module.exports = function(Chart) {
// Common base implementation to handle ticks.min, ticks.max, ticks.beginAtZero
me.handleTickRangeOptions();
},
- getTickLimit: function() {
- var opts = this.options;
- var tickOpts = opts.ticks;
- var tickBackdropHeight = getTickBackdropHeight(opts);
- return Math.min(tickOpts.maxTicksLimit ? tickOpts.maxTicksLimit : 11, Math.ceil(this.drawingArea / tickBackdropHeight));
+ // Returns the maximum number of ticks based on the scale dimension
+ _computeTickLimit: function() {
+ return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options));
},
convertTicksToLabels: function() {
var me = this; | true |
Other | chartjs | Chart.js | aae05a08da0e216371caafa17228b3bff97d9fa9.json | Improve tick generation for linear scales (#5938)
* Improve tick generation for linear scales
* Simplify the tick generation code
* Refactor getTickLimit | test/specs/scale.linear.tests.js | @@ -570,7 +570,7 @@ describe('Linear Scale', function() {
expect(chart.scales.yScale0).not.toEqual(undefined); // must construct
expect(chart.scales.yScale0.min).toBe(1);
expect(chart.scales.yScale0.max).toBe(11);
- expect(chart.scales.yScale0.ticks).toEqual(['11', '9', '7', '5', '3', '1']);
+ expect(chart.scales.yScale0.ticks).toEqual(['11', '10', '8', '6', '4', '2', '1']);
});
it('Should create decimal steps if stepSize is a decimal number', function() {
@@ -749,6 +749,53 @@ describe('Linear Scale', function() {
expect(chart.scales.yScale0.ticks).toEqual(['0.06', '0.05', '0.04', '0.03', '0.02', '0.01', '0']);
});
+ it('Should correctly limit the maximum number of ticks', function() {
+ var chart = window.acquireChart({
+ type: 'bar',
+ data: {
+ labels: ['a', 'b'],
+ datasets: [{
+ data: [0.5, 2.5]
+ }]
+ },
+ options: {
+ scales: {
+ yAxes: [{
+ id: 'yScale'
+ }]
+ }
+ }
+ });
+
+ expect(chart.scales.yScale.ticks).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']);
+
+ chart.options.scales.yAxes[0].ticks.maxTicksLimit = 11;
+ chart.update();
+
+ expect(chart.scales.yScale.ticks).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']);
+
+ chart.options.scales.yAxes[0].ticks.maxTicksLimit = 21;
+ chart.update();
+
+ expect(chart.scales.yScale.ticks).toEqual([
+ '2.5', '2.4', '2.3', '2.2', '2.1', '2.0', '1.9', '1.8', '1.7', '1.6',
+ '1.5', '1.4', '1.3', '1.2', '1.1', '1.0', '0.9', '0.8', '0.7', '0.6',
+ '0.5'
+ ]);
+
+ chart.options.scales.yAxes[0].ticks.maxTicksLimit = 11;
+ chart.options.scales.yAxes[0].ticks.stepSize = 0.01;
+ chart.update();
+
+ expect(chart.scales.yScale.ticks).toEqual(['2.5', '2.0', '1.5', '1.0', '0.5']);
+
+ chart.options.scales.yAxes[0].ticks.min = 0.3;
+ chart.options.scales.yAxes[0].ticks.max = 2.8;
+ chart.update();
+
+ expect(chart.scales.yScale.ticks).toEqual(['2.8', '2.5', '2.0', '1.5', '1.0', '0.5', '0.3']);
+ });
+
it('Should build labels using the user supplied callback', function() {
var chart = window.acquireChart({
type: 'bar', | true |
Other | chartjs | Chart.js | aae05a08da0e216371caafa17228b3bff97d9fa9.json | Improve tick generation for linear scales (#5938)
* Improve tick generation for linear scales
* Simplify the tick generation code
* Refactor getTickLimit | test/specs/scale.radialLinear.tests.js | @@ -282,6 +282,43 @@ describe('Test the radial linear scale', function() {
expect(chart.scale.end).toBe(0);
});
+ it('Should correctly limit the maximum number of ticks', function() {
+ var chart = window.acquireChart({
+ type: 'radar',
+ data: {
+ labels: ['label1', 'label2', 'label3'],
+ datasets: [{
+ data: [0.5, 1.5, 2.5]
+ }]
+ },
+ options: {
+ scale: {
+ pointLabels: {
+ display: false
+ }
+ }
+ }
+ });
+
+ expect(chart.scale.ticks).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']);
+
+ chart.options.scale.ticks.maxTicksLimit = 11;
+ chart.update();
+
+ expect(chart.scale.ticks).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']);
+
+ chart.options.scale.ticks.stepSize = 0.01;
+ chart.update();
+
+ expect(chart.scale.ticks).toEqual(['0.5', '1.0', '1.5', '2.0', '2.5']);
+
+ chart.options.scale.ticks.min = 0.3;
+ chart.options.scale.ticks.max = 2.8;
+ chart.update();
+
+ expect(chart.scale.ticks).toEqual(['0.3', '0.5', '1.0', '1.5', '2.0', '2.5', '2.8']);
+ });
+
it('Should build labels using the user supplied callback', function() {
var chart = window.acquireChart({
type: 'radar', | true |
Other | chartjs | Chart.js | 8780aaf3aa4ad04c3cd0e3417d84a48ecdbd773f.json | add missing types to legend (#9226) | types/index.esm.d.ts | @@ -2120,6 +2120,14 @@ export interface LegendOptions {
* @default 'center'
*/
align: 'start' | 'center' | 'end';
+ /**
+ * Maximum height of the legend, in pixels
+ */
+ maxHeight: number;
+ /**
+ * Maximum width of the legend, in pixels
+ */
+ maxWidth: number;
/**
* Marks that this box should take the full width/height of the canvas (moving other boxes). This is unlikely to need to be changed in day-to-day use.
* @default true
@@ -2200,6 +2208,15 @@ export interface LegendOptions {
*/
usePointStyle: boolean;
};
+ /**
+ * true for rendering the legends from right to left.
+ */
+ rtl: boolean;
+ /**
+ * This will force the text direction 'rtl' or 'ltr' on the canvas for rendering the legend, regardless of the css specified on the canvas
+ * @default canvas' default
+ */
+ textDirection: string;
title: {
/** | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.