Simon Brunel [Tue, 24 Oct 2017 17:11:40 +0000 (19:11 +0200)]
Move extend and inherits helpers in helpers.core.js (#4878)
Fix Rollup issue caused by early access of the `extend` and `inherits` helpers not yet part of the `helpers/index` import. Also added (basic) unit tests for whose methods.
Ben McCann [Sun, 22 Oct 2017 15:32:39 +0000 (08:32 -0700)]
Attempt to fix test flakiness (Firefox) (#4880)
These settings deal with browser disconnects. We had seen test flakiness from Firefox:
[Firefox 56.0.0 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms
Ben McCann [Fri, 20 Oct 2017 07:03:38 +0000 (00:03 -0700)]
Respect min and max when building ticks (#4860)
Generate time scale ticks (`ticks.source: 'auto'`) based on the effective visualized range instead of the actual data range, meaning that the computed units and/or step size may change if the time options min and max are different from the data min and max.
Simon Brunel [Sat, 7 Oct 2017 15:43:09 +0000 (17:43 +0200)]
Fix responsive issue when the chart is recreated (#4774)
Chrome specific issue that happens when destroying a chart and re-creating it immediately (same animation frame?). The CSS animation used to detect when the canvas become visible is not re-evaluated, breaking responsiveness. Accessing the `offsetParent` property will force a reflow and re-evaluate the CSS animation.
Simon Brunel [Sun, 10 Sep 2017 12:31:59 +0000 (14:31 +0200)]
Add Google Analytics to samples and update badges (#4734)
Inject the GA tracking snippet for all samples, including the index page. Also update README.md badges using the shields.io service for consistency with flat-square style and cache, and add release badges to the installation documentation page.
If `window` or `document` are `undefined`, a minimal platform implementation is used instead, which one only returns a context2d read from the given canvas/context.
Simon Brunel [Sat, 26 Aug 2017 05:48:57 +0000 (07:48 +0200)]
Fix wild special zero grid line when undefined (#4700)
Remove the special drawing for an undefined zero grid line since it causes issue when the first tick is not aligned on the scale extremity (ie only linear scales now display a special grid line for the origin). Hide scales in the filler plugin unit test fixtures to avoid future failures due to changes unrelated to the tested features.
New `options.resolve` helper that determines the final value to use from an array of input values (fallback) and a given context and/or index. For now, only the bubble chart support scriptable options, see documentation for details.
Add scriptable options documentation and update the bubble chart dataset properties table with their scriptable and indexable capabilities and default values. Also move point style description under the element configuration section.
Akihiko Kusanagi [Mon, 14 Aug 2017 08:09:33 +0000 (16:09 +0800)]
Make `offsetGridLines` consistent and add new `offset` scale option (#4545)
Add a new `offset` option to scales to add extra space at edges and remove the `includeOffset` argument from `getPixelForValue()` and `getPixelForTick()`. The bar controller now automatically calculates the bar width to avoid overlaps. When `offsetGridLines` is true, grid lines move to the left by one half of the tick interval, and labels don't move.
Simon Brunel [Thu, 3 Aug 2017 16:33:18 +0000 (18:33 +0200)]
Enforce variable declaration coding style (#4610)
For consistency, enable ESLint `one-var` rule to require multiple variable declarations for initialized variables per scope. Uninitialized variables can still be declared together (preferred) or separately.
Simon Brunel [Wed, 2 Aug 2017 05:28:27 +0000 (07:28 +0200)]
Change `scale.ticks.bounds` to `scale.bounds` (#4595)
The `bounds` option makes more sense directly under `scale` since it defines the scale limits strategy when no explicit min/max are specified. Also change the `bounds: 'labels'` option value for `bounds: 'ticks'` because it really means: "ensure ticks to be fully visible in the scale, whatever the ticks `source`.
Simon Brunel [Wed, 2 Aug 2017 05:25:55 +0000 (07:25 +0200)]
Replace the IFRAME resizer by DIVs (#4596)
Resize detection is now based on scroll events from two divs nested under a main one. Implementation inspired from https://github.com/marcj/css-element-queries.
Simon Brunel [Tue, 1 Aug 2017 12:28:45 +0000 (14:28 +0200)]
Add support for detached canvas element (#4591)
Allow to create a chart on a canvas not yet attached to the DOM (detection based on CSS animations described in https://davidwalsh.name/detect-node-insertion). The resize element (IFRAME) is added only when the canvas receives a parent or when `style.display` changes from `none`. This change also allows to re-parent the canvas under a different node (the resizer element following). This is a preliminary work for the DIV based resizer.
Simon Brunel [Sun, 30 Jul 2017 19:24:29 +0000 (21:24 +0200)]
Change `ticks.mode` to `scale.distribution` (#4582)
Fix `ticks.mode` behavior when `ticks.source` is `auto`: the lookup table is now built from the data and not from the ticks, so data (and ticks) are correctly distributed along the scale. Rename the option to `distribution` (more explicit than `mode`) and since this option applies from now on the data, it seems better to have it under `scale` instead `scale.ticks`.
Simon Brunel [Sat, 29 Jul 2017 19:26:36 +0000 (21:26 +0200)]
Change `scale.ticks` back to an array of strings (#4573)
Internal ticks are now stored as objects in the PRIVATE this._ticks member and must not be accessed directly from outside this class. this.ticks is around for a long time and hasn't been marked as private, so we can't change its structure without unexpected breaking changes. If you need to access the scale ticks, use scale.getTicks() instead.
Simon Brunel [Wed, 26 Jul 2017 11:33:45 +0000 (13:33 +0200)]
Rewrite unit test waitForResize helper (#4566)
The original implementation tries to intercept events from the chart internal iframe, which ones failing on Chrome 60. Checking internals doesn't seem the best approach, instead we could consider that a chart has been resized after the resize method has been called and processed. So let's hook `Chart.resize` and callback once it's done.
Simon Brunel [Tue, 25 Jul 2017 08:12:53 +0000 (10:12 +0200)]
New time scale `ticks.bounds` option (#4556)
`ticks.bounds` (`'data'`(default)|`'label'`): `data` preserves the data range while `labels` ensures that all labels are visible. This option is bypassed by the min/max time options.
Remove the useless time scale `_model` object containing private members: instead, make these members private (prefixed by `_`) part of the scale.
Simon Brunel [Sun, 23 Jul 2017 15:41:12 +0000 (17:41 +0200)]
Move and rewrite time helpers (#4549)
Move time helpers back into time scale, remove the `Chart.helpers.time namespace` and attempt to make the auto generation logic a bit simpler. The generate method doesn't anymore enforce min/max, the calling code needs to clamp timestamps if needed.
Simon Brunel [Sat, 22 Jul 2017 12:13:09 +0000 (14:13 +0200)]
Enforce spaces around infix/unary words operators (#4547)
Enable ESLint `space-infix-ops` and `space-unary-ops` (for words only) rules. Also added `samples` to the linting task to match Code Climate expectations.
Ben McCann [Sat, 22 Jul 2017 06:33:22 +0000 (23:33 -0700)]
Allow specifying the time axis via t attribute (#4533)
For time series charts it may make more sense to specify the horizontal axis using the variable `t`. This change will make it much easier to use the time scale with the financial chart, which takes in the data points `{t, o, h, l, c}`.
Simon Brunel [Thu, 20 Jul 2017 17:20:54 +0000 (19:20 +0200)]
Add support for line height CSS values (#4531)
The title plugin and scale title now accept lineHeight specified using unitless value (1.4), length ('1.4em' or '12px'), percentage ('200%') or keyword ('normal' === 1.2). The line height parsing has been refactored under the 'Chart.helpers.options' namespace. Also fix incorrect text positioning in the title plugin.
Simon Brunel [Wed, 19 Jul 2017 19:04:15 +0000 (21:04 +0200)]
New time scale `ticks.mode/.source` options (#4507)
`ticks.source` (`'auto'`(default)|`'labels'`): `auto` generates "optimal" ticks based on min, max and a few more options (current `time` implementation`). `labels` generates ticks from the user given `data.labels` values (two additional trailing and leading ticks can be added if min and max are provided).
`ticks.mode` (`'linear'`(default)|`series`): `series` displays ticks at the same distance from each other, whatever the time value they represent, while `linear` displays them linearly in time: the distance between each tick represent the amount of time between their time values.
Simon Brunel [Sun, 16 Jul 2017 17:38:19 +0000 (19:38 +0200)]
Make `Chart.defaults/Ticks/Interaction` importable (#4512)
Default options can now be accessed by importing `core/core.defaults`. The returned object acts as a singleton and is populated when importing classes that expose their own default values (meaning that importing only `code.defaults` results in an empty object). Also make `Chart.Ticks` and `Chart.Interaction` importable since existing defaults rely on these values.
Add the `defaults._set` method that make easier declaring new defaults by merging given values with existing ones for a specific scope (`global`, `scale`, `bar`, etc).
Simon Brunel [Sat, 15 Jul 2017 13:13:56 +0000 (15:13 +0200)]
Make `Chart.helpers` importable (#4479)
Properly export helpers and remove dependencies to `Chart.helpers`. Helpers can now be accessed from `src/helpers/index.js` (`var helpers = require('path/to/helpers/index')`, instead of `var helpers = Chart.helpers`).
Adrian Liaw [Sun, 9 Jul 2017 12:58:18 +0000 (20:58 +0800)]
Fix links in documentations (#4477)
* Fix relative links in documentation of configurations
* Fix relative link of 'Time Units'
* Fix relative links for chart types documentations
* Fix the release version link in developers/plugins
Simon Brunel [Sat, 1 Jul 2017 12:51:38 +0000 (14:51 +0200)]
Rewrite the clone and merge helpers (#4422)
The `clone` method now accepts any type of input but also recursively perform a deep copy of the array items. Rewrite the `configMerge` and `scaleMerge` helpers which now rely on a new generic and customizable `merge` method, that one accepts a target object in which multiple sources are deep copied. Note that the target (first argument) is not cloned and will be modified after calling `merge(target, sources)`. Add a `mergeIf` helper which merge the source properties only if they do not exist in the target object.
Simon Brunel [Sat, 1 Jul 2017 07:55:11 +0000 (09:55 +0200)]
Increase ESLint complexity and add config for tests (#4421)
Raise the cyclomatic complexity to 10 which seems to better match the project coding style and still reasonable (6 being quite low). Also move unit tests specific eslint rules in the cascaded `./test/.eslintrc` file (previously in `gulp.js`).
etimberg [Sun, 25 Jun 2017 13:06:22 +0000 (09:06 -0400)]
When all datasets are hidden, the linear scale defaults to a range of 0 - 1.
If `ticks.min` was set this would not set the range correctly.
Added a test to cover this case as well
Simon Brunel [Sun, 25 Jun 2017 10:14:28 +0000 (12:14 +0200)]
Fix non-passive event listener warning in Chrome
Deprecate `addEvent` and `removeEvent`, and move implementation in `platform.dom.js`. Add 'options' feature detection to register event listeners as passive and prevent warning in Chrome.
Simon Brunel [Sun, 25 Jun 2017 08:54:37 +0000 (10:54 +0200)]
Change `valueAtIndexOrDefault` behavior (#4423)
For consistency with `valueOrDefault`, `valueAtIndexOrDefault` now returns null if `value` (expected array) is null. Also get rid of the superfluous `get` prefix in `getValueOrDefault` and `getValueAtIndexOrDefault`.
Simon Brunel [Sat, 24 Jun 2017 09:46:06 +0000 (11:46 +0200)]
Cleanup and reorganize core and canvas helpers
Move some of the "core" and "canvas" utils in `helpers.core.js` and `helpers.canvas.js` and introduce the new `isNullOrUndef` and `isObject` helpers. Deprecate `indexOf` and rename `drawRoundedRectangle` to `roundedRect` which now creates a simple `rect` path if radius is 0. Write missing unit tests for the moved helpers.