HighCharts学习笔记
问题1:圆饼图除了显示比例之外显示数值
通过文档找到tooltip(提示框)配置
主要是formatter(格式化),是一个回调函数
文档显示它的值为
Available data are:
this.percentage (not shared) / this.points[i].percentage (shared)
Stacked series and pies only. The point's percentage of the total.
this.point (not shared) / this.points[i].point (shared)
The point object. The point name, if defined, is available through this.point.name.
this.points
In a shared tooltip, this is an array containing all other properties for each point.
this.series (not shared) / this.points[i].series (shared)
The series object. The series name is available through this.series.name.
this.total (not shared) / this.points[i].total (shared)
Stacked series only. The total value at this point's x value.
this.x
The x value. This property is the same regardless of the tooltip being shared or not.
this.y (not shared) / this.points[i].y (shared)
The y value.
名词解释
Stacked series 堆叠系列
point object 点对象
series 数据列 图表上一个或多个数据系列,比如图表中的一条曲线,一个柱形
shared 分享,就是有2个线的时候鼠标位置显示2个线的数据在一起
shared的例子
tooltip: { formatter: function () { var s = '<b>' + this.x + '</b>'; $.each(this.points, function () { s += '<br/>' + this.series.name + ': ' + this.y + 'm'; }); return s; }, shared: true },
非shared的例子
tooltip: { formatter: function () { return 'The value for <b>' + this.x + '</b> is <b>' + this.y + '</b>'; } }
想简单一点的话直接使用 pointFormat(string)
<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>

浙公网安备 33010602011771号