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
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
src/core/core.layouts.js
@@ -49,11 +49,11 @@ function setLayoutDims(layouts, params) { layout = layouts[i]; // store dimensions used instead of available chartArea in fitBoxes if (layout.horizontal) { - layout.width = layout.box.fullWidth && params.availableWidth; + layout.width = layout.box.fullSize && params.availableWidth; layout.height = params.hBoxMaxHeight; } else { layout.width = params.vBoxMaxWidth; - layout.height = layout.box.fullWidth && params.availableHeight; + layout.height = layout.box.fullSize && params.availableHeight; } } } @@ -166,7 +166,7 @@ function fitBoxes(boxes, chartArea, params) { refit = true; } } - if (!box.fullWidth) { // fullWidth boxes don't need to be re-fitted in any case + if (!box.fullSize) { // fullSize boxes don't need to be re-fitted in any case refitBoxes.push(layout); } } @@ -184,17 +184,17 @@ function placeBoxes(boxes, chartArea, params) { layout = boxes[i]; box = layout.box; if (layout.horizontal) { - box.left = box.fullWidth ? userPadding.left : chartArea.left; - box.right = box.fullWidth ? params.outerWidth - userPadding.right : chartArea.left + chartArea.w; + box.left = box.fullSize ? userPadding.left : chartArea.left; + box.right = box.fullSize ? params.outerWidth - userPadding.right : chartArea.left + chartArea.w; box.top = y; box.bottom = y + box.height; box.width = box.right - box.left; y = box.bottom; } else { box.left = x; box.right = x + box.width; - box.top = box.fullWidth ? userPadding.top : chartArea.top; - box.bottom = box.fullWidth ? params.outerHeight - userPadding.right : chartArea.top + chartArea.h; + box.top = box.fullSize ? userPadding.top : chartArea.top; + box.bottom = box.fullSize ? params.outerHeight - userPadding.right : chartArea.top + chartArea.h; box.height = box.bottom - box.top; x = box.right; } @@ -219,7 +219,7 @@ defaults.set('layout', { * @prop {string} position - The position of the item in the chart layout. Possible values are * 'left', 'top', 'right', 'bottom', and 'chartArea' * @prop {number} weight - The weight used to sort the item. Higher weights are further away from the chart area - * @prop {boolean} fullWidth - if true, and the item is horizontal, then push vertical boxes down + * @prop {boolean} fullSize - if true, and the item is horizontal, then push vertical boxes down * @prop {function} isHorizontal - returns true if the layout item is horizontal (ie. top or bottom) * @prop {function} update - Takes two parameters: width and height. Returns size of item * @prop {function} draw - Draws the element @@ -249,7 +249,7 @@ export default { } // initialize item with default values - item.fullWidth = item.fullWidth || false; + item.fullSize = item.fullSize || false; item.position = item.position || 'top'; item.weight = item.weight || 0; // @ts-ignore @@ -284,7 +284,7 @@ export default { * @param {object} options - the new item options. */ configure(chart, item, options) { - const props = ['fullWidth', 'position', 'weight']; + const props = ['fullSize', 'position', 'weight']; const ilen = props.length; let i = 0; let prop;
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
src/core/core.scale.js
@@ -906,8 +906,8 @@ export default class Scale extends Element { /** * @return {boolean} */ - isFullWidth() { - return this.options.fullWidth; + isFullSize() { + return this.options.fullSize; } /**
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
src/plugins/plugin.legend.js
@@ -65,7 +65,7 @@ export class Legend extends Element { this._margins = undefined; this.position = undefined; this.weight = undefined; - this.fullWidth = undefined; + this.fullSize = undefined; } update(maxWidth, maxHeight, margins) { @@ -540,7 +540,7 @@ export default { display: true, position: 'top', align: 'center', - fullWidth: true, + fullSize: true, reverse: false, weight: 1000,
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
src/plugins/plugin.title.js
@@ -23,7 +23,7 @@ export class Title extends Element { this.height = undefined; this.position = undefined; this.weight = undefined; - this.fullWidth = undefined; + this.fullSize = undefined; } update(maxWidth, maxHeight) { @@ -170,7 +170,7 @@ export default { font: { style: 'bold', }, - fullWidth: true, + fullSize: true, padding: 10, position: 'top', text: '',
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
test/specs/core.layouts.tests.js
@@ -206,7 +206,7 @@ describe('Chart.layouts', function() { x2: { type: 'category', position: 'top', - fullWidth: true, + fullSize: true, offset: false }, y: {
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
test/specs/plugin.legend.tests.js
@@ -7,7 +7,7 @@ describe('Legend block tests', function() { display: true, position: 'top', align: 'center', - fullWidth: true, // marks that this box should take the full width of the canvas (pushing down other boxes) + fullSize: true, reverse: false, weight: 1000, @@ -768,24 +768,24 @@ describe('Legend block tests', function() { options: { plugins: { legend: { - fullWidth: true, + fullSize: true, position: 'top', weight: 150 } } } }); - expect(chart.legend.fullWidth).toBe(true); + expect(chart.legend.fullSize).toBe(true); expect(chart.legend.position).toBe('top'); expect(chart.legend.weight).toBe(150); - chart.options.plugins.legend.fullWidth = false; + chart.options.plugins.legend.fullSize = false; chart.options.plugins.legend.position = 'left'; chart.options.plugins.legend.weight = 42; chart.update(); - expect(chart.legend.fullWidth).toBe(false); + expect(chart.legend.fullSize).toBe(false); expect(chart.legend.position).toBe('left'); expect(chart.legend.weight).toBe(42); });
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
test/specs/plugin.title.tests.js
@@ -9,7 +9,7 @@ describe('Title block tests', function() { color: Chart.defaults.color, display: false, position: 'top', - fullWidth: true, + fullSize: true, weight: 2000, font: { style: 'bold' @@ -291,24 +291,24 @@ describe('Title block tests', function() { options: { plugins: { title: { - fullWidth: true, + fullSize: true, position: 'top', weight: 150 } } } }); - expect(chart.titleBlock.fullWidth).toBe(true); + expect(chart.titleBlock.fullSize).toBe(true); expect(chart.titleBlock.position).toBe('top'); expect(chart.titleBlock.weight).toBe(150); - chart.options.plugins.title.fullWidth = false; + chart.options.plugins.title.fullSize = false; chart.options.plugins.title.position = 'left'; chart.options.plugins.title.weight = 42; chart.update(); - expect(chart.titleBlock.fullWidth).toBe(false); + expect(chart.titleBlock.fullSize).toBe(false); expect(chart.titleBlock.position).toBe('left'); expect(chart.titleBlock.weight).toBe(42); });
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
types/index.esm.d.ts
@@ -717,7 +717,7 @@ export const layouts: { configure( chart: Chart, item: LayoutItem, - options: { fullWidth?: number; position?: LayoutPosition; weight?: number } + options: { fullSize?: number; position?: LayoutPosition; weight?: number } ): void; /** @@ -1222,7 +1222,7 @@ export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends El fit(): void; afterFit(): void; - isFullWidth(): boolean; + isFullSize(): boolean; } export const Scale: { prototype: Scale; @@ -2022,10 +2022,10 @@ export interface LegendOptions { */ align: TextAlign; /** - * Marks that this box should take the full width of the canvas (pushing down other boxes). This is unlikely to need to be changed in day-to-day use. + * Marks that this box should take the full width/height of the canvas (moving other boxes). This is unlikely to need to be changed in day-to-day use. * @default true */ - fullWidth: boolean; + fullSize: boolean; /** * Legend will show datasets in reverse order. * @default false @@ -2145,7 +2145,7 @@ export interface TitleOptions { */ color: Color; font: FontSpec; - // fullWidth: boolean; + // fullSize: boolean; /** * Adds padding above and below the title text if a single number is specified. It is also possible to change top and bottom padding separately. */
true
Other
chartjs
Chart.js
ad84d285d841cefc8fef6a8e8e301bd5a68c010e.json
Rename LayoutItem.fullWidth to fullSize (#8358)
types/layout.d.ts
@@ -14,7 +14,7 @@ export interface LayoutItem { /** * if true, and the item is horizontal, then push vertical boxes down */ - fullWidth: boolean; + fullSize: boolean; /** * Width of item. Must be valid after update() */
true
Other
chartjs
Chart.js
4f74a92b80a6f4c83f45668ad4fbdc921eb0ada9.json
Add documentation for vertical line charts (#8327) * add documentation for vertical line charts * remove the indexAxis prop from dataset since it doesnt belong there, fix horizontal bars example and make vertical line example * 2 bars to line rename * fix v3-migration guide * revert deletion of prop from table in bar, added in line. Removed anchor point in link from v3 docs * put right text in general of line
docs/docs/charts/bar.mdx
@@ -294,6 +294,8 @@ The following dataset properties are specific to stacked bar charts. ## 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. +To achieve this you will have to set the `indexAxis` property in the options object to `'y'`. +The default for this property is `'x'` and thus will show vertical bars. export const ExampleChart1 = () => { useEffect(() => { @@ -328,6 +330,7 @@ export const ExampleChart1 = () => { }] }, options: { + indexAxis: 'y', scales: { x: { beginAtZero: true @@ -349,7 +352,9 @@ export const ExampleChart1 = () => { var myBarChart = new Chart(ctx, { type: 'bar', data: data, - options: options + options: { + indexAxis: 'y' + } }); ```
true
Other
chartjs
Chart.js
4f74a92b80a6f4c83f45668ad4fbdc921eb0ada9.json
Add documentation for vertical line charts (#8327) * add documentation for vertical line charts * remove the indexAxis prop from dataset since it doesnt belong there, fix horizontal bars example and make vertical line example * 2 bars to line rename * fix v3-migration guide * revert deletion of prop from table in bar, added in line. Removed anchor point in link from v3 docs * put right text in general of line
docs/docs/charts/line.mdx
@@ -72,6 +72,7 @@ The line chart allows a number of properties to be specified for each dataset. T | [`hoverBorderDashOffset`](#line-styling) | `number` | Yes | - | `undefined` | [`hoverBorderJoinStyle`](#line-styling) | `string` | Yes | - | `undefined` | [`hoverBorderWidth`](#line-styling) | `number` | Yes | - | `undefined` +| [`indexAxis`](#general) | `string` | - | - | `'x'` | [`label`](#general) | `string` | - | - | `''` | [`tension`](#line-styling) | `number` | - | - | `0` | [`order`](#general) | `number` | - | - | `0` @@ -97,6 +98,7 @@ The line chart allows a number of properties to be specified for each dataset. T | Name | Description | ---- | ---- | `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}` +| `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. | `xAxisID` | The ID of the x-axis to plot this dataset on. @@ -215,6 +217,77 @@ var stackedLine = new Chart(ctx, { }); ``` +## Vertical Line Chart + +A vertical line chart is a variation on the horizontal line chart. +To achieve this you will have to set the `indexAxis` property in the options object to `'y'`. +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>; +} + +<ExampleChart1/> + +## 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. + ## Internal data format `{x, y}`
true
Other
chartjs
Chart.js
4f74a92b80a6f4c83f45668ad4fbdc921eb0ada9.json
Add documentation for vertical line charts (#8327) * add documentation for vertical line charts * remove the indexAxis prop from dataset since it doesnt belong there, fix horizontal bars example and make vertical line example * 2 bars to line rename * fix v3-migration guide * revert deletion of prop from table in bar, added in line. Removed anchor point in link from v3 docs * put right text in general of line
docs/docs/getting-started/v3-migration.md
@@ -53,7 +53,7 @@ const chart = new Chart(ctx, { ### Chart types -* `horizontalBar` chart type was removed. Horizontal bar charts can be configured using the new [`indexAxis`](./charts/bar.mdx#general) option +* `horizontalBar` chart type was removed. Horizontal bar charts can be configured using the new [`indexAxis`](./charts/bar.mdx#horizontal-bar-chart) option ### Options
true
Other
chartjs
Chart.js
a730fc68fa4618afeb3dea9201e5c8686e47b2ae.json
Fix broken links in tooltip docs (#8316)
docs/docs/configuration/tooltip.md
@@ -93,17 +93,17 @@ These options are only applied to text lines. Color boxes are always aligned to ### Sort Callback -Allows sorting of [tooltip items](#tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort). This function can also accept a third parameter that is the data object passed to the chart. +Allows sorting of [tooltip items](#tooltip-item-context). Must implement at minimum a function that can be passed to [Array.prototype.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort). This function can also accept a third parameter that is the data object passed to the chart. ### Filter Callback -Allows filtering of [tooltip items](#tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.filter](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). This function can also accept a fourth parameter that is the data object passed to the chart. +Allows filtering of [tooltip items](#tooltip-item-context). Must implement at minimum a function that can be passed to [Array.prototype.filter](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). This function can also accept a fourth parameter that is the data object passed to the chart. ## Tooltip Callbacks The tooltip label configuration is nested below the tooltip configuration using the `callbacks` key. The tooltip has the following callbacks for providing text. For all functions, `this` will be the tooltip object created from the `Tooltip` constructor. -All functions are called with the same arguments: a [tooltip item context](#tooltip-item-interface). All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text. +All functions are called with the same arguments: a [tooltip item context](#tooltip-item-context). All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text. | Name | Arguments | Description | ---- | --------- | -----------
false
Other
chartjs
Chart.js
e63beb8c6da12fe1ae0666bb0a1dea7d9c77629a.json
Add note about v3 dev code in readme (#8283) * Add note about v3 dev code in readme * Adjust note based on feedback
README.md
@@ -13,6 +13,13 @@ ## Documentation +Currently, there are two versions of the library (2.9.4 and 3.x.x). Version 2 is the latest stable version while 3 is the next (currently beta) version. As such bear the following in mind: + +* Current docs points to version 2.9.4 +* Npm/CDN/etc point to version 2.9.4 (unless you explicitly set newer version, e.g. npm next) +* Source currently points to 3.x.x version. 2.9.4 source is available [here](https://github.com/chartjs/Chart.js/tree/2.9) +* Docs for version 3.x.x are available [here](https://www.chartjs.org/docs/master/) + - [Introduction](https://www.chartjs.org/docs/latest/) - [Getting Started](https://www.chartjs.org/docs/latest/getting-started/) - [General](https://www.chartjs.org/docs/latest/general/)
false
Other
chartjs
Chart.js
397d5bdee4163514948d2be7e4910fd26db788af.json
Remove empty line from the options table (#8274)
docs/docs/axes/styling.mdx
@@ -29,7 +29,6 @@ The grid line configuration is nested under the scale configuration in the `grid | `tickColor` | [`Color`](../general/colors.md) | Yes | Yes | | Color of the tick line. If unset, defaults to the grid line color. | `tickLength` | `number` | | | `10` | Length in pixels that the grid lines will draw into the axis area. | `tickWidth` | `number` | Yes | Yes | | Width of the tick mark in pixels. If unset, defaults to the grid line width. - | `z` | `number` | | | `0` | z-index of gridline layer. Values &lt;= 0 are drawn under datasets, &gt; 0 on top. The scriptable context is described in [Options](../general/options.md#tick) section.
false
Other
chartjs
Chart.js
0c48c1148a7f791fb31a01f8b1ef51386559bab3.json
Fix resize bug of line / radar charts (#8266) * Line: Make sure control points are re-calculated * Radar: always set point on update
src/controllers/controller.radar.js
@@ -25,10 +25,10 @@ export default class RadarController extends DatasetController { const labels = meta.iScale.getLabels(); // Update Line + line.points = points; // In resize mode only point locations change, so no need to set the points or options. if (mode !== 'resize') { const properties = { - points, _loop: true, _fullLoop: labels.length === points.length, options: me.resolveDatasetElementOptions()
true
Other
chartjs
Chart.js
0c48c1148a7f791fb31a01f8b1ef51386559bab3.json
Fix resize bug of line / radar charts (#8266) * Line: Make sure control points are re-calculated * Radar: always set point on update
src/elements/element.line.js
@@ -228,9 +228,11 @@ export default class LineElement extends Element { } set points(points) { - this._points = points; - delete this._segments; - delete this._path; + const me = this; + me._points = points; + delete me._segments; + delete me._path; + me._pointsUpdated = false; } get points() {
true
Other
chartjs
Chart.js
81a1e9a95ecf9f7d8f2db94f436e1f30e002e23a.json
Add type linting (#8264)
package-lock.json
@@ -564,6 +564,32 @@ "integrity": "sha512-K3Aul4Ct6O48yWw0/az5rqk2K76oNXXX3Su32Xkh4SfMFvPt0QEkq0Q6+3icE5S3U2c88WAuq3Vh1Iaz4aUH+w==", "dev": true }, + "@nodelib/fs.scandir": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", + "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.4", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", + "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", + "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.4", + "fastq": "^1.6.0" + } + }, "@rollup/plugin-commonjs": { "version": "17.0.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.0.0.tgz", @@ -680,6 +706,12 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, + "@types/json-schema": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz", + "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==", + "dev": true + }, "@types/node": { "version": "14.0.27", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", @@ -695,6 +727,119 @@ "@types/node": "*" } }, + "@typescript-eslint/eslint-plugin": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.11.1.tgz", + "integrity": "sha512-fABclAX2QIEDmTMk6Yd7Muv1CzFLwWM4505nETzRHpP3br6jfahD9UUJkhnJ/g2m7lwfz8IlswcwGGPGiq9exw==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "4.11.1", + "@typescript-eslint/scope-manager": "4.11.1", + "debug": "^4.1.1", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^3.0.0", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + }, + "dependencies": { + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/experimental-utils": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.11.1.tgz", + "integrity": "sha512-mAlWowT4A6h0TC9F+J5pdbEhjNiEMO+kqPKQ4sc3fVieKL71dEqfkKgtcFVSX3cjSBwYwhImaQ/mXQF0oaI38g==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/scope-manager": "4.11.1", + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/typescript-estree": "4.11.1", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + } + }, + "@typescript-eslint/parser": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.11.1.tgz", + "integrity": "sha512-BJ3jwPQu1jeynJ5BrjLuGfK/UJu6uwHxJ/di7sanqmUmxzmyIcd3vz58PMR7wpi8k3iWq2Q11KMYgZbUpRoIPw==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "4.11.1", + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/typescript-estree": "4.11.1", + "debug": "^4.1.1" + } + }, + "@typescript-eslint/scope-manager": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.11.1.tgz", + "integrity": "sha512-Al2P394dx+kXCl61fhrrZ1FTI7qsRDIUiVSuN6rTwss6lUn8uVO2+nnF4AvO0ug8vMsy3ShkbxLu/uWZdTtJMQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1" + } + }, + "@typescript-eslint/types": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.11.1.tgz", + "integrity": "sha512-5kvd38wZpqGY4yP/6W3qhYX6Hz0NwUbijVsX2rxczpY6OXaMxh0+5E5uLJKVFwaBM7PJe1wnMym85NfKYIh6CA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.1.tgz", + "integrity": "sha512-tC7MKZIMRTYxQhrVAFoJq/DlRwv1bnqA4/S2r3+HuHibqvbrPcyf858lNzU7bFmy4mLeIHFYr34ar/1KumwyRw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1", + "debug": "^4.1.1", + "globby": "^11.0.1", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + }, + "dependencies": { + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.1.tgz", + "integrity": "sha512-IrlBhD9bm4bdYcS8xpWarazkKXlE7iYb1HzRuyBP114mIaj5DJPo11Us1HgH60dTt41TCZXMaTCAW+OILIYPOg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", + "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", + "dev": true + } + } + }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -781,6 +926,12 @@ "sprintf-js": "~1.0.2" } }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, "arraybuffer.slice": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", @@ -1570,6 +1721,15 @@ "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", "dev": true }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + } + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -2108,6 +2268,20 @@ "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", "dev": true }, + "fast-glob": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz", + "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.0", + "merge2": "^1.3.0", + "micromatch": "^4.0.2", + "picomatch": "^2.2.1" + } + }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2120,6 +2294,15 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fastq": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.10.0.tgz", + "integrity": "sha512-NL2Qc5L3iQEsyYzweq7qfgy5OtXCmGzGvhElGEd/SoFWEMOEczNh5s5ocaF01HDetxz+p8ecjNPA6cZxxIHmzA==", + "dev": true, + "requires": { + "reusify": "^1.0.4" + } + }, "file-entry-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.0.tgz", @@ -2303,6 +2486,28 @@ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, + "globby": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz", + "integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", + "slash": "^3.0.0" + }, + "dependencies": { + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "dev": true + } + } + }, "graceful-fs": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", @@ -3305,6 +3510,22 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, "mime": { "version": "2.4.6", "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", @@ -3526,6 +3747,12 @@ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, "perf-regexes": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/perf-regexes/-/perf-regexes-1.0.1.tgz", @@ -3739,6 +3966,12 @@ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, "rfdc": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz", @@ -3873,6 +4106,12 @@ } } }, + "run-parallel": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", + "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", + "dev": true + }, "rxjs": { "version": "6.5.5", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.5.tgz", @@ -3984,6 +4223,12 @@ "integrity": "sha512-pEjMUbwJ5Pl/6Vn6FsamXHXItJXSRftcibixDmNCWbWhic0hzHrwkMZo0IZ7fMRH9KxcWDFSkzhccB4285PutA==", "dev": true }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, "slice-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", @@ -4454,6 +4699,15 @@ "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", "dev": true }, + "tsutils": { + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
true
Other
chartjs
Chart.js
81a1e9a95ecf9f7d8f2db94f436e1f30e002e23a.json
Add type linting (#8264)
package.json
@@ -39,6 +39,7 @@ "docs": "cd docs && npm install && npm run build", "lint-js": "eslint samples/**/*.html samples/**/*.js src/**/*.js test/**/*.js", "lint-tsc": "tsc", + "lint-types": "eslint types/**/*.d.ts", "lint": "concurrently \"npm:lint-*\"", "test": "npm run lint && cross-env NODE_ENV=test karma start --auto-watch --single-run --coverage --grep", "typedoc": "npx typedoc" @@ -49,6 +50,8 @@ "@rollup/plugin-inject": "^4.0.2", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^11.0.1", + "@typescript-eslint/eslint-plugin": "^4.11.1", + "@typescript-eslint/parser": "^4.11.1", "chartjs-adapter-moment": "^0.1.2", "chartjs-test-utils": "^0.1.1", "concurrently": "^5.3.0",
true
Other
chartjs
Chart.js
81a1e9a95ecf9f7d8f2db94f436e1f30e002e23a.json
Add type linting (#8264)
types/.eslintrc.yml
@@ -0,0 +1,18 @@ +parser: '@typescript-eslint/parser' + +plugins: + - '@typescript-eslint' + +extends: + - chartjs + - plugin:@typescript-eslint/recommended + +# These rules were set to warning to make the linting pass initially, +# without making any major changes to types. +rules: + no-use-before-define: "warn" + no-shadow: "warn" + object-curly-spacing: ["warn", "always"] + '@typescript-eslint/no-empty-interface': "warn" + '@typescript-eslint/ban-types': "warn" + '@typescript-eslint/adjacent-overload-signatures': "warn"
true
Other
chartjs
Chart.js
81a1e9a95ecf9f7d8f2db94f436e1f30e002e23a.json
Add type linting (#8264)
types/index.esm.d.ts
@@ -12,10 +12,10 @@ * } */ -import { TimeUnit } from "./adapters"; +import { TimeUnit } from './adapters'; import { AnimationEvent } from './animation'; import { Color } from './color'; -import { Element }from './element'; +import { Element } from './element'; import { ChartArea, Point } from './geometric'; import { LayoutItem, LayoutPosition } from './layout'; import {
true
Other
chartjs
Chart.js
b73b8f98633f399ac804d52bb0c8ed6d2212d3ea.json
Update running animations (#7196)
src/core/core.animation.js
@@ -42,6 +42,19 @@ export default class Animation { return this._active; } + update(cfg, to, date) { + const me = this; + if (me._active) { + const currentValue = me._target[me._prop]; + const elapsed = date - me._start; + const remain = me._duration - elapsed; + me._start = date; + me._duration = Math.floor(Math.max(remain, cfg.duration)); + me._to = resolve([cfg.to, to, currentValue, cfg.from]); + me._from = resolve([cfg.from, currentValue, to]); + } + } + cancel() { const me = this; if (me._active) {
true
Other
chartjs
Chart.js
b73b8f98633f399ac804d52bb0c8ed6d2212d3ea.json
Update running animations (#7196)
src/core/core.animations.js
@@ -147,6 +147,7 @@ export default class Animations { const animations = []; const running = target.$animations || (target.$animations = {}); const props = Object.keys(values); + const date = Date.now(); let i; for (i = props.length - 1; i >= 0; --i) { @@ -161,11 +162,17 @@ export default class Animations { } const value = values[prop]; let animation = running[prop]; + const cfg = animatedProps.get(prop); + if (animation) { - animation.cancel(); + if (cfg && animation.active()) { + // There is an existing active animation, let's update that + animation.update(cfg, value, date); + continue; + } else { + animation.cancel(); + } } - - const cfg = animatedProps.get(prop); if (!cfg || !cfg.duration) { // not animated, set directly to new value target[prop] = value;
true
Other
chartjs
Chart.js
b73b8f98633f399ac804d52bb0c8ed6d2212d3ea.json
Update running animations (#7196)
src/core/core.controller.js
@@ -343,7 +343,6 @@ export default class Chart { options.onResize(me, newSize); } - me.stop(); me.update('resize'); } }
true
Other
chartjs
Chart.js
e22f8bd7dcb26532d1c5703f4c7c632ffb406c6c.json
Update Migration Guide (#7186) * Add headers & split list of removed developer properties * Reorganize option changes & include scale option example
docs/getting-started/v3-migration.md
@@ -17,45 +17,13 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released * Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`. Please see the [installation](installation.md) and [integration](integration.md) docs for details on the recommended way to setup Chart.js if you were using these builds. * `moment` is no longer specified as an npm dependency. If you are using the time scale, you must include one of [the available adapters](https://github.com/chartjs/awesome#adapters) and corresponding date library. You no longer need to exclude moment from your build. -### Ticks - -* `options.ticks.userCallback` was renamed to `options.ticks.callback` -* `options.ticks.major` and `options.ticks.minor` were replaced with scriptable options for tick fonts. -* `Chart.Ticks.formatters.linear` and `Chart.Ticks.formatters.logarithmic` were replaced with `Chart.Ticks.formatters.numeric`. - -### Tooltip - -* `xLabel` and `yLabel` were removed. Please use `index` and `value` - -### Interactions - -* `interactions` are now limited to the chart area -* `{mode: 'label'}` was replaced with `{mode: 'index'}` -* `{mode: 'single'}` was replaced with `{mode: 'nearest', intersect: true}` -* `modes['X-axis']` was replaced with `{mode: 'index', intersect: false}` -* `options.onClick` is now limited to the chart area - -### Customizability - -* `custom` attribute of elements was removed. Please use scriptable options -* The `hover` property of scriptable options `context` object was renamed to `active` to align it with the datalabels plugin. -* The `zeroLine*` options of axes were removed. Use scriptable scale options instead. - -## Defaults - -* `global` namespace was removed from `defaults`. So `Chart.defaults.global` is now `Chart.defaults` -* `default` prefix was removed from defaults. For example `Chart.defaults.global.defaultColor` is now `Chart.defaults.color` - * `defaultColor` was renamed to `color` - * `defaultFontColor` was renamed to `fontColor` - * `defaultFontFamily` was renamed to `fontFamily` - * `defaultFontSize` was renamed to `fontSize` - * `defaultFontStyle` was renamed to `fontStyle` - * `defaultLineHeight` was renamed to `lineHeight` - ### Options -* Dataset options are now configured as `options[type].datasets` rather than `options.datasets[type]` -* `Polar area` `startAngle` option is now consistent with `Radar`, 0 is at top and value is in degrees. Default is changed from `-½π` to `0`. +A number of changes were made to the configuration options passed to the `Chart` constructor. Those changes are documented below. + +* `hover.animationDuration` is now configured in `animation.active.duration` +* `responsiveAnimationDuration` is now configured in `animation.resize.duration` +* Polar area `startAngle` option is now consistent with `Radar`, 0 is at top and value is in degrees. Default is changed from `-½π` to `0`. * `scales.[x/y]Axes` arrays were removed. Scales are now configured directly to `options.scales` object with the object key being the scale Id. * `scales.[x/y]Axes.barPercentage` was moved to dataset option `barPercentage` * `scales.[x/y]Axes.barThickness` was moved to dataset option `barThickness` @@ -69,24 +37,137 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released * `scales.[x/y]Axes.ticks.suggestedMax` was renamed to `scales[id].suggestedMax` * `scales.[x/y]Axes.ticks.suggestedMin` was renamed to `scales[id].suggestedMin` * `scales.[x/y]Axes.ticks.unitStepSize` was removed. Use `scales[id].ticks.stepSize` +* `scales.[x/y]Axes.ticks.userCallback` was renamed to `scales[id].ticks.callback` * `scales.[x/y]Axes.time.format` was renamed to `scales[id].time.parser` * `scales.[x/y]Axes.time.max` was renamed to `scales[id].max` * `scales.[x/y]Axes.time.min` was renamed to `scales[id].min` +* `scales.[x/y]Axes.zeroLine*` options of axes were removed. Use scriptable scale options instead. * The dataset option `steppedLine` was removed. Use `stepped` * The dataset option `tension` was removed. Use `lineTension` +* Dataset options are now configured as `options[type].datasets` rather than `options.datasets[type]` * To override the platform class used in a chart instance, pass `platform: PlatformClass` in the config object. Note that the class should be passed, not an instance of the class. -### Animations +#### Defaults + +* `global` namespace was removed from `defaults`. So `Chart.defaults.global` is now `Chart.defaults` +* `default` prefix was removed from defaults. For example `Chart.defaults.global.defaultColor` is now `Chart.defaults.color` +* `defaultColor` was renamed to `color` +* `defaultFontColor` was renamed to `fontColor` +* `defaultFontFamily` was renamed to `fontFamily` +* `defaultFontSize` was renamed to `fontSize` +* `defaultFontStyle` was renamed to `fontStyle` +* `defaultLineHeight` was renamed to `lineHeight` + +#### Scales + +The configuration options for scales is the largest change in v3. The `xAxes` and `yAxes` arrays were removed and axis options are individual scales now keyed by scale ID. + +The v2 configuration below is shown with it's new v3 configuration + +```javascript +options: { + scales: { + xAxes: [{ + id: 'x', + type: 'time', + display: true, + scaleLabel: { + display: true, + labelString: 'Date' + }, + ticks: { + major: { + enabled: true + }, + fontStyle: function(context) { + return context.tick && context.tick.major ? 'bold' : undefined; + }, + fontColor: function(context) { + return context.tick && context.tick.major ? '#FF0000' : undefined; + } + } + }], + yAxes: [{ + id: 'y', + display: true, + scaleLabel: { + display: true, + labelString: 'value' + } + }] + } +} +``` + +And now, in v3: + +```javascript +options: { + scales: { + x: { + type: 'time', + display: true, + scaleLabel: { + display: true, + labelString: 'Date' + }, + ticks: { + major: { + enabled: true + }, + fontStyle: function(context) { + return context.tick && context.tick.major ? 'bold' : undefined; + }, + fontColor: function(context) { + return context.tick && context.tick.major ? '#FF0000' : undefined; + } + } + }, + y: { + display: true, + scaleLabel: { + display: true, + labelString: 'value' + } + } + } +} +``` + +#### Animations Animation system was completely rewritten in Chart.js v3. Each property can now be animated separately. Please see [animations](../configuration/animations.md) docs for details. -* `hover.animationDuration` is now configured in `animation.active.duration` -* `responsiveAnimationDuration` is now configured in `animation.resize.duration` + +#### Customizability + +* `custom` attribute of elements was removed. Please use scriptable options +* The `hover` property of scriptable options `context` object was renamed to `active` to align it with the datalabels plugin. + +#### Interactions + +* `interactions` are now limited to the chart area +* `{mode: 'label'}` was replaced with `{mode: 'index'}` +* `{mode: 'single'}` was replaced with `{mode: 'nearest', intersect: true}` +* `modes['X-axis']` was replaced with `{mode: 'index', intersect: false}` +* `options.onClick` is now limited to the chart area + +#### Ticks + +* `options.ticks.major` and `options.ticks.minor` were replaced with scriptable options for tick fonts. +* `Chart.Ticks.formatters.linear` and `Chart.Ticks.formatters.logarithmic` were replaced with `Chart.Ticks.formatters.numeric`. + +#### Tooltip + +* `xLabel` and `yLabel` were removed. Please use `index` and `value` ## Developer migration ### Removed +The following properties and methods were removed: + +#### Chart * `Chart.borderWidth` * `Chart.chart.chart` * `Chart.Controller` @@ -99,14 +180,25 @@ Animation system was completely rewritten in Chart.js v3. Each property can now * `Chart.radiusLength` * `Chart.types` * `Chart.Tooltip` is now provided by the tooltip plugin. The positioners can be accessed from `tooltipPlugin.positioners` +* `ILayoutItem.minSize` + +#### Dataset Controller + * `DatasetController.addElementAndReset` * `DatasetController.createMetaData` * `DatasetController.createMetaDataset` + +#### Elements + * `Element.getArea` * `Element.height` * `Element.hidden` was replaced by chart level status, usable with `getDataVisibility(index)` / `toggleDataVisibility(index)` * `Element.initialize` * `Element.inLabelRange` +* `Line.calculatePointY` + +#### Helpers + * `helpers.addEvent` * `helpers.aliasPixel` * `helpers.configMerge` @@ -128,10 +220,9 @@ Animation system was completely rewritten in Chart.js v3. Each property can now * `helpers.roundedRect` * `helpers.scaleMerge` * `helpers.where` -* `ILayoutItem.minSize` -* `IPlugin.afterScaleUpdate`. Use `afterLayout` instead -* `Legend.margins` is now private -* `Line.calculatePointY` + +#### Scales + * `LogarithmicScale.minNotZero` * `Scale.getRightValue` * `Scale.longestLabelWidth` @@ -142,11 +233,18 @@ Animation system was completely rewritten in Chart.js v3. Each property can now * `Scale.tickValues` is now private * `TimeScale.getLabelCapacity` is now private * `TimeScale.tickFormatFunction` is now private + +#### Plugins (Legend, Title, and Tooltip) + +* `IPlugin.afterScaleUpdate`. Use `afterLayout` instead +* `Legend.margins` is now private * `Title.margins` is now private * The tooltip item's `x` and `y` attributes were removed. Use `datasetIndex` and `index` to get the element and any corresponding data from it #### Removal of private APIs +The following private APIs were removed. + * `Chart.data.datasets[datasetIndex]._meta` * `Element._ctx` * `Element._model` @@ -158,6 +256,8 @@ Animation system was completely rewritten in Chart.js v3. Each property can now ### Renamed +The following properties were renamed during v3 development: + * `Chart.Animation.animationObject` was renamed to `Chart.Animation` * `Chart.Animation.chartInstance` was renamed to `Chart.Animation.chart` * `helpers._decimalPlaces` was renamed to `helpers.math._decimalPlaces` @@ -188,6 +288,8 @@ Animation system was completely rewritten in Chart.js v3. Each property can now #### Renamed private APIs +The private APIs listed below were renamed: + * `BarController.calculateBarIndexPixels` was renamed to `BarController._calculateBarIndexPixels` * `BarController.calculateBarValuePixels` was renamed to `BarController._calculateBarValuePixels` * `BarController.getStackCount` was renamed to `BarController._getStackCount` @@ -220,6 +322,8 @@ Animation system was completely rewritten in Chart.js v3. Each property can now ### Changed +The APIs listed in this section have changed in signature or behaviour from version 2. + #### Scales * `Scale.getLabelForIndex` was replaced by `scale.getLabelForValue`
false
Other
chartjs
Chart.js
1212ebde868297ed6922887b57aedaa4f0200ac9.json
Allow running releases on v3 release branch (#7185) * Allow running releases on v3 release branch * Remove `on` statement from yml config
.travis.yml
@@ -36,8 +36,7 @@ deploy: - provider: script script: ./scripts/release.sh skip_cleanup: true - on: - branch: release + if: branch IN (release, release-3.x) - provider: releases api_key: $GITHUB_AUTH_TOKEN skip_cleanup: true
false
Other
chartjs
Chart.js
e1796d361fe7a942168a4193e2f7ec14b7ee1c49.json
expose boxWidth and boxHeight on tooltip (#6995)
docs/configuration/tooltip.md
@@ -42,6 +42,8 @@ The tooltip configuration is passed into the `options.tooltips` namespace. The g | `cornerRadius` | `number` | `6` | Radius of tooltip corner curves. | `multiKeyBackground` | `Color` | `'#fff'` | Color to draw behind the colored boxes when multiple items are in the tooltip. | `displayColors` | `boolean` | `true` | If true, color boxes are shown in the tooltip. +| `boxWidth` | `number` | `bodyFontSize` | Width of the color box if displayColors is true. +| `boxHeight` | `number` | `bodyFontSize` | Height of the color box if displayColors is true. | `borderColor` | `Color` | `'rgba(0, 0, 0, 0)'` | Color of the border. | `borderWidth` | `number` | `0` | Size of the border. | `rtl` | `boolean` | | `true` for rendering the legends from right to left.
true
Other
chartjs
Chart.js
e1796d361fe7a942168a4193e2f7ec14b7ee1c49.json
expose boxWidth and boxHeight on tooltip (#6995)
src/plugins/plugin.tooltip.js
@@ -242,6 +242,9 @@ function resolveOptions(options) { options.bodyFontStyle = valueOrDefault(options.bodyFontStyle, defaults.fontStyle); options.bodyFontSize = valueOrDefault(options.bodyFontSize, defaults.fontSize); + options.boxHeight = valueOrDefault(options.boxHeight, options.bodyFontSize); + options.boxWidth = valueOrDefault(options.boxWidth, options.bodyFontSize); + options.titleFontFamily = valueOrDefault(options.titleFontFamily, defaults.fontFamily); options.titleFontStyle = valueOrDefault(options.titleFontStyle, defaults.fontStyle); options.titleFontSize = valueOrDefault(options.titleFontSize, defaults.fontSize); @@ -259,9 +262,10 @@ function resolveOptions(options) { function getTooltipSize(tooltip) { const ctx = tooltip._chart.ctx; const {body, footer, options, title} = tooltip; - const {bodyFontSize, footerFontSize, titleFontSize} = options; + const {bodyFontSize, footerFontSize, titleFontSize, boxWidth, boxHeight} = options; const titleLineCount = title.length; const footerLineCount = footer.length; + const bodyLineItemCount = body.length; let height = options.yPadding * 2; // Tooltip Padding let width = 0; @@ -276,7 +280,10 @@ function getTooltipSize(tooltip) { + options.titleMarginBottom; } if (combinedBodyLength) { - height += combinedBodyLength * bodyFontSize + // Body lines may include some extra height depending on boxHeight + const bodyLineHeight = options.displayColors ? Math.max(boxHeight, bodyFontSize) : bodyFontSize; + height += bodyLineItemCount * bodyLineHeight + + (combinedBodyLength - bodyLineItemCount) * bodyFontSize + (combinedBodyLength - 1) * options.bodySpacing; } if (footerLineCount) { @@ -301,7 +308,7 @@ function getTooltipSize(tooltip) { helpers.each(tooltip.beforeBody.concat(tooltip.afterBody), maxLineWidth); // Body lines may include some extra width due to the color box - widthPadding = options.displayColors ? (bodyFontSize + 2) : 0; + widthPadding = options.displayColors ? (boxWidth + 2) : 0; helpers.each(body, (bodyItem) => { helpers.each(bodyItem.before, maxLineWidth); helpers.each(bodyItem.lines, maxLineWidth); @@ -757,22 +764,24 @@ export class Tooltip extends Element { const me = this; const options = me.options; const labelColors = me.labelColors[i]; - const bodyFontSize = options.bodyFontSize; + const {boxHeight, boxWidth, bodyFontSize} = options; const colorX = getAlignedX(me, 'left'); const rtlColorX = rtlHelper.x(colorX); + const yOffSet = boxHeight < bodyFontSize ? (bodyFontSize - boxHeight) / 2 : 0; + const colorY = pt.y + yOffSet; // Fill a white rect so that colours merge nicely if the opacity is < 1 ctx.fillStyle = options.multiKeyBackground; - ctx.fillRect(rtlHelper.leftForLtr(rtlColorX, bodyFontSize), pt.y, bodyFontSize, bodyFontSize); + ctx.fillRect(rtlHelper.leftForLtr(rtlColorX, boxWidth), colorY, boxWidth, boxHeight); // Border ctx.lineWidth = 1; ctx.strokeStyle = labelColors.borderColor; - ctx.strokeRect(rtlHelper.leftForLtr(rtlColorX, bodyFontSize), pt.y, bodyFontSize, bodyFontSize); + ctx.strokeRect(rtlHelper.leftForLtr(rtlColorX, boxWidth), colorY, boxWidth, boxHeight); // Inner square ctx.fillStyle = labelColors.backgroundColor; - ctx.fillRect(rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), bodyFontSize - 2), pt.y + 1, bodyFontSize - 2, bodyFontSize - 2); + ctx.fillRect(rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2), colorY + 1, boxWidth - 2, boxHeight - 2); // restore fillStyle ctx.fillStyle = me.labelTextColors[i]; @@ -781,14 +790,15 @@ export class Tooltip extends Element { drawBody(pt, ctx) { const me = this; const {body, options} = me; - const {bodyFontSize, bodySpacing, bodyAlign, displayColors} = options; + const {bodyFontSize, bodySpacing, bodyAlign, displayColors, boxHeight, boxWidth} = options; + let bodyLineHeight = bodyFontSize; let xLinePadding = 0; const rtlHelper = getRtlHelper(options.rtl, me.x, me.width); const fillLineOfText = function(line) { - ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyFontSize / 2); - pt.y += bodyFontSize + bodySpacing; + ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2); + pt.y += bodyLineHeight + bodySpacing; }; const bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign); @@ -805,7 +815,7 @@ export class Tooltip extends Element { helpers.each(me.beforeBody, fillLineOfText); xLinePadding = displayColors && bodyAlignForCalculation !== 'right' - ? bodyAlign === 'center' ? (bodyFontSize / 2 + 1) : (bodyFontSize + 2) + ? bodyAlign === 'center' ? (boxWidth / 2 + 1) : (boxWidth + 2) : 0; // Draw body lines now @@ -820,17 +830,21 @@ export class Tooltip extends Element { // Draw Legend-like boxes if needed if (displayColors && lines.length) { me._drawColorBox(ctx, pt, i, rtlHelper); + bodyLineHeight = Math.max(bodyFontSize, boxHeight); } for (j = 0, jlen = lines.length; j < jlen; ++j) { fillLineOfText(lines[j]); + // Reset for any lines that don't include colorbox + bodyLineHeight = bodyFontSize; } helpers.each(bodyItem.after, fillLineOfText); } // Reset back to 0 for after body xLinePadding = 0; + bodyLineHeight = bodyFontSize; // After body lines helpers.each(me.afterBody, fillLineOfText);
true
Other
chartjs
Chart.js
6836e514bf2619ee926b0b85996324f8851bc6c2.json
Make update_latest work with alpha, beta, etc. (#7177) Make update_latest work with alpha, beta, etc.
scripts/deploy.sh
@@ -20,10 +20,22 @@ fi function update_latest { local out_path=$1 + + # The most recent directory whose name is a version number local latest=($(ls -v $out_path | egrep '^('$VERSION_REGEX')$' | tail -1)) + + # As soon as a single version is deployed this line is a no-op if [ "$latest" == "" ]; then latest='master'; fi - rm -f $out_path/latest - ln -s $latest $out_path/latest + + # Don't update "latest" on alpha or beta releases + if [[ "$latest" =~ ^[^-]+$ ]]; then + rm -f $out_path/latest + ln -s $latest $out_path/latest + fi + + # Always update "next" + rm -f $out_path/next + ln -s $latest $out_path/next } function deploy_files {
false
Other
chartjs
Chart.js
788dbd4499f71063357b2dbc2ba29a4e1f5282c6.json
Alphabetize element default options (#7170) * Alphabetize element default options * Add arc * Add missing comma
src/elements/element.arc.js
@@ -6,9 +6,9 @@ const TAU = Math.PI * 2; defaults.set('elements', { arc: { backgroundColor: defaults.color, + borderAlign: 'center', borderColor: '#fff', - borderWidth: 2, - borderAlign: 'center' + borderWidth: 2 } });
true
Other
chartjs
Chart.js
788dbd4499f71063357b2dbc2ba29a4e1f5282c6.json
Alphabetize element default options (#7170) * Alphabetize element default options * Add arc * Add missing comma
src/elements/element.line.js
@@ -13,16 +13,16 @@ const defaultColor = defaults.color; defaults.set('elements', { line: { - tension: 0.4, backgroundColor: defaultColor, - borderWidth: 3, - borderColor: defaultColor, borderCapStyle: 'butt', + borderColor: defaultColor, borderDash: [], - borderDashOffset: 0.0, + borderDashOffset: 0, borderJoinStyle: 'miter', + borderWidth: 3, capBezierPoints: true, - fill: true + fill: true, + tension: 0.4 } });
true
Other
chartjs
Chart.js
788dbd4499f71063357b2dbc2ba29a4e1f5282c6.json
Alphabetize element default options (#7170) * Alphabetize element default options * Add arc * Add missing comma
src/elements/element.point.js
@@ -6,15 +6,14 @@ const defaultColor = defaults.color; defaults.set('elements', { point: { - radius: 3, - pointStyle: 'circle', backgroundColor: defaultColor, borderColor: defaultColor, borderWidth: 1, - // Hover hitRadius: 1, + hoverBorderWidth: 1, hoverRadius: 4, - hoverBorderWidth: 1 + pointStyle: 'circle', + radius: 3 } });
true
Other
chartjs
Chart.js
6638549a7517387fe5ac8ec877c064808c709334.json
Remove unused constructor parameter (#7171)
src/controllers/controller.bubble.js
@@ -124,6 +124,8 @@ export default class BubbleController extends DatasetController { } /** + * @param {number} index + * @param {string} [mode] * @protected */ resolveDataElementOptions(index, mode) {
true
Other
chartjs
Chart.js
6638549a7517387fe5ac8ec877c064808c709334.json
Remove unused constructor parameter (#7171)
src/core/core.element.js
@@ -5,16 +5,12 @@ export default class Element { static extend = inherits; - constructor(cfg) { + constructor() { this.x = undefined; this.y = undefined; this.active = false; this.options = undefined; this.$animations = undefined; - - if (cfg) { - Object.assign(this, cfg); - } } /**
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
docs/axes/cartesian/time.md
@@ -4,7 +4,7 @@ The time scale is used to display times and dates. When building its ticks, it w ## Date Adapters -The time scale requires both a date library and corresponding adapter to be present. By default, Chart.js includes an adapter for Moment.js. You may wish to choose from [other available adapters](https://github.com/chartjs/awesome#adapters) instead. +The time scale **requires** both a date library and corresponding adapter to be present. Please choose from the [available adapters](https://github.com/chartjs/awesome#adapters). ## Data Sets
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
docs/getting-started/integration.md
@@ -35,32 +35,14 @@ require(['path/to/chartjs/dist/Chart.min.js'], function(Chart){ }); ``` -**Note:** in order to use the time scale, you need to make sure [one of the available date adapters](https://github.com/chartjs/awesome#adapters) and corresponding date library are fully loaded **before** requiring Chart.js. The date adapter for Moment.js is included with Chart.js, but you still need to include Moment.js itself if this is the date adapter you choose to use. You can either use a shim: +**Note:** in order to use the time scale, you need to make sure [one of the available date adapters](https://github.com/chartjs/awesome#adapters) and corresponding date library are fully loaded **after** requiring Chart.js. For this you can use nested requires: ```javascript -require.config({ - shim: { - 'chartjs': { - deps: ['moment'] // enforce moment to be loaded before chartjs - } - }, - paths: { - 'chartjs': 'path/to/chartjs/dist/Chart.min.js', - 'moment': 'path/to/moment' - } -}); - require(['chartjs'], function(Chart) { - new Chart(ctx, {...}); -}); -``` - -or simply use two nested `require()`: - -```javascript -require(['moment'], function() { - require(['chartjs'], function(Chart) { - new Chart(ctx, {...}); + require(['moment'], function() { + require(['chartjs-adapter-moment'], function() { + new Chart(ctx, {...}); + }); }); }); ```
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
docs/getting-started/v3-migration.md
@@ -15,7 +15,7 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released ### Setup and installation * Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`. Please see the [installation](installation.md) and [integration](integration.md) docs for details on the recommended way to setup Chart.js if you were using these builds. -* `moment` is no longer specified as an npm dependency. If you are using the time scale, you must include one of [the available adapters](https://github.com/chartjs/awesome#adapters) and corresponding date library. If you are using a date library other than moment, you no longer need to exclude moment from your build. +* `moment` is no longer specified as an npm dependency. If you are using the time scale, you must include one of [the available adapters](https://github.com/chartjs/awesome#adapters) and corresponding date library. You no longer need to exclude moment from your build. ### Ticks
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
karma.conf.js
@@ -55,7 +55,8 @@ module.exports = function(karma) { {pattern: 'test/fixtures/**/*.png', included: false}, 'node_modules/moment/min/moment.min.js', 'test/index.js', - 'src/index.js' + 'src/index.js', + 'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js' ].concat((args.inputs || 'test/specs/**/*.js').split(';')), preprocessors: {
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
package-lock.json
@@ -3932,6 +3932,12 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "chartjs-adapter-moment": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/chartjs-adapter-moment/-/chartjs-adapter-moment-0.1.1.tgz", + "integrity": "sha512-lFGCiqpn+0e6CEbEKdG1L3LYR0jnKFqtXsExzmEWXGCxdymTFSqntiWAqWAYDblL/QB3sUk881xVGzhWZdn4kQ==", + "dev": true + }, "chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
package.json
@@ -39,6 +39,7 @@ "@rollup/plugin-node-resolve": "^7.1.1", "babel-plugin-istanbul": "^6.0.0", "babel-preset-es2015-rollup": "^3.0.0", + "chartjs-adapter-moment": "^0.1.1", "coveralls": "^3.0.9", "eslint": "^6.8.0", "eslint-config-chartjs": "^0.2.0",
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
rollup.config.js
@@ -4,7 +4,6 @@ const babel = require('rollup-plugin-babel'); const cleanup = require('rollup-plugin-cleanup'); const json = require('@rollup/plugin-json'); -const optional = require('./rollup.plugins').optional; const resolve = require('@rollup/plugin-node-resolve'); const terser = require('rollup-plugin-terser').terser; const pkg = require('./package.json'); @@ -28,9 +27,6 @@ module.exports = [ json(), resolve(), babel(), - optional({ - include: ['moment'] - }), cleanup({ sourcemap: true }) @@ -41,23 +37,14 @@ module.exports = [ banner, format: 'umd', indent: false, - globals: { - moment: 'moment' - } }, - external: [ - 'moment' - ] }, { input, plugins: [ json(), resolve(), babel(), - optional({ - include: ['moment'] - }), terser({ output: { preamble: banner @@ -69,13 +56,7 @@ module.exports = [ file: 'dist/Chart.min.js', format: 'umd', indent: false, - globals: { - moment: 'moment' - } }, - external: [ - 'moment' - ] }, // ES6 builds @@ -97,13 +78,7 @@ module.exports = [ banner, format: 'esm', indent: false, - globals: { - moment: 'moment' - } }, - external: [ - 'moment' - ] }, { input, @@ -122,12 +97,6 @@ module.exports = [ file: 'dist/Chart.esm.min.js', format: 'esm', indent: false, - globals: { - moment: 'moment' - } }, - external: [ - 'moment' - ] }, ];
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
rollup.plugins.js
@@ -1,60 +0,0 @@ -/* eslint-disable import/no-commonjs */ -const UMD_WRAPPER_RE = /(\(function \(global, factory\) \{)((?:\s.*?)*)(\}\(this,)/; -const CJS_FACTORY_RE = /(module.exports = )(factory\(.*?\))( :)/; -const AMD_FACTORY_RE = /(define\()(.*?, factory)(\) :)/; - -function optional(config = {}) { - return { - name: 'optional', - renderChunk(code, chunk, options) { - if (options.format !== 'umd') { - this.error('only UMD format is currently supported'); - } - - const wrapper = UMD_WRAPPER_RE.exec(code); - const include = config.include; - if (!wrapper) { - this.error('failed to parse the UMD wrapper'); - } - - let content = wrapper[2]; - let factory = (CJS_FACTORY_RE.exec(content) || [])[2]; - let updated = false; - - for (const lib of chunk.imports) { - if (!include || include.indexOf(lib) !== -1) { - const regex = new RegExp(`require\\('${lib}'\\)`); - if (!regex.test(factory)) { - this.error(`failed to parse the CJS require for ${lib}`); - } - - // We need to write inline try / catch with explicit require - // in order to enable statical extraction of dependencies: - // try { return require('moment'); } catch(e) {} - const loader = `function() { try { return require('${lib}'); } catch(e) { } }()`; - factory = factory.replace(regex, loader); - updated = true; - } - } - - if (!updated) { - return; - } - - // Replace the CJS factory by our updated one. - content = content.replace(CJS_FACTORY_RE, `$1${factory}$3`); - - // Replace the AMD factory by our updated one: we need to use the - // following AMD form in order to be able to try/catch require: - // define(['require'], function(require) { ... require(...); ... }) - // https://github.com/amdjs/amdjs-api/wiki/AMD#using-require-and-exports - content = content.replace(AMD_FACTORY_RE, `$1['require'], function(require) { return ${factory}; }$3`); - - return code.replace(UMD_WRAPPER_RE, `$1${content}$3`); - } - }; -} - -module.exports = { - optional -};
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
samples/.eslintrc.yml
@@ -3,6 +3,7 @@ globals: Chart: true Samples: true moment: true + luxon: true randomScalingFactor: true rules:
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
samples/scales/financial.html
@@ -3,8 +3,9 @@ <head> <title>Line Chart</title> - <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0/moment.min.js"></script> <script src="../../dist/Chart.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> + <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> <script src="../utils.js"></script> <style> canvas { @@ -39,14 +40,14 @@ <button id="update">update</button> <script> function isFirstUnitOfPeriod(date, unit, period) { - let first = date.clone().startOf(period); - while (first.isoWeekday() > 5) { - first.add(1, 'days'); + let first = date.startOf(period); + while (first.weekday > 5) { + first = first.plus({day: 1}); } if (unit === 'second' || unit === 'minute' || unit === 'hour') { - first = first.hours(9).minutes(30); + first = first.set({hour: 9, minute: 30}); } - return date.isSame(first); + return date === first; } // Generate data between the stock market hours of 9:30am - 5pm. @@ -59,17 +60,17 @@ } function beforeNineThirty(date) { - return date.hour() < 9 || (date.hour() === 9 && date.minute() < 30); + return date.hour < 9 || (date.hour === 9 && date.minute < 30); } function after4pm(date) { - return date.hour() > 16 || (date.hour() === 16 && date.minute() > 0); + return date.hour > 16 || (date.hour === 16 && date.minute > 0); } // Returns true if outside 9:30am-4pm on a weekday function outsideMarketHours(date) { - if (date.isoWeekday() > 5) { + if (date.weekday > 5) { return true; } if (unitLessThanDay() && (beforeNineThirty(date) || after4pm(date))) { @@ -86,22 +87,24 @@ const open = randomNumber(lastClose * 0.95, lastClose * 1.05).toFixed(2); const close = randomNumber(open * 0.95, open * 1.05).toFixed(2); return { - t: date.valueOf(), + x: date.valueOf(), y: close }; } - let date = moment('Jan 01 1990', 'MMM DD YYYY'); - const now = moment(); + let date = luxon.DateTime.fromFormat('Jan 01 1990', 'LLL dd yyyy'); + const now = luxon.DateTime.local(); const data = []; const lessThanDay = unitLessThanDay(); - for (; data.length < 600 && date.isBefore(now); date = date.clone().add(1, unit).startOf(unit)) { + const plus = {}; + plus[unit] = 1; + for (; data.length < 600 && date < now; date = date.plus(plus).startOf(unit)) { if (outsideMarketHours(date)) { if (!lessThanDay || !beforeNineThirty(date)) { - date = date.clone().add(date.isoWeekday() >= 5 ? 8 - date.isoWeekday() : 1, 'day'); + date = date.plus({day: date.weekday >= 5 ? 8 - date.weekday : 1}); } if (lessThanDay) { - date = date.hour(9).minute(30).second(0); + date = date.set({hour: 9, minute: 30}); } } data.push(randomBar(date, data.length > 0 ? data[data.length - 1].y : 30)); @@ -164,7 +167,7 @@ // major ticks const ticks = scale.ticks; for (let i = 0; i < ticks.length; i++) { - ticks[i].major = !majorUnit || isFirstUnitOfPeriod(moment(ticks[i].value), unit, majorUnit); + ticks[i].major = !majorUnit || isFirstUnitOfPeriod(luxon.DateTime.fromMillis(ticks[i].value), unit, majorUnit); } scale.ticks = ticks; }
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
samples/scales/time/combo.html
@@ -3,8 +3,8 @@ <head> <title>Line Chart - Combo Time Scale</title> - <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0/moment.min.js"></script> <script src="../../../dist/Chart.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns@1.0.0/dist/chartjs-adapter-date-fns.bundle.min.js"></script> <script src="../../utils.js"></script> <style> canvas { @@ -28,7 +28,10 @@ <button id="removeData">Remove Data</button> <script> function newDate(days) { - return moment().startOf('day').add(days, 'd').valueOf(); + var date = new Date(); + date.setHours(0, 0, 0, 0); + date.setDate(date.getDate() + days); + return date.valueOf(); } var labels = [];
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
samples/scales/time/line-max-span.html
@@ -3,8 +3,9 @@ <head> <title>Time Scale Point Data</title> - <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0/moment.min.js"></script> <script src="../../../dist/Chart.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0"></script> + <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@0.1.1"></script> <script src="../../utils.js"></script> <style> canvas {
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
samples/scales/time/line-point-data.html
@@ -3,8 +3,9 @@ <head> <title>Time Scale Point Data</title> - <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0/moment.min.js"></script> <script src="../../../dist/Chart.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0"></script> + <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@0.1.1"></script> <script src="../../utils.js"></script> <style> canvas {
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
samples/scales/time/line.html
@@ -3,8 +3,9 @@ <head> <title>Line Chart</title> - <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0/moment.min.js"></script> <script src="../../../dist/Chart.min.js"></script> + <script src="https://cdn.jsdelivr.net/npm/moment@2.24.0"></script> + <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@0.1.1"></script> <script src="../../utils.js"></script> <style> canvas {
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
src/adapters/adapter.moment.js
@@ -1,58 +0,0 @@ -// TODO v3 - make this adapter external (chartjs-adapter-moment) - -import moment from 'moment'; -import adapters from '../core/core.adapters'; - -const FORMATS = { - datetime: 'MMM D, YYYY, h:mm:ss a', - millisecond: 'h:mm:ss.SSS a', - second: 'h:mm:ss a', - minute: 'h:mm a', - hour: 'hA', - day: 'MMM D', - week: 'll', - month: 'MMM YYYY', - quarter: '[Q]Q - YYYY', - year: 'YYYY' -}; - -adapters._date.override(typeof moment === 'function' ? { - _id: 'moment', // DEBUG ONLY - - formats() { - return FORMATS; - }, - - parse(value, format) { - if (typeof value === 'string' && typeof format === 'string') { - value = moment(value, format); - } else if (!(value instanceof moment)) { - value = moment(value); - } - return value.isValid() ? value.valueOf() : null; - }, - - format(time, format) { - return moment(time).format(format); - }, - - add(time, amount, unit) { - return moment(time).add(amount, unit).valueOf(); - }, - - diff(max, min, unit) { - return moment(max).diff(moment(min), unit); - }, - - startOf(time, unit, weekday) { - time = moment(time); - if (unit === 'isoWeek') { - return time.isoWeekday(weekday).valueOf(); - } - return time.startOf(unit).valueOf(); - }, - - endOf(time, unit) { - return moment(time).endOf(unit).valueOf(); - } -} : {});
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
src/adapters/index.js
@@ -1,8 +0,0 @@ -// ----------------------------------------------------------------------------- -// IMPORTANT: do NOT submit new adapters to this repository, instead -// create an external library named `chartjs-adapter-{lib-name}` -// ----------------------------------------------------------------------------- - -// Built-in moment adapter that we need to keep for backward compatibility -// https://github.com/chartjs/Chart.js/issues/5542 -import './adapter.moment';
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
src/index.js
@@ -45,9 +45,6 @@ Chart.Ticks = Ticks; import * as scales from './scales/index'; Object.keys(scales).forEach(key => Chart.scaleService.registerScale(scales[key])); -// Load to register built-in adapters (as side effects) -import './adapters/index'; - // Loading built-in plugins import plugins from './plugins/index'; for (const k in plugins) {
true
Other
chartjs
Chart.js
df3c73cc5e05f92a13cf601bff4724d2b3874f7a.json
Give the boot to chartjs-adapter-moment (#7155) Remove default of using chartjs-adapter-moment
src/scales/scale.time.js
@@ -539,10 +539,10 @@ const defaultConfig = { adapters: {}, time: { - parser: false, // false == a pattern string from https://momentjs.com/docs/#/parsing/string-format/ or a custom callback that converts its argument to a moment + parser: false, // false == a pattern string from or a custom callback that converts its argument to a timestamp unit: false, // false == automatic or override with week, month, year, etc. round: false, // none, or override with week, month, year, etc. - isoWeekday: false, // override week start day - see https://momentjs.com/docs/#/get-set/iso-weekday/ + isoWeekday: false, // override week start day minUnit: 'millisecond', displayFormats: {} },
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
docs/developers/axes.md
@@ -6,14 +6,16 @@ Axes in Chart.js can be individually extended. Axes should always derive from `C let MyScale = Chart.Scale.extend({ /* extensions ... */ }); +MyScale.id = 'myScale'; +MyScale.defaults = defaultConfigObject; // MyScale is now derived from Chart.Scale ``` Once you have created your scale class, you need to register it with the global chart object so that it can be used. A default config for the scale may be provided when registering the constructor. The first parameter to the register function is a string key that is used later to identify which scale type to use for a chart. ```javascript -Chart.scaleService.registerScaleType('myScale', MyScale, defaultConfigObject); +Chart.scaleService.registerScale(MyScale); ``` To use the new scale, simply pass in the string key to the config when creating a chart. @@ -25,7 +27,7 @@ var lineChart = new Chart(ctx, { options: { scales: { y: { - type: 'myScale' // this is the same key that was passed to the registerScaleType function + type: 'myScale' // this is the same id that was set on the scale } } }
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
docs/getting-started/v3-migration.md
@@ -223,6 +223,7 @@ Animation system was completely rewritten in Chart.js v3. Each property can now * `Scale.getLabelForIndex` was replaced by `scale.getLabelForValue` * `Scale.getPixelForValue` now has only one parameter. For the `TimeScale` that parameter must be millis since the epoch +* `ScaleService.registerScaleType` was renamed to `ScaleService.registerScale` and now takes a scale constructors which is expected to have `id` and `defaults` properties. ##### Ticks
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/core/core.scaleService.js
@@ -11,9 +11,11 @@ export default { // Scale config defaults defaults: {}, - registerScaleType(type, scaleConstructor, scaleDefaults) { - this.constructors[type] = scaleConstructor; - this.defaults[type] = clone(scaleDefaults); + registerScale(scaleConstructor) { + const me = this; + const type = scaleConstructor.id; + me.constructors[type] = scaleConstructor; + me.defaults[type] = clone(scaleConstructor.defaults); }, getScaleConstructor(type) { return Object.prototype.hasOwnProperty.call(this.constructors, type) ? this.constructors[type] : undefined;
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/index.js
@@ -42,11 +42,8 @@ Chart.scaleService = scaleService; Chart.Ticks = Ticks; // Register built-in scales -import scales from './scales/index'; -Object.keys(scales).forEach((type) => { - const scale = scales[type]; - Chart.scaleService.registerScaleType(type, scale, scale._defaults); -}); +import * as scales from './scales/index'; +Object.keys(scales).forEach(key => Chart.scaleService.registerScale(scales[key])); // Load to register built-in adapters (as side effects) import './adapters/index';
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/scales/index.js
@@ -1,13 +1,5 @@ -import category from './scale.category'; -import linear from './scale.linear'; -import logarithmic from './scale.logarithmic'; -import radialLinear from './scale.radialLinear'; -import time from './scale.time'; - -export default { - category, - linear, - logarithmic, - radialLinear, - time -}; +export {default as CategoryScale} from './scale.category'; +export {default as LinearScale} from './scale.linear'; +export {default as LogarithmicScale} from './scale.logarithmic'; +export {default as RadialLinearScale} from './scale.radialLinear'; +export {default as TimeScale} from './scale.time';
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/scales/scale.category.js
@@ -5,8 +5,9 @@ const defaultConfig = { export default class CategoryScale extends Scale { + static id = 'category'; // INTERNAL: static default options, registered in src/index.js - static _defaults = defaultConfig; + static defaults = defaultConfig; constructor(cfg) { super(cfg);
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/scales/scale.linear.js
@@ -11,8 +11,9 @@ const defaultConfig = { export default class LinearScale extends LinearScaleBase { + static id = 'linear'; // INTERNAL: static default options, registered in src/index.js - static _defaults = defaultConfig; + static defaults = defaultConfig; determineDataLimits() { const me = this;
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/scales/scale.logarithmic.js
@@ -59,8 +59,9 @@ const defaultConfig = { export default class LogarithmicScale extends Scale { + static id = 'logarithmic'; // INTERNAL: static default options, registered in src/index.js - static _defaults = defaultConfig; + static defaults = defaultConfig; constructor(cfg) { super(cfg);
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/scales/scale.radialLinear.js
@@ -292,8 +292,9 @@ function numberOrZero(param) { export default class RadialLinearScale extends LinearScaleBase { + static id = 'radialLinear'; // INTERNAL: static default options, registered in src/index.js - static _defaults = defaultConfig; + static defaults = defaultConfig; constructor(cfg) { super(cfg);
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
src/scales/scale.time.js
@@ -567,8 +567,9 @@ const defaultConfig = { export default class TimeScale extends Scale { + static id = 'time'; // INTERNAL: static default options, registered in src/index.js - static _defaults = defaultConfig; + static defaults = defaultConfig; /** * @param {object} props
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
test/specs/core.scale.tests.js
@@ -460,7 +460,9 @@ describe('Core.scale', function() { return ['tick']; } }); - Chart.scaleService.registerScaleType('customScale', customScale, {}); + customScale.id = 'customScale'; + customScale.defaults = {}; + Chart.scaleService.registerScale(customScale); var chart = window.acquireChart({ type: 'line',
true
Other
chartjs
Chart.js
3c1e04f928f74356d81c12c2034b2bcfde4472ba.json
Allow registering scale with single parameter (#7157) Allow registering scale with single parameter
test/specs/core.scaleService.tests.js
@@ -2,14 +2,15 @@ describe('Test the scale service', function() { it('should update scale defaults', function() { - var defaults = { - testProp: true - }; var type = 'my_test_type'; var Constructor = function() { this.initialized = true; }; - Chart.scaleService.registerScaleType(type, Constructor, defaults); + Constructor.id = type; + Constructor.defaults = { + testProp: true + }; + Chart.scaleService.registerScale(Constructor); // Should equal defaults but not be an identical object expect(Chart.scaleService.getScaleDefaults(type)).toEqual(jasmine.objectContaining({
true
Other
chartjs
Chart.js
fc0a056fee9d33b20883bdf449493baf4d7acec6.json
Remove position defaults (#7165)
src/controllers/controller.bubble.js
@@ -11,12 +11,10 @@ defaults.set('bubble', { }, scales: { x: { - type: 'linear', - position: 'bottom' + type: 'linear' }, y: { - type: 'linear', - position: 'left' + type: 'linear' } },
true
Other
chartjs
Chart.js
fc0a056fee9d33b20883bdf449493baf4d7acec6.json
Remove position defaults (#7165)
src/controllers/controller.horizontalBar.js
@@ -10,12 +10,10 @@ defaults.set('horizontalBar', { scales: { x: { type: 'linear', - position: 'bottom', beginAtZero: true }, y: { type: 'category', - position: 'left', offset: true, gridLines: { offsetGridLines: true
true
Other
chartjs
Chart.js
fc0a056fee9d33b20883bdf449493baf4d7acec6.json
Remove position defaults (#7165)
src/controllers/controller.scatter.js
@@ -4,12 +4,10 @@ import defaults from '../core/core.defaults'; defaults.set('scatter', { scales: { x: { - type: 'linear', - position: 'bottom' + type: 'linear' }, y: { - type: 'linear', - position: 'left' + type: 'linear' } },
true
Other
chartjs
Chart.js
774493e23d1e3ee99f7d865e7852baf73bd9fb44.json
Add some tests to improve coverage (#7164)
test/matchers.js
@@ -69,6 +69,19 @@ function toBeCloseToPixel() { }; } +function toBeCloseToPoint() { + function rnd(v) { + return Math.round(v * 100) / 100; + } + return { + compare: function(actual, expected) { + return { + pass: rnd(actual.x) === rnd(expected.x) && rnd(actual.y) === rnd(expected.y) + }; + } + }; +} + function toEqualOneOf() { return { compare: function(actual, expecteds) { @@ -197,9 +210,10 @@ function toEqualImageData() { } export default { - toBeCloseToPixel: toBeCloseToPixel, - toEqualOneOf: toEqualOneOf, - toBeValidChart: toBeValidChart, - toBeChartOfSize: toBeChartOfSize, - toEqualImageData: toEqualImageData + toBeCloseToPixel, + toBeCloseToPoint, + toEqualOneOf, + toBeValidChart, + toBeChartOfSize, + toEqualImageData };
true
Other
chartjs
Chart.js
774493e23d1e3ee99f7d865e7852baf73bd9fb44.json
Add some tests to improve coverage (#7164)
test/specs/core.helpers.tests.js
@@ -13,47 +13,4 @@ describe('Core helper tests', function() { expect(helpers.uid()).toBe(uid + 2); expect(helpers.uid()).toBe(uid + 3); }); - - describe('Color helper', function() { - function isColorInstance(obj) { - return typeof obj === 'object' && obj.valid; - } - - it('should return a color when called with a color', function() { - expect(isColorInstance(helpers.color('rgb(1, 2, 3)'))).toBe(true); - }); - }); - - describe('Background hover color helper', function() { - it('should return a CanvasPattern when called with a CanvasPattern', function(done) { - var dots = new Image(); - dots.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAAD1BMVEUAAAD///////////////+PQt5oAAAABXRSTlMAHlFhZsfk/BEAAAAqSURBVHgBY2BgZGJmYmSAAUYWEIDzmcBcJhiXGcxlRpPFrhdmMiqgvX0AcGIBEUAo6UAAAAAASUVORK5CYII='; - dots.onload = function() { - var chartContext = document.createElement('canvas').getContext('2d'); - var patternCanvas = document.createElement('canvas'); - var patternContext = patternCanvas.getContext('2d'); - var pattern = patternContext.createPattern(dots, 'repeat'); - patternContext.fillStyle = pattern; - - var backgroundColor = helpers.getHoverColor(chartContext.createPattern(patternCanvas, 'repeat')); - - expect(backgroundColor instanceof CanvasPattern).toBe(true); - - done(); - }; - }); - - it('should return a CanvasGradient when called with a CanvasGradient', function() { - var context = document.createElement('canvas').getContext('2d'); - var gradient = context.createLinearGradient(0, 1, 2, 3); - - expect(helpers.getHoverColor(gradient) instanceof CanvasGradient).toBe(true); - }); - - it('should return a modified version of color when called with a color', function() { - var originalColorRGB = 'rgb(70, 191, 189)'; - - expect(helpers.getHoverColor('#46BFBD')).not.toEqual(originalColorRGB); - }); - }); });
true
Other
chartjs
Chart.js
774493e23d1e3ee99f7d865e7852baf73bd9fb44.json
Add some tests to improve coverage (#7164)
test/specs/helpers.collection.tests.js
@@ -0,0 +1,30 @@ +import {_lookup, _lookupByKey, _rlookupByKey} from '../../src/helpers/helpers.collection'; + +describe('helpers.interpolation', function() { + it('Should do binary search', function() { + const data = [0, 2, 6, 9]; + expect(_lookup(data, 0)).toEqual({lo: 0, hi: 1}); + expect(_lookup(data, 1)).toEqual({lo: 0, hi: 1}); + expect(_lookup(data, 3)).toEqual({lo: 1, hi: 2}); + expect(_lookup(data, 6)).toEqual({lo: 1, hi: 2}); + expect(_lookup(data, 9)).toEqual({lo: 2, hi: 3}); + }); + + it('Should do binary search by key', function() { + const data = [{x: 0}, {x: 2}, {x: 6}, {x: 9}]; + expect(_lookupByKey(data, 'x', 0)).toEqual({lo: 0, hi: 1}); + expect(_lookupByKey(data, 'x', 1)).toEqual({lo: 0, hi: 1}); + expect(_lookupByKey(data, 'x', 3)).toEqual({lo: 1, hi: 2}); + expect(_lookupByKey(data, 'x', 6)).toEqual({lo: 1, hi: 2}); + expect(_lookupByKey(data, 'x', 9)).toEqual({lo: 2, hi: 3}); + }); + + it('Should do reverse binary search by key', function() { + const data = [{x: 10}, {x: 7}, {x: 3}, {x: 0}]; + expect(_rlookupByKey(data, 'x', 0)).toEqual({lo: 2, hi: 3}); + expect(_rlookupByKey(data, 'x', 3)).toEqual({lo: 2, hi: 3}); + expect(_rlookupByKey(data, 'x', 5)).toEqual({lo: 1, hi: 2}); + expect(_rlookupByKey(data, 'x', 8)).toEqual({lo: 0, hi: 1}); + expect(_rlookupByKey(data, 'x', 10)).toEqual({lo: 0, hi: 1}); + }); +});
true
Other
chartjs
Chart.js
774493e23d1e3ee99f7d865e7852baf73bd9fb44.json
Add some tests to improve coverage (#7164)
test/specs/helpers.color.tests.js
@@ -0,0 +1,44 @@ +import {color, getHoverColor} from '../../src/helpers/helpers.color'; + +describe('Color helper', function() { + function isColorInstance(obj) { + return typeof obj === 'object' && obj.valid; + } + + it('should return a color when called with a color', function() { + expect(isColorInstance(color('rgb(1, 2, 3)'))).toBe(true); + }); +}); + +describe('Background hover color helper', function() { + it('should return a CanvasPattern when called with a CanvasPattern', function(done) { + var dots = new Image(); + dots.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAAD1BMVEUAAAD///////////////+PQt5oAAAABXRSTlMAHlFhZsfk/BEAAAAqSURBVHgBY2BgZGJmYmSAAUYWEIDzmcBcJhiXGcxlRpPFrhdmMiqgvX0AcGIBEUAo6UAAAAAASUVORK5CYII='; + dots.onload = function() { + var chartContext = document.createElement('canvas').getContext('2d'); + var patternCanvas = document.createElement('canvas'); + var patternContext = patternCanvas.getContext('2d'); + var pattern = patternContext.createPattern(dots, 'repeat'); + patternContext.fillStyle = pattern; + + var backgroundColor = getHoverColor(chartContext.createPattern(patternCanvas, 'repeat')); + + expect(backgroundColor instanceof CanvasPattern).toBe(true); + + done(); + }; + }); + + it('should return a CanvasGradient when called with a CanvasGradient', function() { + var context = document.createElement('canvas').getContext('2d'); + var gradient = context.createLinearGradient(0, 1, 2, 3); + + expect(getHoverColor(gradient) instanceof CanvasGradient).toBe(true); + }); + + it('should return a modified version of color when called with a color', function() { + var originalColorRGB = 'rgb(70, 191, 189)'; + + expect(getHoverColor('#46BFBD')).not.toEqual(originalColorRGB); + }); +});
true
Other
chartjs
Chart.js
774493e23d1e3ee99f7d865e7852baf73bd9fb44.json
Add some tests to improve coverage (#7164)
test/specs/helpers.interpolation.tests.js
@@ -0,0 +1,35 @@ +import {_pointInLine, _steppedInterpolation, _bezierInterpolation} from '../../src/helpers/helpers.interpolation'; + +describe('helpers.interpolation', function() { + it('Should interpolate a point in line', function() { + expect(_pointInLine({x: 10, y: 10}, {x: 20, y: 20}, 0)).toEqual({x: 10, y: 10}); + expect(_pointInLine({x: 10, y: 10}, {x: 20, y: 20}, 0.5)).toEqual({x: 15, y: 15}); + expect(_pointInLine({x: 10, y: 10}, {x: 20, y: 20}, 1)).toEqual({x: 20, y: 20}); + }); + + it('Should intepolate a point in stepped line', function() { + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0, 'before')).toEqual({x: 10, y: 10}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0.4, 'before')).toEqual({x: 14, y: 20}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0.5, 'before')).toEqual({x: 15, y: 20}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 1, 'before')).toEqual({x: 20, y: 20}); + + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0, 'middle')).toEqual({x: 10, y: 10}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0.4, 'middle')).toEqual({x: 14, y: 10}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0.5, 'middle')).toEqual({x: 15, y: 20}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 1, 'middle')).toEqual({x: 20, y: 20}); + + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0, 'after')).toEqual({x: 10, y: 10}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0.4, 'after')).toEqual({x: 14, y: 10}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 0.5, 'after')).toEqual({x: 15, y: 10}); + expect(_steppedInterpolation({x: 10, y: 10}, {x: 20, y: 20}, 1, 'after')).toEqual({x: 20, y: 20}); + }); + + it('Should interpolate a point in curve', function() { + const pt1 = {x: 10, y: 10, controlPointNextX: 12, controlPointNextY: 12}; + const pt2 = {x: 20, y: 30, controlPointPreviousX: 18, controlPointPreviousY: 28}; + + expect(_bezierInterpolation(pt1, pt2, 0)).toEqual({x: 10, y: 10}); + expect(_bezierInterpolation(pt1, pt2, 0.2)).toBeCloseToPoint({x: 11.616, y: 12.656}); + expect(_bezierInterpolation(pt1, pt2, 1)).toEqual({x: 20, y: 30}); + }); +});
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/controllers/controller.bar.js
@@ -1,6 +1,6 @@ import DatasetController from '../core/core.datasetController'; import defaults from '../core/core.defaults'; -import Rectangle from '../elements/element.rectangle'; +import {Rectangle} from '../elements/index'; import {clipArea, unclipArea} from '../helpers/helpers.canvas'; import {isArray, isNullOrUndef, valueOrDefault} from '../helpers/helpers.core'; import {_limitValue, sign} from '../helpers/helpers.math';
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/controllers/controller.bubble.js
@@ -1,6 +1,6 @@ import DatasetController from '../core/core.datasetController'; import defaults from '../core/core.defaults'; -import Point from '../elements/element.point'; +import {Point} from '../elements/index'; import {resolve} from '../helpers/helpers.options'; defaults.set('bubble', {
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/controllers/controller.doughnut.js
@@ -1,6 +1,6 @@ import DatasetController from '../core/core.datasetController'; import defaults from '../core/core.defaults'; -import Arc from '../elements/element.arc'; +import {Arc} from '../elements/index'; import {isArray, valueOrDefault} from '../helpers/helpers.core'; /**
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/controllers/controller.line.js
@@ -1,7 +1,6 @@ import DatasetController from '../core/core.datasetController'; import defaults from '../core/core.defaults'; -import Line from '../elements/element.line'; -import Point from '../elements/element.point'; +import {Line, Point} from '../elements/index'; import {valueOrDefault} from '../helpers/helpers.core'; import {isNumber} from '../helpers/helpers.math'; import {resolve} from '../helpers/helpers.options';
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/controllers/controller.polarArea.js
@@ -1,6 +1,6 @@ import DatasetController from '../core/core.datasetController'; import defaults from '../core/core.defaults'; -import Arc from '../elements/element.arc'; +import {Arc} from '../elements/index'; import {toRadians} from '../helpers/helpers.math'; import {resolve} from '../helpers/helpers.options';
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/controllers/controller.radar.js
@@ -1,7 +1,6 @@ import DatasetController from '../core/core.datasetController'; import defaults from '../core/core.defaults'; -import Line from '../elements/element.line'; -import Point from '../elements/element.point'; +import {Line, Point} from '../elements/index'; import {valueOrDefault} from '../helpers/helpers.core'; defaults.set('radar', {
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/elements/index.js
@@ -1,11 +1,4 @@ -import Arc from './element.arc'; -import Line from './element.line'; -import Point from './element.point'; -import Rectangle from './element.rectangle'; - -export default { - Arc, - Line, - Point, - Rectangle -}; +export {default as Arc} from './element.arc'; +export {default as Line} from './element.line'; +export {default as Point} from './element.point'; +export {default as Rectangle} from './element.rectangle';
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
src/index.js
@@ -1,3 +1,5 @@ +/* eslint-disable import/no-namespace, import/namespace */ + /** * @namespace Chart */ @@ -12,7 +14,7 @@ import controllers from './controllers/index'; import DatasetController from './core/core.datasetController'; import defaults from './core/core.defaults'; import Element from './core/core.element'; -import elements from './elements/index'; +import * as elements from './elements/index'; import Interaction from './core/core.interaction'; import layouts from './core/core.layouts'; import platforms from './platform/platforms';
true
Other
chartjs
Chart.js
ac69e81b045350724f2bc2ff28ed5ccad2690a67.json
Turn elements/index into an index (#7135)
test/specs/global.namespace.tests.js
@@ -20,9 +20,6 @@ describe('Chart namespace', function() { }); describe('Chart.elements', function() { - it('should be an object', function() { - expect(Chart.elements instanceof Object).toBeTruthy(); - }); it('should contains "elements" classes', function() { expect(Chart.elements.Arc instanceof Function).toBeTruthy(); expect(Chart.elements.Line instanceof Function).toBeTruthy();
true
Other
chartjs
Chart.js
f3ef620c6876ad13188f5c95f65b010952d219ea.json
Make test Context an ES6 module (#7142) * Make test Context an ES6 module * Address comments
karma.conf.js
@@ -68,7 +68,7 @@ module.exports = function(karma) { plugins: [ resolve(), babel({exclude: 'node_modules/**'}), // use babel since we have ES proposal features - commonjs() + commonjs({exclude: ['src/**', 'test/**']}) ], output: { name: 'test',
true
Other
chartjs
Chart.js
f3ef620c6876ad13188f5c95f65b010952d219ea.json
Make test Context an ES6 module (#7142) * Make test Context an ES6 module * Address comments
test/context.js
@@ -1,5 +1,5 @@ // Code from https://stackoverflow.com/questions/4406864/html-canvas-unit-testing -var Context = function() { +const Context = function() { this._calls = []; // names/args of recorded calls this._initMethods(); @@ -136,4 +136,4 @@ Context.prototype.resetCalls = function() { this._calls = []; }; -module.exports = Context; +export default Context;
true
Other
chartjs
Chart.js
428411319a24d2d8e4823a80a07fd3038fcc6dfa.json
Create a Tick typedef (#7124)
src/core/core.scale.js
@@ -8,6 +8,7 @@ import Ticks from './core.ticks'; /** * @typedef { import("./core.controller").default } Chart + * @typedef {{value:any, label?:string, major?:boolean}} Tick */ defaults.set('scale', { @@ -64,7 +65,11 @@ defaults.set('scale', { } }); -/** Returns a new array containing numItems from arr */ +/** + * Returns a new array containing numItems from arr + * @param {any[]} arr + * @param {number} numItems + */ function sample(arr, numItems) { const result = []; const increment = arr.length / numItems; @@ -77,6 +82,11 @@ function sample(arr, numItems) { return result; } +/** + * @param {Scale} scale + * @param {number} index + * @param {boolean} offsetGridLines + */ function getPixelForGridLine(scale, index, offsetGridLines) { const length = scale.ticks.length; const validIndex = Math.min(index, length - 1); @@ -104,6 +114,10 @@ function getPixelForGridLine(scale, index, offsetGridLines) { return lineValue; } +/** + * @param {object} caches + * @param {number} length + */ function garbageCollect(caches, length) { each(caches, (cache) => { const gc = cache.gc; @@ -118,10 +132,16 @@ function garbageCollect(caches, length) { }); } +/** + * @param {object} options + */ function getTickMarkLength(options) { return options.drawTicks ? options.tickMarkLength : 0; } +/** + * @param {object} options + */ function getScaleLabelHeight(options) { if (!options.display) { return 0; @@ -133,6 +153,9 @@ function getScaleLabelHeight(options) { return font.lineHeight + padding.height; } +/** + * @param {number[]} arr + */ function getEvenSpacing(arr) { const len = arr.length; let i, diff; @@ -149,6 +172,12 @@ function getEvenSpacing(arr) { return diff; } +/** + * @param {number[]} majorIndices + * @param {Tick[]} ticks + * @param {number} axisLength + * @param {number} ticksLimit + */ function calculateSpacing(majorIndices, ticks, axisLength, ticksLimit) { const evenMajorSpacing = getEvenSpacing(majorIndices); const spacing = ticks.length / ticksLimit; @@ -169,6 +198,9 @@ function calculateSpacing(majorIndices, ticks, axisLength, ticksLimit) { return Math.max(spacing, 1); } +/** + * @param {Tick[]} ticks + */ function getMajorIndices(ticks) { const result = []; let i, ilen; @@ -180,6 +212,12 @@ function getMajorIndices(ticks) { return result; } +/** + * @param {Tick[]} ticks + * @param {Tick[]} newTicks + * @param {number[]} majorIndices + * @param {number} spacing + */ function skipMajors(ticks, newTicks, majorIndices, spacing) { let count = 0; let next = majorIndices[0]; @@ -195,6 +233,13 @@ function skipMajors(ticks, newTicks, majorIndices, spacing) { } } +/** + * @param {Tick[]} ticks + * @param {Tick[]} newTicks + * @param {number} spacing + * @param {number} [majorStart] + * @param {number} [majorEnd] + */ function skip(ticks, newTicks, spacing, majorStart, majorEnd) { const start = valueOrDefault(majorStart, 0); const end = Math.min(valueOrDefault(majorEnd, ticks.length), ticks.length); @@ -279,7 +324,7 @@ export default class Scale extends Element { this.labelRotation = undefined; this.min = undefined; this.max = undefined; - /** @type {object[]} */ + /** @type {Tick[]} */ this.ticks = []; /** @type {object[]|null} */ this._gridLineItems = null; @@ -394,8 +439,8 @@ export default class Scale extends Element { } /** - * Returns the scale tick objects ({label, major}) - * @return {object[]} + * Returns the scale tick objects + * @return {Tick[]} * @since 2.7 */ getTicks() { @@ -586,7 +631,7 @@ export default class Scale extends Element { } /** * Convert ticks to label strings - * @param {object[]} ticks + * @param {Tick[]} ticks */ generateTickLabels(ticks) { const me = this; @@ -790,7 +835,7 @@ export default class Scale extends Element { } /** - * @param {object[]} ticks + * @param {Tick[]} ticks * @private */ _convertTicksToLabels(ticks) { @@ -977,8 +1022,8 @@ export default class Scale extends Element { /** * Returns a subset of ticks to be plotted to avoid overlapping labels. - * @param {object[]} ticks - * @return {object[]} + * @param {Tick[]} ticks + * @return {Tick[]} * @private */ _autoSkip(ticks) { @@ -1077,7 +1122,7 @@ export default class Scale extends Element { const alignBorderValue = function(pixel) { return _alignPixel(chart, pixel, axisWidth); }; - let borderValue, i, tick, lineValue, alignedLineValue; + let borderValue, i, lineValue, alignedLineValue; let tx1, ty1, tx2, ty2, x1, y1, x2, y2; if (position === 'top') { @@ -1133,7 +1178,8 @@ export default class Scale extends Element { } for (i = 0; i < ticksLength; ++i) { - tick = ticks[i] || {}; + /** @type {Tick|object} */ + const tick = ticks[i] || {}; context = { scale: me,
false
Other
chartjs
Chart.js
392921c35479b6fd8cc947b95a8868765feeb1e9.json
Remove unnecessary changes (#7140)
.travis.yml
@@ -3,7 +3,7 @@ node_js: - lts/* before_install: - - "export CHROME_BIN=/usr/bin/google-chrome-beta" + - "export CHROME_BIN=/usr/bin/google-chrome" services: - xvfb @@ -20,7 +20,7 @@ sudo: required dist: bionic addons: - chrome: beta + chrome: stable firefox: latest # IMPORTANT: scripts require GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables
true
Other
chartjs
Chart.js
392921c35479b6fd8cc947b95a8868765feeb1e9.json
Remove unnecessary changes (#7140)
docs/_config.yml
@@ -1,2 +0,0 @@ -include: - - "_*_.html"
true
Other
chartjs
Chart.js
ee7520b7105618072a6f0870bcc32abcccf1b7cd.json
Remove css from deploy scripts (#7131)
scripts/deploy.sh
@@ -41,7 +41,7 @@ cd $TARGET_DIR git checkout $TARGET_BRANCH # Copy dist files -deploy_files '../dist/*.css ../dist/*.js' './dist' +deploy_files '../dist/*.js' './dist' # Copy generated documentation deploy_files '../dist/docs/*' './docs'
true
Other
chartjs
Chart.js
ee7520b7105618072a6f0870bcc32abcccf1b7cd.json
Remove css from deploy scripts (#7131)
scripts/release.sh
@@ -21,7 +21,7 @@ git remote add auth-origin https://$GITHUB_AUTH_TOKEN@github.com/$TRAVIS_REPO_SL git config --global user.email "$GITHUB_AUTH_EMAIL" git config --global user.name "Chart.js" git checkout --detach --quiet -git add -f dist/*.css dist/*.js bower.json +git add -f dist/*.js bower.json git commit -m "Release $VERSION" git tag -a "v$VERSION" -m "Version $VERSION" git push -q auth-origin refs/tags/v$VERSION 2>/dev/null
true
Other
chartjs
Chart.js
bd4537cae426ca9813cbaf5ed144ce94a8f62f09.json
Fix deploy.sh if (#7132)
scripts/deploy.sh
@@ -8,7 +8,7 @@ TARGET_REPO_URL="https://$GITHUB_AUTH_TOKEN@github.com/chartjs/chartjs.github.io VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?' # Make sure that this script is executed only for the release and master branches -if [ "$TRAVIS_BRANCH" =~ ^release.*$ ]; then +if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then # Travis executes this script from the repository root, so at the same level than package.json VERSION=$(node -p -e "require('./package.json').version") elif [ "$TRAVIS_BRANCH" == "master" ]; then
false
Other
chartjs
Chart.js
4a737729d5ca1718510796d1391b8a8991968efd.json
Move color helpers to helpers.color (#7130) Move color helpers to helpers.color
src/helpers/helpers.color.js
@@ -0,0 +1,24 @@ +import colorLib from '@kurkle/color'; + +/** + * @param {string | CanvasGradient | CanvasPattern} value + */ +const isPatternOrGradient = (value) => value instanceof CanvasGradient || value instanceof CanvasPattern; + +/** + * @param {string|CanvasGradient|CanvasPattern} value + * @return {CanvasGradient|CanvasPattern|colorLib} + */ +export function color(value) { + return isPatternOrGradient(value) ? value : colorLib(value); +} + +/** + * @param {string|CanvasGradient|CanvasPattern} value + * @return {string|CanvasGradient|CanvasPattern} + */ +export function getHoverColor(value) { + return isPatternOrGradient(value) + ? value + : colorLib(value).saturate(0.5).darken(0.1).hexString(); +}
true
Other
chartjs
Chart.js
4a737729d5ca1718510796d1391b8a8991968efd.json
Move color helpers to helpers.color (#7130) Move color helpers to helpers.color
src/helpers/index.js
@@ -1,7 +1,5 @@ /* eslint-disable import/no-namespace */ -import color from '@kurkle/color'; - import * as coreHelpers from './helpers.core'; import * as canvas from './helpers.canvas'; import * as curve from './helpers.curve'; @@ -11,16 +9,7 @@ import * as options from './helpers.options'; import * as math from './helpers.math'; import * as rtl from './helpers.rtl'; -const colorHelper = - function(value) { - if (value instanceof CanvasGradient || value instanceof CanvasPattern) { - // TODO: figure out what this should be. Previously returned - // the default color - return value; - } - - return color(value); - }; +import {color, getHoverColor} from './helpers.color'; export default { ...coreHelpers, @@ -45,10 +34,6 @@ export default { fontString(pixelSize, fontStyle, fontFamily) { return fontStyle + ' ' + pixelSize + 'px ' + fontFamily; }, - color: colorHelper, - getHoverColor(colorValue) { - return (colorValue instanceof CanvasPattern || colorValue instanceof CanvasGradient) ? - colorValue : - colorHelper(colorValue).saturate(0.5).darken(0.1).hexString(); - } + color, + getHoverColor };
true
Other
chartjs
Chart.js
f2aa88f49d432bd87281a7a90a7015388a594dff.json
Prepare babel & karma for class properties (#7126) * Prepare babel & karma for class properties * Remove rollup-plugin-istanbul
babel.config.json
@@ -1,4 +1,12 @@ { "presets": ["@babel/preset-env"], - "plugins": ["@babel/plugin-transform-object-assign"] + "plugins": [ + "@babel/plugin-transform-object-assign", + "@babel/plugin-proposal-class-properties" + ], + "env": { + "test": { + "plugins": ["istanbul"] + } + } }
true
Other
chartjs
Chart.js
f2aa88f49d432bd87281a7a90a7015388a594dff.json
Prepare babel & karma for class properties (#7126) * Prepare babel & karma for class properties * Remove rollup-plugin-istanbul
gulpfile.js
@@ -1,4 +1,4 @@ -/* eslint-disable no-use-before-define */ +/* eslint-disable import/no-nodejs-modules, import/no-commonjs, no-use-before-define */ const gulp = require('gulp'); const eslint = require('gulp-eslint'); const file = require('gulp-file'); @@ -42,15 +42,15 @@ gulp.task('size', gulp.parallel('library-size', 'module-sizes')); gulp.task('default', gulp.parallel('build')); function run(bin, args) { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { const exe = '"' + process.execPath + '"'; const src = require.resolve(bin); const cmd = [exe, src].concat(args || []).join(' '); const ps = exec(cmd); ps.stdout.pipe(process.stdout); ps.stderr.pipe(process.stderr); - ps.on('close', function(error) { + ps.on('close', (error) => { if (error) { reject(error); } else { @@ -162,6 +162,7 @@ function docsTask(done) { } function unittestTask(done) { + process.env.NODE_ENV = 'test'; new karma.Server({ configFile: path.join(__dirname, 'karma.conf.js'), singleRun: !argv.watch, @@ -173,7 +174,7 @@ function unittestTask(done) { } }, // https://github.com/karma-runner/gulp-karma/issues/18 - function(error) { + (error) => { error = error ? new Error('Karma returned with the error code: ' + error) : undefined; done(error); }).start();
true
Other
chartjs
Chart.js
f2aa88f49d432bd87281a7a90a7015388a594dff.json
Prepare babel & karma for class properties (#7126) * Prepare babel & karma for class properties * Remove rollup-plugin-istanbul
karma.conf.js
@@ -1,9 +1,9 @@ -/* eslint-env es6 */ +/* eslint-disable import/no-commonjs */ const commonjs = require('rollup-plugin-commonjs'); -const istanbul = require('rollup-plugin-istanbul'); const resolve = require('rollup-plugin-node-resolve'); const builds = require('./rollup.config'); +const babel = require('rollup-plugin-babel'); module.exports = function(karma) { const args = karma.args || {}; @@ -67,6 +67,7 @@ module.exports = function(karma) { rollupPreprocessor: { plugins: [ resolve(), + babel({exclude: 'node_modules/**'}), // use babel since we have ES proposal features commonjs() ], output: { @@ -102,14 +103,5 @@ module.exports = function(karma) { {type: 'lcovonly', subdir: '.'} ] }; - [ - karma.rollupPreprocessor, - karma.customPreprocessors.sources.options - ].forEach(v => { - (v.plugins || (v.plugins = [])).unshift( - istanbul({ - include: 'src/**/*.js' - })); - }); } };
true
Other
chartjs
Chart.js
f2aa88f49d432bd87281a7a90a7015388a594dff.json
Prepare babel & karma for class properties (#7126) * Prepare babel & karma for class properties * Remove rollup-plugin-istanbul
package-lock.json
@@ -353,6 +353,99 @@ "semver": "^5.5.0" } }, + "@babel/helper-create-class-features-plugin": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.8.3.tgz", + "integrity": "sha512-qmp4pD7zeTxsv0JNecSBsEmG1ei2MqwJq4YQcK3ZWm/0t07QstWfvuV/vm3Qt5xNMFETn2SZqpMx2MQzbtq+KA==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.8.3", + "@babel/helper-member-expression-to-functions": "^7.8.3", + "@babel/helper-optimise-call-expression": "^7.8.3", + "@babel/helper-plugin-utils": "^7.8.3", + "@babel/helper-replace-supers": "^7.8.3", + "@babel/helper-split-export-declaration": "^7.8.3" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "dev": true, + "requires": { + "@babel/highlight": "^7.8.3" + } + }, + "@babel/helper-function-name": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz", + "integrity": "sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.8.3", + "@babel/template": "^7.8.3", + "@babel/types": "^7.8.3" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", + "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", + "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3" + } + }, + "@babel/highlight": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", + "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", + "dev": true + }, + "@babel/template": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", + "integrity": "sha512-04m87AcQgAFdvuoyiQ2kgELr2tV8B4fP/xJAVUL3Yb3bkNdMedD3d0rlSQr3PegP0cms3eHjl1F7PWlvWbU8FQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.8.3", + "@babel/parser": "^7.8.3", + "@babel/types": "^7.8.3" + } + }, + "@babel/types": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.3.tgz", + "integrity": "sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + } + } + }, "@babel/helper-create-regexp-features-plugin": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.8.3.tgz", @@ -1331,6 +1424,16 @@ "@babel/plugin-syntax-async-generators": "^7.8.0" } }, + "@babel/plugin-proposal-class-properties": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.8.3.tgz", + "integrity": "sha512-EqFhbo7IosdgPgZggHaNObkmO1kNUe3slaKu54d5OWvy+p9QIKOzK1GAEpAIsZtWVtPXUHSMcT4smvDrCfY4AA==", + "dev": true, + "requires": { + "@babel/helper-create-class-features-plugin": "^7.8.3", + "@babel/helper-plugin-utils": "^7.8.3" + } + }, "@babel/plugin-proposal-dynamic-import": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.8.3.tgz", @@ -2108,6 +2211,72 @@ "to-fast-properties": "^2.0.0" } }, + "@istanbuljs/load-nyc-config": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz", + "integrity": "sha512-ZR0rq/f/E4f4XcgnDvtMWXCUJpi8eO0rssVhmztsZqLIEFA9UUP9zmpE0VxlM+kv/E1ul2I876Fwil2ayptDVg==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + } + } + }, + "@istanbuljs/schema": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", + "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", + "dev": true + }, "@kurkle/color": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.1.3.tgz", @@ -2597,30 +2766,6 @@ "resolve": "^1.12.0" } }, - "babel-generator": { - "version": "6.26.1", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", - "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", - "dev": true, - "requires": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" - }, - "dependencies": { - "jsesc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", - "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", - "dev": true - } - } - }, "babel-helper-call-delegate": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", @@ -2749,6 +2894,154 @@ "babel-runtime": "^6.22.0" } }, + "babel-plugin-istanbul": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.0.0.tgz", + "integrity": "sha512-AF55rZXpe7trmEylbaE1Gv54wn6rwU03aptvRoVIGP8YykoSxqdVLV1TfwflBCE/QtHmqtP8SWlTENqbK8GCSQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^4.0.0", + "test-exclude": "^6.0.0" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "dev": true, + "requires": { + "@babel/highlight": "^7.8.3" + } + }, + "@babel/generator": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.4.tgz", + "integrity": "sha512-PwhclGdRpNAf3IxZb0YVuITPZmmrXz9zf6fH8lT4XbrmfQKr6ryBzhv593P5C6poJRciFCL/eHGW2NuGrgEyxA==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz", + "integrity": "sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.8.3", + "@babel/template": "^7.8.3", + "@babel/types": "^7.8.3" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", + "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", + "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", + "dev": true, + "requires": { + "@babel/types": "^7.8.3" + } + }, + "@babel/highlight": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", + "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", + "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", + "dev": true + }, + "@babel/template": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", + "integrity": "sha512-04m87AcQgAFdvuoyiQ2kgELr2tV8B4fP/xJAVUL3Yb3bkNdMedD3d0rlSQr3PegP0cms3eHjl1F7PWlvWbU8FQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.8.3", + "@babel/parser": "^7.8.3", + "@babel/types": "^7.8.3" + } + }, + "@babel/traverse": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.4.tgz", + "integrity": "sha512-NGLJPZwnVEyBPLI+bl9y9aSnxMhsKz42so7ApAv9D+b4vAFPpY013FTS9LdKxcABoIYFU52HcYga1pPlx454mg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.8.3", + "@babel/generator": "^7.8.4", + "@babel/helper-function-name": "^7.8.3", + "@babel/helper-split-export-declaration": "^7.8.3", + "@babel/parser": "^7.8.4", + "@babel/types": "^7.8.3", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.8.3.tgz", + "integrity": "sha512-jBD+G8+LWpMBBWvVcdr4QysjUE4mU/syrhN17o1u3gx0/WzJB1kwiVZAXRtWbsIPOwW8pF/YJV5+nmetPzepXg==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", + "dev": true + }, + "istanbul-lib-instrument": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.1.tgz", + "integrity": "sha512-imIchxnodll7pvQBYOqUu88EufLCU56LMeFPZZM/fJZ1irYcYdqroaV+ACK1Ila8ls09iEYArp+nqyC6lW1Vfg==", + "dev": true, + "requires": { + "@babel/core": "^7.7.5", + "@babel/parser": "^7.7.5", + "@babel/template": "^7.7.4", + "@babel/traverse": "^7.7.4", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.0.0", + "semver": "^6.3.0" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "babel-plugin-transform-es2015-arrow-functions": { "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", @@ -4178,15 +4471,6 @@ "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "dev": true }, - "detect-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", - "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, "di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -14567,39 +14851,6 @@ "rollup-pluginutils": "^2.8.1" } }, - "rollup-plugin-istanbul": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-istanbul/-/rollup-plugin-istanbul-2.0.1.tgz", - "integrity": "sha512-5X1ExH74moFY/pHqCrAZQ0V8RyEMCmrUSuo1t1bDzv9UHTd54s79ALDaK8N87PgNzA6UuKtBVAP/tsaSYzIUVQ==", - "dev": true, - "requires": { - "istanbul-lib-instrument": "^1.9.1", - "rollup-pluginutils": "^2.0.1" - }, - "dependencies": { - "istanbul-lib-coverage": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.1.tgz", - "integrity": "sha512-PzITeunAgyGbtY1ibVIUiV679EFChHjoMNRibEIobvmrCRaIgwLxNucOSimtNWUhEib/oO7QY2imD75JVgCJWQ==", - "dev": true - }, - "istanbul-lib-instrument": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.10.2.tgz", - "integrity": "sha512-aWHxfxDqvh/ZlxR8BBaEPVSWDPUkGD63VjGQn3jcw8jCp7sHEMKcrj4xfJn/ABzdMEHiQNyvDQhqm5o8+SQg7A==", - "dev": true, - "requires": { - "babel-generator": "^6.18.0", - "babel-template": "^6.16.0", - "babel-traverse": "^6.18.0", - "babel-types": "^6.18.0", - "babylon": "^6.18.0", - "istanbul-lib-coverage": "^1.2.1", - "semver": "^5.3.0" - } - } - } - }, "rollup-plugin-node-resolve": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz", @@ -15483,6 +15734,17 @@ } } }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -15665,12 +15927,6 @@ "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", "dev": true }, - "trim-right": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", - "dev": true - }, "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
true
Other
chartjs
Chart.js
f2aa88f49d432bd87281a7a90a7015388a594dff.json
Prepare babel & karma for class properties (#7126) * Prepare babel & karma for class properties * Remove rollup-plugin-istanbul
package.json
@@ -31,8 +31,10 @@ ], "devDependencies": { "@babel/core": "^7.8.4", + "@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/plugin-transform-object-assign": "^7.8.3", "@babel/preset-env": "^7.8.4", + "babel-plugin-istanbul": "^6.0.0", "babel-preset-es2015-rollup": "^3.0.0", "coveralls": "^3.0.9", "eslint": "^6.8.0", @@ -70,7 +72,6 @@ "rollup-plugin-babel": "^4.3.3", "rollup-plugin-cleanup": "^3.1.1", "rollup-plugin-commonjs": "^10.0.0", - "rollup-plugin-istanbul": "^2.0.1", "rollup-plugin-node-resolve": "^5.0.0", "rollup-plugin-terser": "^5.2.0", "typedoc": "^0.16.9",
true
Other
chartjs
Chart.js
10c3c3bbc9dfdf18a817f7a48acba1a334e39632.json
Simplify rtlAdapter export (#7120)
src/helpers/helpers.rtl.js
@@ -1,4 +1,4 @@ -const getRtlAdapter = function(rectX, width) { +const getRightToLeftAdapter = function(rectX, width) { return { x(x) { return rectX + rectX + width - x; @@ -21,7 +21,7 @@ const getRtlAdapter = function(rectX, width) { }; }; -const getLtrAdapter = function() { +const getLeftToRightAdapter = function() { return { x(x) { return x; @@ -40,11 +40,11 @@ const getLtrAdapter = function() { }; }; -const getAdapter = function(rtl, rectX, width) { - return rtl ? getRtlAdapter(rectX, width) : getLtrAdapter(); -}; +export function getRtlAdapter(rtl, rectX, width) { + return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter(); +} -const overrideTextDirection = function(ctx, direction) { +export function overrideTextDirection(ctx, direction) { let style, original; if (direction === 'ltr' || direction === 'rtl') { style = ctx.canvas.style; @@ -56,17 +56,11 @@ const overrideTextDirection = function(ctx, direction) { style.setProperty('direction', direction, 'important'); ctx.prevTextDirection = original; } -}; +} -const restoreTextDirection = function(ctx, original) { +export function restoreTextDirection(ctx, original) { if (original !== undefined) { delete ctx.prevTextDirection; ctx.canvas.style.setProperty('direction', original[0], original[1]); } -}; - -export { - getAdapter as getRtlAdapter, - overrideTextDirection, - restoreTextDirection -}; +}
false
Other
chartjs
Chart.js
93f777821a9f9c0475f8669c165fa3149766c4b3.json
Remove version from docs. Use latest (#7128)
docs/getting-started/README.md
@@ -11,7 +11,7 @@ First, we need to have a canvas in our page. Now that we have a canvas we can use, we need to include Chart.js in our page. ```html -<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script> +<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> ``` Now, we can create a chart. We add a script to our page:
false
Other
chartjs
Chart.js
1b1c7fc302f77ee4c1504d5a1202a167620d6ce1.json
Remove unused property _maxLabelLines (#7101)
src/core/core.scale.js
@@ -286,8 +286,6 @@ class Scale extends Element { /** @type {object} */ this._longestTextCache = {}; /** @type {number} */ - this._maxLabelLines = undefined; - /** @type {number} */ this._startPixel = undefined; /** @type {number} */ this._endPixel = undefined; @@ -445,7 +443,6 @@ class Scale extends Element { me.ticks = null; me._labelSizes = null; - me._maxLabelLines = 0; me._gridLineItems = null; me._labelItems = null;
false
Other
chartjs
Chart.js
72c3c6d0802919eb4d24a4ef19cc465e9fa8ff1b.json
Fix memory leak (#7097)
src/core/core.animator.js
@@ -210,6 +210,14 @@ class Animator { anims.items = []; this._notify(chart, anims, Date.now(), 'complete'); } + + /** + * Remove chart from Animator + * @param {Chart} chart + */ + remove(chart) { + return this._charts.delete(chart); + } } const instance = new Animator();
true