Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented aligment by senior unit in time axis. #4267

Merged
merged 9 commits into from May 29, 2017
5 changes: 1 addition & 4 deletions src/helpers/helpers.time.js
Expand Up @@ -56,11 +56,8 @@ module.exports = function(Chart) {
if (options.maxTicks) {
var stepSize = options.stepSize;
var startTick = options.min !== undefined ? options.min : niceRange.min;
var majorUnitStart = startTick;
var majorUnit = options.majorUnit;
if (majorUnit) {
majorUnitStart = moment(startTick).add(1, majorUnit).startOf(majorUnit);
}
var majorUnitStart = majorUnit ? majorUnitStart = moment(startTick).add(1, majorUnit).startOf(majorUnit) : startTick;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line has majorUnitStart = twice. You only need it once:

var majorUnitStart = majorUnit ? moment(startTick).add(1, majorUnit).startOf(majorUnit) : startTick;

var startRange = majorUnitStart.valueOf() - startTick;
var stepValue = interval[options.unit].size * stepSize;
var startFraction = startRange % stepValue;
Expand Down
2 changes: 1 addition & 1 deletion test/specs/scale.time.tests.js
Expand Up @@ -94,7 +94,7 @@ describe('Time scale tests', function() {
displayFormat: false,
minUnit: 'millisecond',
displayFormats: {
millisecond: 'h:mm:ss.SSS a', // 11:20:01.123 AM,
millisecond: 'h:mm:ss.SSS a', // 11:20:01.123 AM
second: 'h:mm:ss a', // 11:20:01 AM
minute: 'h:mm:ss a', // 11:20:01 AM
hour: 'MMM D, hA', // Sept 4, 5PM
Expand Down