我找到了下面的代码。我想在 Highcharts 中为 1 serie 使用不同的符号,阈值 = 50。当 y 值小于 50 时,我想要绿色符号,当 y 值大于 50 时,我想要方形符号。
感谢您的帮助!
http://jsfiddle.net/mhardik/YgxEB/1/
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Scatter Graph Demo'
},
xAxis: {
title: {
enabled: true,
text: 'Height (cm)'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
yAxis: {
title: {
text: 'Weight (kg)'
}
},
tooltip: {
formatter: function() {
return ''+
this.x +' cm, '+ this.y +' kg';
}
},
plotOptions: {
scatter: {
marker: {
radius: 3,
symbol:myFunction(),
}
}
},
series: [{
name: 'Points',
color: 'rgba(223, 83, 83, .5)',
data: [[161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6]]
}]
});
});
});
function myFunction() {
if(true){
return 'url(http://www.lib.udel.edu/ud/ill/images/green_marker.gif)';
} else{
return 'square';
}
}