根据highcharts文档,我应该能够在工具提示上简单地设置xDateFormat,但正如您在下面的示例中所看到的那样,它没有采用该值:
var labels = [1470960000000, 1471046400000, 1471132800000, 1471219200000, 1471305600000, 1471392000000, 1471478400000, 1471564800000, 1471651200000, 1471737600000, 1471824000000, 1471910400000, 1471996800000, 1472083200000]
var sessions = [215595, 352712, 377663, 432526, 422030, 406581, 390111, 382508, 373602, 403029, 428661, 426250, 221721, 0]
var clicks = [49809, 62111, 58268, 120085, 117700, 101222, 97126, 112030, 85859, 60905, 80053, 85758, 21660, 0]
var pageviews = [330385, 552567, 593823, 676728, 670919, 649461, 628206, 610449, 602984, 638633, 675578, 685834, 345341, 0]
var chartOptions = {
chart: {
type: 'column',
renderTo: 'chartcontainer'
},
xAxis: {
type: 'datetime',
categories: labels,
labels: {
formatter: function () {
return Highcharts.dateFormat('%b %e', this.value)
}
}
},
yAxis: {
stackLabels: {
enabled: false
}
},
tooltip: {
shared: true,
tooltip: {
xDateFormat: '%a %b %e'
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false
}
}
},
series: [{
name: 'Pageviews',
data: pageviews
}, {
name: 'Sessions',
data: sessions
}, {
name: 'Clicks',
data: clicks
}]
}
new Highcharts.Chart(chartOptions)

<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="chartcontainer">
</div>
&#13;
答案 0 :(得分:1)
您将工具提示配置堆叠在多余对象中。正确的是:
tooltip: {
shared: true,
xDateFormat: '%a %b %e'
}
请参阅:http://api.highcharts.com/highcharts/tooltip.xDateFormat
下面调整后的代码段:
var labels = [1470960000000, 1471046400000, 1471132800000, 1471219200000, 1471305600000, 1471392000000, 1471478400000, 1471564800000, 1471651200000, 1471737600000, 1471824000000, 1471910400000, 1471996800000, 1472083200000]
var sessions = [215595, 352712, 377663, 432526, 422030, 406581, 390111, 382508, 373602, 403029, 428661, 426250, 221721, 0]
var clicks = [49809, 62111, 58268, 120085, 117700, 101222, 97126, 112030, 85859, 60905, 80053, 85758, 21660, 0]
var pageviews = [330385, 552567, 593823, 676728, 670919, 649461, 628206, 610449, 602984, 638633, 675578, 685834, 345341, 0]
var chartOptions = {
chart: {
type: 'column',
renderTo: 'chartcontainer'
},
xAxis: {
type: 'datetime',
categories: labels,
labels: {
formatter: function () {
return Highcharts.dateFormat('%b %e', this.value)
}
}
},
yAxis: {
stackLabels: {
enabled: false
}
},
tooltip: {
shared: true,
xDateFormat: '%a %b %e'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false
}
}
},
series: [{
name: 'Pageviews',
data: pageviews
}, {
name: 'Sessions',
data: sessions
}, {
name: 'Clicks',
data: clicks
}]
}
new Highcharts.Chart(chartOptions)
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="chartcontainer">
</div>