Commit Graph

88 Commits

Author SHA1 Message Date
Loïc Bourgois
6d58a6a8a8 Add tests related to showLines for controller.scatter (#5150) 2018-01-16 10:29:49 +01:00
Ben McCann
37ec8384d7 Format the label in the time scale tooltip (#5095) 2018-01-13 10:39:16 -05:00
Simon Brunel
2d7f0a46c3 Fix updating plugin options (#5144)
Cached plugin descriptors hold a reference on the plugin options, which break if the plugin options object is replaced. That case happens when the user updates the plugin options with a new object, but also since the new config update logic (#4198) that now always clones the plugin options. The fix consists in explicitly invalidating that cache before updating the chart.
2018-01-13 08:23:50 -05:00
Simon Brunel
6bea15e7cf
Rename Chart.layout to Chart.layouts (#5118)
Chart.layouts seems more consistent with other service names (Chart.plugins, Chart.scales, etc.) but also more inline with the service which handle many layout (one per charts).
2018-01-09 14:12:40 +01:00
Simon Brunel
fb3ea03440
Make Chart.plugins importable (#5114)
Explicitly deprecate (since 2.1.5) `Chart.Legend` and `Chart.Title`.
2018-01-08 11:48:59 +01:00
Simon Brunel
ce27fe5ea6
Make Chart.layout(Service) importable (#5113)
Rename (and deprecate) `Chart.layoutService` to `Chart.layout` and make it importable.
2018-01-07 23:38:26 +01:00
Ben McCann
33c7d941f7 Add back Chart.Ticks.formatters (#5088) 2018-01-06 18:59:47 +01:00
jcopperfield
b04ce949d1 Use time.unit option to create default min/max for empty chart (#5045) 2017-12-15 18:10:30 +01:00
jcopperfield
f0bf3954fe Fix issues #4572 and #4703 (#4959)
- issue #4572: logarithmic type if all numbers are zero browser crashes "Out of memory"
 - issue #4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
2017-12-12 18:43:51 -05:00
jcopperfield
6f34b2224f Fix issue #4928: linear tick generator doesn't round values to needed precision. (#4943)
* Fix issue 4928
 - linear tick generator doesn't round values to needed precision.

* Improve: replace toPrecision() in toString() to improve readability.

* Fix: logarithmic tick generator doesn't round values to needed precision.

* Fix: rounding tick values didn't work for negative values.

* Add: Core ticks tests
2017-12-02 09:24:57 -05:00
Simon Brunel
15d1056b53
Implement equally sized bars (#4994)
When `barThickness: undefined|null` (default), we compute an optimal sample size based on the smallest tick interval reduced to prevent any bar to overlap (bar equally sized). Also added support for a special `barThickness: 'flex'` value (previous default) that globally arranges bars side by side to prevent any gap when percentage options are 1 (variable bar sizes).
2017-12-02 12:38:36 +01:00
Xingan Wang
333f2eba99 Fix scale options update (#4198)
- allow options to be updated in-place or as a new object
- re-merge new options and rebuild scales & tooltips
- preserve reference to old scale if id/type not changed
- related tests and new sample also added.
- update document about options update
- update doc and example
2017-11-29 22:52:23 +01:00
jcopperfield
42d3d91f52 Fix issue #4441 - y-axis labels partially hidden due to restrictive initial fitting. (#4942)
* Fix issue 4441:
 - y-axis labels partially hidden due to restrictive initial fitting.

* Add regression test to linear scale

* Moved regression test from linear scale to core layout service
2017-11-25 08:28:57 -05:00
anders
6b824d9334 add check on overwriting canvas height/width (#4874)
* add check on overwriting canvas height/width

* unit test for this
2017-11-21 19:04:26 -05:00
jcopperfield
e080e782ab Fix bumpy line on smooth data set (#4944)
Linear scale getPixelForValue() method doesn't round the returned value anymore.
2017-11-14 13:56:45 +01:00
Kaido Hallik
683e86e549 Avoid tooltip truncation in x axis if there is enough space (#3998)
* In tooltip x align calculation take into account caretSize

Truncation up to caretSize pixels could happen if label text produced tooltip element with size width:
* left side tooltip: width < x and width > x - caretSize
* right side tooltip: width < chartWidth - x and width > chartWidth - x - caretSize
Default caretSize = 5, so with default configuration truncation up to 5 pixels could happen.

* avoid tooltip truncation if possible
use whole chart area for displaying tooltip

* in xAlign calculation take into account caretPadding

* add tests for tooltip truncation avoid logic

* use caretX instead of xCaret

* fix lint errors
2017-11-11 18:02:05 -05:00
jcopperfield
939756c260 Fix log scale when value is 0 (#4913) 2017-11-10 09:16:48 +01:00
Evert Timberg
13e9676625 Reset tooltip when calling Chart.update (#4840) 2017-10-28 10:20:34 +02:00
Simon Brunel
26c1936dee 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.
2017-10-24 19:11:40 +02:00
Ben McCann
b64fd5db25 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.
2017-10-20 09:03:38 +02:00
JewelsJLF
8ac0257f8d Add "beforeTooltipDraw" and "afterTooltipDraw" plugin hooks (#4793) 2017-10-14 23:29:35 +02:00
Florian Scholz
c83b03f668 Fixes #4772: added scope for tooltip position mode call and added docs (#4784)
* added scope for tooltip position mode call and added docs

* added test for positioner

* removed named func for lint

* resolved pull-request comments
2017-10-10 18:33:25 -04:00
Simon Brunel
3fe198c860 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.
2017-10-07 17:43:09 +02:00
Evert Timberg
52145de5db Fix regression in x-axis interaction mode (#4762) 2017-09-16 08:01:26 -04:00
andig
ea703a54bf Implement scale label padding (#4646) 2017-09-10 13:15:47 -04:00
Ben McCann
427aa99cb1 Make major ticks optional and off by default (#4723) 2017-09-08 18:25:51 -04:00
andig
2f950e2ab3 Improve controller tests stability (#4698) 2017-08-27 22:43:16 +02:00
andig
530c613e5c Improve bar test stability (#4694) 2017-08-24 18:16:08 -04:00
Simon Brunel
872dfec0f3 Introduce scriptable options (bubble chart) (#4671)
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.
2017-08-24 09:34:38 +02:00
andig
46c3b2406e Make bar tests independent from scales (#4686) 2017-08-23 17:07:14 -04:00
Akihiko Kusanagi
7dc71d009b 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.
2017-08-14 10:09:33 +02:00
andig
8dca88c7d5 Fix tests on OSX with retina screen
* Fix retina unit test failures
* Honor config file formatting
* Prevent gulp error on non-zero karma result
2017-08-05 10:48:12 -04:00
Ben McCann
2922dc96cf Allow updating dataset types (#4586) 2017-08-02 07:29:34 +02:00
Simon Brunel
15934e49c5 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`.
2017-08-02 07:28:27 +02:00
Simon Brunel
2c52209ba7 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.
2017-08-02 07:25:55 +02:00
Simon Brunel
f90ee8c786 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.
2017-08-01 14:28:45 +02:00
Simon Brunel
97e2373721 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`.
2017-07-30 21:24:29 +02:00
Simon Brunel
53b7a6392f 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.
2017-07-29 21:26:36 +02:00
Evert Timberg
326991ce50 index-y interaction mode + convert horizontal bar defaults to new mode (#4458)
index-y interaction mode + convert horizontal bar defaults to new mode
2017-07-28 18:07:28 -04:00
Simon Brunel
2cc242d5a3 New time scale ticks.source: 'data' option (#4568)
This new option value generates ticks from data (including labels from {t|x|y} data objects).
2017-07-27 06:41:09 +02:00
Simon Brunel
c6bda02468 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.
2017-07-26 13:33:45 +02:00
Simon Brunel
3aa7a20923 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.
2017-07-25 10:12:53 +02:00
Simon Brunel
48d6face28 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.
2017-07-23 11:41:12 -04:00
andig
e7445a5f00 Honour time scale min/max settings (#4522) 2017-07-22 14:35:06 +02:00
Simon Brunel
4c763bff44 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.

http://eslint.org/docs/rules/space-infix-ops
http://eslint.org/docs/rules/space-unary-ops
2017-07-22 14:13:09 +02:00
Ben McCann
f6b6956a3a Fix ESLint errors (#4485) 2017-07-22 09:19:06 +02:00
Ben McCann
48d76b20fe 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}`.
2017-07-22 08:33:22 +02:00
Simon Brunel
7b6388883a Refactor padding parsing under helpers.options (#4544)
New Chart.helpers.options.toPadding helpers that converts a number or object into a padding {top, right, bottom, left, height, width} object.
2017-07-21 15:03:03 +02:00
Simon Brunel
090196c07c 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.

https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
2017-07-20 19:20:54 +02:00
Simon Brunel
5ad1b4ade7 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.
2017-07-19 21:04:15 +02:00