【发布时间】:2019-08-29 19:06:25
【问题描述】:
我会尽量简明扼要,我尝试渲染一个饼图并设置标签以显示总时间,我得到了刻度,我想在饼图中显示它。
据我所知,饼图没有坐标轴,我找到的所有替代方案都配置在 X 或 Y 轴上。 像这样的:
xAxis: {
type: 'datetime', //y-axis will be in milliseconds
},
在工具提示中:
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%H:%M:%S', new Date(this.y));
},
这是我的文本代码
Highcharts.chart('container', {
chart: {
type: 'pie',
options3d: {
enabled: true,
alpha: 45,
beta: 0
}
},
credits: {
enabled: false
},
title: {
text: ''
},
subtitle: {
text: ''
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.dateFormat('%H:%M:%S', new Date(this.y));
},
shared: true,
useHTML: true
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
depth: 35,
dataLabels: {
enabled: true,
format: '{point.name}'
}
}
},
series: [{
type: 'pie',
data: [
[ 'T1',30600000000 ],
]
}]
});
我尝试了一些在线刻度转换器,它们都将 '30600000000' 转换为 00:51:00 (HH:mm:ss) ut 在我的标签中显示为 04:00:00。
这是一个小提琴 https://jsfiddle.net/lvevano/gp80ckfr/2/ 我做错了什么?
【问题讨论】:
-
当使用这个 [1] 转换器转换 '30600000000' 时,我得到 09/04/2939 @ 4:00pm (UTC)。所以可能你的转换器是错误的。 [1]unixtimestamp.com/index.php
-
没错,我用的是tickstodatetime.azurewebsites.net,可能是UTC配置的问题,但是我尝试禁用它,结果还是一样。
-
嗨@Joel Luevano,工具提示中的日期是正确的。相同的值在标准
line图表中:jsfiddle.net/BlackLabel/opt7xzbv
标签: javascript html json highcharts