Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: chartjs/Chart.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.7.1
Choose a base ref
...
head repository: chartjs/Chart.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.8.0
Choose a head ref
Loading
Showing with 2,485 additions and 1,063 deletions.
  1. +10 −7 .github/workflows/ci.yml
  2. +1 −1 LICENSE.md
  3. +1 −1 auto/auto.esm.js
  4. +1 −1 docs/axes/cartesian/_common_ticks.md
  5. +1 −0 docs/axes/cartesian/time.md
  6. +1 −0 docs/axes/radial/linear.md
  7. +1 −1 docs/charts/area.md
  8. +1 −1 docs/configuration/animations.md
  9. +54 −0 docs/configuration/interactions.md
  10. BIN docs/developers/init_flowchart.png
  11. +1 −1 docs/developers/plugin_flowcharts.drawio
  12. +7 −1 docs/developers/plugins.md
  13. BIN docs/developers/render_flowchart.png
  14. BIN docs/developers/scale_flowchart.png
  15. +7 −2 docs/general/data-structures.md
  16. +2 −2 docs/index.md
  17. +5 −0 docs/samples/advanced/data-decimation.md
  18. +5 −0 docs/samples/advanced/derived-axis-type.md
  19. +4 −0 docs/samples/advanced/derived-chart-type.md
  20. +8 −0 docs/samples/advanced/linear-gradient.md
  21. +12 −0 docs/samples/advanced/programmatic-events.md
  22. +8 −0 docs/samples/advanced/progress-bar.md
  23. +6 −0 docs/samples/advanced/radial-gradient.md
  24. +8 −0 docs/samples/animations/delay.md
  25. +11 −0 docs/samples/animations/drop.md
  26. +16 −0 docs/samples/animations/loop.md
  27. +17 −0 docs/samples/animations/progressive-line-easing.md
  28. +17 −0 docs/samples/animations/progressive-line.md
  29. +7 −0 docs/samples/area/line-boundaries.md
  30. +8 −0 docs/samples/area/line-datasets.md
  31. +6 −0 docs/samples/area/line-drawtime.md
  32. +8 −0 docs/samples/area/line-stacked.md
  33. +7 −0 docs/samples/area/radar.md
  34. +5 −0 docs/samples/bar/border-radius.md
  35. +5 −0 docs/samples/bar/floating.md
  36. +5 −0 docs/samples/bar/horizontal.md
  37. +9 −0 docs/samples/bar/stacked-groups.md
  38. +4 −0 docs/samples/bar/stacked.md
  39. +4 −0 docs/samples/bar/vertical.md
  40. +6 −0 docs/samples/legend/events.md
  41. +7 −0 docs/samples/legend/html.md
  42. +11 −1 docs/samples/legend/point-style.md
  43. +7 −1 docs/samples/legend/position.md
  44. +6 −1 docs/samples/legend/title.md
  45. +6 −0 docs/samples/line/interpolation.md
  46. +4 −0 docs/samples/line/line.md
  47. +8 −0 docs/samples/line/multi-axis.md
  48. +5 −0 docs/samples/line/point-styling.md
  49. +9 −0 docs/samples/line/segments.md
  50. +5 −0 docs/samples/line/stepped.md
  51. +5 −0 docs/samples/line/styling.md
  52. +3 −0 docs/samples/other-charts/bubble.md
  53. +5 −0 docs/samples/other-charts/combo-bar-line.md
  54. +3 −0 docs/samples/other-charts/doughnut.md
  55. +5 −0 docs/samples/other-charts/multi-series-pie.md
  56. +2 −0 docs/samples/other-charts/pie.md
  57. +5 −0 docs/samples/other-charts/polar-area-center-labels.md
  58. +3 −0 docs/samples/other-charts/polar-area.md
  59. +3 −0 docs/samples/other-charts/radar-skip-points.md
  60. +4 −0 docs/samples/other-charts/radar.md
  61. +5 −0 docs/samples/other-charts/scatter-multi-axis.md
  62. +3 −0 docs/samples/other-charts/scatter.md
  63. +10 −0 docs/samples/other-charts/stacked-bar-line.md
  64. +6 −0 docs/samples/plugins/chart-area-border.md
  65. +6 −0 docs/samples/plugins/doughnut-empty-state.md
  66. +6 −0 docs/samples/plugins/quadrants.md
  67. +6 −1 docs/samples/scale-options/center.md
  68. +9 −0 docs/samples/scale-options/grid.md
  69. +9 −0 docs/samples/scale-options/ticks.md
  70. +9 −0 docs/samples/scale-options/titles.md
  71. +7 −0 docs/samples/scales/linear-min-max-suggested.md
  72. +7 −0 docs/samples/scales/linear-min-max.md
  73. +9 −0 docs/samples/scales/linear-step-size.md
  74. +6 −0 docs/samples/scales/log.md
  75. +6 −0 docs/samples/scales/stacked.md
  76. +6 −0 docs/samples/scales/time-combo.md
  77. +4 −0 docs/samples/scales/time-line.md
  78. +5 −0 docs/samples/scales/time-max-span.md
  79. +8 −0 docs/samples/scriptable/bar.md
  80. +5 −0 docs/samples/scriptable/bubble.md
  81. +8 −0 docs/samples/scriptable/line.md
  82. +5 −0 docs/samples/scriptable/pie.md
  83. +5 −0 docs/samples/scriptable/polar.md
  84. +5 −0 docs/samples/scriptable/radar.md
  85. +6 −0 docs/samples/subtitle/basic.md
  86. +6 −1 docs/samples/title/alignment.md
  87. +7 −1 docs/samples/tooltip/content.md
  88. +7 −0 docs/samples/tooltip/html.md
  89. +6 −0 docs/samples/tooltip/interactions.md
  90. +10 −1 docs/samples/tooltip/point-style.md
  91. +8 −1 docs/samples/tooltip/position.md
  92. +174 −154 package-lock.json
  93. +3 −3 package.json
  94. +5 −0 src/controllers/controller.bar.js
  95. +2 −1 src/controllers/controller.line.js
  96. +31 −6 src/controllers/controller.polarArea.js
  97. +6 −2 src/controllers/controller.radar.js
  98. +11 −1 src/core/core.controller.js
  99. +1 −0 src/core/core.datasetController.js
  100. +2 −1 src/core/core.defaults.js
  101. +60 −77 src/core/core.interaction.js
  102. +18 −2 src/core/core.scale.js
  103. +7 −3 src/helpers/helpers.canvas.js
  104. +8 −1 src/helpers/helpers.color.js
  105. +16 −0 src/helpers/helpers.config.js
  106. +2 −2 src/helpers/helpers.core.js
  107. +25 −2 src/helpers/helpers.dom.js
  108. +1 −1 src/platform/platform.dom.js
  109. +1 −1 src/plugins/plugin.decimation.js
  110. +0 −655 src/plugins/plugin.filler.js
  111. +122 −0 src/plugins/plugin.filler/filler.drawing.js
  112. +34 −0 src/plugins/plugin.filler/filler.helper.js
  113. +136 −0 src/plugins/plugin.filler/filler.options.js
  114. +99 −0 src/plugins/plugin.filler/filler.segment.js
  115. +95 −0 src/plugins/plugin.filler/filler.target.js
  116. +110 −0 src/plugins/plugin.filler/filler.target.stack.js
  117. +94 −0 src/plugins/plugin.filler/index.js
  118. +27 −0 src/plugins/plugin.filler/simpleArc.js
  119. +2 −2 src/plugins/plugin.legend.js
  120. +17 −9 src/plugins/plugin.tooltip.js
  121. +22 −3 src/scales/scale.radialLinear.js
  122. +8 −0 src/scales/scale.time.js
  123. BIN test/fixtures/controller.bar/minBarLength/horizontal-neg.png
  124. BIN test/fixtures/controller.bar/minBarLength/horizontal-pos.png
  125. +43 −0 test/fixtures/controller.bar/minBarLength/horizontal-stacked.js
  126. BIN test/fixtures/controller.bar/minBarLength/horizontal-stacked.png
  127. BIN test/fixtures/controller.bar/minBarLength/vertical-neg.png
  128. BIN test/fixtures/controller.bar/minBarLength/vertical-pos.png
  129. +42 −0 test/fixtures/controller.bar/minBarLength/vertical-stacked.js
  130. BIN test/fixtures/controller.bar/minBarLength/vertical-stacked.png
  131. +27 −0 test/fixtures/controller.polarArea/parse-object-data.json
  132. BIN test/fixtures/controller.polarArea/parse-object-data.png
  133. +30 −0 test/fixtures/core.scale/label-align-inner-onlyX.js
  134. BIN test/fixtures/core.scale/label-align-inner-onlyX.png
  135. +28 −0 test/fixtures/core.scale/label-align-inner-reverse.js
  136. BIN test/fixtures/core.scale/label-align-inner-reverse.png
  137. +29 −0 test/fixtures/core.scale/label-align-inner-rotate.js
  138. BIN test/fixtures/core.scale/label-align-inner-rotate.png
  139. +27 −0 test/fixtures/core.scale/label-align-inner.js
  140. BIN test/fixtures/core.scale/label-align-inner.png
  141. +51 −0 test/fixtures/scale.radialLinear/pointLabels/border-radius.js
  142. BIN test/fixtures/scale.radialLinear/pointLabels/border-radius.png
  143. +52 −0 test/fixtures/scale.time/offset-auto-skip-ticks.js
  144. BIN test/fixtures/scale.time/offset-auto-skip-ticks.png
  145. +52 −0 test/specs/controller.line.tests.js
  146. +18 −0 test/specs/controller.polarArea.tests.js
  147. +26 −0 test/specs/controller.radar.tests.js
  148. +2 −2 test/specs/core.controller.tests.js
  149. +78 −0 test/specs/core.interaction.tests.js
  150. +25 −0 test/specs/helpers.dom.tests.js
  151. +40 −0 test/specs/plugin.legend.tests.js
  152. +4 −0 types/helpers/helpers.color.d.ts
  153. +169 −109 types/index.esm.d.ts
  154. +13 −0 types/tests/controllers/line_styling_array.ts
