Commit Graph

283 Commits

Author SHA1 Message Date
Evert Timberg
3ff58e5065 Revert "Fixed tooltip labelling on Bar Chart when min is defined (#3618)" 2016-12-01 07:58:39 -05:00
Jerry Chang
b6807b2dd9 fixed tooltip labelling on Bar Chart when min is defined
added helper method to adjust the index

pass in chartConfig rather than access within method, make it easier to
test

added semi-colon at the end of helper method

added test for adjustIndex helper method

fixed lint issues

added integration test for the interaction of trigger an event over the
bar

.

.

moved adjustIndex into element helper

removed method from helper and adjusted method in core.interaction

added test for the element adjustIndex helper

added a skipIndexAdjustment method to handle when to skip the adjustment
along with test cases

fixed lint issues

removed the test for the helper method
2016-11-28 18:29:56 -05:00
etimberg
7a8f20e88f Fix monotone cubic interpolation when two adjacent points are at the exact same x pixel value 2016-11-28 18:28:06 -05:00
Christopher Moeller
97f6c8f12d Add rectRounded point style 2016-11-26 12:58:49 -05:00
etimberg
2e5df0ff42 Allow updating the config of a chart at runtime 2016-11-25 07:19:59 -05:00
Evert Timberg
7e5e29e3ee Improve radial scale (#3625)
Clean up radial linear scale. It now supports multiple lines for point labels. Fixes #3225
2016-11-25 07:19:43 -05:00
etimberg
58afbe428c 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 2016-11-20 11:52:08 -05:00
Jerry Chang
4fbb1bdbbc Fixed Issue with tooltip label display when given null data value (#3528)
When datasets.data contains a null value, the label displays incorrect
value.

code additions:
- unit tests for truthy label values (when data is null)
- checks to ensure handling of null value in getLabelByIndex method

added mock data sets from issue #3528 example

expect the return value from getLabelForIndex method to be valid (truthy)

added check for null of first data value in getLabelForIndex

fixed indentation and null comparison operator in code

fixed mistake in definition of firstData variable

changed testing for data on index 0 to using index variable

changed firstData to use value instead

condense the statments to use value variable
2016-11-19 09:29:15 -05:00
etimberg
48cb8b78e7 Remove unnecessary padding usages and update category scale tests 2016-11-18 17:58:07 -05:00
Evert Timberg
5dd1c77cf5 Take vertical padding into account 2016-11-18 17:58:07 -05:00
Evert Timberg
eaf109c2b1 When an axis needs padding due to a long, rotated, label it should be added inside the layout system rather than in each axis. 2016-11-18 17:58:07 -05:00
etimberg
f7d60c2606 Allow line chart to use pointBorderWidth of 0 correctly 2016-11-17 21:05:47 -05:00
etimberg
339265d21e use correct option for setting tension on radar charts 2016-11-14 07:27:01 -05:00
etimberg
3f2d7efc70 Add a function to filter items out of the legend 2016-11-12 18:48:25 -05:00
Simon Brunel
6b449a9e7c 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.
2016-11-11 18:10:19 -05:00
Simon Brunel
efced4780c 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.
2016-11-07 19:16:45 -05:00
etimberg
74d4dbc608 X and Y interaction modes now use the intersect option 2016-11-05 08:19:07 -04:00
Simon Brunel
5012dcbdae 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.
2016-10-31 08:47:28 +01:00
Josh Soref
67934920be Spelling fixes (#3522)
Including: actually, aspect, bottom, changes, characters, datasets, divisible, downward, guidelines, instance, instances, interrupted, item, javascript, label, lifecycle, lines, plugins, manually, milliseconds, nearest, occurring, position, predefined, recalculate, tooltip, those
2016-10-27 21:18:31 +02:00
etimberg
5ae268e942 Add a way to filter items in the tooltip 2016-10-23 16:33:08 -05:00
bydooweedoo
3bd4d283f7 Custom tooltip: add data points infos (#3201)
Expose tooltip items from tooltip model and added `x` and `y` properties to `TooltipItemInterface`
2016-10-19 08:48:17 -05:00
Zach Panzarino
a0ce74643f Fix eslint errors in layout service test 2016-10-18 22:00:55 +00:00
etimberg
596ff3718c 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.
2016-10-17 16:59:47 -05:00
etimberg
16f23b2c44 Add reset method to chart prototype 2016-10-17 06:40:29 -05:00
Zach Panzarino
766ca49cd0 Extend eslint to test files (#3473)
* Add eslint to test files

* Fix mockContext for tests

* Make formatting look better for nested objects
2016-10-16 17:34:59 -04:00
Simon Brunel
4a5b5a0e7e 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.
2016-10-16 08:25:13 -05:00
Evert Timberg
6ec6a929f0 Make index mode only work with the horizontal distance to an element (#3471)
Make index mode only work with the horizontal distance to an element if intersect is off
2016-10-15 16:49:35 -05:00
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
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
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
9041b5a2b9 Update default config tests and re-enable 2016-09-24 22:25:05 +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
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
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
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
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