Commit Graph

1043 Commits

Author SHA1 Message Date
Josh Kelley
c057c96693
Interaction functions (#10046)
* Refactor get...Items functions to take events rather than positions

To work toward exposing something like the get...Items functions.

* Switch getAxisItems to use optimizedEvaluateItems

optimizedEvaluateItems falls back to evaluating all items for unsorted items, and sorting / optimizing ought to be okay, so this ought to be equivalent.

* Performance

* Consolidate getRelativePosition

helpers.dom.js's getRelativePosition already had logic to handle ChartEvent vs. Event (as demonstrated by the `native` check within `getCanvasPosition`), so it's redundant for core.interaction.js to have its own `native` check.

Update `getRelativePosition` to use the same `native` check as core.interaction.js's version.  As best as I can tell, the ChartEvent's x and y are populated from `getRelativePosition`, so the previous `getCanvasPosition` was effectively just duplicating `getRelativePosition'`s work.  I added a test to verify this; it depends on a local, not-yet-submitted change in chartjs-test-utils' `triggerMouseEvent` to return the mouse event that it triggers.

* Add an API to refactor duplicate isPointInArea

* Rename and update JSDoc to prepare for making this public

* Give functions a consistent, generic interface

* Export functions for discussion

* Code review feedback

Add a non-null assertion, as requested in code review.

Add JSDoc to clarify that `getCanvasPosition` now expects a native `Event`, not a `ChartEvent`.  Add `@ts-ignore`; `getCanvasPosition` relied on some loose conversions between `Event`, `TouchEvent`, and `Touch` that would require several changes to make TypeScript happy.

* Code review feedback

Return the event directly, to speed up the code a bit.  Add JSDoc to help communicate its intent.  Update various comments.

* Finalize exports; add docs and TypeScript

* Update src/helpers/helpers.dom.js

* Update src/helpers/helpers.dom.js

Only thing needed actually is the update of chartjs-test-utils to 0.4.0

* Bump chartjs-test-utils dependency

To get supporting work from https://github.com/chartjs/chartjs-test-utils/pull/19

Co-authored-by: Jukka Kurkela <jukka.kurkela@gmail.com>
2022-03-24 09:02:30 -04:00
Evert Timberg
edd764fcb5
minimum bar length setting keeps bar base in view (#10157) 2022-02-13 15:27:46 -05:00
Jacco van den Berg
ed68557a99
Make object notation usable for polarArea and radar (#10088)
* start to make object notation usable for polarArea
* enable object notation also for radar chart, test default key
2022-02-12 10:23:31 -05:00
Talla2XLC
7c14ab74aa
Add new align 'inner' for X axis (#10106)
* Add new align for X axis

new align 'left-right' for options.scales['x'].ticks namespace will allow users to aling ticks: 'start" for first (left) tick and 'end' for last (right) tick

* corrected name of aligment to "inner", documentation and add test for inner labels

* delete unnecessary changes

* corrected logic for reverse axis, add tests for reverse axis and withoutY axis

* corrected chart paddings for "inner" tick align

* code clearness

* Update types/index.esm.d.ts

Co-authored-by: Jacco van den Berg <39033624+LeeLenaleee@users.noreply.github.com>

Co-authored-by: Talla2XLC <alexey.ivanov@epc.com.ru>
Co-authored-by: Jukka Kurkela <jukka.kurkela@gmail.com>
Co-authored-by: Jacco van den Berg <39033624+LeeLenaleee@users.noreply.github.com>
2022-02-12 10:07:00 -05:00
Dimitri Papadopoulos Orfanos
a7d98fb1a0
Fix typos found by codespell (#10103) 2022-01-27 09:24:55 -05:00
Charles Masson
c527f47a89
Fix using above/below filling option with discontinuous lines (#10024)
Added a test in the boundary folder
2022-01-01 23:42:45 +02:00
Jukka Kurkela
1da9fdd519
radialLinear: fix positioning & scaling (#10021)
* radialLinear: fix positioning & scaling

* bloody pixels

* better radar fixtures
2021-12-23 20:47:36 +02:00
Jacco van den Berg
d24fe14e71
radialLinear: fix getIndexAngle when there are no labels (left) (#10020)
* Resolve animation if indexAngle is NaN

* make it private

* add test

* use chart.js helper instead of own logic

* implement feedback

* remove extra line

* my precious bits
2021-12-23 09:48:21 +02:00
Jukka Kurkela
f1c99316a7
radialLinear: Hide pointLabels of hidden data (#10018)
* radialLinear: Hide pointLabels of hidden data

* filter after map
2021-12-22 23:09:54 +02:00
t-mangoe
961533c115
Add centerPointLabels option for linear radial scale (#9949)
* center point labels to slices in polar chart

* remove unnecessary comments

* put the code together in one line

* fix the code according to the code review

* Undo changes related to the createContext function

* add documentation and types.
2021-12-21 20:27:07 +02:00
Jukka Kurkela
0d250a1fbf
Fix setActiveElements behavior after a mouse event (#9992)
* Fix setActiveElements behavior after a mouse event

* Better variable name
2021-12-17 00:34:53 +02:00
Jukka Kurkela
5bea389c42
Add random seed reporting to test runs (#9977) 2021-12-09 21:15:50 +02:00
Jukka Kurkela
ba6b446b04
Limit active element changes to chartArea (#9970)
* Limit active element changes to chartArea

* CC, remove duplicate ChartEvent interface

* CC2
2021-12-08 16:44:45 +02:00
Jukka Kurkela
d2d5f49953
Pass object from array as value to _fallback (#9969)
* Pass object from array as value to _fallback

* cleanup

* reduce changes

* reduce even more changes
2021-12-08 16:27:55 +02:00
Josh Kelley
d83f0467da
Improvements to tooltip positioners (#9944)
* Improve positioner types; allow overriding xAlign and yAlign

* More type improvements; pass in Chart as third parameter

* Expose chart as part of TooltipModel

I initially passed the Chart element as the third parameter to the positioner; however, Scale and LegendElement elements expose `this.chart`, and sample code for positioners used `this._chart`, so documenting the chart member and giving it a public name seems to make more sense.

* Update documentation

* Fix documentation

* Fix issues from code review
2021-12-06 07:39:06 -05:00
Josh Kelley
957ca837d5
Specify UTC time zone for the test suite (#9945)
The controller.bar/not-grouped/on-time test was failing on my computer because the date ranges happen to cross the end of Daylight Saving Time in the U.S., so chart was generated with one more hour of time than the test fixture expected.

Using moment-timezone to specify a fixed time zone with no DST seemed like the most robust fix. (Alternatively, I could pick a date range that doesn't change DST; that ought to work.)
2021-12-06 07:38:39 -05:00
Luuk de Vlieger
7784fbfded
Support "r" axis for non-intersecting interaction (#9919)
* Support "r" axis for non-intersecting interaction

* Extract some interaction functionality

* Remove whitespace and semicolons

* WIP: add interaction test

* Update documentation

* Fix test

* Add another test

* Update axis params

* Add additional axis check to binary search

* Update axis type
2021-12-05 08:57:07 -05:00
Jacco van den Berg
6d3a1c5fa6
Feature/active elements on top (#9920)
* add flag to draw active items on top

* add documentation and types

* remove redundent check

* added test

* resolve linting errors

* increase tollerance

* remove axes for better test, hope no tolerance needed
2021-12-05 08:56:53 -05:00
Jukka Kurkela
cd9d5289a4
Add borderJoinStyle option for arc elements (#9877)
* Add borderJoinStyle option for arc elements
* docs + types
* Consistently enumerate the possible choices
2021-12-05 08:56:37 -05:00
Jukka Kurkela
db995af158
Fix resolver caching issue when setting values (#9938) 2021-12-01 17:53:55 -05:00
Jukka Kurkela
f10fab6591
Fix tooltip caret position when it is positioned at the corners (#9922)
* Fix tooltip caret position when  at the corners

* Add test

Co-authored-by: Dirk Gausmann <di.gaus@gmx.de>
2021-11-30 00:02:00 +02:00
Jukka Kurkela
93452501d1
Category: Track automatically added labels (#9921)
* Category: Track automatically added labels

* Use correct yAxisKey (does not change anything)
2021-11-29 23:38:11 +02:00
Evert Timberg
7cbc47becc
Chart area boxes receive 0 margin during the final layout process (#9915) 2021-11-28 10:25:27 -05:00
Jukka Kurkela
bccb1276f0
Detect detach/attach in same observation (#9876)
* Detect detach/attach in same observation

* Missing `!`, better tests

* reduce duplication
2021-11-27 21:46:00 +02:00
Jukka Kurkela
838d40b2c8
Synchronize data visibility with data changes (#9857)
* Synchronize data visibility with data changes

* avoid babel spread bug

* Simpler?

* one more

* simple enough, cc?
2021-11-18 00:13:31 +02:00
Jukka Kurkela
0c5db4973e
Fix inRange for full circle arc (#9871)
* Update misleading sample comment

* Fix inRange for full circle arc
2021-11-18 00:10:19 +02:00
Jukka Kurkela
0dc733a96c
Configure all datasets before updating any (#9872)
* Update misleading sample comment

* Configure all datasets before updating any
2021-11-18 00:09:25 +02:00
Jukka Kurkela
c8b885dd3e
Prevent proxying CanvasGradient in Node platform (#9861) 2021-11-15 20:09:43 -05:00
Josh Kelley
aac0bef060
Fix cleaning up metasets (#9656)
* Fix cleaning up metasets

I believe it's a mistake to only delete the metaset if it has a valid controller; see f191f2f5 for where this behavior was introduced.

This is a minimal fix for #9653; as discussed there, it may also be worth updating `updateHoverStyle`.

As of #7030, `this._metasets` should always be defined, so checking whether it's undefined is no longer necessary.

* Add a test covering metaset behavior

* Add a regression test for #9653; fix `toHaveSize` usage

* Fix test failure
2021-10-23 18:46:33 +03:00
Jukka Kurkela
18fc9760e1
Fix stacked fill with lines over multiple scales (#9767) 2021-10-15 08:00:14 -04:00
Jukka Kurkela
81acad9f2b
Bubble: Properly parse radius for non-object data (#9764) 2021-10-15 07:57:39 -04:00
Jukka Kurkela
0dcf025ab7
Support nested scriptable defaults for datasets (#9770) 2021-10-14 08:35:51 -04:00
Jukka Kurkela
9a47395010
Fix controller.getMinMax for stacked charts (#9766) 2021-10-14 00:24:38 +03:00
Jukka Kurkela
12c5f9a839
Support nested scriptable options for datasets (#9758)
* Support nested scriptable options for datasets
2021-10-13 08:41:22 -04:00
Jukka Kurkela
bc5e5cbf11
Disable animations for BasicPlatform (offcreen) (#9751)
* Disable animations for BasicPlatform (offcreen)
* Update types
2021-10-11 14:37:25 -04:00
Jukka Kurkela
10292c6912
Linear: determine grace amount from range (#9719) 2021-10-04 17:43:04 -04:00
Jukka Kurkela
e1ae5e6abf
Add layout.autoPadding option (#9716) 2021-10-04 14:01:10 -04:00
Jukka Kurkela
0d4880e35c
Fix chart crashing when only min is defined (#9718) 2021-10-04 14:00:27 -04:00
Kurt Preston
60b094a9af
Fix chart crashing when max is defined but ticks are empty (#9641)
* Fix chart crashing when max is defined but ticks are empty

* Adding spec to reproduce scale bounds calculation error

Co-authored-by: Kurt Preston <kpreston@drw.com>
2021-10-04 20:30:16 +03:00
Jukka Kurkela
c3a53f06d7
Bar: fix too thick borders (#9678) 2021-09-25 07:52:03 +03:00
Jukka Kurkela
5587738fa4
Add sanity check for stepSize (#9679) 2021-09-24 18:13:10 -04:00
Jukka Kurkela
183a1a9f67
Fix segment styling with gaps (#9644) 2021-09-13 16:31:34 -04:00
Evert Timberg
f5c9a656ef
Configurable tooltip box padding (#9625) 2021-09-06 09:13:21 -04:00
Jukka Kurkela
3f23aaba9a
Add sanity checks for scale options (#9624) 2021-09-06 07:51:18 +03:00
Evert Timberg
71fa55acac
Add parsing support to pie/doughnut charts (#9622) 2021-09-05 13:46:26 -04:00
Evert Timberg
0cdadd2560
Enable per-corner border radius in tooltip (#9620) 2021-09-05 13:07:28 -04:00
Shubham Aggarwal
4af9851584
Ensure that controllers derived from the bar controller work correct in stacked charts (#9587)
* change parameter of functions
* argument and parameter change in DatasetController.js
* changing variable name to proper convention
* Update controller.bar.js
2021-09-04 13:43:34 -04:00
Jukka Kurkela
50ad1637b0
Fix plugin event filtering of renamed events (#9613) 2021-09-04 13:41:47 -04:00
Jukka Kurkela
8d68b119bc
Fix control points on animated line w/o border (#9592)
Co-authored-by: Jukka Kurkela <jukka.kurkela@scmbest.fi>
2021-09-01 20:39:48 -04:00
Jukka Kurkela
fca0309223
Detect attach/detach from any level (#9557) 2021-08-18 18:14:09 -04:00