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 9521956
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 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,7 +629,6 @@ 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 ts;

if (helpers.isObject(value)) {
label = me.getRightValue(value);
Expand All @@ -654,9 +639,7 @@ module.exports = Scale.extend({
if (typeof label === 'string') {
return label;
}

ts = toTimestamp(label, timeOpts);
return adapter.format(ts, determineLabelFormat(ts));
return adapter.format(toTimestamp(label, timeOpts), timeOpts.displayFormats[me._unit]);
},

/**
Expand Down

0 comments on commit 9521956

Please sign in to comment.