Skip to content

Commit

Permalink
Fixed issue with wrong tooltip date header format on single points. R…
Browse files Browse the repository at this point in the history
…elated to #568.
  • Loading branch information
TorsteinHonsi committed Apr 11, 2013
1 parent ef31959 commit 3d82c5a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
18 changes: 12 additions & 6 deletions js/highcharts.src.js
Expand Up @@ -13278,19 +13278,25 @@ Series.prototype = {
var series = this,
tooltipOptions = series.tooltipOptions,
xDateFormat = tooltipOptions.xDateFormat,
dateTimeLabelFormats = tooltipOptions.dateTimeLabelFormats,
xAxis = series.xAxis,
isDateTime = xAxis && xAxis.options.type === 'datetime',
headerFormat = tooltipOptions.headerFormat,
closestPointRange = xAxis.closestPointRange,
n;

// Guess the best date format based on the closest point distance (#568)
if (isDateTime && !xDateFormat) {
for (n in timeUnits) {
if (timeUnits[n] >= xAxis.closestPointRange) {
xDateFormat = tooltipOptions.dateTimeLabelFormats[n];
break;
}
}
if (closestPointRange) {
for (n in timeUnits) {
if (timeUnits[n] >= closestPointRange) {
xDateFormat = dateTimeLabelFormats[n];
break;
}
}
} else {
xDateFormat = dateTimeLabelFormats.day;
}
}

// Insert the header date format if any
Expand Down
18 changes: 12 additions & 6 deletions js/highstock.src.js
Expand Up @@ -13278,19 +13278,25 @@ Series.prototype = {
var series = this,
tooltipOptions = series.tooltipOptions,
xDateFormat = tooltipOptions.xDateFormat,
dateTimeLabelFormats = tooltipOptions.dateTimeLabelFormats,
xAxis = series.xAxis,
isDateTime = xAxis && xAxis.options.type === 'datetime',
headerFormat = tooltipOptions.headerFormat,
closestPointRange = xAxis.closestPointRange,
n;

// Guess the best date format based on the closest point distance (#568)
if (isDateTime && !xDateFormat) {
for (n in timeUnits) {
if (timeUnits[n] >= xAxis.closestPointRange) {
xDateFormat = tooltipOptions.dateTimeLabelFormats[n];
break;
}
}
if (closestPointRange) {
for (n in timeUnits) {
if (timeUnits[n] >= closestPointRange) {
xDateFormat = dateTimeLabelFormats[n];
break;
}
}
} else {
xDateFormat = dateTimeLabelFormats.day;
}
}

// Insert the header date format if any
Expand Down
18 changes: 12 additions & 6 deletions js/parts/Series.js
Expand Up @@ -1428,19 +1428,25 @@ Series.prototype = {
var series = this,
tooltipOptions = series.tooltipOptions,
xDateFormat = tooltipOptions.xDateFormat,
dateTimeLabelFormats = tooltipOptions.dateTimeLabelFormats,
xAxis = series.xAxis,
isDateTime = xAxis && xAxis.options.type === 'datetime',
headerFormat = tooltipOptions.headerFormat,
closestPointRange = xAxis.closestPointRange,
n;

// Guess the best date format based on the closest point distance (#568)
if (isDateTime && !xDateFormat) {
for (n in timeUnits) {
if (timeUnits[n] >= xAxis.closestPointRange) {
xDateFormat = tooltipOptions.dateTimeLabelFormats[n];
break;
}
}
if (closestPointRange) {
for (n in timeUnits) {
if (timeUnits[n] >= closestPointRange) {
xDateFormat = dateTimeLabelFormats[n];
break;
}
}
} else {
xDateFormat = dateTimeLabelFormats.day;
}
}

// Insert the header date format if any
Expand Down

0 comments on commit 3d82c5a

Please sign in to comment.