PHP mySQL Highcharts Json 多选
PHP mySQL Highcharts Json Multiselect
我正在尝试用两个系列名称(子类别)制作散点图。
This 来自 highcharts 的示例是我的起点。
在这个例子中,你只有两个类别,即女性和男性。我想在工具提示中看到 female/male 的名称。传说中没有!
在 my 示例 jsfiddle 中,我在数据和工具提示中添加了四个名称
我明白这不是正确的方法,但我想澄清一下我想要达到的目的。有谁知道如何正确处理这个问题,以便图例中仍然有两个类别 (female/male),但在工具提示中还有 female/male.
的名称
已经非常感谢您了!
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]]
}]
});
你有相当多的括号和大括号错误,其中括号太多或太少。太多了我不能一一指出来,但主要是围绕分区区域。
但是,在为系列定义名称时,需要将散点图坐标定义为 x 和 y,如下所示:
series: [{
name: 'Female',
data: [{
name: 'Anna'
x: 161.2,
y: 51.6
},
...
]
}
...
]
此外,要显示数据点的名称(即人),您可以使用以下工具提示格式化程序:
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: 'Name: {point.name}, {point.x} cm, {point.y} kg'
}
Highcharts API 散点数据:http://api.highcharts.com/highcharts/series.scatter.data
使用您的数据的工作示例:http://jsfiddle.net/ewolden/0uc1g8b5/2/
我正在尝试用两个系列名称(子类别)制作散点图。
This 来自 highcharts 的示例是我的起点。
在这个例子中,你只有两个类别,即女性和男性。我想在工具提示中看到 female/male 的名称。传说中没有!
在 my 示例 jsfiddle 中,我在数据和工具提示中添加了四个名称
我明白这不是正确的方法,但我想澄清一下我想要达到的目的。有谁知道如何正确处理这个问题,以便图例中仍然有两个类别 (female/male),但在工具提示中还有 female/male.
的名称已经非常感谢您了!
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]]
}]
});
你有相当多的括号和大括号错误,其中括号太多或太少。太多了我不能一一指出来,但主要是围绕分区区域。
但是,在为系列定义名称时,需要将散点图坐标定义为 x 和 y,如下所示:
series: [{
name: 'Female',
data: [{
name: 'Anna'
x: 161.2,
y: 51.6
},
...
]
}
...
]
此外,要显示数据点的名称(即人),您可以使用以下工具提示格式化程序:
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: 'Name: {point.name}, {point.x} cm, {point.y} kg'
}
Highcharts API 散点数据:http://api.highcharts.com/highcharts/series.scatter.data
使用您的数据的工作示例:http://jsfiddle.net/ewolden/0uc1g8b5/2/