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 | 65a601476c9877701ef0f4543059e1711b776bfc.json | Remove debug option from animation (#8512)
* Remove debug option from animation
* Add converage for visible animation
* Update visible animation fn | docs/docs/configuration/animations.mdx | @@ -136,7 +136,6 @@ Namespace: `options.animation`
| ---- | ---- | ------- | -----------
| `duration` | `number` | `1000` | The number of milliseconds an animation takes.
| `easing` | `string` | `'easeOutQuart'` | Easing function to use. [more...](#easing)
-| `debug` | `boolean` | `undefined` | Running animation count + FPS display in upper left corner of the chart.
| `delay` | `number` | `undefined` | Delay before starting the animations.
| `loop` | `boolean` | `undefined` | If set to `true`, the animations loop endlessly.
| true |
Other | chartjs | Chart.js | 65a601476c9877701ef0f4543059e1711b776bfc.json | Remove debug option from animation (#8512)
* Remove debug option from animation
* Add converage for visible animation
* Update visible animation fn | src/core/core.animations.js | @@ -69,7 +69,7 @@ defaults.set('transitions', {
},
visible: {
type: 'boolean',
- fn: v => v < 1 ? 0 : 1 // for keeping the dataset visible all the way through the animation
+ fn: v => v | 0 // for keeping the dataset visible all the way through the animation
},
}
} | true |
Other | chartjs | Chart.js | 65a601476c9877701ef0f4543059e1711b776bfc.json | Remove debug option from animation (#8512)
* Remove debug option from animation
* Add converage for visible animation
* Update visible animation fn | src/core/core.animator.js | @@ -5,20 +5,6 @@ import {requestAnimFrame} from '../helpers/helpers.extras';
* @typedef { import("./core.controller").default } Chart
*/
-function drawFPS(chart, count, date, lastDate) {
- const fps = (1000 / (date - lastDate)) | 0;
- const ctx = chart.ctx;
- ctx.save();
- ctx.clearRect(0, 0, 50, 24);
- ctx.fillStyle = 'black';
- ctx.textAlign = 'right';
- if (count) {
- ctx.fillText(count, 50, 8);
- ctx.fillText(fps + ' fps', 50, 18);
- }
- ctx.restore();
-}
-
/**
* Please use the module's default export which provides a singleton instance
* Note: class is export for typedoc
@@ -35,7 +21,7 @@ export class Animator {
* @private
*/
_notify(chart, anims, date, type) {
- const callbacks = anims.listeners[type] || [];
+ const callbacks = anims.listeners[type];
const numSteps = anims.duration;
callbacks.forEach(fn => fn({
@@ -101,10 +87,6 @@ export class Animator {
me._notify(chart, anims, date, 'progress');
}
- if (chart.options.animation.debug) {
- drawFPS(chart, items.length, date, me._lastDate);
- }
-
if (!items.length) {
anims.running = false;
me._notify(chart, anims, date, 'complete'); | true |
Other | chartjs | Chart.js | 65a601476c9877701ef0f4543059e1711b776bfc.json | Remove debug option from animation (#8512)
* Remove debug option from animation
* Add converage for visible animation
* Update visible animation fn | test/specs/core.animations.tests.js | @@ -64,11 +64,7 @@ describe('Chart.animations', function() {
it('should assign shared options to target after animations complete', function(done) {
const chart = {
draw: function() {},
- options: {
- animation: {
- debug: false
- }
- }
+ options: {}
};
const anims = new Chart.Animations(chart, {value: {duration: 100}, option: {duration: 200}});
@@ -100,11 +96,7 @@ describe('Chart.animations', function() {
it('should not assign shared options to target when animations are cancelled', function(done) {
const chart = {
draw: function() {},
- options: {
- animation: {
- debug: false
- }
- }
+ options: {}
};
const anims = new Chart.Animations(chart, {value: {duration: 100}, option: {duration: 200}});
@@ -141,11 +133,7 @@ describe('Chart.animations', function() {
it('should assign final shared options to target after animations complete', function(done) {
const chart = {
draw: function() {},
- options: {
- animation: {
- debug: false
- }
- }
+ options: {}
};
const anims = new Chart.Animations(chart, {value: {duration: 100}, option: {duration: 200}});
@@ -184,4 +172,47 @@ describe('Chart.animations', function() {
}, 250);
}, 50);
});
+
+ describe('default transitions', function() {
+ describe('hide', function() {
+ it('should keep dataset visible through the animation', function(done) {
+ let test = false;
+ let count = 0;
+ window.acquireChart({
+ type: 'line',
+ data: {
+ labels: [0],
+ datasets: [
+ {data: [1]},
+ ]
+ },
+ options: {
+ animation: {
+ duration: 100,
+ onProgress: (args) => {
+ if (test) {
+ if (args.currentStep < args.numSteps) {
+ // while animating, visible should be truthly
+ expect(args.chart.getDatasetMeta(0).visible).toBeTruthy();
+ count++;
+ }
+ }
+ },
+ onComplete: (args) => {
+ if (!test) {
+ test = true;
+ setTimeout(() => args.chart.hide(0), 1);
+ } else {
+ // and when finished, it should be false
+ expect(args.chart.getDatasetMeta(0).visible).toBeFalsy();
+ expect(count).toBeGreaterThan(0);
+ done();
+ }
+ }
+ }
+ }
+ });
+ });
+ });
+ });
}); | true |
Other | chartjs | Chart.js | ee74dd646a60e605308b90a5147fc7121ac9c0ee.json | Add resizeDelay option (#8509)
* Add resizeDelay option
* Extract helper | docs/docs/configuration/responsive.md | @@ -21,6 +21,7 @@ Namespace: `options`
| `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.
+| `resizeDelay` | `number` | `0` | Delay the resize update by give amount of milliseconds. This can ease the resize process by debouncing update of the elements.
## Important Note
| true |
Other | chartjs | Chart.js | ee74dd646a60e605308b90a5147fc7121ac9c0ee.json | Add resizeDelay option (#8509)
* Add resizeDelay option
* Extract helper | src/core/core.controller.js | @@ -11,6 +11,7 @@ import {each, callback as callCallback, uid, valueOrDefault, _elementsEqual} fro
import {clearCanvas, clipArea, unclipArea, _isPointInArea} from '../helpers/helpers.canvas';
// @ts-ignore
import {version} from '../../package.json';
+import {debounce} from '../helpers/helpers.extras';
/**
* @typedef { import("../platform/platform.base").ChartEvent } ChartEvent
@@ -122,6 +123,7 @@ class Chart {
this.attached = false;
this._animationsDisabled = undefined;
this.$context = undefined;
+ this._doResize = debounce(() => this.update('resize'), options.resizeDelay || 0);
// Add the chart instance to the global namespace
instances[me.id] = me;
@@ -242,7 +244,10 @@ class Chart {
callCallback(options.onResize, [newSize], me);
if (me.attached) {
- me.update('resize');
+ if (me._doResize()) {
+ // The resize update is delayed, only draw without updating.
+ me.render();
+ }
}
}
| true |
Other | chartjs | Chart.js | ee74dd646a60e605308b90a5147fc7121ac9c0ee.json | Add resizeDelay option (#8509)
* Add resizeDelay option
* Extract helper | src/helpers/helpers.extras.js | @@ -40,6 +40,25 @@ export function throttled(fn, thisArg, updateFn) {
};
}
+/**
+ * Debounces calling `fn` for `delay` ms
+ * @param {function} fn - Function to call. No arguments are passed.
+ * @param {number} delay - Delay in ms. 0 = immediate invocation.
+ * @returns {function}
+ */
+export function debounce(fn, delay) {
+ let timeout;
+ return function() {
+ if (delay) {
+ clearTimeout(timeout);
+ timeout = setTimeout(fn, delay);
+ } else {
+ fn();
+ }
+ return delay;
+ };
+}
+
/**
* Converts 'start' to 'left', 'end' to 'right' and others to 'center' | true |
Other | chartjs | Chart.js | e55a12ce87162463bcfe28afc98eb5053382b375.json | Add linting of type tests (.ts) + fix errors (#8505) | package.json | @@ -40,7 +40,7 @@
"lint-js": "eslint \"samples/**/*.html\" \"samples/**/*.js\" \"src/**/*.js\" \"test/**/*.js\"",
"lint-md": "markdownlint-cli2 \"**/*.md\" \"**/*.mdx\" \"#**/node_modules\"",
"lint-tsc": "tsc",
- "lint-types": "eslint \"types/**/*.d.ts\" && tsc -p types/tests/",
+ "lint-types": "eslint \"types/**/*.ts\" && tsc -p types/tests/",
"lint": "concurrently \"npm:lint-*\"",
"test": "npm run lint && cross-env NODE_ENV=test karma start --auto-watch --single-run --coverage --grep",
"typedoc": "npx typedoc" | true |
Other | chartjs | Chart.js | e55a12ce87162463bcfe28afc98eb5053382b375.json | Add linting of type tests (.ts) + fix errors (#8505) | types/tests/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts | @@ -1,9 +1,9 @@
import { Chart } from '../../../index.esm';
Chart.defaults.controllers.bubble.plugins.tooltip.callbacks.label = (item) => {
- const {x, y, _custom: r} = item.parsed;
- return `${item.label}: (${x}, ${y}, ${r})`;
-}
+ const { x, y, _custom: r } = item.parsed;
+ return `${item.label}: (${x}, ${y}, ${r})`;
+};
const chart = new Chart('id', {
type: 'bubble', | true |
Other | chartjs | Chart.js | 36966a46c793c4a4c77b9c56ab620006c13aa6bb.json | update borderskipped typing (#8503) | types/index.esm.d.ts | @@ -1839,10 +1839,10 @@ export interface BarOptions extends CommonElementOptions {
base: number;
/**
- * Skipped (excluded) border: 'start', 'end', 'bottom', 'left', 'top' or 'right'.
+ * Skipped (excluded) border: 'start', 'end', 'left', 'right', 'bottom', 'top' or false (none).
* @default 'start'
*/
- borderSkipped: 'start' | 'end' | 'left' | 'right' | 'bottom' | 'top';
+ borderSkipped: 'start' | 'end' | 'left' | 'right' | 'bottom' | 'top' | false;
/**
* Border radius | false |
Other | chartjs | Chart.js | 311292da7e818ccb1758679618d91d34254f1880.json | Add linting of .mdx files + fix errors (#8496) | docs/docs/axes/cartesian/linear.mdx | @@ -24,9 +24,9 @@ Namespace: `options.scales[scaleId]`
## Tick Configuration
-### Linear Axis specific options
+### Linear Axis specific tick options
-Namespace: `options.scales[scaleId]`
+Namespace: `options.scales[scaleId].ticks`
| Name | Type | Default | Description
| ---- | ---- | ------- | ----------- | true |
Other | chartjs | Chart.js | 311292da7e818ccb1758679618d91d34254f1880.json | Add linting of .mdx files + fix errors (#8496) | docs/docs/axes/radial/linear.mdx | @@ -26,7 +26,7 @@ Namespace: `options.scales[scaleId]`
## Tick Configuration
-### Linear Radial Axis specific options
+### Linear Radial Axis specific tick options
Namespace: `options.scales[scaleId].ticks`
| true |
Other | chartjs | Chart.js | 311292da7e818ccb1758679618d91d34254f1880.json | Add linting of .mdx files + fix errors (#8496) | docs/docs/charts/bar.mdx | @@ -176,7 +176,7 @@ The bar chart accepts the following configuration from the associated dataset op
| `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.
-### Example Usage
+### Example dataset configuration
```javascript
data: {
@@ -215,7 +215,7 @@ The bar chart sets unique default values for the following configuration from th
| `offset` | `boolean` | `true` | If true, extra space is added to both edges and the axis is scaled to fit into the chart area.
| `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
+### Example scale configuration
```javascript
options = {
@@ -305,7 +305,7 @@ export const ExampleChart1 = () => {
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
- axis: 'y',
+ axis: 'y',
label: 'My First Dataset',
data: [65, 59, 80, 81, 56, 55, 40],
fill: false,
@@ -331,7 +331,7 @@ export const ExampleChart1 = () => {
}]
},
options: {
- indexAxis: 'y',
+ indexAxis: 'y',
scales: {
x: {
beginAtZero: true
@@ -354,12 +354,12 @@ var myBarChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
- indexAxis: 'y'
+ indexAxis: 'y'
}
});
```
-### Config Options
+### Horizontal Bar Chart 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.
| true |
Other | chartjs | Chart.js | 311292da7e818ccb1758679618d91d34254f1880.json | Add linting of .mdx files + fix errors (#8496) | docs/docs/charts/doughnut.mdx | @@ -121,7 +121,6 @@ The doughnut/pie chart allows a number of properties to be specified for each da
| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
| `rotation` | Per-dataset override for the starting angle to draw arcs from
-
### Styling
The style of each arc can be controlled with the following properties:
@@ -139,6 +138,7 @@ All these values, if `undefined`, fallback to the associated [`elements.arc.*`](
### Border Alignment
The following values are supported for `borderAlign`.
+
* `'center'` (default)
* `'inner'`
| true |
Other | chartjs | Chart.js | 311292da7e818ccb1758679618d91d34254f1880.json | Add linting of .mdx files + fix errors (#8496) | docs/docs/charts/line.mdx | @@ -224,50 +224,50 @@ To achieve this you will have to set the `indexAxis` property in the options obj
The default for this property is `'x'` and thus will show horizontal lines.
export const ExampleChart1 = () => {
- useEffect(() => {
- const cfg = {
- type: 'line',
- data: {
- labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
- datasets: [{
- axis: 'y',
- label: 'My First Dataset',
- data: [65, 59, 80, 81, 56, 55, 40],
- fill: false,
- backgroundColor: [
- 'rgba(255, 99, 132, 0.2)',
- 'rgba(255, 159, 64, 0.2)',
- 'rgba(255, 205, 86, 0.2)',
- 'rgba(75, 192, 192, 0.2)',
- 'rgba(54, 162, 235, 0.2)',
- 'rgba(153, 102, 255, 0.2)',
- 'rgba(201, 203, 207, 0.2)'
- ],
- borderColor: [
- 'rgb(255, 99, 132)',
- 'rgb(255, 159, 64)',
- 'rgb(255, 205, 86)',
- 'rgb(75, 192, 192)',
- 'rgb(54, 162, 235)',
- 'rgb(153, 102, 255)',
- 'rgb(201, 203, 207)'
- ],
- borderWidth: 1
- }]
- },
- options: {
- indexAxis: 'y',
- scales: {
- x: {
- beginAtZero: true
- }
- }
- }
- };
- const chart = new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg);
- return () => chart.destroy();
- });
- return <div className="chartjs-wrapper"><canvas id="chartjs-1" className="chartjs"></canvas></div>;
+ useEffect(() => {
+ const cfg = {
+ type: 'line',
+ data: {
+ labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
+ datasets: [{
+ axis: 'y',
+ label: 'My First Dataset',
+ data: [65, 59, 80, 81, 56, 55, 40],
+ fill: false,
+ backgroundColor: [
+ 'rgba(255, 99, 132, 0.2)',
+ 'rgba(255, 159, 64, 0.2)',
+ 'rgba(255, 205, 86, 0.2)',
+ 'rgba(75, 192, 192, 0.2)',
+ 'rgba(54, 162, 235, 0.2)',
+ 'rgba(153, 102, 255, 0.2)',
+ 'rgba(201, 203, 207, 0.2)'
+ ],
+ borderColor: [
+ 'rgb(255, 99, 132)',
+ 'rgb(255, 159, 64)',
+ 'rgb(255, 205, 86)',
+ 'rgb(75, 192, 192)',
+ 'rgb(54, 162, 235)',
+ 'rgb(153, 102, 255)',
+ 'rgb(201, 203, 207)'
+ ],
+ borderWidth: 1
+ }]
+ },
+ options: {
+ indexAxis: 'y',
+ scales: {
+ x: {
+ beginAtZero: true
+ }
+ }
+ }
+ };
+ const chart = new Chart(document.getElementById('chartjs-1').getContext('2d'), cfg);
+ return () => chart.destroy();
+ });
+ return <div className="chartjs-wrapper"><canvas id="chartjs-1" className="chartjs"></canvas></div>;
}
<ExampleChart1/>
@@ -279,7 +279,7 @@ var myLineChart = new Chart(ctx, {
type: 'line',
data: data,
options: {
- indexAxis: 'y'
+ indexAxis: 'y'
}
});
``` | true |
Other | chartjs | Chart.js | 311292da7e818ccb1758679618d91d34254f1880.json | Add linting of .mdx files + fix errors (#8496) | package.json | @@ -38,7 +38,7 @@
"dev": "karma start --auto-watch --no-single-run --browsers chrome --grep",
"docs": "cd docs && npm install && npm run build",
"lint-js": "eslint \"samples/**/*.html\" \"samples/**/*.js\" \"src/**/*.js\" \"test/**/*.js\"",
- "lint-md": "markdownlint-cli2 \"**/*.md\" \"#**/node_modules\"",
+ "lint-md": "markdownlint-cli2 \"**/*.md\" \"**/*.mdx\" \"#**/node_modules\"",
"lint-tsc": "tsc",
"lint-types": "eslint \"types/**/*.d.ts\" && tsc -p types/tests/",
"lint": "concurrently \"npm:lint-*\"", | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | docs/docs/configuration/animations.mdx | @@ -33,21 +33,21 @@ function example() {
}]
},
options: {
- animation: {
- tension: {
- duration: 1000,
- easing: 'linear',
- from: 1,
- to: 0,
- loop: true
- }
- },
- scales: {
- y: { // defining min and max so hiding the dataset does not change scale range
- min: 0,
- max: 100
- }
+ animations: {
+ tension: {
+ duration: 1000,
+ easing: 'linear',
+ from: 1,
+ to: 0,
+ loop: true
+ }
+ },
+ scales: {
+ y: { // defining min and max so hiding the dataset does not change scale range
+ min: 0,
+ max: 100
}
+ }
}
};
const chart = new Chart(ctx, cfg);
@@ -77,24 +77,24 @@ function example() {
}]
},
options: {
- animation: {
- show: {
- x: {
- from: 0
- },
- y: {
- from: 0
- }
+ transitions: {
+ show: {
+ x: {
+ from: 0
},
- hide: {
- x: {
- to: 0
- },
- y: {
- to: 0
- }
+ y: {
+ from: 0
+ }
+ },
+ hide: {
+ x: {
+ to: 0
+ },
+ y: {
+ to: 0
}
}
+ }
}
};
const chart = new Chart(ctx, cfg);
@@ -107,10 +107,30 @@ function example() {
</TabItem>
</Tabs>
-## Animation Configuration
+## Animation configuration
+
+Animation configuration consists of 3 keys.
+
+| Name | Type | Details
+| ---- | ---- | -------
+| animation | `object` | [animation](#animation)
+| animations | `object` | [animations](#animations)
+| transitions | `object` | [transitions](#transitions)
+
+These keys can be configured in following paths:
-The default configuration is defined here: <a href="https://github.com/chartjs/Chart.js/blob/master/src/core/core.animations.js#L6-L55" target="_blank">core.animations.js</a>
-Namespace: `options.animation`, the global options are defined in `Chart.defaults.animation`.
+* `` - chart options
+* `controllers[type]` - controller type options
+* `controllers[type].datasets` - dataset type options
+* `datasets[type]` - dataset type options
+
+These paths are valid under `defaults` for global confuguration and `options` for instance configuration.
+
+## animation
+
+The default configuration is defined here: <a href="https://github.com/chartjs/Chart.js/blob/master/src/core/core.animations.js#L9-L56" target="_blank">core.animations.js</a>
+
+Namespace: `options.animation`
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
@@ -119,84 +139,65 @@ Namespace: `options.animation`, the global options are defined in `Chart.defaul
| `debug` | `boolean` | `undefined` | Running animation count + FPS display in upper left corner of the chart.
| `delay` | `number` | `undefined` | Delay before starting the animations.
| `loop` | `boolean` | `undefined` | If set to `true`, the animations loop endlessly.
-| [[mode]](#animation-mode-configuration) | `object` | [defaults...](#default-modes) | Option overrides for update mode. Core modes: `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`. See **Hide and show [mode]** example above.
-| [[property]](#animation-property-configuration) | `object` | `undefined` | Option overrides for a single element `[property]`. These have precedence over `[collection]`. See **Looping tension [property]** example above.
-| [[collection]](#animation-properties-collection-configuration) | `object` | [defaults...](#default-collections) | Option overrides for multiple properties, identified by `properties` array.
These defaults can be overridden in `options.animation` or `dataset.animation` and `tooltip.animation`. These keys are also [Scriptable](../general/options.md#scriptable-options).
-## Animation mode configuration
+## animations
-Mode option configures how an update mode animates the chart.
-The cores modes are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`.
-A custom mode can be used by passing a custom `mode` to [update](../developers/api.md#updatemode).
-A mode option is defined by the same options of the main [animation configuration](#animation-configuration).
+Animations options configures which element properties are animated and how.
+In addition to the main [animation configuration](#animation-configuration), the following options are available:
-### Default modes
-
-Namespace: `options.animation`
-
-| Mode | Option | Value | Description
-| -----| ------ | ----- | -----
-| `active` | duration | 400 | Override default duration to 400ms for hover animations
-| `resize` | duration | 0 | Override default duration to 0ms (= no animation) for resize
-| `show` | colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], from: 'transparent' }` | Colors are faded in from transparent when dataset is shown using legend / [api](../developers/api.md#showdatasetIndex).
-| `show` | visible | `{ type: 'boolean', duration: 0 }` | Dataset visiblity is immediately changed to true so the color transition from transparent is visible.
-| `hide` | colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], to: 'transparent' }` | Colors are faded to transparent when dataset id hidden using legend / [api](../developers/api.md#hidedatasetIndex).
-| `hide` | visible | `{ type: 'boolean', easing: 'easeInExpo' }` | Visibility is changed to false at a very late phase of animation
-
-## Animation property configuration
-
-Property option configures which element property to use to animate the chart and its starting and ending values.
-A property option is defined by the same options of the main [animation configuration](#animation-configuration), adding the following ones:
-
-Namespace: `options.animation[animation]`
+Namespace: `options.animations[animation]`
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
+| `properties` | `string[]` | `key` | The property names this configuration applies to. Defaults to the key name of this object.
| `type` | `string` | `typeof property` | Type of property, determines the interpolator used. Possible values: `'number'`, `'color'` and `'boolean'`. Only really needed for `'color'`, because `typeof` does not get that right.
| `from` | `number`\|`Color`\|`boolean` | `undefined` | Start value for the animation. Current value is used when `undefined`
| `to` | `number`\|`Color`\|`boolean` | `undefined` | End value for the animation. Updated value is used when `undefined`
| `fn` | <code><T>(from: T, to: T, factor: number) => T;</code> | `undefined` | Optional custom interpolator, instead of using a predefined interpolator from `type` |
-## Animation properties collection configuration
-
-Properties collection option configures which set of element properties to use to animate the chart.
-Collection can be named whatever you like, but should not collide with a `[property]` or `[mode]`.
-A properties collection option is defined by the same options as the [animation property configuration](#animation-property-configuration), adding the following one:
-
-The animation properties collection configuration can be adjusted in the `options.animation[collection]` namespace.
-
-| Name | Type | Default | Description
-| ---- | ---- | ------- | -----------
-| `properties` | `string[]` | `undefined` | Set of properties to use to animate the chart.
-
-### Default collections
+### Default animations
| Name | Option | Value
| ---- | ------ | -----
-| `numbers` | `type` | `'number'`
| `numbers` | `properties` | `['x', 'y', 'borderWidth', 'radius', 'tension']`
+| `numbers` | `type` | `'number'`
+| `colors` | `properties` | `['color', 'borderColor', 'backgroundColor']`
| `colors` | `type` | `'color'`
-| `colors` | `properties` | `['borderColor', 'backgroundColor']`
-
-Direct property configuration overrides configuration of same property in a collection.
-
-From collections, a property gets its configuration from first one that has its name in properties.
:::note
-These default collections are overridden by most dataset controllers.
+These default animations are overridden by most of the dataset controllers.
:::
+## transitions
+
+The core transitions are `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'`.
+A custom transtion can be used by passing a custom `mode` to [update](../developers/api.md#updatemode).
+Transition extends the main [animation configuration](#animation-configuration) and [animations configuration](#animations-configuration).
+
+### Default transitions
+
+Namespace: `options.transitions[mode]`
+
+| Mode | Option | Value | Description
+| -----| ------ | ----- | -----
+| `'active'` | animation.duration | 400 | Override default duration to 400ms for hover animations
+| `'resize'` | animation.duration | 0 | Override default duration to 0ms (= no animation) for resize
+| `'show'` | animations.colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], from: 'transparent' }` | Colors are faded in from transparent when dataset is shown using legend / [api](../developers/api.md#showdatasetIndex).
+| `'show'` | animations.visible | `{ type: 'boolean', duration: 0 }` | Dataset visiblity is immediately changed to true so the color transition from transparent is visible.
+| `'hide'` | animations.colors | `{ type: 'color', properties: ['borderColor', 'backgroundColor'], to: 'transparent' }` | Colors are faded to transparent when dataset id hidden using legend / [api](../developers/api.md#hidedatasetIndex).
+| `'hide'` | animations.visible | `{ type: 'boolean', easing: 'easeInExpo' }` | Visibility is changed to false at a very late phase of animation
+
## Disabling animation
To disable an animation configuration, the animation node must be set to `false`, with the exception for animation modes which can be disabled by setting the `duration` to `0`.
```javascript
-chart.options.animation = false; // disables the whole animation
-chart.options.animation.active.duration = 0; // disables the animation for 'active' mode
-chart.options.animation.colors = false; // disables animation defined by the collection of 'colors' properties
-chart.options.animation.x = false; // disables animation defined by the 'x' property
+chart.options.animation = false; // disables all animations
+chart.options.animations.colors = false; // disables animation defined by the collection of 'colors' properties
+chart.options.animations.x = false; // disables animation defined by the 'x' property
+chart.options.transitions.active.animation.duration = 0; // disables the animation for 'active' mode
```
## Easing | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | docs/docs/developers/api.md | @@ -28,7 +28,7 @@ myLineChart.data.datasets[0].data[2] = 50; // Would update the first dataset's v
myLineChart.update(); // Calling update now animates the position of March from 90 to 50.
```
-A `mode` string can be provided to indicate what should be updated and what animation configuration should be used. Core calls this method using any of `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'` or `undefined`. `'none'` is also a supported mode for skipping animations for single update. Please see [animations](../configuration/animations.mdx) docs for more details.
+A `mode` string can be provided to indicate transition configuration should be used. Core calls this method using any of `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'` or `undefined`. `'none'` is also a supported mode for skipping animations for single update. Please see [animations](../configuration/animations.mdx) docs for more details.
Example:
| true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | samples/animations/drop.html | @@ -33,13 +33,13 @@
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First dataset',
- animation: {
+ animations: {
y: {
duration: 2000,
- delay: 100
+ delay: 500
}
},
- backgroundColor: window.chartColors.red,
+ backgroundColor: 'rgba(170,0,0,0.1)',
borderColor: window.chartColors.red,
data: [
randomScalingFactor(),
@@ -50,7 +50,8 @@
randomScalingFactor(),
randomScalingFactor()
],
- fill: false,
+ fill: 1,
+ tension: 0.5
}, {
label: 'My Second dataset',
fill: false,
@@ -68,10 +69,17 @@
}]
},
options: {
- animation: {
+ animations: {
y: {
easing: 'easeInOutElastic',
- from: 0
+ from: (ctx) => {
+ if (ctx.type === 'data') {
+ if (ctx.mode === 'default' && !ctx.dropped) {
+ ctx.dropped = true;
+ return 0;
+ }
+ }
+ }
}
},
responsive: true, | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | samples/animations/loop.html | @@ -62,7 +62,7 @@
}]
},
options: {
- animation: {
+ animations: {
radius: {
duration: 400,
easing: 'linear',
@@ -74,23 +74,18 @@
hoverRadius: 6
}
},
- responsive: true,
+ interaction: {
+ mode: 'nearest',
+ axis: 'x',
+ intersect: false
+ },
plugins: {
title: {
display: true,
text: 'Chart.js Line Chart'
},
- tooltip: {
- mode: 'nearest',
- axis: 'x',
- intersect: false,
- },
- },
- hover: {
- mode: 'nearest',
- axis: 'x',
- intersect: false
},
+ responsive: true,
scales: {
x: {
display: true, | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/controllers/controller.bar.js | @@ -520,7 +520,7 @@ BarController.defaults = {
datasets: {
categoryPercentage: 0.8,
barPercentage: 0.9,
- animation: {
+ animations: {
numbers: {
type: 'number',
properties: ['x', 'y', 'base', 'width', 'height'] | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/controllers/controller.bubble.js | @@ -133,8 +133,9 @@ BubbleController.id = 'bubble';
BubbleController.defaults = {
datasetElementType: false,
dataElementType: 'point',
- animation: {
+ animations: {
numbers: {
+ type: 'number',
properties: ['x', 'y', 'borderWidth', 'radius']
}
}, | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/controllers/controller.doughnut.js | @@ -329,15 +329,17 @@ DoughnutController.defaults = {
datasetElementType: false,
dataElementType: 'arc',
animation: {
- numbers: {
- type: 'number',
- properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y', 'offset', 'borderWidth']
- },
// Boolean - Whether we animate the rotation of the Doughnut
animateRotate: true,
// Boolean - Whether we animate scaling the Doughnut from the centre
animateScale: false
},
+ animations: {
+ numbers: {
+ type: 'number',
+ properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y', 'offset', 'borderWidth']
+ },
+ },
aspectRatio: 1,
datasets: { | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/controllers/controller.polarArea.js | @@ -122,12 +122,14 @@ PolarAreaController.id = 'polarArea';
PolarAreaController.defaults = {
dataElementType: 'arc',
animation: {
+ animateRotate: true,
+ animateScale: true
+ },
+ animations: {
numbers: {
type: 'number',
properties: ['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius']
},
- animateRotate: true,
- animateScale: true
},
aspectRatio: 1,
indexAxis: 'r', | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/core/core.animation.js | @@ -28,7 +28,7 @@ export default class Animation {
this._active = true;
this._fn = cfg.fn || interpolators[cfg.type || typeof from];
- this._easing = effects[cfg.easing || 'linear'];
+ this._easing = effects[cfg.easing] || effects.linear;
this._start = Math.floor(Date.now() + (cfg.delay || 0));
this._duration = Math.floor(cfg.duration);
this._loop = !!cfg.loop; | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/core/core.animations.js | @@ -1,20 +1,31 @@
import animator from './core.animator';
import Animation from './core.animation';
import defaults from './core.defaults';
-import {isObject} from '../helpers/helpers.core';
+import {isArray, isObject} from '../helpers/helpers.core';
const numbers = ['x', 'y', 'borderWidth', 'radius', 'tension'];
-const colors = ['borderColor', 'backgroundColor'];
-const animationOptions = ['delay', 'duration', 'easing', 'fn', 'from', 'loop', 'to', 'type'];
+const colors = ['color', 'borderColor', 'backgroundColor'];
defaults.set('animation', {
- // Plain properties can be overridden in each object
+ delay: undefined,
duration: 1000,
easing: 'easeOutQuart',
- onProgress: undefined,
- onComplete: undefined,
+ fn: undefined,
+ from: undefined,
+ loop: undefined,
+ to: undefined,
+ type: undefined,
+});
+
+const animationOptions = Object.keys(defaults.animation);
- // Property sets
+defaults.describe('animation', {
+ _fallback: false,
+ _indexable: false,
+ _scriptable: (name) => name !== 'onProgress' && name !== 'onComplete' && name !== 'fn',
+});
+
+defaults.set('animations', {
colors: {
type: 'color',
properties: colors
@@ -23,60 +34,63 @@ defaults.set('animation', {
type: 'number',
properties: numbers
},
+});
+
+defaults.describe('animations', {
+ _fallback: 'animation',
+});
- // Update modes. These are overrides / additions to the above animations.
+defaults.set('transitions', {
active: {
- duration: 400
+ animation: {
+ duration: 400
+ }
},
resize: {
- duration: 0
+ animation: {
+ duration: 0
+ }
},
show: {
- colors: {
- type: 'color',
- properties: colors,
- from: 'transparent'
- },
- visible: {
- type: 'boolean',
- duration: 0 // show immediately
- },
+ animations: {
+ colors: {
+ from: 'transparent'
+ },
+ visible: {
+ type: 'boolean',
+ duration: 0 // show immediately
+ },
+ }
},
hide: {
- colors: {
- type: 'color',
- properties: colors,
- to: 'transparent'
- },
- visible: {
- type: 'boolean',
- fn: v => v < 1 ? 0 : 1 // for keeping the dataset visible all the way through the animation
- },
+ animations: {
+ colors: {
+ to: 'transparent'
+ },
+ visible: {
+ type: 'boolean',
+ fn: v => v < 1 ? 0 : 1 // for keeping the dataset visible all the way through the animation
+ },
+ }
}
});
-defaults.describe('animation', {
- _scriptable: (name) => name !== 'onProgress' && name !== 'onComplete' && name !== 'fn',
- _indexable: false,
- _fallback: 'animation',
-});
-
export default class Animations {
- constructor(chart, animations) {
+ constructor(chart, config) {
this._chart = chart;
this._properties = new Map();
- this.configure(animations);
+ this.configure(config);
}
- configure(animations) {
- if (!isObject(animations)) {
+ configure(config) {
+ if (!isObject(config)) {
return;
}
const animatedProps = this._properties;
- Object.getOwnPropertyNames(animations).forEach(key => {
- const cfg = animations[key];
+ Object.getOwnPropertyNames(config).forEach(key => {
+ const cfg = config[key];
if (!isObject(cfg)) {
return;
}
@@ -85,7 +99,7 @@ export default class Animations {
resolved[option] = cfg[option];
}
- (cfg.properties || [key]).forEach((prop) => {
+ (isArray(cfg.properties) && cfg.properties || [key]).forEach((prop) => {
if (prop === key || !animatedProps.has(prop)) {
animatedProps.set(prop, resolved);
} | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/core/core.config.js | @@ -166,11 +166,11 @@ export default class Config {
}
/**
- * Returns the option scope keys for resolving dataset options.
- * These keys do not include the dataset itself, because it is not under options.
- * @param {string} datasetType
- * @return {string[]}
- */
+ * Returns the option scope keys for resolving dataset options.
+ * These keys do not include the dataset itself, because it is not under options.
+ * @param {string} datasetType
+ * @return {string[]}
+ */
datasetScopeKeys(datasetType) {
return cachedKeys(datasetType,
() => [
@@ -182,29 +182,34 @@ export default class Config {
}
/**
- * Returns the option scope keys for resolving dataset animation options.
- * These keys do not include the dataset itself, because it is not under options.
- * @param {string} datasetType
- * @return {string[]}
- */
- datasetAnimationScopeKeys(datasetType) {
- return cachedKeys(`${datasetType}.animation`,
+ * Returns the option scope keys for resolving dataset animation options.
+ * These keys do not include the dataset itself, because it is not under options.
+ * @param {string} datasetType
+ * @param {string} transition
+ * @return {string[]}
+ */
+ datasetAnimationScopeKeys(datasetType, transition) {
+ return cachedKeys(`${datasetType}.transition.${transition}`,
() => [
- `datasets.${datasetType}.animation`,
- `controllers.${datasetType}.animation`,
- `controllers.${datasetType}.datasets.animation`,
- 'animation'
+ `datasets.${datasetType}.transitions.${transition}`,
+ `controllers.${datasetType}.transitions.${transition}`,
+ `controllers.${datasetType}.datasets.transitions.${transition}`,
+ `transitions.${transition}`,
+ `datasets.${datasetType}`,
+ `controllers.${datasetType}`,
+ `controllers.${datasetType}.datasets`,
+ ''
]);
}
/**
- * Returns the options scope keys for resolving element options that belong
- * to an dataset. These keys do not include the dataset itself, because it
- * is not under options.
- * @param {string} datasetType
- * @param {string} elementType
- * @return {string[]}
- */
+ * Returns the options scope keys for resolving element options that belong
+ * to an dataset. These keys do not include the dataset itself, because it
+ * is not under options.
+ * @param {string} datasetType
+ * @param {string} elementType
+ * @return {string[]}
+ */
datasetElementScopeKeys(datasetType, elementType) {
return cachedKeys(`${datasetType}-${elementType}`,
() => [
@@ -219,7 +224,7 @@ export default class Config {
/**
* Returns the options scope keys for resolving plugin options.
* @param {{id: string, additionalOptionScopes?: string[]}} plugin
- * @return {string[]}
+ * @return {string[]}
*/
pluginScopeKeys(plugin) {
const id = plugin.id;
@@ -233,11 +238,11 @@ export default class Config {
}
/**
- * Resolves the objects from options and defaults for option value resolution.
- * @param {object} mainScope - The main scope object for options
- * @param {string[]} scopeKeys - The keys in resolution order
+ * Resolves the objects from options and defaults for option value resolution.
+ * @param {object} mainScope - The main scope object for options
+ * @param {string[]} scopeKeys - The keys in resolution order
* @param {boolean} [resetCache] - reset the cache for this mainScope
- */
+ */
getOptionScopes(mainScope, scopeKeys, resetCache) {
let cache = this._scopeCache.get(mainScope);
if (!cache || resetCache) {
@@ -267,9 +272,9 @@ export default class Config {
}
/**
- * Returns the option scopes for resolving chart options
- * @return {object[]}
- */
+ * Returns the option scopes for resolving chart options
+ * @return {object[]}
+ */
chartOptionScopes() {
return [
this.options,
@@ -281,12 +286,12 @@ export default class Config {
}
/**
- * @param {object[]} scopes
- * @param {string[]} names
- * @param {function|object} context
- * @param {string[]} [prefixes]
- * @return {object}
- */
+ * @param {object[]} scopes
+ * @param {string[]} names
+ * @param {function|object} context
+ * @param {string[]} [prefixes]
+ * @return {object}
+ */
resolveNamedOptions(scopes, names, context, prefixes = ['']) {
const result = {$shared: true};
const {resolver, subPrefixes} = getResolver(this._resolverCache, scopes, prefixes);
@@ -306,10 +311,10 @@ export default class Config {
}
/**
- * @param {object[]} scopes
- * @param {object} [context]
+ * @param {object[]} scopes
+ * @param {object} [context]
* @param {string[]} [prefixes]
- */
+ */
createResolver(scopes, context, prefixes = ['']) {
const {resolver} = getResolver(this._resolverCache, scopes, prefixes);
return isObject(context)
@@ -342,7 +347,7 @@ function needContext(proxy, names) {
for (const prop of names) {
if ((isScriptable(prop) && isFunction(proxy[prop]))
- || (isIndexable(prop) && isArray(proxy[prop]))) {
+ || (isIndexable(prop) && isArray(proxy[prop]))) {
return true;
}
} | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/core/core.datasetController.js | @@ -763,23 +763,23 @@ export default class DatasetController {
/**
* @private
*/
- _resolveAnimations(index, mode, active) {
+ _resolveAnimations(index, transition, active) {
const me = this;
const chart = me.chart;
const cache = me._cachedDataOpts;
- const cacheKey = 'animation-' + mode;
+ const cacheKey = `animation-${transition}`;
const cached = cache[cacheKey];
if (cached) {
return cached;
}
let options;
if (chart.options.animation !== false) {
const config = me.chart.config;
- const scopeKeys = config.datasetAnimationScopeKeys(me._type);
- const scopes = config.getOptionScopes(me.getDataset().animation, scopeKeys);
- options = config.createResolver(scopes, me.getContext(index, active, mode));
+ const scopeKeys = config.datasetAnimationScopeKeys(me._type, transition);
+ const scopes = config.getOptionScopes(me.getDataset(), scopeKeys);
+ options = config.createResolver(scopes, me.getContext(index, active, transition));
}
- const animations = new Animations(chart, options && options[mode] || options);
+ const animations = new Animations(chart, options && options.animations);
if (options && options._cacheable) {
cache[cacheKey] = Object.freeze(animations);
} | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/core/core.scale.js | @@ -83,12 +83,16 @@ defaults.route('scale.ticks', 'color', '', 'color');
defaults.route('scale.gridLines', 'color', '', 'borderColor');
defaults.route('scale.scaleLabel', 'color', '', 'color');
-defaults.describe('scales', {
- _fallback: 'scale',
+defaults.describe('scale', {
+ _fallback: false,
_scriptable: (name) => !name.startsWith('before') && !name.startsWith('after') && name !== 'callback' && name !== 'parser',
_indexable: (name) => name !== 'borderDash' && name !== 'tickBorderDash',
});
+defaults.describe('scales', {
+ _fallback: 'scale',
+});
+
/**
* Returns a new array containing numItems from arr
* @param {any[]} arr | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/helpers/helpers.config.js | @@ -1,26 +1,33 @@
-import {defined, isArray, isFunction, isObject, resolveObjectKey, valueOrDefault, _capitalize} from './helpers.core';
+import {defined, isArray, isFunction, isObject, resolveObjectKey, _capitalize} from './helpers.core';
/**
* Creates a Proxy for resolving raw values for options.
* @param {object[]} scopes - The option scopes to look for values, in resolution order
* @param {string[]} [prefixes] - The prefixes for values, in resolution order.
+ * @param {object[]} [rootScopes] - The root option scopes
+ * @param {string|boolean} [fallback] - Parent scopes fallback
* @returns Proxy
* @private
*/
-export function _createResolver(scopes, prefixes = ['']) {
+export function _createResolver(scopes, prefixes = [''], rootScopes = scopes, fallback) {
+ if (!defined(fallback)) {
+ fallback = _resolve('_fallback', scopes);
+ }
const cache = {
[Symbol.toStringTag]: 'Object',
_cacheable: true,
_scopes: scopes,
- override: (scope) => _createResolver([scope, ...scopes], prefixes),
+ _rootScopes: rootScopes,
+ _fallback: fallback,
+ override: (scope) => _createResolver([scope, ...scopes], prefixes, rootScopes, fallback),
};
return new Proxy(cache, {
/**
* A trap for getting property values.
*/
get(target, prop) {
return _cached(target, prop,
- () => _resolveWithPrefixes(prop, prefixes, scopes));
+ () => _resolveWithPrefixes(prop, prefixes, scopes, target));
},
/**
@@ -186,7 +193,7 @@ function _resolveScriptable(prop, value, target, receiver) {
_stack.delete(prop);
if (isObject(value)) {
// When scriptable option returns an object, create a resolver on that.
- value = createSubResolver(_proxy._scopes, prop, value);
+ value = createSubResolver(_proxy._scopes, _proxy, prop, value);
}
return value;
}
@@ -202,64 +209,69 @@ function _resolveArray(prop, value, target, isIndexable) {
const scopes = _proxy._scopes.filter(s => s !== arr);
value = [];
for (const item of arr) {
- const resolver = createSubResolver(scopes, prop, item);
+ const resolver = createSubResolver(scopes, _proxy, prop, item);
value.push(_attachContext(resolver, _context, _subProxy && _subProxy[prop]));
}
}
return value;
}
-function createSubResolver(parentScopes, prop, value) {
- const set = new Set([value]);
- const lookupScopes = [value, ...parentScopes];
- const {keys, includeParents} = _resolveSubKeys(lookupScopes, prop, value);
- while (keys.length) {
- const key = keys.shift();
- for (const item of lookupScopes) {
- const scope = resolveObjectKey(item, key);
- if (scope) {
- set.add(scope);
- // fallback detour?
- const fallback = scope._fallback;
- if (defined(fallback)) {
- keys.push(...resolveFallback(fallback, key, scope).filter(k => k !== key));
- }
+function resolveFallback(fallback, prop, value) {
+ return isFunction(fallback) ? fallback(prop, value) : fallback;
+}
- } else if (key !== prop && scope === false) {
- // If any of the fallback scopes is explicitly false, return false
- // For example, options.hover falls back to options.interaction, when
- // options.interaction is false, options.hover will also resolve as false.
- return false;
+const getScope = (key, parent) => key === true ? parent : resolveObjectKey(parent, key);
+
+function addScopes(set, parentScopes, key, parentFallback) {
+ for (const parent of parentScopes) {
+ const scope = getScope(key, parent);
+ if (scope) {
+ set.add(scope);
+ const fallback = scope._fallback;
+ if (defined(fallback) && fallback !== key && fallback !== parentFallback) {
+ // When we reach the descriptor that defines a new _fallback, return that.
+ // The fallback will resume to that new scope.
+ return fallback;
}
+ } else if (scope === false && key !== 'fill') {
+ // Fallback to `false` results to `false`, expect for `fill`.
+ // The special case (fill) should be handled through descriptors.
+ return null;
}
}
- if (includeParents) {
- parentScopes.forEach(set.add, set);
- }
- return _createResolver([...set]);
-}
-
-function resolveFallback(fallback, prop, value) {
- const resolved = isFunction(fallback) ? fallback(prop, value) : fallback;
- return isArray(resolved) ? resolved : typeof resolved === 'string' ? [resolved] : [];
+ return false;
}
-function _resolveSubKeys(parentScopes, prop, value) {
- const fallback = valueOrDefault(_resolve('_fallback', parentScopes.map(scope => scope[prop] || scope)), true);
- const keys = [prop];
- if (defined(fallback)) {
- keys.push(...resolveFallback(fallback, prop, value));
+function createSubResolver(parentScopes, resolver, prop, value) {
+ const rootScopes = resolver._rootScopes;
+ const fallback = resolveFallback(resolver._fallback, prop, value);
+ const allScopes = [...parentScopes, ...rootScopes];
+ const set = new Set([value]);
+ let key = prop;
+ while (key !== false) {
+ key = addScopes(set, allScopes, key, fallback);
+ if (key === null) {
+ return false;
+ }
}
- return {keys: keys.filter(v => v), includeParents: fallback !== false && fallback !== prop};
+ if (defined(fallback) && fallback !== prop) {
+ const fallbackScopes = allScopes;
+ key = fallback;
+ while (key !== false) {
+ key = addScopes(set, fallbackScopes, key, fallback);
+ }
+ }
+ return _createResolver([...set], [''], rootScopes, fallback);
}
-function _resolveWithPrefixes(prop, prefixes, scopes) {
+
+function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {
let value;
for (const prefix of prefixes) {
value = _resolve(readKey(prefix, prop), scopes);
if (defined(value)) {
- return (needsSubResolver(prop, value))
- ? createSubResolver(scopes, prop, value)
+ return needsSubResolver(prop, value)
+ ? createSubResolver(scopes, proxy, prop, value)
: value;
}
} | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | src/plugins/plugin.tooltip.js | @@ -385,9 +385,11 @@ export class Tooltip extends Element {
const chart = me._chart;
const options = me.options;
- const opts = options.enabled && chart.options.animation && options.animation;
+ const opts = options.enabled && chart.options.animation && options.animations;
const animations = new Animations(me._chart, opts);
- me._cachedAnimations = Object.freeze(animations);
+ if (opts._cacheable) {
+ me._cachedAnimations = Object.freeze(animations);
+ }
return animations;
}
@@ -1108,6 +1110,8 @@ export default {
animation: {
duration: 400,
easing: 'easeOutQuart',
+ },
+ animations: {
numbers: {
type: 'number',
properties: ['x', 'y', 'width', 'height', 'caretX', 'caretY'],
@@ -1203,6 +1207,12 @@ export default {
callbacks: {
_scriptable: false,
_indexable: false,
+ },
+ animation: {
+ _fallback: false
+ },
+ animations: {
+ _fallback: 'animation'
}
},
| true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | test/specs/core.datasetController.tests.js | @@ -742,6 +742,18 @@ describe('Chart.DatasetController', function() {
});
describe('_resolveAnimations', function() {
+ function animationsExpectations(anims, props) {
+ for (const [prop, opts] of Object.entries(props)) {
+ const anim = anims._properties.get(prop);
+ expect(anim).withContext(prop).toBeInstanceOf(Object);
+ if (anim) {
+ for (const [name, value] of Object.entries(opts)) {
+ expect(anim[name]).withContext('"' + name + '" of ' + JSON.stringify(anim)).toEqual(value);
+ }
+ }
+ }
+ }
+
it('should resolve to empty Animations when globally disabled', function() {
const chart = acquireChart({
type: 'line',
@@ -778,5 +790,70 @@ describe('Chart.DatasetController', function() {
expect(controller._resolveAnimations(0)._properties.size).toEqual(0);
});
+
+ it('should fallback properly', function() {
+ const chart = acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ data: [1],
+ animation: {
+ duration: 200
+ }
+ }, {
+ type: 'bar',
+ data: [2]
+ }]
+ },
+ options: {
+ animation: {
+ delay: 100
+ },
+ animations: {
+ x: {
+ delay: 200
+ }
+ },
+ transitions: {
+ show: {
+ x: {
+ delay: 300
+ }
+ }
+ },
+ datasets: {
+ bar: {
+ animation: {
+ duration: 500
+ }
+ }
+ }
+ }
+ });
+ const controller = chart.getDatasetMeta(0).controller;
+
+ expect(Chart.defaults.animation.duration).toEqual(1000);
+
+ const def0 = controller._resolveAnimations(0, 'default', false);
+ animationsExpectations(def0, {
+ x: {
+ delay: 200,
+ duration: 200
+ },
+ y: {
+ delay: 100,
+ duration: 200
+ }
+ });
+
+ const controller2 = chart.getDatasetMeta(1).controller;
+ const def1 = controller2._resolveAnimations(0, 'default', false);
+ animationsExpectations(def1, {
+ x: {
+ delay: 200,
+ duration: 500
+ }
+ });
+ });
});
}); | true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | test/specs/helpers.config.tests.js | @@ -17,7 +17,10 @@ describe('Chart.helpers.config', function() {
expect(resolver.hoverColor).toEqual(defaults.hoverColor);
});
- it('should resolve to parent scopes', function() {
+ it('should resolve to parent scopes, when _fallback is true', function() {
+ const descriptors = {
+ _fallback: true
+ };
const defaults = {
root: true,
sub: {
@@ -28,7 +31,7 @@ describe('Chart.helpers.config', function() {
child: 'sub default comes before this',
opt: 'opt'
};
- const resolver = _createResolver([options, defaults]);
+ const resolver = _createResolver([options, defaults, descriptors]);
const sub = resolver.sub;
expect(sub.root).toEqual(true);
expect(sub.child).toEqual(true);
@@ -125,10 +128,9 @@ describe('Chart.helpers.config', function() {
});
});
- it('should not fallback when _fallback is false', function() {
+ it('should not fallback by default', function() {
const defaults = {
hover: {
- _fallback: false,
a: 'defaults.hover'
},
controllers: {
@@ -252,16 +254,23 @@ describe('Chart.helpers.config', function() {
});
it('should fallback throuhg multiple routes', function() {
+ const descriptors = {
+ _fallback: 'level1',
+ level1: {
+ _fallback: 'root'
+ },
+ level2: {
+ _fallback: 'level1'
+ }
+ };
const defaults = {
root: {
a: 'root'
},
level1: {
- _fallback: 'root',
b: 'level1',
},
level2: {
- _fallback: 'level1',
level1: {
g: 'level2.level1'
},
@@ -277,7 +286,7 @@ describe('Chart.helpers.config', function() {
}
}
};
- const resolver = _createResolver([defaults]);
+ const resolver = _createResolver([defaults, descriptors]);
expect(resolver.level1).toEqualOptions({
a: 'root',
b: 'level1',
@@ -292,7 +301,7 @@ describe('Chart.helpers.config', function() {
expect(resolver.level2.sublevel1).toEqualOptions({
a: 'root',
b: 'level1',
- c: 'level2', // TODO: this should be undefined
+ c: undefined,
d: 'sublevel1',
e: undefined,
f: undefined,
@@ -301,7 +310,7 @@ describe('Chart.helpers.config', function() {
expect(resolver.level2.sublevel2).toEqualOptions({
a: 'root',
b: 'level1',
- c: 'level2', // TODO: this should be undefined
+ c: undefined,
d: undefined,
e: 'sublevel2',
f: undefined,
@@ -310,13 +319,129 @@ describe('Chart.helpers.config', function() {
expect(resolver.level2.sublevel2.level1).toEqualOptions({
a: 'root',
b: 'level1',
- c: 'level2', // TODO: this should be undefined
+ c: undefined,
d: undefined,
- e: 'sublevel2', // TODO: this should be undefined
+ e: undefined,
f: 'sublevel2.level1',
- g: 'level2.level1'
+ g: undefined // same key only included from immediate parents and root
+ });
+ });
+
+ it('should fallback through multiple routes (animations)', function() {
+ const descriptors = {
+ animations: {
+ _fallback: 'animation',
+ },
+ };
+ const defaults = {
+ animation: {
+ duration: 1000,
+ easing: 'easeInQuad'
+ },
+ animations: {
+ colors: {
+ properties: ['color', 'backgroundColor'],
+ type: 'color'
+ },
+ numbers: {
+ properties: ['x', 'y'],
+ type: 'number'
+ }
+ },
+ transitions: {
+ resize: {
+ animation: {
+ duration: 0
+ }
+ },
+ show: {
+ animation: {
+ duration: 400
+ },
+ animations: {
+ colors: {
+ from: 'transparent'
+ }
+ }
+ }
+ }
+ };
+ const options = {
+ animation: {
+ easing: 'linear'
+ },
+ animations: {
+ colors: {
+ properties: ['color', 'borderColor', 'backgroundColor'],
+ },
+ duration: {
+ properties: ['a', 'b'],
+ type: 'boolean'
+ }
+ }
+ };
+
+ const show = _createResolver([options, defaults.transitions.show, defaults, descriptors]);
+ expect(show.animation).toEqualOptions({
+ duration: 400,
+ easing: 'linear'
+ });
+ expect(show.animations.colors._scopes).toEqual([
+ options.animations.colors,
+ defaults.transitions.show.animations.colors,
+ defaults.animations.colors,
+ options.animation,
+ defaults.transitions.show.animation,
+ defaults.animation
+ ]);
+ expect(show.animations.colors).toEqualOptions({
+ duration: 400,
+ from: 'transparent',
+ easing: 'linear',
+ type: 'color',
+ properties: ['color', 'borderColor', 'backgroundColor']
});
+ expect(show.animations.duration).toEqualOptions({
+ duration: 400,
+ easing: 'linear',
+ type: 'boolean',
+ properties: ['a', 'b']
+ });
+ expect(Object.getOwnPropertyNames(show.animations).filter(k => Chart.helpers.isObject(show.animations[k]))).toEqual([
+ 'colors',
+ 'duration',
+ 'numbers',
+ ]);
+ const def = _createResolver([options, defaults, descriptors]);
+ expect(def.animation).toEqualOptions({
+ duration: 1000,
+ easing: 'linear'
+ });
+ expect(def.animations.colors._scopes).toEqual([
+ options.animations.colors,
+ defaults.animations.colors,
+ options.animation,
+ defaults.animation
+ ]);
+ expect(def.animations.colors).toEqualOptions({
+ duration: 1000,
+ easing: 'linear',
+ type: 'color',
+ properties: ['color', 'borderColor', 'backgroundColor']
+ });
+ expect(def.animations.duration).toEqualOptions({
+ duration: 1000,
+ easing: 'linear',
+ type: 'boolean',
+ properties: ['a', 'b']
+ });
+ expect(Object.getOwnPropertyNames(def.animations).filter(k => Chart.helpers.isObject(show.animations[k]))).toEqual([
+ 'colors',
+ 'duration',
+ 'numbers',
+ ]);
});
+
});
});
| true |
Other | chartjs | Chart.js | 5d5e48d01b0aed1279c60c5ea0c97d5328de346e.json | Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name | types/index.esm.d.ts | @@ -1335,12 +1335,9 @@ export interface HoverInteractionOptions extends CoreInteractionOptions {
onHover(event: ChartEvent, elements: ActiveElement[], chart: Chart): void;
}
-export interface CoreChartOptions extends ParsingOptions {
- animation: Scriptable<AnimationOptions | false, ScriptableContext>;
+export interface CoreChartOptions extends ParsingOptions, AnimationOptions {
- datasets: {
- animation: Scriptable<AnimationOptions | false, ScriptableContext>;
- };
+ datasets: AnimationOptions;
/**
* The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
@@ -1460,76 +1457,81 @@ export type EasingFunction =
| 'easeOutBounce'
| 'easeInOutBounce';
-export interface AnimationCommonSpec {
+export type AnimationSpec = {
/**
* The number of milliseconds an animation takes.
* @default 1000
*/
- duration: number;
+ duration: Scriptable<number, ScriptableContext>;
/**
* Easing function to use
* @default 'easeOutQuart'
*/
- easing: EasingFunction;
+ easing: Scriptable<EasingFunction, ScriptableContext>;
/**
* Running animation count + FPS display in upper left corner of the chart.
* @default false
*/
- debug: boolean;
+ debug: Scriptable<boolean, ScriptableContext>;
/**
* Delay before starting the animations.
* @default 0
*/
- delay: number;
+ delay: Scriptable<number, ScriptableContext>;
/**
* If set to true, the animations loop endlessly.
* @default false
*/
- loop: boolean;
+ loop: Scriptable<boolean, ScriptableContext>;
}
-export interface AnimationPropertySpec extends AnimationCommonSpec {
- properties: string[];
+export type AnimationsSpec = {
+ [name: string]: AnimationSpec & {
+ properties: string[];
- /**
- * Type of property, determines the interpolator used. Possible values: 'number', 'color' and 'boolean'. Only really needed for 'color', because typeof does not get that right.
- */
- type: 'color' | 'number' | 'boolean';
+ /**
+ * Type of property, determines the interpolator used. Possible values: 'number', 'color' and 'boolean'. Only really needed for 'color', because typeof does not get that right.
+ */
+ type: 'color' | 'number' | 'boolean';
- fn: <T>(from: T, to: T, factor: number) => T;
+ fn: <T>(from: T, to: T, factor: number) => T;
- /**
- * Start value for the animation. Current value is used when undefined
- */
- from: Color | number | boolean;
- /**
- *
- */
- to: Color | number | boolean;
+ /**
+ * Start value for the animation. Current value is used when undefined
+ */
+ from: Scriptable<Color | number | boolean, ScriptableContext>;
+ /**
+ *
+ */
+ to: Scriptable<Color | number | boolean, ScriptableContext>;
+ } | false
}
-export type AnimationSpecContainer = AnimationCommonSpec & {
- [prop: string]: AnimationPropertySpec | false;
-};
+export type TransitionSpec = {
+ animation: AnimationSpec;
+ animations: AnimationsSpec;
+}
-export type AnimationOptions = AnimationSpecContainer & {
- /**
- * Callback called on each step of an animation.
- */
- onProgress: (this: Chart, event: AnimationEvent) => void;
- /**
- * Callback called when all animations are completed.
- */
- onComplete: (this: Chart, event: AnimationEvent) => void;
+export type TransitionsSpec = {
+ [mode: string]: TransitionSpec
+}
- active: AnimationSpecContainer | false;
- hide: AnimationSpecContainer | false;
- reset: AnimationSpecContainer | false;
- resize: AnimationSpecContainer | false;
- show: AnimationSpecContainer | false;
+export type AnimationOptions = {
+ animation: AnimationSpec & {
+ /**
+ * Callback called on each step of an animation.
+ */
+ onProgress: (this: Chart, event: AnimationEvent) => void;
+ /**
+ * Callback called when all animations are completed.
+ */
+ onComplete: (this: Chart, event: AnimationEvent) => void;
+ };
+ animations: AnimationsSpec;
+ transitions: TransitionsSpec;
};
export interface FontSpec {
@@ -2452,7 +2454,9 @@ export interface TooltipOptions extends CoreInteractionOptions {
*/
textDirection: string;
- animation: Scriptable<AnimationSpecContainer, ScriptableContext>;
+ animation: AnimationSpec;
+
+ animations: AnimationsSpec;
callbacks: TooltipCallbacks;
} | true |
Other | chartjs | Chart.js | 284e357fd371ff6447313cfbb479b92c1d1b2040.json | Fix broken links (#8463) | docs/docs/developers/plugins.md | @@ -118,4 +118,4 @@ var chart = new Chart(ctx, {
## Plugin Core API
-Read more about the [existing plugin extension hooks](../jsdoc/IPlugin.html).
+Read more about the [existing plugin extension hooks](https://github.com/chartjs/Chart.js/blob/master/types/index.esm.d.ts#L733). | true |
Other | chartjs | Chart.js | 284e357fd371ff6447313cfbb479b92c1d1b2040.json | Fix broken links (#8463) | docs/docs/developers/updates.md | @@ -97,7 +97,7 @@ function updateScale(chart) {
}
```
-Code sample for updating options can be found in [toggle-scale-type.html](./../../../samples/latest/scales/toggle-scale-type.html).
+Code sample for updating options can be found in [toggle-scale-type.html](https://www.chartjs.org/samples/latest/scales/toggle-scale-type.html).
## Preventing Animations
| true |
Other | chartjs | Chart.js | 284e357fd371ff6447313cfbb479b92c1d1b2040.json | Fix broken links (#8463) | docs/docs/getting-started/index.mdx | @@ -4,7 +4,7 @@ title: Getting Started
Let's get started using Chart.js!
-First, we need to have a canvas in our page. It's recommended to give the chart its own container for [responsiveness](../general/responsive.md).
+First, we need to have a canvas in our page. It's recommended to give the chart its own container for [responsiveness](../configuration/responsive.md).
```html
<div> | true |
Other | chartjs | Chart.js | ce0f7ff903e42ea39677429644fb4f6cb38b4dda.json | Update polar animation tests to less error prone (#8461) | test/fixtures/controller.polarArea/polar-area-animation-rotate.js | @@ -31,7 +31,7 @@ module.exports = {
animation: {
animateRotate: true,
animateScale: false,
- duration: 800,
+ duration: 8000,
easing: 'linear'
},
responsive: false,
@@ -57,19 +57,29 @@ module.exports = {
},
run: function(chart) {
const animator = Chart.animator;
- const start = animator._getAnims(chart).items[0]._start;
- animator._running = false;
- return new Promise((resolve) => setTimeout(() => {
- for (let i = 0; i < 16; i++) {
- animator._update(start + i * 50);
- let x = i % 4 * 128;
- let y = Math.floor(i / 4) * 128;
- ctx.drawImage(chart.canvas, x, y, 128, 128);
- }
- Chart.helpers.clearCanvas(chart.canvas);
- chart.ctx.drawImage(canvas, 0, 0);
- resolve();
- }, 100));
+ const anims = animator._getAnims(chart);
+ // disable animator
+ const backup = animator._refresh;
+ animator._refresh = function() { };
+
+ return new Promise((resolve) => {
+ window.requestAnimationFrame(() => {
+
+ const start = anims.items[0]._start;
+ for (let i = 0; i < 16; i++) {
+ animator._update(start + i * 500);
+ let x = i % 4 * 128;
+ let y = Math.floor(i / 4) * 128;
+ ctx.drawImage(chart.canvas, x, y, 128, 128);
+ }
+
+ Chart.helpers.clearCanvas(chart.canvas);
+ chart.ctx.drawImage(canvas, 0, 0);
+
+ animator._refresh = backup;
+ resolve();
+ });
+ });
}
}
}; | true |
Other | chartjs | Chart.js | ce0f7ff903e42ea39677429644fb4f6cb38b4dda.json | Update polar animation tests to less error prone (#8461) | test/fixtures/controller.polarArea/polar-area-animation-scale.js | @@ -31,7 +31,7 @@ module.exports = {
animation: {
animateRotate: false,
animateScale: true,
- duration: 800,
+ duration: 8000,
easing: 'linear'
},
responsive: false,
@@ -57,19 +57,28 @@ module.exports = {
},
run: function(chart) {
const animator = Chart.animator;
- const start = animator._getAnims(chart).items[0]._start;
- animator._running = false;
- return new Promise((resolve) => setTimeout(() => {
- for (let i = 0; i < 16; i++) {
- animator._update(start + i * 50);
- let x = i % 4 * 128;
- let y = Math.floor(i / 4) * 128;
- ctx.drawImage(chart.canvas, x, y, 128, 128);
- }
- Chart.helpers.clearCanvas(chart.canvas);
- chart.ctx.drawImage(canvas, 0, 0);
- resolve();
- }, 100));
+ const anims = animator._getAnims(chart);
+ // disable animator
+ const backup = animator._refresh;
+ animator._refresh = function() { };
+
+ return new Promise((resolve) => {
+ window.requestAnimationFrame(() => {
+
+ const start = anims.items[0]._start;
+ for (let i = 0; i < 16; i++) {
+ animator._update(start + i * 500);
+ let x = i % 4 * 128;
+ let y = Math.floor(i / 4) * 128;
+ ctx.drawImage(chart.canvas, x, y, 128, 128);
+ }
+ Chart.helpers.clearCanvas(chart.canvas);
+ chart.ctx.drawImage(canvas, 0, 0);
+
+ animator._refresh = backup;
+ resolve();
+ });
+ });
}
}
}; | true |
Other | chartjs | Chart.js | 0770e8096649b89e17ea02b58ac87d477239234f.json | add clarification about object data structure (#8447)
* add clarification about object data structure
* improved description with feedback
* fix push of wrong file | docs/docs/general/data-structures.md | @@ -32,6 +32,8 @@ data: [{x:'Sales', y:20}, {x:'Revenue', y:10}]
This is also the internal format used for parsed data. In this mode, parsing can be disabled by specifying `parsing: false` at chart options or dataset. If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
+The values provided must be parsable by the associated scales or in the internal format of the associated scales. A common mistake would be to provide integers for the `category` scale, which uses integers as an internal format, where each integer represents an index in the labels array.
+
## Object[] using custom properties
```javascript | false |
Other | chartjs | Chart.js | e8f954249a165718dff56ab9204d1af3e4449da2.json | Update doughnut animation fixture (#8457) | test/fixtures/controller.doughnut/doughnut-animation.js | @@ -29,7 +29,7 @@ module.exports = {
},
options: {
animation: {
- duration: 800,
+ duration: 8000,
easing: 'linear'
},
responsive: false,
@@ -54,19 +54,28 @@ module.exports = {
},
run: function(chart) {
const animator = Chart.animator;
- const start = animator._getAnims(chart).items[0]._start;
- animator._running = false;
- return new Promise((resolve) => setTimeout(() => {
- for (let i = 0; i < 16; i++) {
- animator._update(start + i * 50);
- let x = i % 4 * 128;
- let y = Math.floor(i / 4) * 128;
- ctx.drawImage(chart.canvas, x, y, 128, 128);
- }
- Chart.helpers.clearCanvas(chart.canvas);
- chart.ctx.drawImage(canvas, 0, 0);
- resolve();
- }, 100));
+ const anims = animator._getAnims(chart);
+ // disable animator
+ const backup = animator._refresh;
+ animator._refresh = function() { };
+
+ return new Promise((resolve) => {
+ window.requestAnimationFrame(() => {
+
+ const start = anims.items[0]._start;
+ for (let i = 0; i < 16; i++) {
+ animator._update(start + i * 500);
+ let x = i % 4 * 128;
+ let y = Math.floor(i / 4) * 128;
+ ctx.drawImage(chart.canvas, x, y, 128, 128);
+ }
+ Chart.helpers.clearCanvas(chart.canvas);
+ chart.ctx.drawImage(canvas, 0, 0);
+
+ animator._refresh = backup;
+ resolve();
+ });
+ });
}
}
}; | false |
Other | chartjs | Chart.js | 5411be10a02e09189a3db9feadd277ce9e014003.json | Add support for common object methods to Proxies (#8452) | src/helpers/helpers.config.js | @@ -15,19 +15,46 @@ export function _createResolver(scopes, prefixes = ['']) {
override: (scope) => _createResolver([scope].concat(scopes), prefixes),
};
return new Proxy(cache, {
+ /**
+ * A trap for getting property values.
+ */
get(target, prop) {
return _cached(target, prop,
() => _resolveWithPrefixes(prop, prefixes, scopes));
},
- ownKeys(target) {
- return getKeysFromAllScopes(target);
- },
-
+ /**
+ * A trap for Object.getOwnPropertyDescriptor.
+ * Also used by Object.hasOwnProperty.
+ */
getOwnPropertyDescriptor(target, prop) {
return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);
},
+ /**
+ * A trap for Object.getPrototypeOf.
+ */
+ getPrototypeOf() {
+ return Reflect.getPrototypeOf(scopes[0]);
+ },
+
+ /**
+ * A trap for the in operator.
+ */
+ has(target, prop) {
+ return getKeysFromAllScopes(target).includes(prop);
+ },
+
+ /**
+ * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
+ */
+ ownKeys(target) {
+ return getKeysFromAllScopes(target);
+ },
+
+ /**
+ * A trap for setting property values.
+ */
set(target, prop, value) {
scopes[0][prop] = value;
return delete target[prop];
@@ -54,19 +81,46 @@ export function _attachContext(proxy, context, subProxy) {
override: (scope) => _attachContext(proxy.override(scope), context, subProxy)
};
return new Proxy(cache, {
+ /**
+ * A trap for getting property values.
+ */
get(target, prop, receiver) {
return _cached(target, prop,
() => _resolveWithContext(target, prop, receiver));
},
- ownKeys() {
- return Reflect.ownKeys(proxy);
+ /**
+ * A trap for Object.getOwnPropertyDescriptor.
+ * Also used by Object.hasOwnProperty.
+ */
+ getOwnPropertyDescriptor(target, prop) {
+ return Reflect.getOwnPropertyDescriptor(proxy, prop);
},
- getOwnPropertyDescriptor(target, prop) {
- return Reflect.getOwnPropertyDescriptor(proxy._scopes[0], prop);
+ /**
+ * A trap for Object.getPrototypeOf.
+ */
+ getPrototypeOf() {
+ return Reflect.getPrototypeOf(proxy);
+ },
+
+ /**
+ * A trap for the in operator.
+ */
+ has(target, prop) {
+ return Reflect.has(proxy, prop);
+ },
+
+ /**
+ * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
+ */
+ ownKeys() {
+ return Reflect.ownKeys(proxy);
},
+ /**
+ * A trap for setting property values.
+ */
set(target, prop, value) {
proxy[prop] = value;
return delete target[prop]; | true |
Other | chartjs | Chart.js | 5411be10a02e09189a3db9feadd277ce9e014003.json | Add support for common object methods to Proxies (#8452) | test/specs/helpers.config.tests.js | @@ -88,6 +88,41 @@ describe('Chart.helpers.config', function() {
option3: 'defaults3'
});
});
+
+ it('should support common object methods', function() {
+ const defaults = {
+ option1: 'defaults'
+ };
+ class Options {
+ constructor() {
+ this.option2 = 'options';
+ }
+ get getter() {
+ return 'options getter';
+ }
+ }
+ const options = new Options();
+
+ const resolver = _createResolver([options, defaults]);
+
+ expect(Object.prototype.hasOwnProperty.call(resolver, 'option2')).toBeTrue();
+
+ expect(Object.prototype.hasOwnProperty.call(resolver, 'option1')).toBeFalse();
+ expect(Object.prototype.hasOwnProperty.call(resolver, 'getter')).toBeFalse();
+ expect(Object.prototype.hasOwnProperty.call(resolver, 'nonexistent')).toBeFalse();
+
+ expect(Object.keys(resolver)).toEqual(['option2']);
+ expect(Object.getOwnPropertyNames(resolver)).toEqual(['option2', 'option1']);
+
+ expect('option2' in resolver).toBeTrue();
+ expect('option1' in resolver).toBeTrue();
+ expect('getter' in resolver).toBeFalse();
+ expect('nonexistent' in resolver).toBeFalse();
+
+ expect(resolver instanceof Options).toBeTrue();
+
+ expect(resolver.getter).toEqual('options getter');
+ });
});
describe('_attachContext', function() {
@@ -249,6 +284,41 @@ describe('Chart.helpers.config', function() {
expect(opts.fn).toEqual(1);
});
+ it('should support common object methods', function() {
+ const defaults = {
+ option1: 'defaults'
+ };
+ class Options {
+ constructor() {
+ this.option2 = () => 'options';
+ }
+ get getter() {
+ return 'options getter';
+ }
+ }
+ const options = new Options();
+ const resolver = _createResolver([options, defaults]);
+ const opts = _attachContext(resolver, {index: 1});
+
+ expect(Object.prototype.hasOwnProperty.call(opts, 'option2')).toBeTrue();
+
+ expect(Object.prototype.hasOwnProperty.call(opts, 'option1')).toBeFalse();
+ expect(Object.prototype.hasOwnProperty.call(opts, 'getter')).toBeFalse();
+ expect(Object.prototype.hasOwnProperty.call(opts, 'nonexistent')).toBeFalse();
+
+ expect(Object.keys(opts)).toEqual(['option2']);
+ expect(Object.getOwnPropertyNames(opts)).toEqual(['option2', 'option1']);
+
+ expect('option2' in opts).toBeTrue();
+ expect('option1' in opts).toBeTrue();
+ expect('getter' in opts).toBeFalse();
+ expect('nonexistent' in opts).toBeFalse();
+
+ expect(opts instanceof Options).toBeTrue();
+
+ expect(opts.getter).toEqual('options getter');
+ });
+
describe('_indexable and _scriptable', function() {
it('should default to true', function() {
const options = { | true |
Other | chartjs | Chart.js | d8ecf8bae5cb88f94c9efad26a91a916a3192fa1.json | Fix controller specific animations (#8444) | src/core/core.config.js | @@ -173,7 +173,12 @@ export default class Config {
*/
datasetScopeKeys(datasetType) {
return cachedKeys(datasetType,
- () => [`datasets.${datasetType}`, `controllers.${datasetType}.datasets`, '']);
+ () => [
+ `datasets.${datasetType}`,
+ `controllers.${datasetType}`,
+ `controllers.${datasetType}.datasets`,
+ ''
+ ]);
}
/**
@@ -186,6 +191,7 @@ export default class Config {
return cachedKeys(`${datasetType}.animation`,
() => [
`datasets.${datasetType}.animation`,
+ `controllers.${datasetType}.animation`,
`controllers.${datasetType}.datasets.animation`,
'animation'
]); | false |
Other | chartjs | Chart.js | c96c167074d5c6e1f420d4be03baa484dafda726.json | Update .editorconfig and fix conf indents (#8442) | .editorconfig | @@ -8,3 +8,7 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
+
+[*.html]
+indent_style = tab
+indent_size = 4 | true |
Other | chartjs | Chart.js | c96c167074d5c6e1f420d4be03baa484dafda726.json | Update .editorconfig and fix conf indents (#8442) | docs/docusaurus.config.js | @@ -1,98 +1,97 @@
-/* eslint-disable import/no-commonjs */
// VERSION replaced by deploy script
module.exports = {
- title: 'Chart.js',
- tagline: 'Open source HTML5 Charts for your website',
- url: 'https://chartjs.org',
- baseUrl: '/docs/VERSION/',
- favicon: 'img/favicon.ico',
- organizationName: 'chartjs', // Usually your GitHub org/user name.
- projectName: 'chartjs.github.io', // Usually your repo name.
- scripts: ['https://www.chartjs.org/dist/VERSION/chart.min.js'],
- themes: ['@docusaurus/theme-live-codeblock'],
- onBrokenLinks: 'warn',
- themeConfig: {
- algolia: {
- apiKey: 'd7ee00a3cbaaf3c33e28ad1c274e7ba6',
- indexName: 'chartjs',
- algoliaOptions: {
- facetFilters: ['version:VERSION'],
- }
- },
- googleAnalytics: {
- trackingID: 'UA-28909194-3',
- // Optional fields.
- anonymizeIP: true, // Should IPs be anonymized?
- },
- colorMode: {
- disableSwitch: true, // Would need to implement for Charts embedded in docs
- },
- navbar: {
- title: 'Chart.js',
- logo: {
- alt: 'Chart.js Logo',
- src: 'img/logo.svg',
- },
- },
- footer: {
- style: 'dark',
- links: [
- {
- title: 'Other Docs',
- items: [
- {
- label: 'Samples',
- href: 'https://www.chartjs.org/samples/VERSION/',
- },
- {
- label: 'v2 Docs',
- href: 'https://www.chartjs.org/docs/2.9.4/',
- },
- ],
- },
- {
- title: 'Community',
- items: [
- {
- label: 'Slack',
- href: 'https://chartjs-slack.herokuapp.com/',
- },
- {
- label: 'Stack Overflow',
- href: 'https://stackoverflow.com/questions/tagged/chart.js',
- },
- ],
- },
- {
- title: 'Developers',
- items: [
- {
- label: 'GitHub',
- href: 'https://github.com/chartjs/Chart.js',
- },
- {
- label: 'Contributing',
- to: 'developers/contributing',
- },
- ],
- },
- ],
- copyright: `Copyright © ${new Date().getFullYear()} Chart.js contributors.`,
- },
- },
- presets: [
- [
- '@docusaurus/preset-classic',
- {
- docs: {
- sidebarPath: require.resolve('./sidebars.js'),
- routeBasePath: '/',
- editUrl: 'https://github.com/chartjs/Chart.js/edit/master/docs/',
- },
- theme: {
- customCss: require.resolve('./src/css/custom.css'),
- },
- },
- ],
- ],
+ title: 'Chart.js',
+ tagline: 'Open source HTML5 Charts for your website',
+ url: 'https://chartjs.org',
+ baseUrl: '/docs/VERSION/',
+ favicon: 'img/favicon.ico',
+ organizationName: 'chartjs', // Usually your GitHub org/user name.
+ projectName: 'chartjs.github.io', // Usually your repo name.
+ scripts: ['https://www.chartjs.org/dist/VERSION/chart.min.js'],
+ themes: ['@docusaurus/theme-live-codeblock'],
+ onBrokenLinks: 'warn',
+ themeConfig: {
+ algolia: {
+ apiKey: 'd7ee00a3cbaaf3c33e28ad1c274e7ba6',
+ indexName: 'chartjs',
+ algoliaOptions: {
+ facetFilters: ['version:VERSION'],
+ }
+ },
+ googleAnalytics: {
+ trackingID: 'UA-28909194-3',
+ // Optional fields.
+ anonymizeIP: true, // Should IPs be anonymized?
+ },
+ colorMode: {
+ disableSwitch: true, // Would need to implement for Charts embedded in docs
+ },
+ navbar: {
+ title: 'Chart.js',
+ logo: {
+ alt: 'Chart.js Logo',
+ src: 'img/logo.svg',
+ },
+ },
+ footer: {
+ style: 'dark',
+ links: [
+ {
+ title: 'Other Docs',
+ items: [
+ {
+ label: 'Samples',
+ href: 'https://www.chartjs.org/samples/VERSION/',
+ },
+ {
+ label: 'v2 Docs',
+ href: 'https://www.chartjs.org/docs/2.9.4/',
+ },
+ ],
+ },
+ {
+ title: 'Community',
+ items: [
+ {
+ label: 'Slack',
+ href: 'https://chartjs-slack.herokuapp.com/',
+ },
+ {
+ label: 'Stack Overflow',
+ href: 'https://stackoverflow.com/questions/tagged/chart.js',
+ },
+ ],
+ },
+ {
+ title: 'Developers',
+ items: [
+ {
+ label: 'GitHub',
+ href: 'https://github.com/chartjs/Chart.js',
+ },
+ {
+ label: 'Contributing',
+ to: 'developers/contributing',
+ },
+ ],
+ },
+ ],
+ copyright: `Copyright © ${new Date().getFullYear()} Chart.js contributors.`,
+ },
+ },
+ presets: [
+ [
+ '@docusaurus/preset-classic',
+ {
+ docs: {
+ sidebarPath: require.resolve('./sidebars.js'),
+ routeBasePath: '/',
+ editUrl: 'https://github.com/chartjs/Chart.js/edit/master/docs/',
+ },
+ theme: {
+ customCss: require.resolve('./src/css/custom.css'),
+ },
+ },
+ ],
+ ],
}; | true |
Other | chartjs | Chart.js | c96c167074d5c6e1f420d4be03baa484dafda726.json | Update .editorconfig and fix conf indents (#8442) | docs/sidebars.js | @@ -2,88 +2,88 @@ const pkg = require('../package.json');
const docsVersion = pkg.version.indexOf('-') > -1 ? 'next' : 'latest';
module.exports = {
- someSidebar: {
- Introduction: ['index'],
- 'Getting Started': [
- 'getting-started/index',
- 'getting-started/installation',
- 'getting-started/integration',
- 'getting-started/usage',
- 'getting-started/v3-migration'
- ],
- General: [
- 'general/data-structures',
- 'general/accessibility',
- 'general/responsive',
- 'general/device-pixel-ratio',
- 'general/locale',
- {Interactions: ['general/interactions/index', 'general/interactions/events', 'general/interactions/modes']},
- 'general/options',
- 'general/colors',
- 'general/fonts',
- 'general/performance'
- ],
- Configuration: [
- 'configuration/index',
- 'configuration/animations',
- 'configuration/layout',
- 'configuration/legend',
- 'configuration/title',
- 'configuration/tooltip',
- 'configuration/elements',
- 'configuration/decimation'
- ],
- 'Chart Types': [
- 'charts/line',
- 'charts/bar',
- 'charts/radar',
- 'charts/doughnut',
- 'charts/polar',
- 'charts/bubble',
- 'charts/scatter',
- 'charts/area',
- 'charts/mixed'
- ],
- Axes: [
- 'axes/index',
- {Cartesian: [
- 'axes/cartesian/index',
- 'axes/cartesian/category',
- 'axes/cartesian/linear',
- 'axes/cartesian/logarithmic',
- 'axes/cartesian/time',
- 'axes/cartesian/timeseries'
- ]},
- {Radial: [
- 'axes/radial/index',
- 'axes/radial/linear'
- ]},
- 'axes/labelling',
- 'axes/styling'
- ],
- Developers: [
- 'developers/index',
- 'developers/api',
- {
- type: 'link',
- label: 'TypeDoc',
- href: 'https://chartjs.org/docs/' + docsVersion + '/typedoc/'
- },
- 'developers/updates',
- 'developers/plugins',
- 'developers/charts',
- 'developers/axes',
- 'developers/contributing',
- 'developers/publishing'
- ],
- 'Additional Notes': [
- 'notes/comparison',
- {
- type: 'link',
- label: 'Extensions',
- href: 'https://github.com/chartjs/awesome'
- },
- 'notes/license'
- ]
- },
+ someSidebar: {
+ Introduction: ['index'],
+ 'Getting Started': [
+ 'getting-started/index',
+ 'getting-started/installation',
+ 'getting-started/integration',
+ 'getting-started/usage',
+ 'getting-started/v3-migration'
+ ],
+ General: [
+ 'general/data-structures',
+ 'general/accessibility',
+ 'general/responsive',
+ 'general/device-pixel-ratio',
+ 'general/locale',
+ {Interactions: ['general/interactions/index', 'general/interactions/events', 'general/interactions/modes']},
+ 'general/options',
+ 'general/colors',
+ 'general/fonts',
+ 'general/performance'
+ ],
+ Configuration: [
+ 'configuration/index',
+ 'configuration/animations',
+ 'configuration/layout',
+ 'configuration/legend',
+ 'configuration/title',
+ 'configuration/tooltip',
+ 'configuration/elements',
+ 'configuration/decimation'
+ ],
+ 'Chart Types': [
+ 'charts/line',
+ 'charts/bar',
+ 'charts/radar',
+ 'charts/doughnut',
+ 'charts/polar',
+ 'charts/bubble',
+ 'charts/scatter',
+ 'charts/area',
+ 'charts/mixed'
+ ],
+ Axes: [
+ 'axes/index',
+ {Cartesian: [
+ 'axes/cartesian/index',
+ 'axes/cartesian/category',
+ 'axes/cartesian/linear',
+ 'axes/cartesian/logarithmic',
+ 'axes/cartesian/time',
+ 'axes/cartesian/timeseries'
+ ]},
+ {Radial: [
+ 'axes/radial/index',
+ 'axes/radial/linear'
+ ]},
+ 'axes/labelling',
+ 'axes/styling'
+ ],
+ Developers: [
+ 'developers/index',
+ 'developers/api',
+ {
+ type: 'link',
+ label: 'TypeDoc',
+ href: 'https://chartjs.org/docs/' + docsVersion + '/typedoc/'
+ },
+ 'developers/updates',
+ 'developers/plugins',
+ 'developers/charts',
+ 'developers/axes',
+ 'developers/contributing',
+ 'developers/publishing'
+ ],
+ 'Additional Notes': [
+ 'notes/comparison',
+ {
+ type: 'link',
+ label: 'Extensions',
+ href: 'https://github.com/chartjs/awesome'
+ },
+ 'notes/license'
+ ]
+ },
}; | true |
Other | chartjs | Chart.js | c96c167074d5c6e1f420d4be03baa484dafda726.json | Update .editorconfig and fix conf indents (#8442) | karma.conf.js | @@ -6,118 +6,118 @@ const builds = require('./rollup.config');
const yargs = require('yargs');
module.exports = function(karma) {
- const args = yargs
- .option('verbose', {default: false})
- .argv;
+ const args = yargs
+ .option('verbose', {default: false})
+ .argv;
- const grep = args.grep === true ? '' : args.grep;
- const specPattern = 'test/specs/**/*' + grep + '*.js';
+ const grep = args.grep === true ? '' : args.grep;
+ const specPattern = 'test/specs/**/*' + grep + '*.js';
- // Use the same rollup config as our dist files: when debugging (npm run dev),
- // we will prefer the unminified build which is easier to browse and works
- // better with source mapping. In other cases, pick the minified build to
- // make sure that the minification process (terser) doesn't break anything.
- const regex = karma.autoWatch ? /chart\.js$/ : /chart\.min\.js$/;
- const build = builds.filter(v => v.output.file && v.output.file.match(regex))[0];
+ // Use the same rollup config as our dist files: when debugging (npm run dev),
+ // we will prefer the unminified build which is easier to browse and works
+ // better with source mapping. In other cases, pick the minified build to
+ // make sure that the minification process (terser) doesn't break anything.
+ const regex = karma.autoWatch ? /chart\.js$/ : /chart\.min\.js$/;
+ const build = builds.filter(v => v.output.file && v.output.file.match(regex))[0];
- if (args.coverage) {
- build.plugins = [
- json(),
- resolve(),
- istanbul({exclude: ['node_modules/**/*.js', 'package.json']})
- ];
- }
+ if (args.coverage) {
+ build.plugins = [
+ json(),
+ resolve(),
+ istanbul({exclude: ['node_modules/**/*.js', 'package.json']})
+ ];
+ }
- karma.set({
- frameworks: ['jasmine'],
- reporters: ['progress', 'kjhtml'],
- browsers: (args.browsers || 'chrome,firefox').split(','),
- logLevel: karma.LOG_INFO,
+ karma.set({
+ frameworks: ['jasmine'],
+ reporters: ['progress', 'kjhtml'],
+ browsers: (args.browsers || 'chrome,firefox').split(','),
+ logLevel: karma.LOG_INFO,
- client: {
- jasmine: {
- failFast: !!karma.autoWatch
- }
- },
+ client: {
+ jasmine: {
+ failFast: !!karma.autoWatch
+ }
+ },
- // Explicitly disable hardware acceleration to make image
- // diff more stable when ran on Travis and dev machine.
- // https://github.com/chartjs/Chart.js/pull/5629
- customLaunchers: {
- chrome: {
- base: 'Chrome',
- flags: [
- '--disable-accelerated-2d-canvas',
- '--disable-background-timer-throttling',
- '--disable-backgrounding-occluded-windows',
- '--disable-renderer-backgrounding'
- ]
- },
- firefox: {
- base: 'Firefox',
- prefs: {
- 'layers.acceleration.disabled': true
- }
- },
- safari: {
- base: 'SafariPrivate'
- },
- edge: {
- base: 'Edge'
- }
- },
+ // Explicitly disable hardware acceleration to make image
+ // diff more stable when ran on Travis and dev machine.
+ // https://github.com/chartjs/Chart.js/pull/5629
+ customLaunchers: {
+ chrome: {
+ base: 'Chrome',
+ flags: [
+ '--disable-accelerated-2d-canvas',
+ '--disable-background-timer-throttling',
+ '--disable-backgrounding-occluded-windows',
+ '--disable-renderer-backgrounding'
+ ]
+ },
+ firefox: {
+ base: 'Firefox',
+ prefs: {
+ 'layers.acceleration.disabled': true
+ }
+ },
+ safari: {
+ base: 'SafariPrivate'
+ },
+ edge: {
+ base: 'Edge'
+ }
+ },
- files: [
- {pattern: 'test/fixtures/**/*.js', included: false},
- {pattern: 'test/fixtures/**/*.json', included: false},
- {pattern: 'test/fixtures/**/*.png', included: false},
- 'node_modules/moment/min/moment.min.js',
- {pattern: 'test/index.js', watched: false},
- {pattern: 'test/BasicChartWebWorker.js', included: false},
- {pattern: 'src/index.js', watched: false},
- 'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js',
- {pattern: specPattern}
- ],
+ files: [
+ {pattern: 'test/fixtures/**/*.js', included: false},
+ {pattern: 'test/fixtures/**/*.json', included: false},
+ {pattern: 'test/fixtures/**/*.png', included: false},
+ 'node_modules/moment/min/moment.min.js',
+ {pattern: 'test/index.js', watched: false},
+ {pattern: 'test/BasicChartWebWorker.js', included: false},
+ {pattern: 'src/index.js', watched: false},
+ 'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js',
+ {pattern: specPattern}
+ ],
- preprocessors: {
- 'test/index.js': ['rollup'],
- 'src/index.js': ['sources']
- },
+ preprocessors: {
+ 'test/index.js': ['rollup'],
+ 'src/index.js': ['sources']
+ },
- rollupPreprocessor: {
- plugins: [
- json(),
- resolve(),
- commonjs({exclude: ['src/**', 'test/**']}),
- ],
- output: {
- name: 'test',
- format: 'umd',
- sourcemap: karma.autoWatch ? 'inline' : false
- }
- },
+ rollupPreprocessor: {
+ plugins: [
+ json(),
+ resolve(),
+ commonjs({exclude: ['src/**', 'test/**']}),
+ ],
+ output: {
+ name: 'test',
+ format: 'umd',
+ sourcemap: karma.autoWatch ? 'inline' : false
+ }
+ },
- customPreprocessors: {
- sources: {
- base: 'rollup',
- options: build
- }
- },
+ customPreprocessors: {
+ sources: {
+ base: 'rollup',
+ options: build
+ }
+ },
- // These settings deal with browser disconnects. We had seen test flakiness from Firefox
- // [Firefox 56.0.0 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
- // https://github.com/jasmine/jasmine/issues/1327#issuecomment-332939551
- browserDisconnectTolerance: 3
- });
+ // These settings deal with browser disconnects. We had seen test flakiness from Firefox
+ // [Firefox 56.0.0 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
+ // https://github.com/jasmine/jasmine/issues/1327#issuecomment-332939551
+ browserDisconnectTolerance: 3
+ });
- if (args.coverage) {
- karma.reporters.push('coverage');
- karma.coverageReporter = {
- dir: 'coverage/',
- reporters: [
- {type: 'html', subdir: 'html'},
- {type: 'lcovonly', subdir: (browser) => browser.toLowerCase().split(/[ /-]/)[0]}
- ]
- };
- }
+ if (args.coverage) {
+ karma.reporters.push('coverage');
+ karma.coverageReporter = {
+ dir: 'coverage/',
+ reporters: [
+ {type: 'html', subdir: 'html'},
+ {type: 'lcovonly', subdir: (browser) => browser.toLowerCase().split(/[ /-]/)[0]}
+ ]
+ };
+ }
}; | true |
Other | chartjs | Chart.js | c96c167074d5c6e1f420d4be03baa484dafda726.json | Update .editorconfig and fix conf indents (#8442) | rollup.config.js | @@ -1,6 +1,3 @@
-/* eslint-disable import/no-commonjs */
-/* eslint-env es6 */
-
const cleanup = require('rollup-plugin-cleanup');
const dts = require('rollup-plugin-dts').default;
const json = require('@rollup/plugin-json');
@@ -10,12 +7,12 @@ const pkg = require('./package.json');
const input = 'src/index.js';
const inputESM = {
- 'dist/chart.esm': 'src/index.esm.js',
- 'dist/helpers.esm': 'src/helpers/index.js'
+ 'dist/chart.esm': 'src/index.esm.js',
+ 'dist/helpers.esm': 'src/helpers/index.js'
};
const inputESMTypings = {
- 'dist/chart.esm': 'types/index.esm.d.ts',
- 'dist/helpers.esm': 'types/helpers/index.d.ts'
+ 'dist/chart.esm': 'types/index.esm.d.ts',
+ 'dist/helpers.esm': 'types/helpers/index.d.ts'
};
const banner = `/*!
@@ -26,79 +23,79 @@ const banner = `/*!
*/`;
module.exports = [
- // UMD builds
- // dist/chart.min.js
- // dist/chart.js
- {
- input,
- plugins: [
- json(),
- resolve(),
- cleanup({
- sourcemap: true
- })
- ],
- output: {
- name: 'Chart',
- file: 'dist/chart.js',
- banner,
- format: 'umd',
- indent: false,
- },
- },
- {
- input,
- plugins: [
- json(),
- resolve(),
- terser({
- output: {
- preamble: banner
- }
- })
- ],
- output: {
- name: 'Chart',
- file: 'dist/chart.min.js',
- format: 'umd',
- indent: false,
- },
- },
+ // UMD builds
+ // dist/chart.min.js
+ // dist/chart.js
+ {
+ input,
+ plugins: [
+ json(),
+ resolve(),
+ cleanup({
+ sourcemap: true
+ })
+ ],
+ output: {
+ name: 'Chart',
+ file: 'dist/chart.js',
+ banner,
+ format: 'umd',
+ indent: false,
+ },
+ },
+ {
+ input,
+ plugins: [
+ json(),
+ resolve(),
+ terser({
+ output: {
+ preamble: banner
+ }
+ })
+ ],
+ output: {
+ name: 'Chart',
+ file: 'dist/chart.min.js',
+ format: 'umd',
+ indent: false,
+ },
+ },
- // ES6 builds
- // dist/chart.esm.js
- // helpers/*.js
- {
- input: inputESM,
- plugins: [
- json(),
- resolve(),
- cleanup({
- sourcemap: true
- })
- ],
- output: {
- dir: './',
- chunkFileNames: 'dist/chunks/[name].js',
- banner,
- format: 'esm',
- indent: false,
- },
- },
- // ES6 Typings builds
- // dist/chart.esm.d.ts
- // helpers/*.d.ts
- {
- input: inputESMTypings,
- plugins: [
- dts()
- ],
- output: {
- dir: './',
- chunkFileNames: 'dist/chunks/[name].ts',
- banner,
- format: 'esm',
- indent: false,
- },
- }
+ // ES6 builds
+ // dist/chart.esm.js
+ // helpers/*.js
+ {
+ input: inputESM,
+ plugins: [
+ json(),
+ resolve(),
+ cleanup({
+ sourcemap: true
+ })
+ ],
+ output: {
+ dir: './',
+ chunkFileNames: 'dist/chunks/[name].js',
+ banner,
+ format: 'esm',
+ indent: false,
+ },
+ },
+ // ES6 Typings builds
+ // dist/chart.esm.d.ts
+ // helpers/*.d.ts
+ {
+ input: inputESMTypings,
+ plugins: [
+ dts()
+ ],
+ output: {
+ dir: './',
+ chunkFileNames: 'dist/chunks/[name].ts',
+ banner,
+ format: 'esm',
+ indent: false,
+ },
+ }
]; | true |
Other | chartjs | Chart.js | a73a8c4a5ec83b1fd55fdfbbffcaf0e3b4787025.json | Fix couple of animation bugs (#8439) | src/core/core.animations.js | @@ -5,7 +5,7 @@ import {isObject} from '../helpers/helpers.core';
const numbers = ['x', 'y', 'borderWidth', 'radius', 'tension'];
const colors = ['borderColor', 'backgroundColor'];
-const animationOptions = ['duration', 'easing', 'from', 'to', 'type', 'easing', 'loop', 'fn'];
+const animationOptions = ['delay', 'duration', 'easing', 'fn', 'from', 'loop', 'to', 'type'];
defaults.set('animation', {
// Plain properties can be overridden in each object | true |
Other | chartjs | Chart.js | a73a8c4a5ec83b1fd55fdfbbffcaf0e3b4787025.json | Fix couple of animation bugs (#8439) | src/core/core.config.js | @@ -1,5 +1,5 @@
import defaults from './core.defaults';
-import {mergeIf, resolveObjectKey, isArray, isFunction, valueOrDefault} from '../helpers/helpers.core';
+import {mergeIf, resolveObjectKey, isArray, isFunction, valueOrDefault, isObject} from '../helpers/helpers.core';
import {_attachContext, _createResolver, _descriptors} from '../helpers/helpers.config';
export function getIndexAxis(type, options) {
@@ -301,13 +301,14 @@ export default class Config {
/**
* @param {object[]} scopes
- * @param {function|object} context
+ * @param {object} [context]
+ * @param {string[]} [prefixes]
*/
createResolver(scopes, context, prefixes = ['']) {
- const cached = getResolver(this._resolverCache, scopes, prefixes);
- return context && cached.needContext
- ? _attachContext(cached.resolver, isFunction(context) ? context() : context)
- : cached.resolver;
+ const {resolver} = getResolver(this._resolverCache, scopes, prefixes);
+ return isObject(context)
+ ? _attachContext(resolver, isFunction(context) ? context() : context)
+ : resolver;
}
}
@@ -323,8 +324,7 @@ function getResolver(resolverCache, scopes, prefixes) {
const resolver = _createResolver(scopes, prefixes);
cached = {
resolver,
- subPrefixes: prefixes.filter(p => !p.toLowerCase().includes('hover')),
- needContext: needContext(resolver, Object.getOwnPropertyNames(resolver))
+ subPrefixes: prefixes.filter(p => !p.toLowerCase().includes('hover'))
};
cache.set(cacheKey, cached);
} | true |
Other | chartjs | Chart.js | a73a8c4a5ec83b1fd55fdfbbffcaf0e3b4787025.json | Fix couple of animation bugs (#8439) | src/core/core.datasetController.js | @@ -777,8 +777,7 @@ export default class DatasetController {
const config = me.chart.config;
const scopeKeys = config.datasetAnimationScopeKeys(me._type);
const scopes = config.getOptionScopes(me.getDataset().animation, scopeKeys);
- const context = () => me.getContext(index, active, mode);
- options = config.createResolver(scopes, context);
+ options = config.createResolver(scopes, me.getContext(index, active, mode));
}
const animations = new Animations(chart, options && options[mode] || options);
if (options && options._cacheable) { | true |
Other | chartjs | Chart.js | ca50287a76af74c7f25015f704809f49ca425725.json | Add `initial` property to animation callbacks (#8926) | docs/configuration/animations.md | @@ -252,14 +252,17 @@ The callback is passed the following object:
```javascript
{
- // Chart object
- chart: Chart,
+ // Chart object
+ chart: Chart,
- // Number of animations still in progress
- currentStep: number,
+ // Number of animations still in progress
+ currentStep: number,
- // Total number of animations at the start of current animation
- numSteps: number,
+ // `true` for the initial animation of the chart
+ initial: boolean,
+
+ // Total number of animations at the start of current animation
+ numSteps: number,
}
```
| true |
Other | chartjs | Chart.js | ca50287a76af74c7f25015f704809f49ca425725.json | Add `initial` property to animation callbacks (#8926) | docs/samples/.eslintrc.yml | @@ -0,0 +1,2 @@
+rules:
+ no-console: "off" | true |
Other | chartjs | Chart.js | ca50287a76af74c7f25015f704809f49ca425725.json | Add `initial` property to animation callbacks (#8926) | docs/samples/advanced/progress-bar.md | @@ -1,5 +1,11 @@
# Animation Progress Bar
+## Initial animation
+
+<progress id="initialProgress" max="1" value="0" style="width: 100%"></progress>
+
+## Other animations
+
<progress id="animationProgress" max="1" value="0" style="width: 100%"></progress>
```js chart-editor
@@ -67,6 +73,7 @@ const actions = [
// </block:actions>
// <block:setup:1>
+const initProgress = document.getElementById('initialProgress');
const progress = document.getElementById('animationProgress');
const DATA_COUNT = 7;
@@ -99,11 +106,19 @@ const config = {
options: {
animation: {
duration: 2000,
- onProgress: function(animation) {
- progress.value = animation.currentStep / animation.numSteps;
+ onProgress: function(context) {
+ if (context.initial) {
+ initProgress.value = context.currentStep / context.numSteps;
+ } else {
+ progress.value = context.currentStep / context.numSteps;
+ }
},
- onComplete: function() {
- //
+ onComplete: function(context) {
+ if (context.initial) {
+ console.log('Initial animation finished');
+ } else {
+ console.log('animation finished');
+ }
}
},
interaction: {
@@ -124,5 +139,6 @@ const config = {
module.exports = {
actions: actions,
config: config,
+ output: 'console.log output is displayed here'
};
``` | true |
Other | chartjs | Chart.js | ca50287a76af74c7f25015f704809f49ca425725.json | Add `initial` property to animation callbacks (#8926) | src/core/core.animator.js | @@ -26,6 +26,7 @@ export class Animator {
callbacks.forEach(fn => fn({
chart,
+ initial: anims.initial,
numSteps,
currentStep: Math.min(date - anims.start, numSteps)
}));
@@ -95,6 +96,7 @@ export class Animator {
if (!items.length) {
anims.running = false;
me._notify(chart, anims, date, 'complete');
+ anims.initial = false;
}
remaining += items.length;
@@ -116,6 +118,7 @@ export class Animator {
if (!anims) {
anims = {
running: false,
+ initial: true,
items: [],
listeners: {
complete: [], | true |
Other | chartjs | Chart.js | 9e06f90d14365e7a313acfa57042daf000989853.json | Fix: Initialize data object when replaced (#8918) | src/core/core.config.js | @@ -85,12 +85,16 @@ function initOptions(config) {
options.scales = mergeScaleConfig(config, options);
}
-function initConfig(config) {
- config = config || {};
-
- const data = config.data = config.data || {datasets: [], labels: []};
+function initData(data) {
+ data = data || {};
data.datasets = data.datasets || [];
data.labels = data.labels || [];
+ return data;
+}
+
+function initConfig(config) {
+ config = config || {};
+ config.data = initData(config.data);
initOptions(config);
@@ -137,7 +141,7 @@ export default class Config {
}
set data(data) {
- this._config.data = data;
+ this._config.data = initData(data);
}
get options() { | true |
Other | chartjs | Chart.js | 9e06f90d14365e7a313acfa57042daf000989853.json | Fix: Initialize data object when replaced (#8918) | test/specs/core.controller.tests.js | @@ -230,6 +230,17 @@ describe('Chart', function() {
expect(createChart).toThrow(new Error('"area" is not a registered controller.'));
});
+ it('should initialize the data object', function() {
+ const chart = acquireChart({type: 'bar'});
+ expect(chart.data).toEqual(jasmine.objectContaining({labels: [], datasets: []}));
+ chart.data = {};
+ expect(chart.data).toEqual(jasmine.objectContaining({labels: [], datasets: []}));
+ chart.data = null;
+ expect(chart.data).toEqual(jasmine.objectContaining({labels: [], datasets: []}));
+ chart.data = undefined;
+ expect(chart.data).toEqual(jasmine.objectContaining({labels: [], datasets: []}));
+ });
+
describe('should disable hover', function() {
it('when options.hover=false', function() {
var chart = acquireChart({ | true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/.vuepress/config.js | @@ -113,7 +113,6 @@ module.exports = {
nav: [
{text: 'Home', link: '/'},
{text: 'API', link: '/api/'},
- // TODO: Make local when samples moved to vuepress
{text: 'Samples', link: `/samples/`},
{
text: 'Ecosystem', | true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/axes/cartesian/_common_ticks.md | @@ -5,7 +5,7 @@ Namespace: `options.scales[scaleId].ticks`
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `align` | `string` | `'center'` | The tick alignment along the axis. Can be `'start'`, `'center'`, or `'end'`.
-| `crossAlign` | `string` | `'near'` | The tick alignment perpendicular to the axis. Can be `'near'`, `'center'`, or `'far'`. See [Tick Alignment](./index#tick-alignment)
+| `crossAlign` | `string` | `'near'` | The tick alignment perpendicular to the axis. Can be `'near'`, `'center'`, or `'far'`. See [Tick Alignment](/axes/cartesian/#tick-alignment)
| `sampleSize` | `number` | `ticks.length` | The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length.
| `autoSkip` | `boolean` | `true` | If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to `maxRotation` before skipping any. Turn `autoSkip` off to show all labels no matter what.
| `autoSkipPadding` | `number` | `3` | Padding between the ticks on the horizontal axis when `autoSkip` is enabled. | true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/axes/cartesian/index.md | @@ -2,11 +2,11 @@
Axes that follow a cartesian grid are known as 'Cartesian Axes'. Cartesian axes are used for line, bar, and bubble charts. Four cartesian axes are included in Chart.js by default.
-* [linear](./linear)
-* [logarithmic](./logarithmic)
-* [category](./category)
-* [time](./time)
-* [timeseries](./timeseries)
+* [linear](./linear.md)
+* [logarithmic](./logarithmic.md)
+* [category](./category.md)
+* [time](./time.md)
+* [timeseries](./timeseries.md)
## Visual Components
| true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/axes/index.md | @@ -1,8 +1,8 @@
# Axes
-Axes are an integral part of a chart. They are used to determine how data maps to a pixel value on the chart. In a cartesian chart, there is 1 or more X-axis and 1 or more Y-axis to map points onto the 2-dimensional canvas. These axes are known as ['cartesian axes'](./cartesian/index#cartesian-axes).
+Axes are an integral part of a chart. They are used to determine how data maps to a pixel value on the chart. In a cartesian chart, there is 1 or more X-axis and 1 or more Y-axis to map points onto the 2-dimensional canvas. These axes are known as ['cartesian axes'](./cartesian/).
-In a radial chart, such as a radar chart or a polar area chart, there is a single axis that maps points in the angular and radial directions. These are known as ['radial axes'](./radial/index#radial-axes).
+In a radial chart, such as a radar chart or a polar area chart, there is a single axis that maps points in the angular and radial directions. These are known as ['radial axes'](./radial/).
Scales in Chart.js >v2.0 are significantly more powerful, but also different than those of v1.0.
| true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/configuration/elements.md | @@ -54,16 +54,16 @@ Namespace: `options.elements.line`, global line options: `Chart.defaults.element
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `tension` | `number` | `0` | Bézier curve tension (`0` for no Bézier curves).
-| `backgroundColor` | [`Color`](../general/colors.md) | `Chart.defaults.backgroundColor` | Line fill color.
+| `backgroundColor` | [`Color`](/general/colors.md) | `Chart.defaults.backgroundColor` | Line fill color.
| `borderWidth` | `number` | `3` | Line stroke width.
-| `borderColor` | [`Color`](../general/colors.md) | `Chart.defaults.borderColor` | Line stroke color.
+| `borderColor` | [`Color`](/general/colors.md) | `Chart.defaults.borderColor` | 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.
-| `cubicInterpolationMode` | `string` | `'default'` | Interpolation mode to apply. [See more...](./charts/line.md/#cubicinterpolationmode)
-| `fill` | `boolean`\|`string` | `false` | How to fill the area under the line. See [area charts](../charts/area.md#filling-modes).
+| `cubicInterpolationMode` | `string` | `'default'` | Interpolation mode to apply. [See more...](/charts/line.md/#cubicinterpolationmode)
+| `fill` | `boolean`\|`string` | `false` | How to fill the area under the line. See [area charts](/charts/area.md#filling-modes).
| `stepped` | `boolean` | `false` | `true` to show the line as a stepped line (`tension` will be ignored).
## Bar Configuration
@@ -74,9 +74,9 @@ Namespace: `options.elements.bar`, global bar options: `Chart.defaults.elements.
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
-| `backgroundColor` | [`Color`](../general/colors.md) | `Chart.defaults.backgroundColor` | Bar fill color.
+| `backgroundColor` | [`Color`](/general/colors.md) | `Chart.defaults.backgroundColor` | Bar fill color.
| `borderWidth` | `number` | `0` | Bar stroke width.
-| `borderColor` | [`Color`](../general/colors.md) | `Chart.defaults.borderColor` | Bar stroke color.
+| `borderColor` | [`Color`](/general/colors.md) | `Chart.defaults.borderColor` | Bar stroke color.
| `borderSkipped` | `string` | `'start'` | Skipped (excluded) border: `'start'`, `'end'`, `'bottom'`, `'left'`, `'top'` or `'right'`.
| `borderRadius` | `number`\|`object` | `0` | The bar border radius (in pixels).
| [`pointStyle`](#point-styles) | `string`\|`Image` | `'circle'` | Style of the point for legend.
@@ -90,7 +90,7 @@ Namespace: `options.elements.arc`, global arc options: `Chart.defaults.elements.
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `angle` - for polar only | `number` | `circumference / (arc count)` | Arc angle to cover.
-| `backgroundColor` | [`Color`](../general/colors.md) | `Chart.defaults.backgroundColor` | Arc fill color.
+| `backgroundColor` | [`Color`](/general/colors.md) | `Chart.defaults.backgroundColor` | Arc fill color.
| `borderAlign` | `string` | `'center'` | Arc stroke alignment.
-| `borderColor` | [`Color`](../general/colors.md) | `'#fff'` | Arc stroke color.
+| `borderColor` | [`Color`](/general/colors.md) | `'#fff'` | Arc stroke color.
| `borderWidth`| `number` | `2` | Arc stroke width. | true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/configuration/tooltip.md | @@ -332,7 +332,7 @@ var myPieChart = new Chart(ctx, {
});
```
-See [samples](https://www.chartjs.org/samples/) for examples on how to get started with external tooltips.
+See [samples](/samples/tooltip/html) for examples on how to get started with external tooltips.
## Tooltip Model
| true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/general/padding.md | @@ -45,7 +45,7 @@ let chart = new Chart(ctx, {
This is a shorthand for defining left/right and top/bottom to same values.
-For example, 10px left / right and 4px top / bottom padding on a Radial Linear Axis [tick backdropPadding](../axes/radial/linear#tick-configuration):
+For example, 10px left / right and 4px top / bottom padding on a Radial Linear Axis [tick backdropPadding](/axes/radial/linear.html#linear-radial-axis-specific-tick-options):
```javascript
let chart = new Chart(ctx, { | true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/general/performance.md | @@ -16,19 +16,19 @@ Chart.js is fastest if you provide data with indices that are unique, sorted, an
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.
-The [decimation plugin](./configuration/decimation.md) can be used with line charts to decimate data before the chart is rendered. This will provide the best performance since it will reduce the memory needed to render the chart.
+The [decimation plugin](/configuration/decimation.md) can be used with line charts to decimate data before the chart is rendered. This will provide the best performance since it will reduce the memory needed to render the chart.
Line charts are able to do [automatic data decimation during draw](#automatic-data-decimation-during-draw), when certain conditions are met. You should still consider decimating data yourself before passing it in for maximum performance since the automatic decimation occurs late in the chart life cycle.
## Tick Calculation
### Rotation
-[Specify a rotation value](./axes/cartesian/index.md#tick-configuration) by setting `minRotation` and `maxRotation` to the same value, which avoids the chart from having to automatically determine a value to use.
+[Specify a rotation value](/axes/cartesian/index.md#tick-configuration) by setting `minRotation` and `maxRotation` to the same value, which avoids the chart from having to automatically determine a value to use.
### Sampling
-Set the [`ticks.sampleSize`](./axes/cartesian/index.md#tick-configuration) option. This will determine how large your labels are by looking at only a subset of them in order to render axes more quickly. This works best if there is not a large variance in the size of your labels.
+Set the [`ticks.sampleSize`](/axes/cartesian/index.md#tick-configuration) option. This will determine how large your labels are by looking at only a subset of them in order to render axes more quickly. This works best if there is not a large variance in the size of your labels.
## Disable Animations
| true |
Other | chartjs | Chart.js | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/getting-started/index.md | @@ -55,10 +55,10 @@ module.exports = {
Finally, render the chart using our configuration:
-```html
+```html
<script>
// === include 'setup' then 'config' above ===
-
+
var myChart = new Chart(
document.getElementById('myChart'),
config
@@ -68,4 +68,4 @@ Finally, render the chart using our configuration:
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.
-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.
+All our examples are [available online](/samples/) 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 | d5f4a82e74dfe8be63a5d56f0d7d08c52b824a17.json | Fix minor issues in docs (#8910) | docs/getting-started/v3-migration.md | @@ -63,8 +63,8 @@ A number of changes were made to the configuration options passed to the `Chart`
* The input properties of object data can now be freely specified, see [data structures](../general/data-structures.md) for details.
* Most options are resolved utilizing proxies, instead of merging with defaults. In addition to easily enabling different resolution routes for different contexts, it allows using other resolved options in scriptable options.
* Options are by default scriptable and indexable, unless disabled for some reason.
- * Scriptable options receive a option reolver as second parameter for accessing other options in same context.
- * Resolution falls to upper scopes, if no match is found earlier. See [options](./general/options.md) for details.
+ * Scriptable options receive a option resolver as second parameter for accessing other options in same context.
+ * Resolution falls to upper scopes, if no match is found earlier. See [options](../general/options.md) for details.
#### Specific changes
| true |
Other | chartjs | Chart.js | aee45c611ed43cd7040b1942b54a21088eb5c055.json | Fix tooltip positioners and scriptable signature (#8909) | types/index.esm.d.ts | @@ -31,7 +31,7 @@ export interface ScriptableLineSegmentContext {
p1: PointElement
}
-export type Scriptable<T, TContext> = T | ((ctx: TContext) => T);
+export type Scriptable<T, TContext> = T | ((ctx: TContext, options: AnyObject) => T);
export type ScriptableOptions<T, TContext> = { [P in keyof T]: Scriptable<T[P], TContext> };
export type ScriptableAndArray<T, TContext> = readonly T[] | Scriptable<T, TContext>;
export type ScriptableAndArrayOptions<T, TContext> = { [P in keyof T]: ScriptableAndArray<T[P], TContext> };
@@ -2331,7 +2331,7 @@ export interface TooltipModel<TType extends ChartType> {
export const Tooltip: Plugin & {
readonly positioners: {
- [key: string]: (items: readonly Element[], eventPosition: { x: number; y: number }) => { x: number; y: number } | false;
+ [key: string]: (items: readonly ActiveElement[], eventPosition: { x: number; y: number }) => { x: number; y: number } | false;
};
getActiveElements(): ActiveElement[]; | false |
Other | chartjs | Chart.js | 0ae0fd4b2a659f1ac3fde4ffd46608c3f747ca22.json | Limit onHover to chartArea (#8794) | docs/configuration/interactions.md | @@ -18,8 +18,8 @@ Namespace: `options`
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `events` | `string[]` | `['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']` | The `events` option defines the browser events that the chart should listen to for. Each of these events trigger hover and are passed to plugins. [more...](#event-option)
-| `onHover` | `function` | `null` | Called when any of the events fire. Passed the event, an array of active elements (bars, points, etc), and the chart.
-| `onClick` | `function` | `null` | Called if the event is of type `'mouseup'` or `'click'`. Passed the event, an array of active elements, and the chart.
+| `onHover` | `function` | `null` | Called when any of the events fire over chartArea. Passed the event, an array of active elements (bars, points, etc), and the chart.
+| `onClick` | `function` | `null` | Called if the event is of type `'mouseup'`, `'click'` or '`'contextmenu'` over chartArea. Passed the event, an array of active elements, and the chart.
### Event Option
| true |
Other | chartjs | Chart.js | 0ae0fd4b2a659f1ac3fde4ffd46608c3f747ca22.json | Limit onHover to chartArea (#8794) | src/core/core.controller.js | @@ -1108,11 +1108,11 @@ class Chart {
// This prevents recursion if the handler calls chart.update()
me._lastEvent = null;
- // Invoke onHover hook
- callCallback(options.onHover, [e, active, me], me);
+ if (_isPointInArea(e, me.chartArea, me._minPadding)) {
+ // Invoke onHover hook
+ callCallback(options.onHover, [e, active, me], me);
- if (e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu') {
- if (_isPointInArea(e, me.chartArea, me._minPadding)) {
+ if (e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu') {
callCallback(options.onClick, [e, active, me], me);
}
} | true |
Other | chartjs | Chart.js | 05ba2eedffecfd5631d59b21648bdf160869c449.json | Add version menu in documentation (#8866)
* Add version menu in documentation
* Use filters for tags
* Use limit
* Update
* Use released plugin
* use published version | docs/.vuepress/config.js | @@ -41,6 +41,43 @@ module.exports = {
},
},
],
+ ['@simonbrunel/vuepress-plugin-versions', {
+ filters: {
+ suffix: (v) => v ? ` (${v})` : ''
+ },
+ menu: {
+ items: [
+ {
+ text: 'Documentation',
+ items: [
+ {
+ text: 'Development (master)',
+ link: '/docs/master/',
+ },
+ {
+ type: 'versions',
+ text: '{{version}}{{tag|suffix}}',
+ link: '/docs/{{version}}/',
+ exclude: /^[01]\.|2\.[0-5]\./,
+ group: 'minor',
+ }
+ ]
+ },
+ {
+ text: 'Release notes (5 latest)',
+ items: [
+ {
+ type: 'versions',
+ limit: 5,
+ target: '_blank',
+ group: 'patch',
+ link: 'https://github.com/chartjs/Chart.js/releases/tag/v{{version}}'
+ }
+ ]
+ }
+ ]
+ },
+ }],
],
chainWebpack(config) {
config.merge({ | true |
Other | chartjs | Chart.js | 05ba2eedffecfd5631d59b21648bdf160869c449.json | Add version menu in documentation (#8866)
* Add version menu in documentation
* Use filters for tags
* Use limit
* Update
* Use released plugin
* use published version | package-lock.json | @@ -2944,6 +2944,17 @@
}
}
},
+ "@simonbrunel/vuepress-plugin-versions": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/@simonbrunel/vuepress-plugin-versions/-/vuepress-plugin-versions-0.1.0.tgz",
+ "integrity": "sha512-C1J3u9060+hNY/DTz4Ksos/ksDBt2wc83OoWJw3VmyFNiOPr6ot/pGLw92W9E4ylXzlSsvIvWdVM5s3N8yOASA==",
+ "dev": true,
+ "requires": {
+ "node-fetch": "^2.6.1",
+ "semiver": "^1.1.0",
+ "stringify-object": "^3.3.0"
+ }
+ },
"@sindresorhus/is": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
@@ -10869,6 +10880,12 @@
"lower-case": "^1.1.1"
}
},
+ "node-fetch": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
+ "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
+ "dev": true
+ },
"node-forge": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",
@@ -13215,6 +13232,12 @@
"node-forge": "^0.10.0"
}
},
+ "semiver": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz",
+ "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==",
+ "dev": true
+ },
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
@@ -14098,6 +14121,31 @@
"safe-buffer": "~5.1.0"
}
},
+ "stringify-object": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz",
+ "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==",
+ "dev": true,
+ "requires": {
+ "get-own-enumerable-property-symbols": "^3.0.0",
+ "is-obj": "^1.0.1",
+ "is-regexp": "^1.0.0"
+ },
+ "dependencies": {
+ "is-obj": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
+ "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
+ "dev": true
+ },
+ "is-regexp": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz",
+ "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=",
+ "dev": true
+ }
+ }
+ },
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", | true |
Other | chartjs | Chart.js | 05ba2eedffecfd5631d59b21648bdf160869c449.json | Add version menu in documentation (#8866)
* Add version menu in documentation
* Use filters for tags
* Use limit
* Update
* Use released plugin
* use published version | package.json | @@ -54,6 +54,7 @@
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.1",
+ "@simonbrunel/vuepress-plugin-versions": "^0.1.0",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"@vuepress/plugin-google-analytics": "1.8.2", | true |
Other | chartjs | Chart.js | 82d42bd799f5c47f1d69299db29039d97cb49329.json | Fix typos in canvas-background.md (#8837) | docs/configuration/canvas-background.md | @@ -1,8 +1,8 @@
# Canvas background
-In some use cases you would want a background image or color over the whole canvas. There is no build in support for this, the way you can achieve this is by writing a custom plugin.
+In some use cases you would want a background image or color over the whole canvas. There is no built-in support for this, the way you can achieve this is by writing a custom plugin.
-In the two example plugins underneath here you can see how you can draw an color or image to the canvas as background. This way of giving the chart a background is only necessary if you want to export the chart with that specific background.
+In the two example plugins underneath here you can see how you can draw a color or image to the canvas as background. This way of giving the chart a background is only necessary if you want to export the chart with that specific background.
For normal use you can set the background more easily with [CSS](https://www.w3schools.com/cssref/css3_pr_background.asp).
:::: tabs | false |
Other | chartjs | Chart.js | 873223fc784bd761fb9b18159b7c99856003e7d7.json | Fix typo in migration guide (#8836) | docs/getting-started/v3-migration.md | @@ -61,7 +61,7 @@ A number of changes were made to the configuration options passed to the `Chart`
* Indexable options are now looping. `backgroundColor: ['red', 'green']` will result in alternating `'red'` / `'green'` if there are more than 2 data points.
* The input properties of object data can now be freely specified, see [data structures](../general/data-structures.md) for details.
-* Most options are resolved utilizing proxies, instead merging with defaults. In addition to easily enabling different resolution routes for different contexts, it allows using other resolved options in scriptable options.
+* Most options are resolved utilizing proxies, instead of merging with defaults. In addition to easily enabling different resolution routes for different contexts, it allows using other resolved options in scriptable options.
* Options are by default scriptable and indexable, unless disabled for some reason.
* Scriptable options receive a option reolver as second parameter for accessing other options in same context.
* Resolution falls to upper scopes, if no match is found earlier. See [options](./general/options.md) for details. | false |
Other | chartjs | Chart.js | 7d08bab45d57060af5ca84b464b2281da22c8938.json | Time: Use callback helper on ticks.callback (#8822) | src/scales/scale.time.js | @@ -1,5 +1,5 @@
import adapters from '../core/core.adapters';
-import {isFinite, isNullOrUndef, mergeIf, valueOrDefault} from '../helpers/helpers.core';
+import {callback as call, isFinite, isNullOrUndef, mergeIf, valueOrDefault} from '../helpers/helpers.core';
import {toRadians, isNumber, _limitValue} from '../helpers/helpers.math';
import Scale from '../core/core.scale';
import {_arrayUnique, _filterBetween, _lookup} from '../helpers/helpers.collection';
@@ -468,7 +468,7 @@ export default class TimeScale extends Scale {
const major = majorUnit && majorFormat && tick && tick.major;
const label = me._adapter.format(time, format || (major ? majorFormat : minorFormat));
const formatter = options.ticks.callback;
- return formatter ? formatter(label, index, ticks) : label;
+ return formatter ? call(formatter, [label, index, ticks], me) : label;
}
/** | false |
Other | chartjs | Chart.js | da9d12ee45821389d0b5e10a5f5e05391f3ae87e.json | Fix utils.sh location (#8819) | scripts/deploy-docs.sh | @@ -2,7 +2,7 @@
set -e
-source utils.sh
+source ./scripts/utils.sh
TARGET_DIR='gh-pages'
TARGET_BRANCH='master' | true |
Other | chartjs | Chart.js | da9d12ee45821389d0b5e10a5f5e05391f3ae87e.json | Fix utils.sh location (#8819) | scripts/docs-config.sh | @@ -2,7 +2,7 @@
set -e
-source utils.sh
+source ./scripts/utils.sh
VERSION=$1
MODE=$2 | true |
Other | chartjs | Chart.js | 77cdadb1dcb8296e43751ed2d1ea999d26ba3149.json | Update codepen url in bug template (#8816) | .github/ISSUE_TEMPLATE/BUG.md | @@ -9,7 +9,7 @@ labels: 'type: bug'
Head to https://stackoverflow.com/questions/tagged/chart.js
Bug reports MUST be submitted with an interactive example:
- https://codepen.io/pen?template=JXVYzq
+ https://codepen.io/pen?template=BapRepQ
Chart.js versions lower then 3.x are NOT supported anymore, new issues will be disregarded.
-->
@@ -29,7 +29,7 @@ labels: 'type: bug'
## Steps to Reproduce
<!--
Provide a link to a live example. Bug reports MUST be submitted with an
- interactive example (https://codepen.io/pen?template=JXVYzq).
+ interactive example (https://codepen.io/pen/?template=BapRepQ).
If filing a bug against `master`, you may reference the latest code via
https://www.chartjs.org/dist/master/chart.min.js (changing the filename to | false |
Other | chartjs | Chart.js | 33df3a6d73b97a342221ab239aad71bc75f189cc.json | Update chart type documentation (#8805)
* Update chart type documentation
* Self-review | docs/charts/bar.md | @@ -53,52 +53,77 @@ module.exports = {
};
```
-## Example Usage
+## Dataset Properties
-```javascript
-var myBarChart = new Chart(ctx, {
- type: 'bar',
- data: data,
- options: options
-});
-```
+Namespaces:
-## Dataset Properties
+* `data.datasets[index]` - options for this dataset only
+* `options.datasets.bar` - options for all bar datasets
+* `options.elements.bar` - options for all [bar elements](../configuration/elements.md#bar-configuration)
+* `options` - options for the whole chart
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.
+Only the `data` option needs to be specified in the dataset namespace.
| 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)'`
| [`base`](#general) | `number` | Yes | Yes |
+| [`barPercentage`](#barpercentage) | `number` | - | - | `0.9` |
+| [`barThickness`](#barthickness) | `number`\|`string` | - | - | |
| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0, 0, 0, 0.1)'`
| [`borderSkipped`](#borderskipped) | `string` | Yes | Yes | `'start'`
| [`borderWidth`](#borderwidth) | `number`\|`object` | Yes | Yes | `0`
| [`borderRadius`](#borderradius) | `number`\|`object` | Yes | Yes | `0`
-| [`clip`](#general) | `number`\|`object` | - | - | `undefined`
-| [`data`](#data-structure) | `object`\|`object[]`\|`number[]`\|`string[]` | - | - | **required**
-| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
-| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
+| [`categoryPercentage`](#categorypercentage) | `number` | - | - | `0.8` |
+| [`clip`](#general) | `number`\|`object` | - | - |
+| [`data`](#data-structure) | `object`\|`object[]`\| `number[]`\|`string[]` | - | - | **required**
+| [`grouped`](#general) | `boolean` | - | - | `true` |
+| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes |
+| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes |
| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `1`
| [`hoverBorderRadius`](#interactions) | `number` | Yes | Yes | `0`
| [`indexAxis`](#general) | `string` | - | - | `'x'`
+| [`maxBarThickness`](#maxbarthickness) | `number` | - | - | |
+| [`minBarLength`](#styling) | `number` | - | - | |
| [`label`](#general) | `string` | - | - | `''`
| [`order`](#general) | `number` | - | - | `0`
| [`pointStyle`](../configuration/elements.md#point-styles) | `string`\|`Image` | Yes | - | `'circle'`
+| [`skipNull`](#general) | `boolean` | - | - | |
+| [`stack`](#general) | `string` | - | - | `'bar'` |
| [`xAxisID`](#general) | `string` | - | - | first x axis
| [`yAxisID`](#general) | `string` | - | - | first y axis
+All these values, if `undefined`, fallback to the scopes described in [option resolution](../general/options)
+
+### Example dataset configuration
+
+```javascript
+data: {
+ datasets: [{
+ barPercentage: 0.5,
+ barThickness: 6,
+ maxBarThickness: 8,
+ minBarLength: 2,
+ data: [10, 20, 30, 40, 50, 60, 70]
+ }]
+};
+```
+
### General
| Name | Description
| ---- | ----
| `base` | Base value for the bar in data units along the value axis. If not set, defaults to the value axis base value.
| `clip` | How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. `0` = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
+| `grouped` | Should the bars be grouped on index axis. When `true`, all the datasets at same index value will be placed next to each other centering on that index value. When `false`, each bar is placed on its actual index-axis value.
| `indexAxis` | The base axis of the dataset. `'x'` for vertical bars and `'y'` for horizontal bars.
| `label` | The label for the dataset which appears in the legend and tooltips.
| `order` | The drawing order of dataset. Also affects order for stacking, tooltip, and legend.
+| `skipNull` | If `true`, null or undefined values will not be used for spacing calculations when determining bar size.
+| `stack` | The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack). [more](#stacked-bar-charts)
| `xAxisID` | The ID of the x-axis to plot this dataset on.
| `yAxisID` | The ID of the y-axis to plot this dataset on.
@@ -113,6 +138,7 @@ The style of each bar can be controlled with the following properties:
| [`borderSkipped`](#borderskipped) | The edge to skip when drawing bar.
| [`borderWidth`](#borderwidth) | The bar border width (in pixels).
| [`borderRadius`](#borderradius) | The bar border radius (in pixels).
+| `minBarLength` | Set this to ensure that bars have a minimum length in pixels.
| `pointStyle` | Style of the point for legend. [more...](../configuration/elements.md#point-styles)
All these values, if `undefined`, fallback to the associated [`elements.bar.*`](../configuration/elements.md#bar-configuration) options.
@@ -158,33 +184,13 @@ The interaction with each bar can be controlled with the following properties:
All these values, if `undefined`, fallback to the associated [`elements.bar.*`](../configuration/elements.md#bar-configuration) options.
-## Dataset Configuration
+### barPercentage
-The bar chart accepts the following configuration from the associated dataset options:
+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)
-| 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)
-| `base` | `number` | | Base value for the bar in data units along the value axis. If not set, defaults to the value axis base value.
-| `grouped` | `boolean` | `true` | Should the bars be grouped on index axis. When `true`, all the datasets at same index value will be placed next to each other centering on that index value. When `false`, each bar is placed on its actual index-axis value.
-| `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.
+### categoryPercentage
-### Example dataset configuration
-
-```javascript
-data: {
- datasets: [{
- barPercentage: 0.5,
- barThickness: 6,
- maxBarThickness: 8,
- minBarLength: 2,
- data: [10, 20, 30, 40, 50, 60, 70]
- }]
-};
-```
+Percent (0-1) of the available width each category should be within the sample width. [more...](#barpercentage-vs-categorypercentage)
### barThickness
@@ -194,13 +200,9 @@ If set to `'flex'`, the base sample widths are calculated automatically based on
If not set (default), the base sample widths are calculated using the smallest interval that prevents bar overlapping, and bars are sized using `barPercentage` and `categoryPercentage`. This mode always generates bars equally sized.
-## Config Options
+### maxBarThickness
-These are the customisation options specific to Bar charts. These options are looked up on access, and form together with the global chart configuration, `Chart.defaults`, the options of the chart.
-
-| Name | Type | Default | Description
-| ---- | ---- | ------- | -----------
-| `skipNull` | `boolean` | `undefined` | If `true`, null or undefined values will not be drawn
+Set this to ensure that bars are not sized thicker than this.
## Scale Configuration
@@ -282,12 +284,6 @@ var stackedBar = new Chart(ctx, {
});
```
-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). Defaults to `bar`.
-
## 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 | 33df3a6d73b97a342221ab239aad71bc75f189cc.json | Update chart type documentation (#8805)
* Update chart type documentation
* Self-review | docs/charts/bubble.md | @@ -25,6 +25,7 @@ const data = {
const config = {
type: 'bubble',
data: data,
+ options: {}
};
// </block:config>
@@ -34,18 +35,14 @@ module.exports = {
};
```
-## Example Usage
+## Dataset Properties
-```javascript
-// For a bubble chart
-var myBubbleChart = new Chart(ctx, {
- type: 'bubble',
- data: data,
- options: options
-});
-```
+Namespaces:
-## Dataset Properties
+* `data.datasets[index]` - options for this dataset only
+* `options.datasets.bubble` - options for all bubble datasets
+* `options.elements.point` - options for all [point elements](../configuration/elements.md#point-configuration)
+* `options` - options for the whole chart
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.
@@ -67,6 +64,8 @@ The bubble chart allows a number of properties to be specified for each dataset.
| [`rotation`](#styling) | `number` | Yes | Yes | `0`
| [`radius`](#styling) | `number` | Yes | Yes | `3`
+All these values, if `undefined`, fallback to the scopes described in [option resolution](../general/options)
+
### General
| Name | Description | true |
Other | chartjs | Chart.js | 33df3a6d73b97a342221ab239aad71bc75f189cc.json | Update chart type documentation (#8805)
* Update chart type documentation
* Self-review | docs/charts/doughnut.md | @@ -90,6 +90,14 @@ module.exports = {
## Dataset Properties
+Namespaces:
+
+* `data.datasets[index]` - options for this dataset only
+* `options.datasets.doughnut` - options for all doughnut datasets
+* `options.datasets.pie` - options for all pie datasets
+* `options.elements.arc` - options for all [arc elements](../configuration/elements.md#arc-configuration)
+* `options` - options for the whole chart
+
The doughnut/pie chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colours of the dataset's arcs are generally set this way.
| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
@@ -110,6 +118,8 @@ The doughnut/pie chart allows a number of properties to be specified for each da
| [`rotation`](#general) | `number` | - | - | `undefined`
| [`weight`](#styling) | `number` | - | - | `1`
+All these values, if `undefined`, fallback to the scopes described in [option resolution](../general/options)
+
### General
| Name | Description | true |
Other | chartjs | Chart.js | 33df3a6d73b97a342221ab239aad71bc75f189cc.json | Update chart type documentation (#8805)
* Update chart type documentation
* Self-review | docs/charts/line.md | @@ -30,17 +30,15 @@ module.exports = {
};
```
-## Example Usage
+## Dataset Properties
-```javascript
-var myLineChart = new Chart(ctx, {
- type: 'line',
- data: data,
- options: options
-});
-```
+Namespaces:
-## Dataset Properties
+* `data.datasets[index]` - options for this dataset only
+* `options.datasets.line` - options for all line datasets
+* `options.elements.line` - options for all [line elements](../configuration/elements.md#line-configuration)
+* `options.elements.point` - options for all [point elements](../configuration/elements.md#point-configuration)
+* `options` - options for the whole chart
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.
@@ -54,7 +52,7 @@ The line chart allows a number of properties to be specified for each dataset. T
| [`borderJoinStyle`](#line-styling) | `string` | Yes | - | `'miter'`
| [`borderWidth`](#line-styling) | `number` | Yes | - | `3`
| [`clip`](#general) | `number`\|`object` | - | - | `undefined`
-| [`data`](#data-structure) | `object`\|`object[]`\|`number[]`\|`string[]` | - | - | **required**
+| [`data`](#data-structure) | `object`\|`object[]`\| `number[]`\|`string[]` | - | - | **required**
| [`cubicInterpolationMode`](#cubicinterpolationmode) | `string` | Yes | - | `'default'`
| [`fill`](#line-styling) | `boolean`\|`string` | Yes | - | `false`
| [`hoverBackgroundColor`](#line-styling) | [`Color`](../general/colors.md) | Yes | - | `undefined`
@@ -81,10 +79,13 @@ The line chart allows a number of properties to be specified for each dataset. T
| [`pointStyle`](#point-styling) | `string`\|`Image` | Yes | Yes | `'circle'`
| [`showLine`](#line-styling) | `boolean` | - | - | `true`
| [`spanGaps`](#line-styling) | `boolean`\|`number` | - | - | `undefined`
+| [`stack`](#general) | `string` | - | - | `'line'` |
| [`stepped`](#stepped) | `boolean`\|`string` | - | - | `false`
| [`xAxisID`](#general) | `string` | - | - | first x axis
| [`yAxisID`](#general) | `string` | - | - | first y axis
+All these values, if `undefined`, fallback to the scopes described in [option resolution](../general/options)
+
### General
| Name | Description
@@ -93,6 +94,7 @@ The line chart allows a number of properties to be specified for each dataset. T
| `indexAxis` | The base axis of the dataset. `'x'` for horizontal lines and `'y'` for vertical lines.
| `label` | The label for the dataset which appears in the legend and tooltips.
| `order` | The drawing order of dataset. Also affects order for stacking, tooltip, and legend.
+| `stack` | The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack). [more](#stacked-area-charts)
| `xAxisID` | The ID of the x-axis to plot this dataset on.
| `yAxisID` | The ID of the y-axis to plot this dataset on.
@@ -168,15 +170,6 @@ The following values are supported for `stepped`.
If the `stepped` value is set to anything other than false, `tension` will be ignored.
-## Configuration Options
-
-The line chart defines the following configuration options. These options are looked up on access, and form together with the global chart configuration, `Chart.defaults`, the options of the chart.
-
-| Name | Type | Default | Description
-| ---- | ---- | ------- | -----------
-| `showLine` | `boolean` | `true` | If false, the lines between points are not drawn.
-| `spanGaps` | `boolean`\|`number` | `false` | If true, lines will be drawn between points with no or null data. If false, points with `null` data will create a break in the line. Can also be a number specifying the maximum gap length to span. The unit of the value depends on the scale used.
-
## Default Options
It is common to want to apply a configuration setting to all created line charts. The global line chart settings are stored in `Chart.overrides.line`. Changing the global options only affects charts created after the change. Existing charts are not changed.
@@ -269,18 +262,6 @@ module.exports = {
};
```
-## Example
-
-```javascript
-var myLineChart = new Chart(ctx, {
- type: 'line',
- data: data,
- options: {
- indexAxis: 'y'
- }
-});
-```
-
### Config Options
The configuration options for the vertical line chart are the same as for the [line chart](#configuration-options). However, any options specified on the x-axis in a line chart, are applied to the y-axis in a vertical line chart. | true |
Other | chartjs | Chart.js | 33df3a6d73b97a342221ab239aad71bc75f189cc.json | Update chart type documentation (#8805)
* Update chart type documentation
* Self-review | docs/charts/polar.md | @@ -32,6 +32,7 @@ const data = {
const config = {
type: 'polarArea',
data: data,
+ options: {}
};
// </block:config>
@@ -41,17 +42,14 @@ module.exports = {
};
```
-## Example Usage
+## Dataset Properties
-```javascript
-new Chart(ctx, {
- data: data,
- type: 'polarArea',
- options: options
-});
-```
+Namespaces:
-## Dataset Properties
+* `data.datasets[index]` - options for this dataset only
+* `options.datasets.polarArea` - options for all polarArea datasets
+* `options.elements.arc` - options for all [arc elements](../configuration/elements.md#arc-configuration)
+* `options` - options for the whole chart
The following options can be included in a polar area chart dataset to configure options for that specific dataset.
@@ -67,6 +65,8 @@ The following options can be included in a polar area chart dataset to configure
| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | Yes | Yes | `undefined`
| [`hoverBorderWidth`](#interactions) | `number` | Yes | Yes | `undefined`
+All these values, if `undefined`, fallback to the scopes described in [option resolution](../general/options)
+
### General
| Name | Description | true |
Other | chartjs | Chart.js | 33df3a6d73b97a342221ab239aad71bc75f189cc.json | Update chart type documentation (#8805)
* Update chart type documentation
* Self-review | docs/charts/radar.md | @@ -60,19 +60,15 @@ module.exports = {
};
```
-<ExampleChart/>
+## Dataset Properties
-## Example Usage
+Namespaces:
-```javascript
-var myRadarChart = new Chart(ctx, {
- type: 'radar',
- data: data,
- options: options
-});
-```
-
-## Dataset Properties
+* `data.datasets[index]` - options for this dataset only
+* `options.datasets.line` - options for all line datasets
+* `options.elements.line` - options for all [line elements](../configuration/elements.md#line-configuration)
+* `options.elements.point` - options for all [point elements](../configuration/elements.md#point-configuration)
+* `options` - options for the whole chart
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.
@@ -111,6 +107,8 @@ The radar chart allows a number of properties to be specified for each dataset.
| [`pointStyle`](#point-styling) | `string`\|`Image` | Yes | Yes | `'circle'`
| [`spanGaps`](#line-styling) | `boolean` | - | - | `undefined`
+All these values, if `undefined`, fallback to the scopes described in [option resolution](../general/options)
+
### General
| Name | Description
@@ -165,14 +163,6 @@ The interaction with each point can be controlled with the following properties:
| `pointHoverBorderWidth` | Border width of point when hovered.
| `pointHoverRadius` | The radius of the point when hovered.
-## Configuration Options
-
-The radar chart defines the following configuration options. These options are looked up on access, and form together with the global chart configuration, `Chart.defaults`, the options of the chart.
-
-| Name | Type | Default | Description
-| ---- | ---- | ------- | -----------
-| `spanGaps` | `boolean` | `false` | If false, `null` data causes a break in the line.
-
## Scale Options
The radar chart supports only a single scale. The options for this scale are defined in the `scale` property. | true |
Other | chartjs | Chart.js | 33df3a6d73b97a342221ab239aad71bc75f189cc.json | Update chart type documentation (#8805)
* Update chart type documentation
* Self-review | docs/charts/scatter.md | @@ -48,6 +48,14 @@ module.exports = {
## Dataset Properties
+Namespaces:
+
+* `data.datasets[index]` - options for this dataset only
+* `options.datasets.scatter` - options for all scatter datasets
+* `options.elements.line` - options for all [line elements](../configuration/elements.md#line-configuration)
+* `options.elements.point` - options for all [point elements](../configuration/elements.md#point-configuration)
+* `options` - options for the whole chart
+
The scatter chart supports all of the same properties as the [line chart](./charts/line.md#dataset-properties).
By default, the scatter chart will override the showLine property of the line chart to `false`.
| true |
Other | chartjs | Chart.js | a4cc21f9a919ab9f80fc133a309820b6f6c4f599.json | Update ticks.callback documentation (#8798) | docs/axes/labelling.md | @@ -17,11 +17,25 @@ Namespace: `options.scales[scaleId].title`, it defines options for the scale tit
## Creating Custom Tick Formats
-It is also common to want to change the tick marks to include information about the data type. For example, adding a dollar sign ('$'). To do this, you need to override the `ticks.callback` method in the axis configuration.
-In the following example, every label of the Y-axis would be displayed with a dollar sign at the front.
+It is also common to want to change the tick marks to include information about the data type. For example, adding a dollar sign ('$').
+To do this, you need to override the `ticks.callback` method in the axis configuration.
+
+The method receiver 3 arguments:
+
+* `value` - the tick value in the **internal data format** of the associated scale.
+* `index` - the tick index in the ticks array.
+* `ticks` - the array containing all of the [tick objects](../api/interfaces/tick).
+
+The call to the method is scoped to the scale. `this` inside the method is the scale object.
If the callback returns `null` or `undefined` the associated grid line will be hidden.
+:::tip
+The [category axis](../axes/cartesian/category), which is the default x-axis for line and bar charts, uses the `index` as internal data format. For accessing the label, use `this.getLabelForValue(value)`. [API: getLabelForValue](../api/classes/scale.html#getlabelforvalue)
+:::
+
+In the following example, every label of the Y-axis would be displayed with a dollar sign at the front.
+
```javascript
var chart = new Chart(ctx, {
type: 'line',
@@ -41,4 +55,6 @@ var chart = new Chart(ctx, {
});
```
-The third parameter passed to the callback function is an array of labels, but in the time scale, it is an array of `{label: string, major: boolean}` objects.
+Related samples:
+
+* [Tick configuration sample](../samples/scale-options/ticks) | false |
Other | chartjs | Chart.js | 8780e15c73c96db58034466e47174eb21b724857.json | v3.0.0 version bump (#8781)
* v3.0.0 version bump
* Update urls for next -> latest
* Remove TS urls | .github/release-drafter.yml | @@ -43,10 +43,10 @@ template: |
# Essential Links
* [npm](https://www.npmjs.com/package/chart.js)
- * [Migration guide](https://www.chartjs.org/docs/next/getting-started/v3-migration)
- * [Docs](https://www.chartjs.org/docs/next/)
- * [API](https://www.chartjs.org/docs/next/api/)
- * [Samples](https://www.chartjs.org/docs/next/samples/)
+ * [Migration guide](https://www.chartjs.org/docs/latest/getting-started/v3-migration)
+ * [Docs](https://www.chartjs.org/docs/latest/)
+ * [API](https://www.chartjs.org/docs/latest/api/)
+ * [Samples](https://www.chartjs.org/docs/latest/samples/)
$CHANGES
| true |
Other | chartjs | Chart.js | 8780e15c73c96db58034466e47174eb21b724857.json | v3.0.0 version bump (#8781)
* v3.0.0 version bump
* Update urls for next -> latest
* Remove TS urls | package-lock.json | @@ -1,6 +1,6 @@
{
"name": "chart.js",
- "version": "3.0.0-rc.7",
+ "version": "3.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": { | true |
Other | chartjs | Chart.js | 8780e15c73c96db58034466e47174eb21b724857.json | v3.0.0 version bump (#8781)
* v3.0.0 version bump
* Update urls for next -> latest
* Remove TS urls | package.json | @@ -2,7 +2,7 @@
"name": "chart.js",
"homepage": "https://www.chartjs.org",
"description": "Simple HTML5 charts using the canvas element.",
- "version": "3.0.0-rc.7",
+ "version": "3.0.0",
"license": "MIT",
"jsdelivr": "dist/chart.min.js",
"unpkg": "dist/chart.min.js", | true |
Other | chartjs | Chart.js | 8780e15c73c96db58034466e47174eb21b724857.json | v3.0.0 version bump (#8781)
* v3.0.0 version bump
* Update urls for next -> latest
* Remove TS urls | types/index.esm.d.ts | @@ -2796,12 +2796,10 @@ export type LinearScaleOptions = CartesianScaleOptions & {
/**
* Adjustment used when calculating the maximum data value.
- * @see https://www.chartjs.org/docs/next/axes/cartesian/linear#axis-range-settings
*/
suggestedMin?: number;
/**
* Adjustment used when calculating the minimum data value.
- * @see https://www.chartjs.org/docs/next/axes/cartesian/linear#axis-range-settings
*/
suggestedMax?: number;
@@ -2823,7 +2821,6 @@ export type LinearScaleOptions = CartesianScaleOptions & {
/**
* User defined fixed step size for the scale
- * @see https://www.chartjs.org/docs/next/axes/cartesian/linear#step-size
*/
stepSize: number;
@@ -2844,12 +2841,10 @@ export type LogarithmicScaleOptions = CartesianScaleOptions & {
/**
* Adjustment used when calculating the maximum data value.
- * @see https://www.chartjs.org/docs/next/axes/cartesian/linear#axis-range-settings
*/
suggestedMin?: number;
/**
* Adjustment used when calculating the minimum data value.
- * @see https://www.chartjs.org/docs/next/axes/cartesian/linear#axis-range-settings
*/
suggestedMax?: number;
@@ -2872,7 +2867,6 @@ export type TimeScaleOptions = CartesianScaleOptions & {
* Scale boundary strategy (bypassed by min/max time options)
* - `data`: make sure data are fully visible, ticks outside are removed
* - `ticks`: make sure ticks are fully visible, data outside are truncated
- * @see https://www.chartjs.org/docs/next/axes/cartesian/time#scale-bounds
* @since 2.7.0
* @default 'data'
*/
@@ -2888,7 +2882,6 @@ export type TimeScaleOptions = CartesianScaleOptions & {
time: {
/**
* Custom parser for dates.
- * @see https://www.chartjs.org/docs/next/axes/cartesian/time#parser
*/
parser: string | ((v: unknown) => number);
/**
@@ -2903,7 +2896,6 @@ export type TimeScaleOptions = CartesianScaleOptions & {
isoWeekday: false | number;
/**
* Sets how different time units are displayed.
- * @see https://www.chartjs.org/docs/next/axes/cartesian/time#display-formats
*/
displayFormats: {
[key: string]: string;
@@ -2939,7 +2931,6 @@ export type TimeScaleOptions = CartesianScaleOptions & {
* @see https://github.com/chartjs/Chart.js/pull/4507
* @since 2.7.0
* @default 'auto'
- * @see https://www.chartjs.org/docs/next/axes/cartesian/time#ticks-source
*/
source: 'labels' | 'auto' | 'data';
};
@@ -3033,7 +3024,6 @@ export type RadialLinearScaleOptions = CoreScaleOptions & {
*/
color: Scriptable<Color, ScriptableScaleContext>;
/**
- * @see https://www.chartjs.org/docs/next/axes/general/fonts.md
*/
font: Scriptable<FontSpec, ScriptableScaleContext>;
| true |
Other | chartjs | Chart.js | 1749e5791874eec524500dddfbb5db5bcc592c58.json | Remove scriptability from defaults.font types (#9794)
* Remove scriptability from defaults.font types
* Remove failing test | types/index.esm.d.ts | @@ -1417,7 +1417,7 @@ export interface CoreChartOptions<TType extends ChartType> extends ParsingOption
* base font
* @see Defaults.font
*/
- font: Scriptable<Partial<FontSpec>, ScriptableContext<TType>>;
+ font: Partial<FontSpec>;
/**
* Resizes the chart canvas when its container does (important note...).
* @default true | true |
Other | chartjs | Chart.js | 1749e5791874eec524500dddfbb5db5bcc592c58.json | Remove scriptability from defaults.font types (#9794)
* Remove scriptability from defaults.font types
* Remove failing test | types/tests/defaults.ts | @@ -7,3 +7,16 @@ Chart.defaults.plugins.title.display = false;
Chart.defaults.datasets.bar.backgroundColor = 'red';
Chart.defaults.animation = { duration: 500 };
+
+Chart.defaults.font.size = 8;
+
+// @ts-expect-error should be number
+Chart.defaults.font.size = '8';
+
+// @ts-expect-error should be number
+Chart.defaults.font.size = () => '10';
+
+Chart.defaults.font = {
+ family: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+ size: 10
+}; | true |
Other | chartjs | Chart.js | 1749e5791874eec524500dddfbb5db5bcc592c58.json | Remove scriptability from defaults.font types (#9794)
* Remove scriptability from defaults.font types
* Remove failing test | types/tests/scriptable_core_chart_options.ts | @@ -8,7 +8,6 @@ const getConfig = (): ChartConfiguration<'bar'> => {
},
options: {
backgroundColor: (context) => context.active ? '#fff' : undefined,
- font: (context) => context.datasetIndex === 1 ? { size: 10 } : { size: 12, family: 'arial' }
}
};
}; | true |
Other | chartjs | Chart.js | 12d5e4c7e7f048c6b8a6724d5c152d46a8464f70.json | ci(workflow): add cache to workflows using actions/setup-node (#9757)
* ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows
* style(workflows): restore single quotes and remove unnecessary 'null' | .github/workflows/ci.yml | @@ -10,7 +10,6 @@ on:
- master
- "2.9"
workflow_dispatch:
-
jobs:
build:
runs-on: ${{ matrix.os }}
@@ -24,80 +23,80 @@ jobs:
fail-fast: false
steps:
- - uses: actions/checkout@v2
- - name: Use Node.js
- uses: actions/setup-node@v1
- with:
- node-version: '14'
- - uses: dorny/paths-filter@v2
- id: changes
- with:
- filters: |
- docs:
- - 'docs/**'
- - 'package.json'
- - 'tsconfig.json'
- src:
- - 'src/**'
- - 'package.json'
- test:
- - 'test/**'
- - 'karma.conf.js'
- - 'package.json'
- types:
- - 'types/**'
- - 'package.json'
- - 'tsconfig.json'
- - name: Install
- run: npm ci
- - name: Build
- run: npm run build
- - name: Test
- if: |
- steps.changes.outputs.src == 'true' ||
- steps.changes.outputs.test == 'true'
- run: |
- npm run build
- if [ "${{ runner.os }}" == "Windows" ]; then
- npm test
- elif [ "${{ runner.os }}" == "macOS" ]; then
- npm test --browsers chrome,safari
- else
- xvfb-run --auto-servernum npm test
- fi
- shell: bash
- - name: Lint
- run: npm run lint
- - name: Package
- if: steps.changes.outputs.docs == 'true'
- run: |
- npm run docs
- npm pack
- - name: Coveralls Parallel - Chrome
- if: steps.changes.outputs.src == 'true'
- uses: coverallsapp/github-action@master
- with:
- github-token: ${{ secrets.github_token }}
- path-to-lcov: './coverage/chrome/lcov.info'
- flag-name: ${{ matrix.os }}-chrome
- parallel: true
- - name: Coveralls Parallel - Firefox
- if: steps.changes.outputs.src == 'true'
- uses: coverallsapp/github-action@master
- with:
- github-token: ${{ secrets.github_token }}
- path-to-lcov: './coverage/firefox/lcov.info'
- flag-name: ${{ matrix.os }}-firefox
- parallel: true
-
+ - uses: actions/checkout@v2
+ - name: Use Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '14'
+ cache: npm
+ - uses: dorny/paths-filter@v2
+ id: changes
+ with:
+ filters: |
+ docs:
+ - 'docs/**'
+ - 'package.json'
+ - 'tsconfig.json'
+ src:
+ - 'src/**'
+ - 'package.json'
+ test:
+ - 'test/**'
+ - 'karma.conf.js'
+ - 'package.json'
+ types:
+ - 'types/**'
+ - 'package.json'
+ - 'tsconfig.json'
+ - name: Install
+ run: npm ci
+ - name: Build
+ run: npm run build
+ - name: Test
+ if: |
+ steps.changes.outputs.src == 'true' ||
+ steps.changes.outputs.test == 'true'
+ run: |
+ npm run build
+ if [ "${{ runner.os }}" == "Windows" ]; then
+ npm test
+ elif [ "${{ runner.os }}" == "macOS" ]; then
+ npm test --browsers chrome,safari
+ else
+ xvfb-run --auto-servernum npm test
+ fi
+ shell: bash
+ - name: Lint
+ run: npm run lint
+ - name: Package
+ if: steps.changes.outputs.docs == 'true'
+ run: |
+ npm run docs
+ npm pack
+ - name: Coveralls Parallel - Chrome
+ if: steps.changes.outputs.src == 'true'
+ uses: coverallsapp/github-action@master
+ with:
+ github-token: ${{ secrets.github_token }}
+ path-to-lcov: './coverage/chrome/lcov.info'
+ flag-name: ${{ matrix.os }}-chrome
+ parallel: true
+ - name: Coveralls Parallel - Firefox
+ if: steps.changes.outputs.src == 'true'
+ uses: coverallsapp/github-action@master
+ with:
+ github-token: ${{ secrets.github_token }}
+ path-to-lcov: './coverage/firefox/lcov.info'
+ flag-name: ${{ matrix.os }}-firefox
+ parallel: true
finish:
needs: build
runs-on: ubuntu-latest
steps:
- - name: Coveralls Finished
- if: needs.build.outputs.coveralls == 'true'
- uses: coverallsapp/github-action@master
- with:
- github-token: ${{ secrets.github_token }}
- parallel-finished: true
+ - name: Coveralls Finished
+ if: needs.build.outputs.coveralls == 'true'
+ uses: coverallsapp/github-action@master
+ with:
+ github-token: ${{ secrets.github_token }}
+ parallel-finished: true | true |
Other | chartjs | Chart.js | 12d5e4c7e7f048c6b8a6724d5c152d46a8464f70.json | ci(workflow): add cache to workflows using actions/setup-node (#9757)
* ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows
* style(workflows): restore single quotes and remove unnecessary 'null' | .github/workflows/deploy-docs.yml | @@ -10,27 +10,28 @@ jobs:
correct_repository:
runs-on: ubuntu-latest
steps:
- - name: fail on fork
- if: github.repository_owner != 'chartjs'
- run: exit 1
+ - name: fail on fork
+ if: github.repository_owner != 'chartjs'
+ run: exit 1
build:
needs: correct_repository
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - name: Use Node.js
- uses: actions/setup-node@v1
- with:
- node-version: '14.x'
- - name: Package & Deploy Docs
- run: |
- npm ci
- npm run build
- ./scripts/docs-config.sh "master"
- npm run docs
- npm pack
- ./scripts/deploy-docs.sh "master"
- env:
- GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
- GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
+ - uses: actions/checkout@v2
+ - name: Use Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '14.x'
+ cache: npm
+ - name: Package & Deploy Docs
+ run: |
+ npm ci
+ npm run build
+ ./scripts/docs-config.sh "master"
+ npm run docs
+ npm pack
+ ./scripts/deploy-docs.sh "master"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
+ GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }} | true |
Other | chartjs | Chart.js | 12d5e4c7e7f048c6b8a6724d5c152d46a8464f70.json | ci(workflow): add cache to workflows using actions/setup-node (#9757)
* ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows
* style(workflows): restore single quotes and remove unnecessary 'null' | .github/workflows/release.yml | @@ -20,10 +20,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - uses: actions/setup-node@v1
+ - uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: https://registry.npmjs.org/
+ cache: npm
- name: Setup and build
run: |
npm ci
@@ -59,15 +60,16 @@ jobs:
asset_name: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
asset_content_type: application/gzip
release-tag:
- needs: [setup,release]
+ needs: [setup, release]
runs-on: ubuntu-latest
if: "!github.event.release.prerelease"
steps:
- uses: actions/checkout@v2
- - uses: actions/setup-node@v1
+ - uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: https://registry.npmjs.org/
+ cache: npm
- name: Setup and build
run: |
npm ci | true |
Other | chartjs | Chart.js | 6a250de81dd0ebcd66014911460d3076d41e8737.json | Add chart, p0.raw, p1.raw to segment context (#9761)
* Add chart, p0.raw, p1.raw to segment context
* Types | src/controllers/controller.line.js | @@ -26,6 +26,7 @@ export default class LineController extends DatasetController {
}
// Update Line
+ line._chart = this.chart;
line._datasetIndex = this.index;
line._decimated = !!_dataset._decimated;
line.points = points;
@@ -46,13 +47,13 @@ export default class LineController extends DatasetController {
updateElements(points, start, count, mode) {
const reset = mode === 'reset';
- const {iScale, vScale, _stacked} = this._cachedMeta;
+ const {iScale, vScale, _stacked, _dataset} = this._cachedMeta;
const firstOpts = this.resolveDataElementOptions(start, mode);
const sharedOptions = this.getSharedOptions(firstOpts);
const includeOptions = this.includeOptions(mode, sharedOptions);
const iAxis = iScale.axis;
const vAxis = vScale.axis;
- const spanGaps = this.options.spanGaps;
+ const {spanGaps, segment} = this.options;
const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
const directUpdate = this.chart._animationsDisabled || reset || mode === 'none';
let prevParsed = start > 0 && this.getParsed(start - 1);
@@ -67,7 +68,10 @@ export default class LineController extends DatasetController {
properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;
properties.stop = i > 0 && (parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;
- properties.parsed = parsed;
+ if (segment) {
+ properties.parsed = parsed;
+ properties.raw = _dataset.data[i];
+ }
if (includeOptions) {
properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode); | true |
Other | chartjs | Chart.js | 6a250de81dd0ebcd66014911460d3076d41e8737.json | Add chart, p0.raw, p1.raw to segment context (#9761)
* Add chart, p0.raw, p1.raw to segment context
* Types | src/core/core.controller.js | @@ -8,7 +8,7 @@ import registry from './core.registry';
import Config, {determineAxis, getIndexAxis} from './core.config';
import {retinaScale, _isDomSupported} from '../helpers/helpers.dom';
import {each, callback as callCallback, uid, valueOrDefault, _elementsEqual, isNullOrUndef, setsEqual, defined, isFunction} from '../helpers/helpers.core';
-import {clearCanvas, clipArea, unclipArea, _isPointInArea} from '../helpers/helpers.canvas';
+import {clearCanvas, clipArea, createContext, unclipArea, _isPointInArea} from '../helpers';
// @ts-ignore
import {version} from '../../package.json';
import {debounce} from '../helpers/helpers.extras';
@@ -735,7 +735,7 @@ class Chart {
}
getContext() {
- return this.$context || (this.$context = {chart: this, type: 'chart'});
+ return this.$context || (this.$context = createContext(null, {chart: this, type: 'chart'}));
}
getVisibleDatasetCount() { | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.