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.
etimberg [Mon, 19 Jun 2017 01:21:37 +0000 (21:21 -0400)]
Line height setting for scale titles. The text is centered within the line height, so setting the line height to a size
greater than the font size moves it away from the axis edge.
Peter-Van-Drunen [Fri, 23 Jun 2017 22:08:16 +0000 (18:08 -0400)]
Ensure that chart dimensions are always >= 0
Elements were resizing incorrectly if they were regenerated while the chart was in a div that was display:none. Added a check to avoid this issue. Resolves #4397
According to the (issue tracker of highcharts)[https://github.com/highcharts/highcharts/issues/4405#issuecomment-125124004] they do not consider the code open source. It's available for reading but that's about it.
The code is provided under CC-BY-NC via github.
See also:
https://shop.highsoft.com/faq#Non-Commercial-0
Ricardo Costa [Sun, 11 Jun 2017 16:06:39 +0000 (17:06 +0100)]
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.
Andrew [Mon, 29 May 2017 22:40:10 +0000 (01:40 +0300)]
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.
Ricardo Costa [Sun, 28 May 2017 21:23:20 +0000 (22:23 +0100)]
Fix onHover event not being triggered (#4297)
Fix onHover event not being triggered
The core controller was looking at the wrong object (options.hover) to
find the function to be called on hover. The function is provided on the
top level options object (options.onHover).
By using the helper function, there's no need to verify if the callback
is defined, as the helper already does that.
Simon Brunel [Fri, 19 May 2017 19:58:34 +0000 (21:58 +0200)]
Deploy to GitHub pages (#4256)
Add Travis CI task to deploy the docs, samples and dist files to chartjs.github.io for the `release` and `master` branches. A `latest` symbolic links is also created for each folder to the highest version (or `master` if any).
Simon Brunel [Sat, 22 Apr 2017 07:49:10 +0000 (09:49 +0200)]
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`.
Simon Brunel [Sat, 22 Apr 2017 11:59:56 +0000 (13:59 +0200)]
Enhance the responsive documentation
Make sure to explain responsiveness limitations with CANVAS elements and how to correctly setup a responsive chart using a dedicated and relatively positioned div wrapper.
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
Simon Brunel [Sun, 19 Mar 2017 16:51:18 +0000 (17:51 +0100)]
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`.
etimberg [Sat, 25 Mar 2017 23:34:55 +0000 (19:34 -0400)]
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.
Thomas Redston [Sun, 2 Apr 2017 12:49:00 +0000 (14:49 +0200)]
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).
etimberg [Tue, 28 Mar 2017 00:19:57 +0000 (20:19 -0400)]
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.
Martin Zürn [Mon, 27 Mar 2017 22:02:56 +0000 (00:02 +0200)]
Fixed misplaced data points on category scale
* Fixed issue, that category scale shows data points misplaced. See #4060
* Cleaned code
* Fixed Irregular whitespace
* Fixed error in case value is undefined
* Verified that no error is thrown in case value === null