17 changes: 10 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -54,13 +54,12 @@ jobs:
run: npm run build
- name: Test
if: |
steps.changes.outputs.src == 'true' ||
steps.changes.outputs.test == 'true'
(steps.changes.outputs.src == 'true' ||
steps.changes.outputs.test == 'true') &&
runner.os != 'Windows'
run: |
npm run build
if [ "${{ runner.os }}" == "Windows" ]; then
npm test
elif [ "${{ runner.os }}" == "macOS" ]; then
if [ "${{ runner.os }}" == "macOS" ]; then
npm test --browsers chrome,safari
else
xvfb-run --auto-servernum npm test
@@ -74,15 +73,19 @@ jobs:
npm run docs
npm pack
- name: Coveralls Parallel - Chrome
if: steps.changes.outputs.src == 'true'
if: |
steps.changes.outputs.src == 'true' &&
runner.os != 'Windows'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: './coverage/chrome/lcov.info'
flag-name: ${{ matrix.os }}-chrome
parallel: true
- name: Coveralls Parallel - Firefox
if: steps.changes.outputs.src == 'true'
if: |
steps.changes.outputs.src == 'true' &&
runner.os != 'Windows'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2021 Chart.js Contributors
Copyright (c) 2014-2022 Chart.js Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

2 changes: 1 addition & 1 deletion auto/auto.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Chart, registerables} from '../dist/chart.esm';
import {Chart, registerables} from '../dist/chart.esm.js';

