【发布时间】:2017-10-10 10:08:46
【问题描述】:
我正在尝试使用两个系列名称(子类别)制作散点图。
highcharts 中的This 示例是我的起点。
在此示例中,您只有两个类别,即女性和男性。我想在工具提示中看到女性/男性的名字。不在传说中!
在myexample jsfiddle中我在数据和工具提示中添加了四个名字
我知道这不是正确的方法,但我想澄清一下我想要实现的目标。有谁知道如何正确处理这个,所以图例中仍然有两个类别(女/男),但在工具提示中还有女/男的名字。
已经非常感谢你了!
Highcharts.chart('container', {
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Height Versus Weight of 507 Individuals by Gender'
},
subtitle: {
text: 'Source: Heinz 2003'
},
xAxis: {
title: {
enabled: true,
text: 'Height (cm)'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
yAxis: {
title: {
text: 'Weight (kg)'
}
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: 'name: (), {point.x} cm, {point.y} kg'
}
}
},
series: [{
name: 'Female',
color: 'rgba(223, 83, 83, .5)',
data: [{name: 'Anna', [161.2, 51.6]}, {name: 'Clair',[167.5, 59.0]]
}, {
name: 'Male',
color: 'rgba(119, 152, 191, .5)',
data: [{name: 'James',[174.0, 65.6], {name: 'Peet',[175.3, 71.8]]
}]
});
【问题讨论】:
-
您可以使用
tooltip.formatter来显示点的名称。示例:jsfiddle.net/2zoLp1xm.
标签: highcharts series names