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.
Evert Timberg [Sun, 9 Oct 2016 16:26:59 +0000 (12:26 -0400)]
Fix/3061 (#3446)
Solve weird animation issues with the tooltip. The optimization in Chart.Element.transition when the animation finishes to set `_view = _model` caused problems during update because we were using `helpers.extend` all over the place.
I changed to code so that we regenerate the model variable rather than continuously extending the old version. I also removed unnecessary tooltip reinitializations from the controller which should improve overall performance during interaction.
Simon Brunel [Sat, 1 Oct 2016 13:38:19 +0000 (15:38 +0200)]
Better animation when adding or removing data
In order to simulate real-time chart updates (i.e. horizontal animation), it's necessary to distinguish a removed or added value from a simple update. The dataset controller now hooks array methods that alter the data array length to synchronize metadata accordingly. Also remove the duplicate calls of updateBezierControlPoints() for line and radar charts.
Simon Brunel [Sat, 24 Sep 2016 19:51:12 +0000 (21:51 +0200)]
Inject iframe for responsive charts only
Responsiveness is currently based on the use of an iframe, however this method causes performance issues and could be troublesome when used with ad blockers. So make sure that the user is still able to create a chart without iframe when responsive is false.
CanvasRenderingContext2D.fillText() accepts a fourth parameter called maxWidth that sets the maximum width of the drawn text, enforced by scaling the entire line.
This commit uses the title element's layout dimensions to set maxWidth and avoid overflow outside of the canvas.
Simon Brunel [Fri, 23 Sep 2016 15:44:06 +0000 (17:44 +0200)]
Fix radar default aspect ratio and samples
Now that the aspect ratio is correctly handled, fix samples for charts with aspect ratio of 1 which was vertically too large. Also fix the default aspect ratio for radar charts which wasn't applied when creating a chart directly using new Chart(ctx, { type: 'radar' }).
Simon Brunel [Fri, 23 Sep 2016 15:43:52 +0000 (17:43 +0200)]
Fix initial aspect ratio when not responsive
When responsive is false and no canvas height explicitly set, the aspectRatio option wasn't applied because of the canvas default height. Prevent the retinaScale method to change the canvas display size since this method is called for none responsive charts, but instead make the resize() responsible of these changes. Also, as discussed some time ago, moved most of the core.js logic into core.controller.js. Clean up the destroy process and make sure that initial canvas values are properly saved and restored.
Simon Brunel [Fri, 23 Sep 2016 15:42:56 +0000 (17:42 +0200)]
Gulp command switch to run specific test files
Add the --inputs command switch to the unittest and unittestWatch tasks, to be able to run unit tests from the specified files only (e.g. gulp unittest --inputs=test/core.element.tests.js;test/core.helpers.tests.js).
Simon Brunel [Fri, 23 Sep 2016 15:46:17 +0000 (17:46 +0200)]
Make charts vertically responsive (#3105) (#3326)
Ensure that the hidden iframe is stretched vertically in order to detect height changes. Remove the classlist check/call since it was incorrectly spelled (should be classList), but also useless since the iframe has just been generated. Also remove the callback check: addResizeListener should never be called w/o a valid callback.
Simon Brunel [Sat, 17 Sep 2016 09:24:31 +0000 (11:24 +0200)]
Change bower package name for chart.js (#1562)
Thanks to the Bower team, we have been able to register the chart.js package name, previously pointing on a dead repository, which make the Bower integration more consistent with the npm one. All other alias still work (Chart.js, chartjs, Chart-js, chartjs-Chart.js).
Fix bug with pie/doughnut chart legends
Fixes a rendering issue when there are multiple datasets on a pie chart and they do not all contain the same number of data in their datasets
Fixes #3309
Simon Brunel [Tue, 6 Sep 2016 09:10:44 +0000 (11:10 +0200)]
Auto-release charts if not persistent (tests)
For convenience, charts are now automatically released after each spec if they are not acquired using `persistent: true`. Also remove the confusing and error prone `chartInstance` global variable and make sure that chart instances are local to each spec.
Fix 3267 Add "onHover" functionality for legend (#3271)
Add "onHover" to the legend options that will hold a user defined function (default is null) and called when a "mousemove" event is registered on top of a label item, with same parameters as the "onClick" option.
Also introduced logic that determines if the type of event passed to the legend "handleEvent" function is one we can handle. Currently allowing "click" and "mousemove" events. If the event is not one of those we stop the function execution (this is for the sake of reusing the legend hitbox calculations).
Ian Ker-Seymer [Fri, 2 Sep 2016 20:39:25 +0000 (16:39 -0400)]
Suport minUnit for time scale
When dealing with time-delineated datasets, often we have data for known
intervals of time. For example, we may have a dataset which represents number
of purchases per day:
In this case, Chart.js will attempt to figure out the best interval to display
the data, and could pick `hours` as the unit. However, in this case, we would
prefer to just use the `days` interval since our data's granularity can not be
represented well with `hours`.
To remedy this, this commit adds the `minUnit` option which allows
users to (optionally) specify what the minimum unit they would like
to use.
Tomasz Moń [Sun, 4 Sep 2016 07:22:27 +0000 (10:22 +0300)]
Build labelDiffs cache once per update (#3211)
Previously buildLabelDiffs() was called at the end of buildTicks() and
hence labelDiffs cache was calculated twice (in getMinimumBoxSize() and
then in fitBox()).
Simon Brunel [Fri, 2 Sep 2016 19:56:22 +0000 (21:56 +0200)]
Use gulp-eslint instead of gulp-jshint
Change the linter in gulp tasks to be consistent with Code Climate results which are based on ESLint using .eslintrc options. However, defaults Code Climate rules are too strict, so turn as warnings the 'complexity' and 'max-statements' rules (other errors has been fixed). Note that the Gulp task name has been changed for `gulp lint`.