Simon Brunel [Sat, 18 Feb 2017 10:58:45 +0000 (11:58 +0100)]
Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before.
Simon Brunel [Sat, 11 Feb 2017 15:02:15 +0000 (16:02 +0100)]
Add chart data property setter and unit tests
Chart data can now be entirely replaced using `chart.data = {...}` thanks to the new property setter (instead of using `chart.config.data = {}`). Also update the documentation, as suggested by @ldaguise and @kennethkalmer, with a note about versions prior 2.6.
Simon Brunel [Sun, 22 Jan 2017 19:13:40 +0000 (20:13 +0100)]
Plugin hooks and jsdoc enhancements
Make all `before` hooks cancellable (except `beforeInit`), meaning that if any plugin return explicitly `false`, the current action is not performed. Ensure that `init` hooks are called before `update` hooks and add associated calling order unit tests. Deprecate `Chart.PluginBase` in favor of `IPlugin` (no more an inheritable class) and document plugin hooks (also rename `extension` by `hook`).
Simon Brunel [Sat, 14 Jan 2017 13:38:56 +0000 (14:38 +0100)]
Platform event API abstraction
Move base platform definition and logic in src/platform/platform.js and simplify the browser -> Chart.js event mapping by listing only different naming then fallback to the native type.
Replace `createEvent` by `add/removeEventListener` methods which dispatch Chart.js IEvent objects instead of native events. Move `add/removeResizeListener` implementation into the DOM platform which is now accessible via `platform.add/removeEventListener(chart, 'resize', listener)`.
Finally, remove `bindEvent` and `unbindEvent` from the helpers since the implementation is specific to the chart controller (and should be private).
Evert Timberg [Wed, 21 Dec 2016 15:22:05 +0000 (10:22 -0500)]
Refactoring to put browser specific code in a new class (#3718)
Refactoring to put browser specific code in a new class, BrowserPlatform.
BrowserPlatform implements IPlatform. Chart.Platform is the constructor for the platform object that is attached to the chart instance.
Plugins are notified about the event using the `onEvent` call. The legend plugin was converted to use onEvent instead of the older private `handleEvent` method.
Wrote test to check that plugins are notified about events
SAiTO TOSHiKi [Tue, 20 Dec 2016 14:01:07 +0000 (22:01 +0800)]
Fix bar draw issue with `borderWidth`. (#3680)
Fix bar draw issue.
1. `Chart.elements.Rectangle.draw` function supports both horizontal and vertical bar.
2. Corrected bar position at minus.
3. Adjust bar size when `borderWidth` is set.
4. Adjust bar size when `borderSkipped` is set.
5. Adjust `borderWidth` with value near 0(base).
6. Update test.
Simon Brunel [Thu, 3 Nov 2016 21:40:47 +0000 (22:40 +0100)]
Add support for local plugins and plugin options
Plugins can now be declared in the chart `config.plugins` array and will only be applied to the associated chart(s), after the globally registered plugins. Plugin specific options are now scoped under the `config.options.plugins` options. Hooks now receive the chart instance as first argument and the plugin options as last argument.
Evert Timberg [Tue, 8 Nov 2016 02:17:20 +0000 (21:17 -0500)]
Fix rotated label meaasurements (#2879, #3354). When measuring the first width and last width, the fact that arrays of text are
present must be considered. In addition to fixing this, I did some general code cleanup in the fit and calculateLabelRotation methods.
Evert Timberg [Tue, 29 Nov 2016 09:43:52 +0000 (04:43 -0500)]
Do not notify plugins when a silent resize occurs (#3650)
Prevent the resize method from notifying plugins if it is a silent resize. A silent resize occurs during startup and we do not want plugins to do anything here because the chart is not set up.
etimberg [Sat, 5 Nov 2016 00:41:54 +0000 (20:41 -0400)]
Properly use the ticks.padding option. To correctly fix the issue, the default padding was changed from 0 to 10. This change caused all of the test changes since the width of a vertical scale was lowered by 10px
Simon Brunel [Fri, 11 Nov 2016 18:53:45 +0000 (19:53 +0100)]
Fix retina scale when display size is implicit
The retinaScale helper now enforces the display size to the correct values because if no style has been set on the canvas, the render size is used as display size, making the chart bigger (or smaller) when deviceAspectRatio is different of 1.
Simon Brunel [Mon, 7 Nov 2016 23:16:58 +0000 (00:16 +0100)]
Fix context state restoration on destroy
In many cases, the canvas render size is changed by the lib, causing the state stack to be discarded, meaning that we can't use save() and restore() to release the context with its initial state (i.e. before creating the chart). Since we don't need (want) to manually save / restore the context initial state, simply make sure to reset it to the default state to give a fresh context back to the user. That also means we don't need to revert the scale when the pixel device ratio is not 1.
Simon Brunel [Thu, 3 Nov 2016 21:43:52 +0000 (22:43 +0100)]
Fix the event handler when legend is disabled (#3544)
When legend is disabled (i.e. {options: {legend: false}}), me.legend is null. Add the same test on me.tooltip even if the tooltip object is always created in case of {options: {tooltips: false}}.
Simon Brunel [Mon, 31 Oct 2016 07:47:28 +0000 (08:47 +0100)]
Fix iframe resize handler when re-attached to DOM (#3527)
When the iframe is attached to the DOM, its content is reloaded (invaliding the resize listener) so make sure to install the handler after the iframe is loaded. Optimize resize events by throttling resize process until the next animation frame. Rewrite the unit test "waitForResize" method, the previous one (timeout) was too weak and most tests was failing on FF.
etimberg [Sun, 30 Oct 2016 15:03:19 +0000 (11:03 -0400)]
When an event triggers an update while the bufferedUpdate state is true, we need to do that render with priority over any other renders that take place for animations and tooltips
etimberg [Fri, 21 Oct 2016 03:12:10 +0000 (23:12 -0400)]
Reorganized sample files into sub directories. Added a helper containing colours that should be used by all samples.
I added new samples to explain behaviour and modified all samples to have consistent styling. In updating the samples,
I removed the use of jQuery and instead use standard methods.
For the custom tooltip samples, I updated the styling to show color boxes like the regular tooltips.
etimberg [Sat, 15 Oct 2016 21:04:22 +0000 (17:04 -0400)]
Add new properties for the caretX,caretY point of a tooltip. Useful for custom tooltips.
The custom tooltip sample was updated as well to use the new properties.
etimberg [Sun, 16 Oct 2016 01:16:35 +0000 (21:16 -0400)]
Layout service now supports configurable padding on left, top, right and bottom.
Re-enabled the layout service tests and then properly disabled the tests that
fail on the CI.
Simon Brunel [Sat, 15 Oct 2016 21:40:22 +0000 (23:40 +0200)]
Enhance context acquisition on chart creation
Add support for creating a chart from the canvas id and prevent exceptions, at construction time, when the given item doesn't provide a valid CanvasRenderingContext2D or when the getContext API is not accessible (e.g. undefined by add-ons to prevent fingerprinting). New jasmine matcher to verify chart validity.