我会将小时和分钟打印到我的图表中,例如“发展:27 小时 30 米”。
现在我有这个:
在我的脚本中,“数据”代表“小时”
{
name: value.blank? ? "other" : value,
data: all_weeks.merge(data_weeks.to_h).values.map do |data_value|
data_value.nil? ? 0 : ( data_value.to_f / 60 ).round(2)
end
}
....
f.tooltip(
pointFormat: "<span style='color:{series.color}'>{series.name}</span>: <b>{point.y} h</b><br/>",
split: true
)
我试过设置point.y
但pointFormat
没有效果。(编辑:pointFormat 将是一个通用字符串!)
我该如何解决?提前致谢。
编辑:
我解决了添加:
LazyHighCharts::HighChart.new("container") do |f|
f.tooltip(
formatter: "\
function() { \
var s = []; \
s.push(this.x); \
this.points.forEach(function(point) { \
s.push('<b>' + point.series.name + '</b>: ' + Math.floor(point.y) + ' h ' + Math.floor((point.y % 1) * 60) + ' m'); \
}); \
return s; \
}".js_code,
split: true
)
....
end