Skip to content

Commit

Permalink
Use tick format for tooltips as well
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Feb 3, 2019
1 parent 10f89d9 commit acd515c
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,6 @@ function ticksFromTimestamps(values, majorUnit) {
return ticks;
}

/**
* Return the time format for the label with the most parts (milliseconds, second, etc.)
*/
function determineLabelFormat(timestamp) {
var presets = adapter.presets();
if (timestamp % INTERVALS.second.size !== 0) {
return presets.full;
}
if (adapter.startOf(timestamp, 'day') !== timestamp) {
return presets.time;
}
return presets.date;
}

var defaultConfig = {
position: 'bottom',

Expand Down Expand Up @@ -643,6 +629,7 @@ module.exports = Scale.extend({
var timeOpts = me.options.time;
var label = data.labels && index < data.labels.length ? data.labels[index] : '';
var value = data.datasets[datasetIndex].data[index];
var format = timeOpts.displayFormats[me._unit];
var ts;

if (helpers.isObject(value)) {
Expand All @@ -655,8 +642,9 @@ module.exports = Scale.extend({
return label;
}


ts = toTimestamp(label, timeOpts);
return adapter.format(ts, determineLabelFormat(ts));
return adapter.format(ts, format);
},

/**
Expand Down

0 comments on commit acd515c

Please sign in to comment.