Commit Graph

135 Commits

Author SHA1 Message Date
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
Jukka Kurkela
dd261b22f9 Use interpolation in fill: 'stack' (and fix interpolation) (#7711)
* Add tests and fix _boundSegment
* Use interpolate for finding points below
* Remove _refPoints logic (getTarget in draw)
2020-08-16 11:18:46 -04:00
Jukka Kurkela
6f83c55be5 'stack' mode for filler (#7705)
'stack' mode for filler
2020-08-11 09:31:18 -04:00
Jukka Kurkela
e756fb93a3 Resolve fonts through options.font (#7674)
* Resolve fonts through options.font
* Remove defaultRoutes from Tooltip fonts
2020-08-03 12:32:58 -04:00
Evert Timberg
70c2b07eb2 Do not use line defaults in legend (#7649) 2020-07-19 12:52:59 -04:00
Jukka Kurkela
af855d7646 Fix remaining issues in samples (#7625)
* Fix remaining issues in samples
* Update migration guide
* Use element instead
* Update tooltip.md
2020-07-16 13:28:12 -04:00
Ben McCann
426d8debba Tooltip: add dataPoint and rename value to formattedValue (#7618)
* Tooltip: add dataPoint and rename value to formattedValue
* Add a test
2020-07-14 17:40:32 -04:00
Jukka Kurkela
b8ad2a6a0a Registry bugs (#7608)
* Stop failing early when no scales are registered
* Move filler defaults
* Move legend defaults
* Remove legendHitBoxes from title
* Move @kurkle/color to devDependencies
2020-07-13 09:41:42 -04:00
Ben McCann
30e197742d Align the tooltip callbacks parameters with scriptable options (#7603)
Align the tooltip callbacks parameters with scriptable options
2020-07-12 18:26:13 -04:00
Jukka Kurkela
7024aad38f PluginService using registry (#7590)
PluginService using registry
2020-07-11 18:08:45 -04:00
Ben McCann
6c38c31a0a Pass context parameter to custom tooltip (#7579) 2020-07-06 09:34:06 -04:00
Evert Timberg
ff29522f5f Fix tooltip caret border when caret is on right or bottom (#7565)
* Fix tooltip caret border when caret is on right or bottom
* Lint fixes

* Code review feedback
2020-06-29 07:55:09 -04:00
Ben McCann
2ca155cce1 Add parameters to tooltip filter option (#7556) 2020-06-29 07:51:20 -04:00
Evert Timberg
ba5c9e01c6 Update tooltip when the display position changes (#7469) 2020-06-25 13:51:34 -04:00
Evert Timberg
537cd74919 Update the legend object during beforeUpdate (#7528)
* Update the legend object during beforeUpdate

When the legend is updated in afterUpdate, the position is not updated
before the layout system runs. When the event that the legend position
was changed, the legend would not move to the new position in the layout
system. This causes the chart to render incorrectly because the layout
system handled the layout as if the legend was still at the original position.

The update is split into two passes to ensure that labels still update correctly
after datasets (#6968)
2020-06-20 07:30:31 -04:00
Jukka Kurkela
2e4d623bf3 Tooltip: Provide argument for custom callback (#7522) 2020-06-18 17:37:27 -04:00
Jukka Kurkela
d0d9d7dd5c Read Title font options from correct place (#7502) 2020-06-12 17:58:09 -04:00
Evert Timberg
0703d78286 Enable custom legend box heights (#7459)
Enable custom legend box heights
2020-06-04 19:53:40 -04:00