Commit Graph

1035 Commits

Author SHA1 Message Date
Evert Timberg
f8e90b1c2d New fill modes for lines (#3460)
New fill modes for lines allowing the user to customize where the fill goes to
2016-10-14 06:19:47 -05:00
etimberg
0817199f45 No longer merge arrays during the config merge. Simply replace the property 2016-10-10 08:14:58 -04:00
Evert Timberg
d21a853f30 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.
2016-10-09 12:26:59 -04:00
Evert Timberg
65a06e4735 Properly merge colors for the label colors in the tooltip. I added a private helper to simplify the code in the tooltip 2016-10-08 07:28:45 -04:00
Evert Timberg
4d2772e313 Fix bubble chart tooltip callback to use correct labels (#3421)
Fix bubble chart tooltip callback to use correct label parsed from scales. Fixes #3029
2016-10-06 08:54:50 -04:00
Mickael Jeanroy
b64cab0046 Refactor tooltip draw function to extract drawBackground method
See issue #3416.
2016-10-04 14:10:56 -04:00
Aidan Fewster
365bdbb346 If tick options have min, max and stepSize use them to generate evenly spaced ticks 2016-10-04 09:30:28 -04:00
Evert Timberg
c15fa98978 Display tooltip color boxes for all tooltips. Added a new displayColors option to turn them off 2016-10-04 09:20:20 -04:00
Evert Timberg
03735563f4 Improve Tooltip and Hover Interaction (#3400)
Refactored interaction modes to use lookup functions in Chart.Interaction.modes and added new modes for 'point', 'index', 'nearest', 'x', and 'y'
2016-10-03 16:05:21 -04:00
Simon Brunel
1484520692 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.
2016-10-03 16:01:38 -04:00
Simon Brunel
9deebf8371 Fix config initialization and add unit tests 2016-09-29 17:55:04 -04:00
Simon Brunel
806a3832ef 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.
2016-09-28 15:43:15 -04:00
Evert Timberg
d3d9573af5 Fixes HTML legend string for polar area charts to match doughnut charts. (#3361)
Fixes HTML legend string for polar area charts to match doughnut charts
2016-09-25 08:30:39 -04:00
Evert Timberg
d09a17a2b1 Better number -> string callback for the radial linear scale (#3281)
Also create a new Chart.Ticks namespace to host common tick generators and formatters.
2016-09-24 22:56:16 +02:00
Simon Brunel
d407da4e36 Merge pull request #3325 from chartjs/fix/3269
Improve multiline labeling for tooltips in doughnut charts
2016-09-24 22:31:29 +02:00
Evert Timberg
c3d7a3328d In the doughnut chart, specifically handle multiline strings. 2016-09-24 22:25:04 +02:00
Evert Timberg
62ef40ebf6 skip non finite data points when determining scale sizes. Fixes #3125 2016-09-24 12:19:49 -04:00
Evert Timberg
ba133876c2 Merge pull request #3356 from simonbrunel/aspect-ratio
Fix aspect ratio and add responsive unit tests
2016-09-24 12:06:45 -04:00
Evert Timberg
11e8c50f72 Compute correct tooltip size when there is no title present (#3324) 2016-09-24 10:58:31 +02:00
Evert Timberg
9015e72ae1 Fix the legend drawing when labels.usePointStyle is true (#3323) 2016-09-24 10:57:33 +02: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
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
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
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
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
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
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
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
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
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
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
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
Evert Timberg
2268bef321 Merge pull request #3242 from Pikamander2/new_branch
Fix zero border width not working (issue #3241)
2016-09-02 18:46:16 -04:00
Ekaterina Dontsova
6408ba426c Fix #3022 Multi-lines label alignment (#3239) 2016-09-03 00:26:02 +02:00
Pikamander2
f3c51fc624 Fix zero border width not working (issue #3241) 2016-09-01 02:28:10 -04:00
Pikamander2
2002ca058b Fix zero border width not working (issue #3241) 2016-09-01 02:18:42 -04:00
Ekaterina Dontsova
4a4dccd6c1 Fix #3044 Line chart single data point centering (#3166)
In line charts, when there is only one label and data point, both are now horizontally centered.
2016-08-25 18:52:12 +02:00
Evert Timberg
8afac7bd3c Merge pull request #3191 from chartjs/fix/2994
Fix issues with repeated labels in the category scale and added a tes…
2016-08-23 17:09:31 -04:00
etimberg
904f19fb7e When drawTicks is false, we should not include their size in the size of the axis 2016-08-22 20:09:09 -04:00