4559 Commits

Author SHA1 Message Date
Lucas Leung
bcc7681ba1
Fix minor typo (#12068) 2025-04-25 13:47:44 +02:00
Josh Kelley
3361a63705
Require 'this' when calling tick formatters (#12064)
The `numeric` and `logarithmic` tick formatters require that `this` be provided. That happens automatically if they're used directly as a tick callback but not if they're invoked manually. Failing to pass `this` results in runtime errors similar to the following:

```
TypeError: Cannot read properties of undefined (reading 'chart')
```
2025-04-18 13:16:34 +02:00
Josh Kelley
f46572e19a
Add beforeEvent changed (#12063) 2025-04-18 13:15:57 +02:00
Pierre
74961d1c86
Add selfJoin option for doughnut graphs (#12054)
Co-authored-by: Pierre Gueguen <gueguenpierre.pro@gmail.com>
2025-04-15 15:32:13 +02:00
FabTechAT
9b1306ab0a
feature: make above/below colors in filler plugin work with pivoted line charts (#12058)
* adapted filler plugin to make above/below colors work with pivoted line charts

resolved conflicts in src/plugins/plugin.filler/filler.drawing.js

* fixed doFill; added tests
2025-04-15 15:31:58 +02:00
Jacco van den Berg
817bec0439
Bump version to 4.4.9 (#12062) v4.4.9 2025-04-15 09:19:05 -04:00
Adrian Cerbaro
3dffb4fb8e
fix: respect dataset clipping area when filling line charts (#12057)
* fix(plugin.filler): respect dataset clipping area when filling line charts

The filling area must respect the dataset's clipping area when clipping is enabled. Before this change, the line would be clipped according to the dataset's area but the fill would overlap other datasets.

Closes #12052

* chore(plugin.filler): use @ts-expect-error instead of @ts-ignore
2025-04-14 15:41:14 +02:00
Josh Kelley
a647e0d007
Add docs on using from Node.js (#12039)
This has come up a couple of times in Discord, so I thought it would be helpful to have official docs.
2025-02-25 11:15:56 -05:00
Josh Kelley
44908f546f
Update docs (#12037)
* Update docs

Grammar and style: "TypeScript", add articles, etc.

Add docs covering the `Array[]` version of data. Please review and let me know if I've made any mistakes.

Fix an apparent mistake in the `parsing: false` description of category axes: I believe it's trying to say that _strings_ would be a mistake.

* Reword based on feedback and further testing
2025-02-25 11:15:48 -05:00
Evert Timberg
32c8032e3f
chore: bump to v4.4.8 (#12036) v4.4.8 2025-02-19 10:37:15 -05:00
Josh Kelley
ebe20add53
Export ...ParsedData interfaces (#12035)
Otherwise, trying to inherit from DatasetController in a TypeScript project may result in TypeScript errors similar to the following:

> error TS9006: Declaration emit for this file requires using private name 'RadialParsedData' from module '"/Users/joshkel/src/app/node_modules/chart.js/dist/types/index"'. An explicit type annotation may unblock declaration emit.
2025-02-18 13:36:35 -05:00
Josh Kelley
2f425290ee
[fix] Handle non-primitives in isNumber (#12034)
While investigating https://github.com/chartjs/chartjs-plugin-zoom/issues/928, I found that `isNonPrimitive` will throw TypeError on a Moment.js object after it's passed through Chart.js's options proxy, because the object has its `Symbol.toPrimitive`, `toString`, and `valueOf` all set to null.

(See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion for background reading.)

Since isNumber appears to be a low-level function that can take any arbitrary input, it seems worth letting it handle this case.
2025-02-16 12:24:26 -05:00
Josh Kelley
370f6c385d
Fix helpers Chart type (#12012)
helpers.dom.ts functions referenced the internal `Chart` JavaScript class rather than the published `Chart<TType, TData, TLabel>` TypeScript definition. This causes errors when outside code tries to call helper functions.

The two `Chart` interfaces are incompatible - the `width`, `height`, and `currentDevicePixelRatio` properties are declared as readonly in the TS declaration but are manipulated by helpers.dom.ts functions, and helpers.dom.ts functions need to be invoked both by internal Chart.js code (which uses the JS class) and by outside code (which uses the TS types). To address this, I'm importing the JS version as `PrivateChart`. There may be a better solution.

It's my understanding that the comment about "typedefs are auto-exported" is obsolete now that helpers.dom is a native TS file.

Fixes #11153
2025-01-30 10:29:19 +01:00
Josh Kelley
f744621c9c
Type fixes for time adapters (#12010)
Specific changes:

* `formats` is defined as an arbitrary record.  In practice, it maps from `TimeUnit` and `'datetime'` to the specific date library's format strings.
* `parse` and `format` were defined as requiring `TimeUnit`, but they actually take date library format strings.  (E.g., it's up to the caller to look up format strings via `formats()` or user parameters.)
* `endOf` is never passed `isoWeek` (`isoWeek` isn't a normal `TimeUnit`, it's only used as a special case to `startOf`), and [chartjs-adapter-date-fns](https://github.com/chartjs/chartjs-adapter-date-fns/blob/v3.0.0/src/index.js#L101) doesn't support it.
* The constructor's options parameter is optional.
* `weekday` is documented as allowing a boolean (true means to start on Monday).
* `export default { _date: DateAdapterBase }` meant that `new _date()` returns a `DateAdapterBase` instance, whose methods take no parameters.  Since it can be overridden at runtime, I replaced it with a more generic constructor + static methods.
2025-01-29 11:32:29 +01:00
Ethan Shea
246c5c78ed
Correct broken link in animations.md (#12005) 2025-01-21 07:58:31 -05:00
Prem
b24cb2fd30
Update linear-step-size.md (#11997)
hover: {
      mode: 'index',
      intersec: false
    },

corrected the spelling of intersect.
2025-01-14 12:27:41 +01:00
Mariss Tubelis
97b564b718
Bugfix: Binary search wrapper returns non-existing index (#11991) 2025-01-05 09:42:33 -05:00
Mariss Tubelis
a77a63b16b
Bugfix: return nearest non-null point on interaction when spanGaps=true (#11986)
* First step in fixing the bug of spanGaps null point interaction

* Complete bugfix of spanGaps null point interaction

* Add two tests in core.interaction.tests for the bugfix change

* Remove odd line break

* Use isNullOrUndef helper for point value checks

* Add 10 more test cases for nearest interaction when spanGaps=true
2025-01-03 10:50:56 -05:00
Mariss Tubelis
1e3d6e5711
Bugfix: span gaps over null values beyond scale limits (#11984)
* Bugfix: spanGaps not working near min and max limits

* Fix error when meta.dataset.options = null

* Add tests for correct setting of line controller properties _drawStart and _drawCount

* Fix spacing in controller line tests

* Add tension to test

* Add a better test case

* Avoid the use of FindLastIndex

* Avoid taking 0 for null value and improve naming
2025-01-02 19:17:24 -05:00
Jacco van den Berg
57b5c5b78f
Chore: bump version to 4.4.7 (#11969) v4.4.7 2024-12-01 17:35:13 +01:00
Jacco van den Berg
4d034a0275
Add documentation about setting default tooltip font (#11968) 2024-12-01 10:49:55 +01:00
Jacco van den Berg
79773b7243
Show correct title in multi series pie chart example (#11962)
Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-11-21 21:47:09 +01:00
dependabot[bot]
36d992027c
Bump cross-spawn from 6.0.5 to 6.0.6 (#11959)
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 6.0.5 to 6.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/v6.0.6/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v6.0.5...v6.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-21 20:47:57 +01:00
DustinEwan
3a515d08e8
fix: correct typing for doughnut, pie, and polarArea charts (#11521)
* fix(#10896): correct typing for doughnut, pie, and polarArea charts

* formatting
2024-11-18 15:43:17 -05:00
Mikhail
49256c6149
simplify check undefinded (#11501) 2024-11-18 15:24:43 -05:00
Jacco van den Berg
bb82c8f549
Export TRBL from geometric (#11948)
Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-11-04 15:10:35 +01:00
Evert Timberg
47245a7f36
chore: version bump for 4.4.6 release (#11943) v4.4.6 2024-10-28 14:36:05 +01:00
Nikolai Iakovlev
6dd448b933
Fix: applyStack() returned the sum of all values for hidden dataset indices, which resulted in wrong show animations (#11938) 2024-10-24 11:55:58 -04:00
Jacco van den Berg
bb5ca384a3
Fix 404 to samples in release drafter (#11933)
Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-10-15 21:12:00 +02:00
Jacco van den Berg
7af71f5077
Bump package version to 4.4.5 (#11932)
Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
v4.4.5
2024-10-15 20:50:45 +02:00
Jacco van den Berg
03d1d5caa2
Allow array's in backgroundColor defaults and add hover background and border color to defaults (#11931)
* Allow array as default and add extra default options

* Add test

---------

Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-10-15 20:31:51 +02:00
Damien Regad
22a0ba9709
Fix typo in time.md (#11930) 2024-10-15 08:06:50 -04:00
Jacco van den Berg
3f2968cb41
Add check to colors plugin if defaults are set (#11927) 2024-10-13 09:12:16 +02:00
Moriwaki Masafumi
5d2dfbe68d
Avoid error if borderOpts.dash is undefined (#11907) 2024-10-12 21:14:07 -04:00
dependabot[bot]
ea88dba68d
Bump socket.io from 4.6.1 to 4.7.5 (#11875)
Bumps [socket.io](https://github.com/socketio/socket.io) from 4.6.1 to 4.7.5.
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/4.7.5/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io/compare/4.6.1...4.7.5)

---
updated-dependencies:
- dependency-name: socket.io
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-26 17:13:23 +02:00
Jacco van den Berg
680cd227d4
Fix initial dataset stacks (#11882)
* Update cahced _stacked value after updating stacks

* Add test

---------

Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-08-26 17:13:12 +02:00
Jacco van den Berg
dd554e0d87
Bump package version to 4.4.4 (#11874) v4.4.4 2024-08-20 22:25:36 +02:00
Jacco van den Berg
2fa724110a
Check if range method exists on element before executing it (#11873)
Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-08-20 21:37:23 +02:00
Jacco van den Berg
a1f7355ab8
Add radial linear scale to docs section of samples (#11871)
* Add radial linear scale to docs section of samples

* white space

---------

Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-08-20 18:11:00 +02:00
Jacco van den Berg
3dac05ed00
Return false from the average tooltip positioner on no valid data (#11863) 2024-08-17 08:52:36 +02:00
Artur Morys - Magiera
b51b57aca4
fix(types): exclude DeepPartial<unknown[]> from ChartOptions interface (#11867)
* fix(types): exclude DeepPartial<unknown[]> from ChartOptions interface

* refactor: format index.d.ts to comply with ESLint rules
2024-08-16 19:57:26 -04:00
Artur Morys - Magiera
74122c1b0f
fix(types): add xCenter and yCenter properties to RadialLinearScale interface (#11862) 2024-08-16 08:25:47 +02:00
huqingkun
b9c01414ba
Bugfix/issue 11804 tooltip show for all invisible (#11858)
* exclude 0 angle from inRange to not showing tooltip when all data are hidden

Signed-off-by: Hu, Vince <Qingkun.Hu@fmr.com>

* test 0 angle point not in arc range

---------

Signed-off-by: Hu, Vince <Qingkun.Hu@fmr.com>
2024-08-12 11:56:35 -04:00
Dimitris-Rafail Katsampas
f3f84fd624
fix: Unset _resizeBeforeDraw before _resize() call to avoid possible recursion (#11851)
* fix: Unset _resizeBeforeDraw before _resize to avoid possible recursion

* chore: Comment update

* chore: Reverted dependency change in package json
2024-08-08 20:08:30 +02:00
huqingkun
147ee593ba
fix issue #11717 (#11844)
* fix issue #11717

Signed-off-by: Hu, Vince <Qingkun.Hu@fmr.com>

* unit test for issue #11717

* fixing test lint style issue

* update codes according review comments

---------

Signed-off-by: Hu, Vince <Qingkun.Hu@fmr.com>
2024-08-06 17:32:26 +02:00
Jo Liss
0ca1b6ef85
Update OffscreenCanvas documentation, as it is widely available now (#11823) 2024-06-30 11:27:07 +02:00
Jacco van den Berg
19c02c8a25
Remove boxPading from legend options (#11817)
Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-06-26 14:01:19 +02:00
Michel Machado
4ee6c9e279
Add fit method to LegendElement interface (#11796) 2024-05-31 08:43:46 -04:00
Jacco van den Berg
ff740789a5
Fix drawing angle lines on reversed radial scale (#11788)
* Fix drawing angle lines on reversed radial scale

* add test

* Show ticks in test

---------

Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
2024-05-24 16:15:28 +02:00
Jon Dufresne
228a485603
types: Allow passing undefined for chart options (#11780)
When exactOptionalPropertyTypes, TypeScript distinguishes between the
value undefined and the property not existing. See:

https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes

For Chart.js options, this difference is not important and either
passing undefined or not including it have the same effect.
2024-05-21 09:07:35 -04:00