Skip to content

Commit

Permalink
Release v3.0.0-beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Oct 1, 2020
2 parents e9a01e6 + 948b88d commit b245fee
Show file tree
Hide file tree
Showing 65 changed files with 1,236 additions and 902 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
@@ -1,7 +1,7 @@
<!--
Please consider the following before submitting a pull request:
Guidelines for contributing: https://github.com/chartjs/Chart.js/blob/master/docs/developers/contributing.md
Guidelines for contributing: https://github.com/chartjs/Chart.js/blob/master/docs/docs/developers/contributing.md
Example of changes on an interactive website such as the following:
- https://jsbin.com/
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -3,7 +3,6 @@
/custom
/dist
/gh-pages
/helpers

# Node.js
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/axes/cartesian/time.md
Expand Up @@ -28,7 +28,7 @@ The following options are provided by the time scale. You may also set options p
| `bounds` | `string` | `'data'` | Determines the scale bounds. [more...](#scale-bounds)
| `ticks.source` | `string` | `'auto'` | How ticks are generated. [more...](#ticks-source)
| `time.displayFormats` | `object` | | Sets how different time units are displayed. [more...](#display-formats)
| `time.isoWeekday` | `boolean` | `false` | If true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
| `time.isoWeekday` | `boolean`\|`number` | `false` | If `boolean` and true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday. If `number`, the index of the first day of the week (0 - Sunday, 6 - Saturday)
| `time.parser` | `string`\|`function` | | Custom parser for dates. [more...](#parser)
| `time.round` | `string` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#time-units) below for the allowed units.
| `time.tooltipFormat` | `string` | | The format string to use for the tooltip.
Expand Down
25 changes: 25 additions & 0 deletions docs/docs/developers/charts.md
Expand Up @@ -150,3 +150,28 @@ new Chart(ctx, {
options: options
});
```

## TypeScript Typings

If you want your new chart type to be statically typed, you must provide a `.d.ts` TypeScript declaration file. Chart.js provides a way to augment built-in types with user-defined ones, by using the concept of "declaration merging".

There are three main declarations that can be augmented when adding a new chart type:

* `ChartTypeEnum` enumeration must contain an entry for the new type.
* `IChartTypeRegistry` must contains the declarations for the new type, either by extending an existing entry in `IChartTypeRegistry` or by creating a new one.

For example, to provide typings for a new chart type that extends from a bubble chart, you would add a `.d.ts` containing:

```javascript
import { IChartTypeRegistry } from 'chart.js'

declare module 'chart.js' {
enum ChartTypeEnum {
derivedBubble = 'derivedBubble'
}

interface IChartTypeRegistry {
derivedBubble: IChartTypeRegistry['bubble']
}
}
```
6 changes: 3 additions & 3 deletions docs/docs/developers/plugins.md
Expand Up @@ -43,7 +43,7 @@ However, this approach is not ideal when the customization needs to apply to man
Plugins can be registered globally to be applied on all charts (a.k.a. *global plugins*):

```javascript
Chart.plugins.register({
Chart.register({
// plugin implementation
});
```
Expand Down Expand Up @@ -92,7 +92,7 @@ var chart = new Chart(ctx, {
To disable a global plugin for a specific chart instance, the plugin options must be set to `false`:

```javascript
Chart.plugins.register({
Chart.register({
id: 'p1',
// ...
});
Expand All @@ -106,6 +106,6 @@ var chart = new Chart(ctx, {
});
```

## Plugin Core API
## Plugin Core API

Read more about the [existing plugin extension hooks](../jsdoc/IPlugin.html).
15 changes: 11 additions & 4 deletions docs/docs/developers/publishing.md
Expand Up @@ -20,12 +20,19 @@ But not the helpers.

In UMD, helpers are available through `Chart.helpers`. In ESM, they are imported from `chart.js/helpers`.

There are multiple namespaces under helpers. Some of the namespaces are bundled directly under `Chart.helpers` for backward compatibility, those are: `core`, `color` and `extras`.

For example `import {isNullOrUndef} from 'chart.js/helpers/core'` is available at `Chart.helpers.isNullOrUndef` for UMD.
For example `import {isNullOrUndef} from 'chart.js/helpers'` is available at `Chart.helpers.isNullOrUndef` for UMD.

### Rollup

`output.globals` can be used to convert the helpers.

For convinience, a plugin is available for the configuration: [rollup-plugin-chartjs-globals](https://www.npmjs.com/package/rollup-plugin-chartjs-globals).
```js
{
output: {
globals: {
'chart.js': 'Chart',
'chart.js/helpers': 'Chart.helpers'
}
}
}
```
36 changes: 10 additions & 26 deletions docs/docs/getting-started/v3-migration.md
Expand Up @@ -263,6 +263,7 @@ The following properties and methods were removed:
* `Chart.offsetY`
* `Chart.outerRadius` now lives on doughnut, pie, and polarArea controllers
* `Chart.plugins` was replaced with `Chart.registry`. Plugin defaults are now in `Chart.defaults.plugins[id]`.
* `Chart.plugins.register` was replaced by `Chart.register`.
* `Chart.PolarArea`. New charts are created via `new Chart` and providing the appropriate `type` parameter
* `Chart.prototype.generateLegend`
* `Chart.platform`. It only contained `disableCSSInjection`. CSS is never injected in v3.
Expand Down Expand Up @@ -305,9 +306,9 @@ The following properties and methods were removed:
* `helpers.getValueAtIndexOrDefault`. Use `helpers.resolve` instead.
* `helpers.indexOf`
* `helpers.lineTo`
* `helpers.longestText` was moved to the `helpers.canvas` namespace and made private
* `helpers.longestText` was made private
* `helpers.max`
* `helpers.measureText` was moved to the `helpers.canvas` namespace and made private
* `helpers.measureText` was made private
* `helpers.min`
* `helpers.nextItem`
* `helpers.niceNum`
Expand Down Expand Up @@ -368,31 +369,12 @@ 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`
* `Chart.canvasHelpers` was renamed to `Chart.helpers.canvas`
* `Chart.canvasHelpers` was merged with `Chart.helpers`
* `Chart.layoutService` was renamed to `Chart.layouts`
* `Chart.pluginService` was renamed to `Chart.plugins`
* `helpers._decimalPlaces` was renamed to `helpers.math._decimalPlaces`
* `helpers.almostEquals` was renamed to `helpers.math.almostEquals`
* `helpers.almostWhole` was renamed to `helpers.math.almostWhole`
* `helpers.callCallback` was renamed to `helpers.callback`
* `helpers.clear` was renamed to `helpers.canvas.clear`
* `helpers.distanceBetweenPoints` was renamed to `helpers.math.distanceBetweenPoints`
* `helpers.drawRoundedRectangle` was renamed to `helpers.canvas.roundedRect`
* `helpers.getAngleFromPoint` was renamed to `helpers.math.getAngleFromPoint`
* `helpers.getMaximumHeight` was renamed to `helpers.dom.getMaximumHeight`
* `helpers.getMaximumWidth` was renamed to `helpers.dom.getMaximumWidth`
* `helpers.getRelativePosition` was renamed to `helpers.dom.getRelativePosition`
* `helpers.getStyle` was renamed to `helpers.dom.getStyle`
* `helpers.drawRoundedRectangle` was renamed to `helpers.roundedRect`
* `helpers.getValueOrDefault` was renamed to `helpers.valueOrDefault`
* `helpers.easingEffects` was renamed to `helpers.easing.effects`
* `helpers.log10` was renamed to `helpers.math.log10`
* `helpers.isNumber` was renamed to `helpers.math.isNumber`
* `helpers.sign` was renamed to `helpers.math.sign`
* `helpers.retinaScale` was renamed to `helpers.dom.retinaScale`
* `helpers.splineCurve` was renamed to `helpers.curve.splineCurve`
* `helpers.splineCurveMonotone` was renamed to `helpers.curve.splineCurveMonotone`
* `helpers.toDegrees` was renamed to `helpers.math.toDegrees`
* `helpers.toRadians` was renamed to `helpers.math.toRadians`
* `Scale.calculateTickRotation` was renamed to `Scale.calculateLabelRotation`
* `Tooltip.options.legendColorBackgroupd` was renamed to `Tooltip.options.multiKeyBackground`

Expand Down Expand Up @@ -427,8 +409,6 @@ The private APIs listed below were renamed:
* `DatasetController.resyncElements` was renamed to `DatasetController._resyncElements`
* `RadialLinearScale.setReductions` was renamed to `RadialLinearScale._setReductions`
* `Scale.handleMargins` was renamed to `Scale._handleMargins`
* `helpers._alignPixel` was renamed to `helpers.canvas._alignPixel`
* `helpers._decimalPlaces` was renamed to `helpers.math._decimalPlaces`

### Changed

Expand Down Expand Up @@ -460,7 +440,7 @@ The APIs listed in this section have changed in signature or behaviour from vers

##### Dataset Controllers

* `updateElement` was replaced with `updateElements` now taking the elements to update, the `start` index, and `mode`
* `updateElement` was replaced with `updateElements` now taking the elements to update, the `start` index, `count`, and `mode`
* `setHoverStyle` and `removeHoverStyle` now additionally take the `datasetIndex` and `index`

#### Interactions
Expand All @@ -473,9 +453,13 @@ The APIs listed in this section have changed in signature or behaviour from vers

#### Helpers

All helpers are now exposed in a flat hierarchy, e.g., `Chart.helpers.canvas.clipArea` -> `Chart.helpers.clipArea`

##### Canvas Helper

* The second parameter to `drawPoint` is now the full options object, so `style`, `rotation`, and `radius` are no longer passed explicitly
* `helpers.getMaximumHeight` was replaced by `helpers.dom.getMaximumSize`
* `helpers.getMaximumWidth` was replaced by `helpers.dom.getMaximumSize`

#### Platform

Expand Down
1 change: 1 addition & 0 deletions helpers/helpers.esm.d.ts
@@ -0,0 +1 @@
export * from '../dist/helpers.esm';
1 change: 1 addition & 0 deletions helpers/helpers.esm.js
@@ -0,0 +1 @@
export * from '../dist/helpers.esm';
1 change: 1 addition & 0 deletions helpers/helpers.js
@@ -0,0 +1 @@
module.exports = require('..').helpers;
8 changes: 8 additions & 0 deletions helpers/package.json
@@ -0,0 +1,8 @@
{
"name": "chart.js-helpers",
"private": true,
"description": "helper package",
"main": "helpers.js",
"module": "helpers.esm.js",
"types": "helpers.esm.d.ts"
}

0 comments on commit b245fee

Please sign in to comment.