美好的一天
我希望有人可以帮助我。我在AMcharts上创建了一个散点图,每个数据点都有自己的标签,但是只要我将更多的数据放在流量上。我试过单独定位每个标签,但我似乎无法做到正确。我也尝试使用labelFunction来改变单个数据点的位置,但我不确定我是否正确行事。有人可以帮帮我吗。
我真的很挣扎这件事。
的javaScript
var chart = AmCharts.makeChart("chartdiv", {
"type": "xy",
"pathToImages": "http://www.amcharts.com/lib/3/images/",
"theme": "none",
"dataProvider": [{
"y": 10,
"x": 14,
"value": 59,
"y2": -5,
"x2": -3,
"value2": 44
}, {
"y": 5,
"x": 3,
"value": 50,
"y2": -15,
"x2": -8,
"value2": 12
}, {
"y": -10,
"x": 8,
"value": 19,
"y2": -4,
"x2": 6,
"value2": 35
}, {
"y": -6,
"x": 5,
"value": 65,
"y2": -5,
"x2": -6,
"value2": 168
}, {
"y": 15,
"x": -4,
"value": 92,
"y2": -10,
"x2": -8,
"value2": 102
}, {
"y": 13,
"x": 1,
"value": 8,
"y2": -2,
"x2": 0,
"value2": 41
}, {
"y": 1,
"x": 6,
"value": 35,
"y2": 0,
"x2": -3,
"value2": 16
}],
"valueAxes": [{
"position":"bottom",
"axisAlpha": 0
}, {
"minMaxMultiplier": 1.2,
"axisAlpha": 0,
"position": "left"
}],
"graphs": [{
"balloonText": "x:<b>[[x]]</b> y:<b>[[y]]</b><br>value:<b>[[value]] </b>",
"bullet": "circle",
"bulletBorderAlpha": 0.2,
"bulletAlpha": 0.8,
"lineAlpha": 0,
"fillAlphas": 0,
"valueField": "value",
"xField": "x",
"yField": "y",
"maxBulletSize": 100,
"labelText": "[[x]]",
"labelFunction": function(obj,label) {
setTimeout(function() {
console.log(obj.bulletGraphics.node.nextElementSibling);
},100); // delay to generate the element
return label;
}
}, {
"balloonText": "x:<b>[[x]]</b> y:<b>[[y]]</b><br>value:<b>[[value]]</b>",
"bullet": "diamond",
"bulletBorderAlpha": 0.2,
"bulletAlpha": 0.8,
"lineAlpha": 0,
"fillAlphas": 0,
"valueField": "value2",
"xField": "x2",
"yField": "y2",
"maxBulletSize": 100
}],
"marginLeft": 46,
"marginBottom": 35
});
答案 0 :(得分:1)
好的,我得到的就是这个Fiddle
它使用labelFunction
移动标签。当labelFunction
返回空白字符串时,您必须使用\u00a0
(空格)或\n
(新行)执行此操作。
所以函数检查,如果前一个(!)点有相同的(!)坐标。
你可以修改它来检查整个数据集,看看是否有任何数据点。
希望你能工作有了这个。 :)