Commit Graph

152 Commits

Author SHA1 Message Date
Jukka Kurkela
b2c7baf10d Avoid recursive event replay loops (#8738)
* chart._lastEvent = null while processing onHover

* Pass replay flag to external tooltip

* Add test for replay

* cc
2021-03-27 06:11:51 -04:00
Jukka Kurkela
97136d0cbf Add textAlign for legend labels (#8665)
* Add textAlign for legend labels

* Update tests
2021-03-18 07:37:03 -04:00
Jukka Kurkela
f10b510890 Fix tooltip padding (#8666) 2021-03-18 07:27:37 -04:00
Jukka Kurkela
a6b3b99675 Fix tooltip positioning issues (#8646)
* Fix tooltip positioning issues

* Update fixture, add npm run dev:ff

* Refactor determineXAlign

* Simplify more

* remove unneeded change
2021-03-16 08:06:05 -04:00
Jukka Kurkela
4d173c6b8a Allow tooltip callback override in dataset (#8640) 2021-03-14 11:29:54 -04:00
Evert Timberg
96f6b42c57 Use font lineHeight for tooltip alignment (#8631)
* Use font lineHeight for tooltip alignment
* Remove toFontString usage from tooltip
2021-03-13 15:14:48 -05:00
Evert Timberg
6ac89cbb25 Rename scale gridLines options to be clearer (#8628)
* Rename `options.gridLines` to `options.grid`

* Rename `offsetGridLines` to `offset`
2021-03-13 19:49:09 +02:00
Evert Timberg
91628c1449 Tooltip specific scriptable context (#8561)
* Update plugin to use it's own tooltip context

* Scriptable tooltip option types

* Tests

* Update types to use UnionToIntersection

* Update TooltipItem to use UnionToIntersection
2021-03-04 08:25:24 -05:00
Jacco van den Berg
9741942976 rename tooltip.custom property to tooltip.external (#8523)
* rename tooltip.custom property to tooltip.external

* Implement feedback

* missed 1
2021-02-27 18:18:12 +02:00
Jukka Kurkela
692d8a4128 Remove unreachable code paths from plugins (#8513) 2021-02-24 21:33:07 +02:00
Evert Timberg
8c4e862a2c Merge tooltip padding settings (#8493) 2021-02-22 08:30:25 +02:00
Evert Timberg
5c9e1d578c LTTB Decimation (#8468)
* LTTB Decimation
* Lint fixes
2021-02-21 09:15:45 -05:00
Evert Timberg
709dc3e854 Decimation plugin fixes (#8467)
* fix: Decimation plugin no longer changes the data order
fix: Decimation plugin no longer duplicates data points

* Use nullOrUndef helper instead of direct check

* Compute averageX value when decimating data using minMax decimation

* Place last point of interval at real X

This reduces the fuzziness on screens with devicePixelRatio > 1
2021-02-20 15:01:21 -05:00
Jukka Kurkela
5d5e48d01b Isolate properties / modes from animation options (#8332)
* Isolate properties / modes from animation options
* tabs, something wrong with the linter
* Update misleading variable name
2021-02-20 09:02:22 -05:00
Jukka Kurkela
aa5e0fe413 Remove core plugin fallbacks to root options (#8462)
* Remove core plugin fallbacks to root options
* Legend font color default fallbacks
2021-02-19 17:53:01 -05:00
Jukka Kurkela
cfd9c98575 Option resolution with proxies (#8374)
* Option resolution with proxies

* Remove plugin fallback to root options/defaults

* Update core plugins, reduntant font fallbacks

* Add some notes
2021-02-15 14:42:32 -05:00
Jukka Kurkela
ddfbcf777a Update eslint-config-chartjs to v0.3.0 (#8406) 2021-02-10 08:21:39 -05:00
Ben McCann
eb7ce4e5a0 Add raw data to context and rename dataPoint to parsed (#8318)
* Make the raw data point available in scriptable context
* Rename variables
* Update samples
2021-02-05 09:13:32 -05:00
Evert Timberg
650956b2e1 Create a new hook to enable data decimation (#8255)
* Create a new hook to enable data decimation

The `beforeElementUpdate` hook can be used to decimate data. The chart
elements will not be created until after this hook has fired ensuring that
if decimation occurs, only the needed elements will be created.

* Address code review feedback

* Rename hook to beforeElementsUpdate

* Simplify parsing logic

* Add decimation plugin to the core

* Allow a dataset to specify a different data key

* Decimation plugin uses the dataKey feature

* Refactor the decimation plugin to support configurable algorithms

* Lint the plugin changes

* Tests for the dataKey feature

* Convert test files to tabs

* Standardize on tabs in ts files

* Remove the dataKey feature

* Replace dataKey usage in decimation plugin

We define a new descriptor for the `data` key allowing the
plugin to be simpler.

* Disable decimation when indexAxis is Y

* Simplify the decimation width approximation

* Resolve the indexAxis correctly in all cases

* Initial documentation

* Reverse check

* Update TS definitions for new plugin options

* Move defineProperty after bailouts

* Add destroy hook
2021-02-01 16:37:32 -05:00
Jukka Kurkela
ad84d285d8 Rename LayoutItem.fullWidth to fullSize (#8358) 2021-01-31 13:44:44 -05:00
Jukka Kurkela
610461d714 Use provided options in tooltip plugin (#8254) 2020-12-31 08:46:23 +02:00
Jukka Kurkela
d00ffdcd76 Tooltip: Render when animations are disabled (#8252) 2020-12-30 08:33:30 -05:00
Evert Timberg
988b3c5d2b Create standardized text render method (#8227)
* Create standardized text render method
* Document renderText options and enable configurable decoration width
* Add tests for font rendering
* Split color definition to it's own file
* renderText supports setting styles
* Mock context needs to track textBaseline
* renderText can set textAlign and textBaseline
* renderText does not mutate the context + translate/rotate
* Explicitly set the text decoration style
* Move useStroke logic into renderText
* Cartesian scale: Update computeLabelItems to avoid duplicate allocations
2020-12-26 11:23:02 -05:00
Jukka Kurkela
7a2acebc28 Layout: enforce box limits, reject <0 chartArea (#8193)
* Skip chartArea boxes when chartArea <= 0
* Legend: limit to maxWidth/maxHeight
* Layout: enforce box limits, reject <0 chartArea
* Update legend fixtures
2020-12-18 12:56:04 -05:00
Jukka Kurkela
979cd4131b Fix legend alignment issues (#8168) 2020-12-15 08:50:13 +02:00
Jukka Kurkela
8ab62f57be Use correct color for legend labels (#8167)
* Legend colors fallback
* Update test
2020-12-14 16:08:40 -05:00
Jukka Kurkela
e1a3303c67 Legend plugin cleanup (#8109)
* Legend plugin cleanup

* cc1

* cc2

* cc3

* start/stop
2020-12-14 15:35:04 +02:00
Evert Timberg
e268845c7b Quick exit the legend fit function when the legend is not displayed (#8161)
When the legend is not displayed, there are no guarantees that the
format of the options dictionary is correct. Rather than performing
computations and then exiting without using the results, we can instead
exit quickly since the size of the legend will be (0, 0) if not displayed
2020-12-14 12:04:10 +02:00
LeeLenaleee
ae04fcf3c3 fix default font color for legend (#8139)
* fix default font color for legend
* adjusted docs to be consistent with fontColor to color
2020-12-05 14:34:34 -05:00
Jukka Kurkela
78dbeea1f0 Add new hooks for plugins (#8103)
* Notify beforeUpdate on disabled plugins

cc?

cc2

cc3

typo

* init, unInit, enabled, disabled

self review :)

update the new hook signatures to unified

merge error

* Review update

* start/stop, cc

* types, jsdoc

* stop between destroy and uninstall
2020-11-28 22:57:45 +02:00
Jukka Kurkela
61aea761f4 Unify signature of plugin hooks (#8102) 2020-11-28 09:45:43 +02:00
Jukka Kurkela
5faffae81b Title plugin cleanup (#8104)
* Title plugin cleanup

* more cleanup

* cc

* center formula

* Fix / update sample

* Restore functionality on RTL page
2020-11-26 15:07:01 +02:00
Jukka Kurkela
913a01a3a6 Move title, tooltip and legend to options.plugins (#8089)
* Move title, tooltip and legend to options.plugins

* Update tooltip.md

* Update legend.md and title.md

* Add migration notes

* typo

* Types

* Restore plurals

* One more s, restore tabs

* All plugins disabled

* lint

* cc
2020-11-25 08:50:12 +02:00
Jukka Kurkela
ddc72fcfbb Align font options with CSS (#8066)
* Align font options with CSS

* Review comments
2020-11-19 20:59:24 +02:00
Jukka Kurkela
910158055f Drop legacy browser support (#8009)
* Drop legacy browser support

* Docs

* Use rollup-plugin-istanbul for coverage

* exclude node_modules from coverage

* No cleanup() when doing coverage
2020-11-16 21:01:33 +02:00
LeeLenaleee
c3e861d78c dataset tooltip now shows correctly (#8024)
* dataset tooltip now shows correctly

* removed optional chaining
2020-11-08 15:41:52 -05:00
Evert Timberg
17f6edb650 Remove I prefix from TS types (#8017)
* Remove I prefix from TS types
* Update missing `ILayoutItem` typedefs
* IEvent should become ChartEvent
* Prevent FillTarget collision
* Import FontSpec instead of IFontSpec
* Prevent recursive DateAdapter problem
2020-11-07 08:35:19 -05:00
Jukka Kurkela
61d2227985 Tooltip: clear cached animations on initialize (#7983) 2020-10-30 18:43:46 -04:00
Dan Manastireanu
6869a41d40 feat: Draw tooltips with point styles. Closes #7774 (#7972)
* feat: Draw tooltips with point styles. Closes #7774

* chore: Add tooltip usePointStyle docs

* chore: Add tests and visual tests for tooltip usePointStyle

* chore: Update typescript with tooltip usePointStyle
2020-10-29 22:55:40 +02:00
stockiNail
ea047f5cf2 Legend item lineWidth is the average of borderWidth when set as object (Bar) (#7964)
* fixed default of tension property of line element

* Fix #7942

* Fixes some lint errors

* fixes "Expected property shorthand" error
2020-10-28 13:12:52 +02:00
Evert Timberg
4ed650acbe Enable overriding the legend pointStyle using new pointStyle option (#7959) 2020-10-26 14:16:00 +02:00
Jukka Kurkela
58d1911d05 Add args.mode to before/after update plugin hooks (#7949) 2020-10-24 18:36:31 +03:00
Evert Timberg
bc11f10216 Rename elements to mark as elements, i.e. Arc -> ArcElement (#7924)
* Rename elements to mark as elements, i.e. Arc -> ArcElement
* Rename RectangleElement to BarElement
* Also updates options.elements.rectangle to options.elements.bar
2020-10-20 08:18:56 -04:00
Jukka Kurkela
f5c4f97504 Add interaction options (#7922)
* Add interaction options
* Add migration note
2020-10-19 07:24:06 -04:00
Jukka Kurkela
73b4e82fd5 Use Object.create(null) as merge target, to prevent prototype pollution (#7917)
Use Object.create(null) as merge target to prevent polluting `Object.prototype`
2020-10-18 13:31:01 -04:00
Evert Timberg
c68ec57672 Reduce tooltip implied padding at top and bottom edges of the canvas (#7908)
* Allow the tooltip to get closer to the canvas edge

Closer to the top & bottom by considering (height/2) instead of height.

* Update missing options in TS types

* Remove unneeded brackets
2020-10-18 16:51:48 +03:00
Evert Timberg
c22d3bedea Ability to fill a line from a specified value along an axis (#7905) 2020-10-17 15:46:56 -04:00
Jukka Kurkela
06b5325778 Add maxWidth/maxHeight options for legend (#7852) 2020-10-06 07:41:16 -04:00
Evert Timberg
168965fa38 Enable custom sorting of the legend items (#7851) 2020-10-05 22:15:38 -04:00
Evert Timberg
a8a83d12cd Provide APIs to set active (hovered) and tooltip elements. (#7845)
Provide APIs to set active (hovered) and tooltip elements.

Chart.setActiveElements will set the hovered items.
Chart.tooltip.setActiveElements will set the tooltip items.
2020-10-05 17:14:38 -04:00