我希望散点图能够在每个 PLOT 点或 BUBBLE 旁边自动显示一段识别它的文本。
任何帮助将不胜感激!
You need the name in the data, and add a dataLabel in series, check this:
series: [{
dataLabels: {
enabled: true,
x:40,
formatter:function() {
return this.point.name;
},
style:{color:"black"}
},
data: [{
"x": 23,
"y": 22,
"z": 200,
"name":"point1"
}, {
"x": 43,
"y": 12,
"z": 100,
"name":"point2"
}]
}]
Example: http://jsfiddle.net/tqVF8/
我会将每个数据点创建为单独的系列,然后利用 dataLabels 选项:
$('#container').highcharts({
chart: {
type: 'scatter'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{series.name}', // make it show the name
x: 15, // place it on right side
y: 10
},
},
scatter: {
marker: {
radius: 10
}
}
},
series: [
{
name: 'A',
data: [[Math.random() * 100, Math.random() * 100]]
},
{
name: 'B',
data: [[Math.random() * 100, Math.random() * 100]]
},
{
name: 'C',
data: [[Math.random() * 100, Math.random() * 100]]
},
{
name: 'D',
data: [[Math.random() * 100, Math.random() * 100]]
},
{
name: 'E',
data: [[Math.random() * 100, Math.random() * 100]]
},
{
name: 'F',
data: [[Math.random() * 100, Math.random() * 100]]
},
{
name: 'G',
data: [[Math.random() * 100, Math.random() * 100]]
}
]
});
在这里拉小提琴。