Commit Graph

513 Commits

Author SHA1 Message Date
etimberg
0c642720d4 Layout service supports a new order setting to configure how boxes are ordered on left and right edges 2017-02-25 12:10:27 -05:00
Adam Kirk
1e14124d55 fading tooltip 2017-02-24 19:27:05 -05:00
Marcelo Tedeschi
f97cab12b1 Refactored drawCaret and drawBackground functions to draw the background together with the caret in the same path 2017-02-24 19:27:05 -05:00
Marcelo Tedeschi
af11be3ce4 Added possibility to draw tooltip borders 2017-02-24 19:27:05 -05:00
Simon Brunel
4741c6f09d Add new dataset update and draw plugin hooks
In order to take full advantage of the new plugin hooks called before and after a dataset is drawn, all drawing operations must happen on stable meta data, so make sure that transitions are performed before.
2017-02-21 20:28:16 -05:00
Simon Brunel
cc90c5c643 Add chart data property setter and unit tests
Chart data can now be entirely replaced using `chart.data = {...}` thanks to the new property setter (instead of using `chart.config.data = {}`). Also update the documentation, as suggested by @ldaguise and @kennethkalmer, with a note about versions prior 2.6.
2017-02-18 11:53:39 -05:00
etimberg
8dafbc02c0 when axes are in the wrong place, update the config position 2017-02-12 11:23:17 -05:00
Evert Timberg
fed42e218a When the dataset label is not defined, the tooltip label string should not include a ':' character. Added a test to cover this case. 2017-02-10 19:30:52 -05:00
Jerry
8f217182b8 Update tooltip only when active element has changed (#3856)
Resolves #3746
2017-02-10 18:51:37 -05:00
Simon Brunel
ba6e041713 Unit tests for Chart constructor and deprecations 2017-02-10 18:37:56 -05:00
Simon Brunel
28ea6c4967 Rename chartInstance to chart 2017-02-10 18:37:56 -05:00
Simon Brunel
13c6121876 Remove deprecated nested chart accesses 2017-02-10 18:37:56 -05:00
Simon Brunel
a0077d4117 Deprecate Chart.Controller (and nested chart) 2017-02-10 18:37:56 -05:00
etimberg
8c90b9f2de Fix issue with how Chart.PluginBase is defined 2017-02-09 17:36:32 -05:00
Simon Brunel
7205ff5e2a Replace onEvent by before/afterEvent 2017-01-27 19:32:35 -05:00
Simon Brunel
1e9224d49c Make beforeDraw cancellable and fix easing value 2017-01-27 19:32:35 -05:00
Simon Brunel
979341ecb0 Plugin hooks and jsdoc enhancements
Make all `before` hooks cancellable (except `beforeInit`), meaning that if any plugin return explicitly `false`, the current action is not performed. Ensure that `init` hooks are called before `update` hooks and add associated calling order unit tests. Deprecate `Chart.PluginBase` in favor of `IPlugin` (no more an inheritable class) and document plugin hooks (also rename `extension` by `hook`).
2017-01-27 19:32:35 -05:00
Evert Timberg
1934358663 remove unnecessary extra init steps 2017-01-22 15:16:35 -05:00
Simon Brunel
312773ba7b Platform event API abstraction
Move base platform definition and logic in src/platform/platform.js and simplify the browser -> Chart.js event mapping by listing only different naming then fallback to the native type.

Replace `createEvent` by `add/removeEventListener` methods which dispatch Chart.js IEvent objects instead of native events. Move `add/removeResizeListener` implementation into the DOM platform which is now accessible via `platform.add/removeEventListener(chart, 'resize', listener)`.

Finally, remove `bindEvent` and `unbindEvent` from the helpers since the implementation is specific to the chart controller (and should be private).
2017-01-15 14:25:38 -05:00
SAiTO TOSHiKi
83c54194ae Fix : Scale label display at top and right. (#3741)
Fix Scale position at rotation when scale is top.
2017-01-05 09:00:05 -05:00
Evert Timberg
ecc35c527b Refactoring to put browser specific code in a new class (#3718)
Refactoring to put browser specific code in a new class, BrowserPlatform.
BrowserPlatform implements IPlatform. Chart.Platform is the constructor for the platform object that is attached to the chart instance.

Plugins are notified about the event using the `onEvent` call. The legend plugin was converted to use onEvent instead of the older private `handleEvent` method.
Wrote test to check that plugins are notified about events
2016-12-21 10:22:05 -05:00
etimberg
7756bedec6 fix stacked bars on logarithmic axes 2016-12-18 09:11:58 -05:00
Simon Brunel
3187a788e1 Add support for local plugins and plugin options
Plugins can now be declared in the chart `config.plugins` array and will only be applied to the associated chart(s), after the globally registered plugins. Plugin specific options are now scoped under the `config.options.plugins` options. Hooks now receive the chart instance as first argument and the plugin options as last argument.
2016-12-18 08:46:15 -05:00
etimberg
e249de7162 fix options in getDatasetAtEvent 2016-12-17 19:00:03 -05:00
SAiTO TOSHiKi
a5d9a02d5b Update core.scale.js
Change sie to size.
2016-12-16 19:59:32 -05:00
Tarqwyn
34d26ea497 Fix bug when calculating if steps fit into scale as a whole number then smal floating point errors make the consition pass false 2016-12-13 21:22:02 -05:00
etimberg
6f40d04964 Fix infinite loop in logarithmic tick generation 2016-12-07 18:47:30 -05:00
etimberg
75d15ff98b Fix newly introduced drawing bug when tick marks are not drawn 2016-12-07 18:47:30 -05:00
Jonathon Hill
152ce9c9f8 Pass the hover event to the onHover event handler (#3669)
Pass the hover event to the onHover event handler

This makes the behavior of the `onHover` handler consistent with the `onClick` handler:

```
function(event, activeElements) {
    var chartInstance = this;
}
```
2016-12-03 17:42:33 -05:00
SAiTO TOSHiKi
5a24bfa500 Implement clipping (#3658)
Implements clipping of items outside the chart area. Resolves #3506 #3491 #2873
2016-12-03 16:09:45 -05:00
Evert Timberg
b39c0e1f93 Fix rotated label meaasurements (#2879, #3354). When measuring the first width and last width, the fact that arrays of text are
present must be considered. In addition to fixing this, I did some general code cleanup in the fit and calculateLabelRotation methods.
2016-12-02 07:56:54 -05:00
Evert Timberg
3ff58e5065 Revert "Fixed tooltip labelling on Bar Chart when min is defined (#3618)" 2016-12-01 07:58:39 -05:00
Evert Timberg
5bf203037c Do not notify plugins when a silent resize occurs (#3650)
Prevent the resize method from notifying plugins if it is a silent resize. A silent resize occurs during startup and we do not want plugins to do anything here because the chart is not set up.
2016-11-29 10:43:52 +01: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
etimberg
68b00b2dc5 Labels can get bigger when the 2nd fit happens. Don't arbitrarily force the size to change 2016-11-20 13:49:44 -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
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
Jeff Carey
fd2e40ce11 Fixed vertical alignment in legend text (#3387) 2016-11-18 07:35:31 -05:00
Evert Timberg
68a2c8240f remove unused cancel animation frame method 2016-11-13 08:16:40 -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
a94885e32d 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}}.
2016-11-03 22:43:52 +01: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
etimberg
f288bc727b 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 2016-10-30 16:58:40 -05:00