Skip to content

Commit

Permalink
New time scale ticks.mode/.source options (#4507)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
simonbrunel committed Jul 19, 2017
1 parent 3bb31ca commit 5ad1b4a
Show file tree
Hide file tree
Showing 3 changed files with 559 additions and 174 deletions.
4 changes: 3 additions & 1 deletion src/helpers/helpers.time.js
Expand Up @@ -3,6 +3,8 @@
var moment = require('moment');
moment = typeof(moment) === 'function' ? moment : window.moment;

var helpers = require('./helpers.core');

var interval = {
millisecond: {
size: 1,
Expand Down Expand Up @@ -53,7 +55,7 @@ function generateTicksNiceRange(options, dataRange, niceRange) {
var ticks = [];
if (options.maxTicks) {
var stepSize = options.stepSize;
var startTick = options.min !== undefined ? options.min : niceRange.min;
var startTick = helpers.isNullOrUndef(options.min)? niceRange.min : options.min;
var majorUnit = options.majorUnit;
var majorUnitStart = majorUnit ? moment(startTick).add(1, majorUnit).startOf(majorUnit) : startTick;
var startRange = majorUnitStart.valueOf() - startTick;
Expand Down

0 comments on commit 5ad1b4a

Please sign in to comment.