Commit Graph

352 Commits

Author SHA1 Message Date
Jukka Kurkela
d9012d9459 Trigger mouse events at the center of arc (#5991) 2019-01-18 07:46:13 -05:00
Jukka Kurkela
7bbf3cab5b Return correct label for value type axis (#5920) 2019-01-17 16:04:08 +01:00
Evert Timberg
a655da076e Implement scriptable options for points in line charts (#5973) 2019-01-15 09:24:12 +01:00
Evert Timberg
f3dd96779a Implement scriptable options for polar area charts (#5976) 2019-01-13 21:17:27 +01:00
Simon Brunel
8a3eb85928
Implement adapter to abstract date/time features (#5960) 2019-01-11 08:03:28 +01:00
Jukka Kurkela
20c748f90b Fix modifying ticks in afterBuildTicks (#5913) 2019-01-11 07:29:38 +01:00
Evert Timberg
e1ed26f315 Implement scriptable options for doughnut charts (#5966) 2019-01-10 16:00:36 +01:00
Simon Brunel
e03d8d8d7b
Make the main controller importable (#5969)
Merge `core/core.js` in `core/core.controller.js`, split default options next to their associated code and deprecate `Chart.types` (not sure what it was for).
2019-01-09 14:40:11 +01:00
Nodar Nutsubidze
9ecae7c5fb Test default tooltip callbacks for scatter charts (#5967)
This moves the mouse over the drawn point and verifies that there is no title in the tooltip and that the body contains expected content.
2019-01-09 14:37:25 +01:00
Jukka Kurkela
9d7eacd251 Fix generateTicks when working with tiny numbers (#5948) 2019-01-09 07:58:13 +01:00
Jukka Kurkela
dd3564aee5 Fix title, body and footer alignment inside tooltip (#5925) 2019-01-08 13:37:36 +01:00
Simon Brunel
87e44fa360
Cleanup scales export for better import strategy (#5953)
Scales now export their class and associated defaults (`_defaults`), the registration being done globally in `src/chart.js`.
2019-01-05 14:37:54 +01:00
Akihiko Kusanagi
26b7375329 Prevent bezier points from being capped when a data point is off the chart (#5937) 2019-01-05 12:28:15 +01:00
serhii-yakymuk
c51ac8a64a Make animation duration consistent across browsers (#5331) 2019-01-02 16:13:56 +01:00
Akihiko Kusanagi
39b4d61ac2 Fix time scale ticks.reverse issue (#5933) 2019-01-02 16:00:55 +01:00
Jukka Kurkela
918e2c027f Cast getRightValue to number in the bar controller (#5947) 2019-01-02 15:55:27 +01:00
Akihiko Kusanagi
aae05a08da Improve tick generation for linear scales (#5938)
* Improve tick generation for linear scales
* Simplify the tick generation code
* Refactor getTickLimit
2019-01-01 08:38:09 -05:00
Jukka Kurkela
4b6e53a617 Properly calculate space needed by tick label on autoSkip (#5922) 2018-12-21 07:56:53 +01:00
Jukka Kurkela
d7e8b733e3 Add reverse support to time scale (#5927) 2018-12-20 16:08:13 +01:00
Akihiko Kusanagi
d29ec5a485 Add scale.pointLabels.lineHeight and scale.ticks.lineHeight options (#5914) 2018-12-20 09:56:06 +01:00
Jukka Kurkela
c8ce3d2018 Add support for typed arrays (#5905) 2018-12-18 14:49:39 +01:00
Angus Comrie
7e429a8fc6 Add 'middle' interpolation to stepped plots (#5908) 2018-12-18 14:47:24 +01:00
Akihiko Kusanagi
db8f6c38dc Add support for 'inner' border for arc elements (#5841) 2018-12-18 13:58:02 +01:00
Dave Salomon
4fb259e3ac Add support for hiding axis when all linked datasets are hidden (#5885)
When `display: 'auto'`, the axis is visible only if at least one associated dataset is visible.
2018-12-18 09:33:03 +01:00
Simon Brunel
52b9793ba0 Use HTTPS instead of HTTP for URLs supporting it 2018-12-17 07:50:02 +01:00
Steve Gray
69fcba029b Remove autoSkip logic to always display last tick (#5891)
This changes the behavior of `autoSkip` so that it does not force the
display of the last tick. If the last tick can be displayed with equal
spacing to the rest of the ticks, it will be. Otherwise, it is not.
2018-12-09 12:56:51 -05:00
Akihiko Kusanagi
40495ec9d0 Fix the rounding issue of floating point numbers in category scale (#5880)
- Remove `Math.round` in the category scale code
- Add `helpers._alignPixel` to align grid/tick/axis border lines
- Fix grid/tick/axis border line calculation
- Add a check of the width of the axis border
- Refactor core.scale code
2018-12-09 11:34:34 +01:00
Akihiko Kusanagi
7c45fdac0d Remove gaps on the left and right when the axis offset is true (#5884) 2018-12-05 17:59:07 +01:00
Simon Brunel
be8d78a900
Make Chart.controllers.* importable (#5871)
`controllers.*.js` and `core.datasetController.js` are now importable (no more function export), that's why there is so many changes mainly due to one indentation level removed. Split code for `bar/horizontalBar` and `doughnut/pie` in separate files, added a global controllers import (`src/controllers/index.js`) and add tests to check that all dataset controllers are correctly registered under `chart.controllers.{type}`.
2018-11-29 21:06:34 +01:00
Akihiko Kusanagi
c84d249035 Fix test failures on Windows (#5872) 2018-11-29 21:05:36 +01:00
Akihiko Kusanagi
ecfa7b24c6 Add support for CanvasPattern and CanvasGradient in tooltip (#5869) 2018-11-29 13:52:56 +01:00
Simon Brunel
aa652df240
Deprecate Chart.{Type} classes (#5868)
It looks like these classes are a legacy from version 1 but we actually never promoted their usage. Instead, the regular way to create a chart is to set the type in the config, for example: `new Chart(ctx, {type: 'bar'})`. Some types are actually missing (no `Chart.HorizontalBar` or `Chart.Pie`) but it's also not scalable because it can easily conflict with other classes scoped under the `Chart` namespace.
2018-11-29 07:56:20 +01:00
Akihiko Kusanagi
d6ac7d8a80 Fix cut off tick labels in radial scale (#5848)
Fix the issue that the topmost tick label and the bottom of the chart area are cut off with a radial scale.
2018-11-28 08:35:15 +01:00
Akihiko Kusanagi
1f2fa5c90c Adjust the size of rectRounded/rectRot point to fit pointRadius (#5858)
- Calculate the vertices of the shapes so that they are inscribed in the circle that has the radius of `pointRadius`
- Remove `translate()` and `rotate()` to fix the regression introduced by #5319
- Refactor `rectRounded` for better performance
2018-11-28 07:53:41 +01:00
Akihiko Kusanagi
241499d27f Make getHoverColor() return the original value if it is CanvasGradient (#5865) 2018-11-27 19:54:03 -05:00
Jukka Kurkela
f5437fe548 Fix nearest interaction mode to return all items (#5857)
Return all items that are at the nearest distance to the point and add unit tests for nearest + axis: 'x' and nearest + axis: 'y'
2018-11-27 16:26:41 +01:00
Akihiko Kusanagi
0351a88a63 Add support for gridLines/angleLines borderDash for polarArea/radar charts (#5850) 2018-11-26 08:57:31 +01:00
chtheis
b68341d9b8 Correct calculation of padding in percent (#5846) 2018-11-21 09:35:49 +01:00
Akihiko Kusanagi
bc494e0a81 Use empty labels for tests so as not to be affected by the font width (#5842) 2018-11-21 08:58:39 +01:00
Simon Brunel
75aa44eef6
Upgrade dev dependencies to reduce vulnerabilities (#5840) 2018-11-18 09:33:34 +01:00
Jan Tagscherer
3ea93a09f2 Add regression test for legend layout issue (#5776) 2018-11-14 11:12:57 +01:00
Jan Tagscherer
56b30e1db1 Check pixel values using the pixel proximity matcher (#5833) 2018-11-14 11:08:40 +01:00
Akihiko Kusanagi
637c2176ec Support decimal stepSize (#5786) 2018-11-12 21:12:09 +01:00
Akihiko Kusanagi
e730f87e15 Fix legend item layout issue (#5816) 2018-11-12 08:57:16 +01:00
Akihiko Kusanagi
f74699a591 Fix offsetGridLine behavior with a single data point (#5609) 2018-11-02 08:44:10 +01:00
Evert Timberg
b3b5c7de4f Ensure that when we check typeof x == 'number' we also check instanceof Number (#5752) 2018-10-22 09:52:05 +02:00
Simon Brunel
2dbf1cd1af
Add support for *.js test fixture config (#5777)
JSON doesn't support functions which are needed to create scriptable options, so implement a very basic method to load a JavaScript file exporting the config in `module.exports`. Also rename test sources (remove the `jasmine.` prefix), cleanup `karma.conf.js` and add an example .js fixture config (bubble radius option).
2018-10-20 11:38:48 +02:00
Alexandre Dubé
5816770e45 Introduce the 'minBarLength' bar option (#5741) 2018-10-18 22:28:56 +02:00
Carl Osterwisch
7a65546629 Fix scale when data is all small numbers (#5723)
* Add test for correct handling of small numbers

* Calculate tick precision for arbitrarily small numbers

* Use scientific notation for very small tick numbers

* Calculate significant digits for exponential tick values
2018-09-16 11:33:48 +02:00
Simon Brunel
91608398b6 Add "point style" image tests
Replace the old style canvas "mock" context checks by image based unit tests which are easier to maintain and allow more flexibility in the drawing logic since we are not testing the context calls but the final painted result.
2018-07-29 22:43:23 +02:00
Colin
352268616b Fix min and max option checks in linear scales (#5209)
When 0, the min and max options was considered not being set, instead we should check for null or undefined.
2018-07-29 18:09:16 +02:00
Akihiko Kusanagi
493eaa8424 Refactor helpers.canvas.drawPoint() (#5623)
Bring ctx.beginPath() before switch and replace ctx.fillRect()/ctx.strokeRect() with ctx.rect()/ctx.fill() to make it consistent with the other styles. It is also preferable that helpers.canvas.roundedRect() include ctx.closePath() at the end because CanvasRenderingContext2D.rect() closes the subpath.

Get rid of ctx.closePath() for cross, crossRot, star, line and dash because these have no closed path shape, and it should be avoided that ctx.closePath() makes a round-trip path.
2018-07-29 11:31:28 +02:00
Joel Hamilton
0ddd0ee16b Enable arbitrary rotation of datapoints (#5319) 2018-07-07 17:54:05 +02:00
Réda Housni Alaoui
387a23df73 Add support for Shadow DOM (#5585)
https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/host
2018-07-07 17:52:29 +02:00
Simon Brunel
88308c600c
Enhance the rounded rectangle implementation (#5597)
Use `arcTo` instead of `quadraticCurveTo` (both methods have the same compatibility level) because it generates better results when the final rect is a circle but also when it's actually a rectangle and not a square. This change is needed by the datalabels plugin where the user can configure the `borderRadius` and thus generate circle from a rounded rectangle.
2018-06-26 17:58:32 +02:00
Ben McCann
da3aa68f38 Restore original styles when removing hover (#5570)
Refactor `updateElement` and `removeHoverStyle` and fix tests.
2018-06-26 08:56:53 +02:00
Shayne Linhart
a0a195f353 Added 'angle' option to Polar Charts (#5279)
* added 'angle' option to polar charts. image comparison test is work in progress; not currently passing

* removed unnecessary variable assignment

* code cleanup based on PR; for 'angle' option on polarCharts

* Made polar chart image comparison test pass by removing debug flag. Also explicitly marked _computeAngle as private.

* Removed visibleCount computation in polar chart

* split out code related to updating the radius in polar chart's update function, into it's own 'updateRadius' function

* made updateRadius method private

* fix linting error

* updated polar charts to read custom angles from "chart.options.elements.arc.angle" instead of "chart.options.angle"
2018-06-17 11:56:57 -04:00
Matt Haff
8198d760bb Handle '\n' as new line in tooltips (#5521) 2018-06-05 09:14:37 +02:00
andi-b
73b8ceeb35 Fix responsive in IE11 with padding as percentage (#4620)
When the chart is responsive to the parent container, the calculations for padding assumes that the figure is in pixels so that 20% is taken to be 20 (pixels), which results in the chart exceeding the parent container. This appears to be an IE11 only issue.
2018-04-22 20:32:42 +02:00
Simon Brunel
bee8e3cd9b Make Chart.Scale/scaleService importable (#5383) 2018-04-02 17:43:28 -04:00
Simon Brunel
d284686452
Make Chart.Animation/animations/Tooltip importable (#5382) 2018-04-02 10:55:52 +02:00
Evert Timberg
9fbac88938 Add ticks.precision option to linear scale. (#4841)
If defined and `stepSize` is not specified, the step size will be rounded to this many decimal places.
2018-04-01 18:56:45 +02:00
jcopperfield
c2a5b12376 Bugfix: Improve polyfill function of log10 to return whole powers of 10 (#5275)
* Bugfix: Improve polyfill function of log10 to return whole powers of 10
        as integer values, as it caused endless loop in IE11 in the tick
        creation loop.

* Compare floating-point numbers directly instead of using unnecessary division.
2018-02-20 18:44:01 -05:00
Evert Timberg
26c44cf7ab
Treat negative values in doughnut charts as positive (#5165) 2018-01-21 12:12:33 -05:00
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
andig
3bb31ca592 Allow category labels definition at scale level (#4506) 2017-07-19 12:41:17 +02:00
Suhaib Khan
b03ab1ca45 Fix labelOffset not working for vertical axes (#4249) 2017-07-15 10:19:16 +02:00
Simon Brunel
56050dc9b7 Move easing effects in separate file + unit tests 2017-07-08 12:02:33 -04:00
etimberg
7d60857819 Use proper reverse option in radial linear scale 2017-07-04 07:25:58 -04:00
Evert Timberg
cc9e88aebc Support an array for line chart pointBorderWidth 2017-07-04 07:24:37 -04:00
Simon Brunel
225bfd36f3 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.
2017-07-01 14:51:38 +02:00
etimberg
ccb2898539 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
2017-06-25 13:32:08 -04:00
Simon Brunel
548edc65ea 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.
2017-06-25 10:15:55 -04:00
Evert Timberg
8834babef2 Ensure deprecated unitStepSize property of time scale is respected (#4401) 2017-06-25 14:37:38 +02:00
Simon Brunel
5d95280d7b 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`.
2017-06-25 10:54:37 +02:00
Simon Brunel
5196e05062 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.
2017-06-24 13:28:52 -04:00
Evert Timberg
6c82c93853 Fix error when legend label options are not defined (#4402) 2017-06-24 17:35:46 +02:00
etimberg
de0ea5c6ba Multiple lines of text in the chart title 2017-06-19 07:07:35 -04:00
Andrew
2d7c1f0d2c Time axis tick formatting with major and minor units (#4268)
Working towards creating the TimeSeries scale, this PR adds formatting for major and minor ticks on axes.
2017-06-15 07:20:16 -04:00
Ricardo Costa
009ae4dec6 Support hover animation duration during updates (#4300)
See discussion in the issue for context and possible approaches.

When invoking update() inside an event handler, such as onHover,
`options.hover.animationDuration` was not being respected. Given that
some use cases may require additional animation properties for the
manual update call, this commit changes that method signature to accept
a configuration object.

This object provides backwards compatibility with duration and lazy
properties, and also introduces the easing property so that the event
animation is different from the global one. 

Add tests that guarantee that when update is called manually with
arguments, it properly builds the _bufferedRequest or calls render with
the proper arguments.
It includes test cases for when update is called with legacy arguments
(duration and lazy) instead of the config object.

.update() documentation was previously updated but .render() was left
out. Since the backwards compatible change was also made to render(),
this commit adds documentation for it.
2017-06-11 12:06:39 -04:00
OlduwanSteve
8eee12486d Added 'devicePixelRatio' option to override the window's DPR setting (#4270) 2017-06-04 18:57:55 +02:00
Jerome Touffe-Blin
fa6be2f772 Fix inconsistent aspect ratio 2017-06-04 09:41:13 -04:00
Andrew
f7f177f5ad Implemented aligment by senior unit in time axis. (#4267)
Implemented alignment by major unit in the time scale. This allows showing the first tick of a larger unit like days in a special way and is part of the basis of the time series scale.
2017-05-29 18:40:10 -04:00
ApoorvA
394382b931 Add tooltip textLabelColor callback (#4199)
Add a new tooltip callback `labelTextColor` that returns the colour for each item in the body of the tooltip.

Fixes issue #4191
2017-05-28 08:39:29 -04:00
Simon Brunel
f0c6b3f834 Fix legend and title layout options update 2017-04-29 11:38:42 -04:00
Simon Brunel
f7d2d7536a Fix failing instanceof when reading context
`instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when the item is inside an iframe or when running in a protected environment. We could guess the types from their toString() value but let's keep things flexible and assume it's a sufficient condition if the item has a context2D which has item as `canvas`.
2017-04-22 13:14:16 -04:00
Thomas Redston
3ec6377f11 Fix hidden charts hanging the browser
Ensure width cannot be greater than maxWidth. Similar to `minSize.height` calculation.
2017-04-22 11:25:09 -04:00
Eric Nikolay Katz
205cedc0ef Enhancement: adds step-after functionality, true defaults to step-before (#4065)
* Adds step-after functionality, true defaults to step-before

* Update stepped line sample to include all variations of steppedLine configurations

* Update documentation on steppedLine values

* Add tests for new steppedLine values 'before' and 'after'
2017-04-16 16:13:13 -04:00
etimberg
19d6df21e3 Fix pointRadius and pointHitRadius settings for radar charts 2017-04-16 16:12:45 -04:00
GabrielMancik
254bd4bf86 Fixed calculation of scale min and max when dataset contains no values (#4064)
* Fixed different calculation of scale min and max when dataset contains no values
* Removed trailing spaces
* Added test for correct min/max calculation
* Removed trailing spaces
2017-04-15 12:37:49 -04:00
Simon Brunel
50a80da1e9 Fix and refactor bar controllers
Merge most of the horizontalBar controller into the bar one but also fix stack groups and bar positioning when scales are stacked or when a min and/or max tick values are explicitly defined. Note that this is a breaking change for derived controllers that rely on the following removed methods: `calculateBarBase`, `calculateBarX`, `calculateBarY`, `calculateBarWidth` and `calculateBarHeight`.
2017-04-08 13:40:21 -04:00
cizmiak
69dd0bde6c scale service - respect new weight scale option for axes ordering (#4094)
* respect new scale option 'order' when ordering scales

* scale service - respect new weight scale option for axes ordering

* added test for scale ordering by weight

* removed trailing spaces from layout weight scale order test
2017-04-04 19:42:25 -04:00
etimberg
06383669be Adds a better error message when the chart type is incorrect. Previously the user got a message about type being undefined.
This gives something that's easier to understand and debug.
2017-04-03 17:39:09 -04:00
Thomas Redston
35dcfe00b1 Time scale improvements to improve performance and reliability
* Make parseTime private
* start on fixing time scale
* Reimplement existing functionality
* Tidy tests
* Fix labels for non-linearly sized units

Months, quarters and years have non-constant numbers of seconds. A scale that's linear WRT milliseconds produces incorrect tick labels due to the label formatting losing precision (eg year labels lose month and day so a label of 2016-12-32 displays as 2016 instead of 2017).

* Re-implement tick generation

As in v2.5
2017-04-02 08:49:00 -04:00
etimberg
222479c5c7 Update the tooltip with a new caretPadding setting. Previously this value was essentially hard coded to
2 because of a typo that read it from the positioner output. Based on #3599 we agreed to make this into
a config setting.
2017-03-28 18:17:26 -04:00
Simon Brunel
f3816b560c Move legend and title in the plugins folder (#4076) 2017-03-25 18:28:54 +01:00
Lee N Dobryden
20a832809e Zero line dash options (#4019)
* Add of zero line border dash options
* Update Readme with zero line border dash config options
2017-03-21 06:38:09 -04:00
Hiroshi Shirosaki
cffa9447a1 Fix radar chart horizontal position (#4032)
Radar chart position is not center horizontally with v2.5.0.

Right and left of `furthestLimits` would be switched wrongly on
this refactoring commit.
e1606f88ed
2017-03-20 20:39:18 -04:00
Evert Timberg
36ccf40946 Fix for stacked bar charts with log axes (#4010)
* Undo fix for #3585 since it has broken the stacked bar charts when the axis has a user defined minimum value.

* When a value of 0 is requested for a vertical logarithmic axis, return the bottom point
2017-03-20 20:38:15 -04:00
Simon Brunel
bd60fa2dfd Correctly handle decimal display size (#4009)
Fix the `readUsedSize` regular expression to correctly parse (truncate) pixel decimal values.
2017-03-18 11:54:56 +01:00
Simon Brunel
4b421a50bf Add support to fill between datasets (#4008)
The `fill` option now accepts the index of the target dataset (number) or a string starting by "+" or "-" followed by a number representing the dataset index relative to the current one (e.g. `fill: "-2"` on dataset at index 3 will fill to dataset at index 1). It's also possible to "propagate" the filling to the target of an hidden dataset (`options.plugins.filler.propagate`). Fill boundaries `zero`, `top` and `bottom` have been deprecated and replaced by `origin`, `start` and `end`.

Implementation has been moved out of the line element into a new plugin (`src/plugins/plugin.filler.js`) and does not rely anymore on the deprecated model `scaleTop`, `scaleBottom` and `scaleZero` values. Drawing Bézier splines has been refactored in the canvas helpers (note that `Chart.helpers.canvas` is now an alias of `Chart.canvasHelpers`).

Add 3 new examples and extend utils with a pseudo-random number generator that can be initialized with `srand`. That makes possible to design examples starting always with the same initial data.
2017-03-18 11:08:57 +01:00
Simon Brunel
1ca0ffb5d5 Introduce unit test based on image comparison (#3988)
Attempt to make easier the creation of unit tests that check the drawing output. Until now, this was done by checking calls on a 'fake' context, which is hard to maintain (need to update pixel values by hands) and also not reliable when optimizing code (i.e. different calls sequence but same result).

As of now, it's possible to define 'auto' tests based on JSON/PNG fixtures: chart is generated from the JSON file and compared to the associated PNG image. The image diff is done using `pixelmatch`. As an example (and in preparation of the `filler` plugin), add auto tests for the line element `fill` options.
2017-03-05 09:49:12 -07:00
Simon Brunel
c216c0af76 Cleanup and upgrade unit tests environment
`karma.conf.ci.js` has been merged into `karma.conf.js` for local testing consistency: `gulp unittestWatch` has been replaced by `gulp unittest --watch` and thus use exactly the same config file. Upgrade to latest jasmine and karma packages and remove deprecated `gulp-karma` dependency (directly use `karma.Server` in gulp).

Split `test/mockContext.js` into smaller `test/jasmine.*` modules to make easier unit tests maintenance and finally, move all `*.test.js` files under the `test/specs` folder.
2017-03-04 11:39:48 -05:00