Commit Graph

2584 Commits

Author SHA1 Message Date
Evert Timberg
d57526c453 Merge pull request #3357 from kant/patch-1
Minor fixes (proposal)
2016-09-23 20:19:08 -04:00
Simon Brunel
7d65bd3f52 Initial core.controller.js unit tests 2016-09-24 00:04:33 +02:00
dylan-kerr
4f668c3ed9 Adjust expected values in core.title.tests.js 2016-09-23 22:36:58 +01:00
dylan-kerr
fb302d5f00 Set maxWidth during title draw to avoid overflow
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.
2016-09-23 22:15:23 +01:00
Darío Hereñú
503e6f8291 Minor fixes (proposal) 2016-09-23 16:00:34 -03:00
Simon Brunel
d610987cfb 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' }).
2016-09-23 17:47:36 +02:00
Simon Brunel
16bcd6adc5 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.
2016-09-23 17:47:35 +02:00
Simon Brunel
8ec7ce2f93 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).
2016-09-23 17:47:33 +02:00
Simon Brunel
84da2e0a10 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.
2016-09-23 17:46:17 +02:00
Zach Panzarino
88c69f5f8c Move reverse option for labels to correct section in docs
Addresses comment in #3102
2016-09-23 00:12:40 +00:00
Simon Brunel
eea51e8678 Bump version to 2.3.0 2016-09-22 20:53:26 +02:00
Nick Downie
631b54522c Ensure the second pie chart sits inline 2016-09-21 11:17:17 +01:00
Simon Brunel
4da47a8430 Bump version to 2.3.0-rc.1 2016-09-17 11:42:28 +02:00
Simon Brunel
d9f6e6d0c5 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).
2016-09-17 11:40:26 +02:00
Zach Panzarino
56845d3cbb Merge pull request #3315 from zachpanz88/fix-pie-multi-dataset
Fix error where pie/doughnut charts did not render correctly with multiple datasets
2016-09-15 23:19:47 -04:00
Zach Panzarino
051f5b015b 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
2016-09-16 01:29:01 +00:00
Evert Timberg
b5544d1a1b Merge pull request #3287 from simonbrunel/tests-cleanup
Tests cleanup
2016-09-15 18:12:34 -04:00
Simon Brunel
5c5b1bfe59 Turn off linebreak-style linting rule
On Windows, this rule conflicts when running ESLint locally on a repository setup with autoCrlf (then all lines are errors).
2016-09-15 23:10:03 +02:00
Simon Brunel
8e37a11e39 Merge pull request #3308 from zachpanz88/eslint
ESLint Updates
2016-09-15 18:01:19 +02:00
Zach Panzarino
8207027743 Implement eslint changes proposed by @simonbrunel in code review 2016-09-15 12:49:11 +00:00
Zach Panzarino
a929fd473e Include changes suggested by @etimberg in code review 2016-09-15 01:21:45 +00:00
Zach Panzarino
8bc280e185 Allow variable use before define with warning 2016-09-15 00:27:29 +00:00
Zach Panzarino
bddd4cd94b Fix style issues in core and scales 2016-09-15 00:23:30 +00:00
Zach Panzarino
dd8fa78b45 Fix more style errors in controllers, elements, and scales 2016-09-14 22:34:41 +00:00
Zach Panzarino
9bf2e2bf7a Remove func-call-spacing rule 2016-09-14 18:16:21 +00:00
Zach Panzarino
11739234a4 Add keyword spacing to eslint and update code 2016-09-14 18:12:23 +00:00
Zach Panzarino
2d2f475a7a First round of eslint fixes 2016-09-14 18:05:19 +00:00
Zach Panzarino
f6eb675470 Update new eslint rules 2016-09-14 18:03:55 +00:00
Zach Panzarino
894b9928e7 Fix broken links in Maintaining.md 2016-09-12 23:21:40 -04:00
Evert Timberg
d8b13ca4ab Merge pull request #3261 from desowin/3211
Implement moment diff cache in time scale
2016-09-12 19:37:50 -04:00
Tomasz Moń
0514ed4793 Fix check for undefined
Use '!==' instead of '!='. This fixes eqeqeq error reported by gulp-eslint.
2016-09-12 10:41:27 +03:00
Evert Timberg
1c831230e3 Merge pull request #3284 from chartjs/fix/3278
Return correct tooltip data in category scale when double category scale is used
2016-09-11 07:46:06 -04:00
Evert Timberg
eb5bca6a4a When the category scale is used as the non main scale, return the correct data for the tooltip 2016-09-09 21:03:59 -04:00
Chris Fä
eb15ddfd2b Cleanup React extension links (#3282)
Remove the existing link which was for Chart.js v1 and add 2 links for Chart.js v2
2016-09-09 23:17:31 +02:00
Evert Timberg
90b56efab0 Merge pull request #3280 from trantorLiu/master
Update 01-Chart-Configuration.md
2016-09-08 19:26:55 -04:00
Chun-Yi Liu
a4bf786c2c Update 01-Chart-Configuration.md
Fix an anchor link.
2016-09-08 18:23:31 -05:00
Simon Brunel
4901471445 Automatically expose custom Jasmine matchers 2016-09-08 23:32:47 +02:00
Simon Brunel
8254331eef Fix time scale tests using the wrong chart instance
Some tests were using the removed global `chartInstance` variable, so tests values were incorrect since against the wrong chart instance.
2016-09-08 23:32:45 +02:00
Simon Brunel
efb82d93d8 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.
2016-09-08 23:32:43 +02:00
Lubomir Sotirov
38f85c98b5 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).
2016-09-08 14:42:42 +02:00
Simon Brunel
52cdff5fc1 Merge pull request #3254 from ianks/minDisplayFormat
Suport minUnit for time scale
2016-09-08 13:34:53 +02:00
Evert Timberg
7dcbde48f9 Merge pull request #3256 from simonbrunel/code-cleanup
ESLint and cleanup
2016-09-06 15:21:24 -04:00
Ian Ker-Seymer
7af6e7f192
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:

```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.
2016-09-06 13:11:06 -04:00
Tomasz Moń
cd24895cd1 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()).
2016-09-04 10:22:27 +03:00
Tomasz Moń
020ac35852 Build label diff lookup table
This reduces number of calls to momentjs diff() if there are multiple
datasets sharing the same labels (#3211).
2016-09-03 22:30:05 +03:00
Simon Brunel
7c93255b16 Enforce curly braces for single statement block
curly: [error, all] (http://eslint.org/docs/rules/curly)
2016-09-03 18:42:28 +02:00
Simon Brunel
3d40774c7d Enforce consistent tab indentation
indent: [error, tab] (http://eslint.org/docs/rules/indent)
2016-09-03 18:42:26 +02:00
Simon Brunel
69ab0d3e23 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`.
2016-09-03 18:42:22 +02:00
Simon Brunel
1f67e54d79 Remove unused npm packages 2016-09-03 18:09:57 +02:00
courchef
6269e2c437 Error possible when using the plugin Chart.Zoom.js used with time scale (#3194)
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.
2016-09-03 18:06:09 +02:00