我想换一个箱形图在弹出的文本。
从API和链接出现的例子,我以为这将是增加一个格式化功能,该系列的情况。 于是我去了演示 ,并点击“中的jsfiddle编辑”。 后来我改变:
tooltip: {
headerFormat: '<em>Experiment No {point.key}</em><br/>'
}
至
tooltip: {
headerFormat: '<em>Experiment No {point.key}</em><br/>',
formatter: function() { return 'some random string'; }
}
我预计提示更改为“一些随机字符串”(如从提示API参考链接演示发生),但它是不变的。 任何提示?
该formatter
应该被添加到tooltip
的主要对象选择的属性。
这里演示: http://jsfiddle.net/kxbXx/
我们来看一看REFFERENCE。
series.tooltip
"A configuration object for the tooltip rendering of each single series. Properties are inherited from tooltip, but only the following properties can be defined on a series level."
资源
正如你所看到的,有没有formatter
那里。
您正在寻找这样一个 ,其中有在主工具提示对象使用。
像李嘉图提到如果添加formatter
为整个图表的工具提示方法,属性,它将应用格式化所有的时间序列。
您可以使用pointFormatter
如果你想添加特殊格式个别系列财产。 下面是一个箱线图系列的样本格式。
tooltip: {
pointFormatter: function() {
const x = this.x;
const currentData = this.series.data.find(data => data.x === x);
const boxplotValues = currentData ? currentData.options : {};
return `Max: ${boxplotValues.high}<br>
Q3: ${boxplotValues.q3}<br>
Median: ${boxplotValues.median}<br>
Q1: ${boxplotValues.q1}<br>
Low: ${boxplotValues.low}<br>`;
}
}
找到工作小提琴这里