[英]HighChart Bubble and Date / Tooltip
I want to create a BubbleChart with HighChart, with dates on X Axes, with a custom Tooltip. 我想用自定义工具提示用HighChart创建一个带有X轴上日期的BubbleChart。
Here's my code : 这是我的代码:
public ActionResult BubbleChart(int id)
{
Project p = db.Projects.Find(id);
Series Serie1 = new Series();
List<object> obj1= new List<object>();
foreach (Info info in p.Infos)
{
object a = new object[] { info.Date, p.Amount, Amount/100 };
obj1.Add(a);
}
Serie1.Data = new DotNet.Highcharts.Helpers.Data(obj1.ToArray());
Serie1.Name = "Name1";
Highcharts chart = new Highcharts("chart")
.InitChart(new Chart { Type = ChartTypes.Bubble, ZoomType = ZoomTypes.Xy, Width = 600, Height = 400 })
.SetTitle(new Title { Text = "ProjectInfo" + p.Name })
.SetXAxis(new XAxis { Type = AxisTypes.Datetime, Title = new XAxisTitle { Text = "Date" } })
.SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Amount" } })
.SetSeries(new[]
{
Serie1
}).SetTooltip(new Tooltip
{
HeaderFormat = "<span style=\"font-size:11px\">{series.name}</span><br>",
PointFormat = "<span style=\"color:{point.color}\">Date</span>: <b>{point.x}</b><br/><span style=\"color:{point.color}\">Amount</span>: <b>{point.y:.2f}</b>"
});
return View(chart);
}
This Code shows in tooltip : "Date:14002943820497398" but not the date I want, how to fix it ? 此代码显示在工具提示中:“ Date:14002943820497398”,但没有显示我想要的日期,如何解决?
My second question is about adding datas in the tooltip (name of project, description, etc...) How can I Do that ? 我的第二个问题是关于在工具提示中添加数据(项目名称,描述等),我该怎么做?
Thanks 谢谢
Highcharts expects time as timestamps in milliseconds but you are sending time in microseconds .this value 14002943820497398 is in microsecond . Highcharts期望时间以毫秒为单位,但是您以毫秒为单位发送时间。此值14002943820497398以毫秒为单位 。 send as millisecond it will resolve your issue.
以毫秒为单位发送,它将解决您的问题。
for custom data in tooltip you should fill your data in series : 对于工具提示中的自定义数据,您应该按系列填写数据:
data: [ { y : 10, customData: 'something' },
{ y : 12, customData: 'something' },
{ y : 14, customData: 'something' } ]
and in formatter function of tooltip 并在工具提示的格式化程序功能中
tooltip: {
formatter: function() {
return 'Addition info: <b>'+ this.point.customData+'</b>';
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.