Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ env:
browser: true
node: true

parserOptions:
ecmaVersion: 6

plugins: ['html']
2 changes: 1 addition & 1 deletion docs/axes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ There are a number of config callbacks that can be used to change parameters in
| `beforeDataLimits` | `axis` | Callback that runs before data limits are determined.
| `afterDataLimits` | `axis` | Callback that runs after data limits are determined.
| `beforeBuildTicks` | `axis` | Callback that runs before ticks are created.
| `afterBuildTicks` | `axis`, `ticks` | Callback that runs after ticks are created. Useful for filtering ticks. Should return the filtered ticks.
| `afterBuildTicks` | `axis` | Callback that runs after ticks are created. Useful for filtering ticks.
| `beforeTickToLabelConversion` | `axis` | Callback that runs before ticks are converted into strings.
| `afterTickToLabelConversion` | `axis` | Callback that runs after ticks are converted into strings.
| `beforeCalculateTickRotation` | `axis` | Callback that runs before tick rotation is determined.
Expand Down
12 changes: 12 additions & 0 deletions docs/getting-started/v3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released
* `helpers.aliasPixel`
* `helpers.configMerge`
* `helpers.indexOf`
* `helpers.min`
* `helpers.max`
* `helpers.numberOfLabelLines`
* `helpers.removeEvent`
* `helpers.scaleMerge`
* `scale.mergeTicksOptions`
* `scale.ticksAsNumbers`
* `Chart.Controller`
* `Chart.chart.chart`
* `Chart.types`
* Made `scale.handleDirectionalChanges` private
* Made `scale.tickValues` private

### Renamed

Expand All @@ -65,6 +70,13 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released

### Changed

#### Ticks

* `scale.ticks` now contains objects instead of strings
* `buildTicks` is now expected to return tick objects
* `afterBuildTicks` now has no parameters like the other callbacks
* `convertTicksToLabels` was renamed to `generateTickLabels`. It is now expected to set the label property on the ticks given as input

#### Time Scale

* `getValueForPixel` now returns milliseconds since the epoch
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions samples/scales/time/financial.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@
maxRotation: 0,
sampleSize: 100
},
afterBuildTicks: function(scale, ticks) {
afterBuildTicks: function(scale) {
var majorUnit = scale._majorUnit;
var ticks = scale.ticks;
var firstTick = ticks[0];
var i, ilen, val, tick, currMajor, lastMajor;

Expand All @@ -154,7 +155,6 @@
tick.major = currMajor !== lastMajor;
lastMajor = currMajor;
}
return ticks;
}
}],
yAxes: [{
Expand Down
26 changes: 16 additions & 10 deletions src/core/core.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,27 @@ module.exports = function() {
var rounded = Math.round(x);
return ((rounded - epsilon) <= x) && ((rounded + epsilon) >= x);
};
helpers.max = function(array) {
return array.reduce(function(max, value) {
helpers._setMinAndMax = function(array, target) {
var i, ilen, value;

for (i = 0, ilen = array.length; i < ilen; i++) {
value = array[i];
if (!isNaN(value)) {
return Math.max(max, value);
target.min = Math.min(target.min, value);
target.max = Math.max(target.max, value);
}
return max;
}, Number.NEGATIVE_INFINITY);
}
};
helpers.min = function(array) {
return array.reduce(function(min, value) {
helpers._setMinAndMaxByKey = function(array, target, property) {
var i, ilen, value;

for (i = 0, ilen = array.length; i < ilen; i++) {
value = array[i][property];
if (!isNaN(value)) {
return Math.min(min, value);
target.min = Math.min(target.min, value);
target.max = Math.max(target.max, value);
}
Comment thread
benmccann marked this conversation as resolved.
return min;
}, Number.POSITIVE_INFINITY);
}
};
helpers.sign = Math.sign ?
function(x) {
Expand Down
Loading