Chart.register(...registerables);

2 changes: 1 addition & 1 deletion docs/axes/cartesian/_common_ticks.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ Namespace: `options.scales[scaleId].ticks`

| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `align` | `string` | `'center'` | The tick alignment along the axis. Can be `'start'`, `'center'`, or `'end'`.
| `align` | `string` | `'center'` | The tick alignment along the axis. Can be `'start'`, `'center'`, `'end'`, or `'inner'`. `inner` alignment means align `start` for first tick and `end` for the last tick of horizontal axis
| `crossAlign` | `string` | `'near'` | The tick alignment perpendicular to the axis. Can be `'near'`, `'center'`, or `'far'`. See [Tick Alignment](/axes/cartesian/#tick-alignment)
| `sampleSize` | `number` | `ticks.length` | The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length.
| `autoSkip` | `boolean` | `true` | If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to `maxRotation` before skipping any. Turn `autoSkip` off to show all labels no matter what.
1 change: 1 addition & 0 deletions docs/axes/cartesian/time.md
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ Namespace: `options.scales[scaleId]`
| `suggestedMax` | `number`\|`string` | | The maximum item to display if there is no datapoint behind it. [more...](../index.md#axis-range-settings)
| `adapters.date` | `object` | `{}` | Options for adapter for external date library if that adapter needs or supports options
| `bounds` | `string` | `'data'` | Determines the scale bounds. [more...](./index.md#scale-bounds)
| `offsetAfterAutoskip` | `boolean` | `false` | If true, bar chart offsets are computed with auto skipped ticks.
| `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`\|`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)
1 change: 1 addition & 0 deletions docs/axes/radial/linear.md
Original file line number Diff line number Diff line change
@@ -120,6 +120,7 @@ Namespace: `options.scales[scaleId].pointLabels`
| ---- | ---- | ------- | ------- | -----------
| `backdropColor` | [`Color`](../../general/colors.md) | `true` | `undefined` | Background color of the point label.
| `backdropPadding` | [`Padding`](../../general/padding.md) | | `2` | Padding of label backdrop.
| `borderRadius` | `number`\|`object` | `true` | `0` | Border radius of the point label
| `display` | `boolean` | | `true` | If true, point labels are shown.
| `callback` | `function` | | | Callback function to transform data labels to point labels. The default implementation simply returns the current string.
| `color` | [`Color`](../../general/colors.md) | Yes | `Chart.defaults.color` | Color of label.
2 changes: 1 addition & 1 deletion docs/charts/area.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
Both [line](./line.md) and [radar](./radar.md) charts support a `fill` option on the dataset object which can be used to create space between two datasets or a dataset and a boundary, i.e. the scale `origin`, `start,` or `end` (see [filling modes](#filling-modes)).

:::tip Note
This feature is implemented by the [`filler` plugin](https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler.js).
This feature is implemented by the [`filler` plugin](https://github.com/chartjs/Chart.js/blob/master/src/plugins/plugin.filler/index.js).
:::

## Filling modes
2 changes: 1 addition & 1 deletion docs/configuration/animations.md
Original file line number Diff line number Diff line change
@@ -282,4 +282,4 @@ const chart = new Chart(ctx, {
});
```

Another example usage of these callbacks can be found on [Github](https://github.com/chartjs/Chart.js/blob/master/samples/advanced/progress-bar.html): this sample displays a progress bar showing how far along the animation is.
Another example usage of these callbacks can be found [in this progress bar sample.](../samples/advanced/progress-bar.md) which displays a progress bar showing how far along the animation is.
54 changes: 54 additions & 0 deletions docs/configuration/interactions.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ Namespace: `options.interaction`, the global interaction configuration is at `Ch
| `mode` | `string` | `'nearest'` | Sets which elements appear in the interaction. See [Interaction Modes](#modes) for details.
| `intersect` | `boolean` | `true` | if true, the interaction mode only applies when the mouse position intersects an item on the chart.
| `axis` | `string` | `'x'` | Can be set to `'x'`, `'y'`, `'xy'` or `'r'` to define which directions are used in calculating distances. Defaults to `'x'` for `'index'` mode and `'xy'` in `dataset` and `'nearest'` modes.
| `includeInvisible` | `boolean` | `true` | if true, the invisible points that are outside of the chart area will also be included when evaluating interactions.

By default, these options apply to both the hover and tooltip interactions. The same options can be set in the `options.hover` namespace, in which case they will only affect the hover interaction. Similarly, the options can be set in the `options.plugins.tooltip` namespace to independently configure the tooltip interactions.

@@ -220,3 +221,56 @@ const chart = new Chart(ctx, {
}
});
```

## Custom Interaction Modes

New modes can be defined by adding functions to the `Chart.Interaction.modes` map. You can use the `Chart.Interaction.evaluateInteractionItems` function to help implement these.

Example:

```javascript
import { Interaction } from 'chart.js';
import { getRelativePosition } from 'chart.js/helpers';

/**
* Custom interaction mode
* @function Interaction.modes.myCustomMode
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {InteractionOptions} options - options to use
* @param {boolean} [useFinalPosition] - use final element position (animation target)
* @return {InteractionItem[]} - items that are found
*/
Interaction.modes.myCustomMode = function(chart, e, options, useFinalPosition) {
const position = getRelativePosition(e, chart);

const items = [];
Interaction.evaluateInteractionItems(chart, 'x', position, (element, datasetIndex, index) => {
if (element.inXRange(position.x, useFinalPosition) && myCustomLogic(element)) {
items.push({element, datasetIndex, index});
}
});
return items;
};

// Then, to use it...
new Chart.js(ctx, {
type: 'line',
data: data,
options: {
interaction: {
mode: 'myCustomMode'
}
}
})
```

If you're using TypeScript, you'll also need to register the new mode:

```typescript
declare module 'chart.js' {
interface InteractionModeMap {
myCustomMode: InteractionModeFunction;
}
}
```
Binary file modified docs/developers/init_flowchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading