Commit Graph

24 Commits

Author SHA1 Message Date
Akihiko Kusanagi
14007a912d Fix ticks.minor and ticks.major configuration issues (#6102) 2019-04-02 09:45:34 +02:00
Simon Brunel
87a74f99a1
Fix missing Chart.Chart (deprecated) alias (#6112) 2019-03-06 09:12:29 +01:00
Simon Brunel
0697d0de90
Deprecate configMerge and scaleMerge helpers (#6022)
These methods shouldn't have been public since they are specific to the chart controller internal logic. Note that this scale custom merging will be removed in v3.
2019-01-29 17:52:21 +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
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
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
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
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
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
Evert Timberg
52145de5db Fix regression in x-axis interaction mode (#4762) 2017-09-16 08:01:26 -04: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
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
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
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
Simon Brunel
56050dc9b7 Move easing effects in separate file + unit tests 2017-07-08 12:02:33 -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
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
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
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