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.
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).
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:
```json
{
labels: ['2016-01-01', '2016-01-02', '2016-01-03']
datasets: [
{
data: [12, 87, 42]
}
],
'...': '...'
}
```
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.
Previously buildLabelDiffs() was called at the end of buildTicks() and
hence labelDiffs cache was calculated twice (in getMinimumBoxSize() and
then in fitBox()).
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`.
Zooming in can cause the params `datasetIndex` and `index` to be null in method `getLabelMoment`. This happens when no ticks are visible on scale. It also throws an error and the chart becomes broken.
Add a new Travis deploy task to push dist/*.js and bower.json files into tag sources:
- requires Travis GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables
- skipped if not built from the "release" branch
- release.sh must be executable (see comment)
- reads tag version from package.json
- fails if tag already exists
In case of charts with over 4000 points, smallestLabelSeparation
calculation contributes significantly to total cpu usage (about 25% according
to built-in Chrome profiler). Important thing to note is that result
of this calculation is not used at all.
Related commits:
* 677c249b61
introduced smallestLabelSeparation. It was used in calculateBaseWidth
function.
* d198157fb8
removed last use of smallestLabelSeparation. Since then the calculated
value was never used.
* Added borderDash support for grid lines (#3136)
* Save and restore context to prevent border dash being applied to other elements
* Adds support for borderDashOffset, checks for setLineDash (IE9/IE10)
* Fixes tests