我正在用highcharts构建一个项目但是我遇到了word cloud中加载事件的问题,当wordcloud加载时它永远不会被触发/注册。这是JSfiddle的一个例子。
var lines = text.split(/[,\. ]+/g),
data = Highcharts.reduce(lines, function (arr, word) {
var obj = Highcharts.find(arr, function (obj) {
return obj.name === word;
});
if (obj) {
obj.weight += 1;
} else {
obj = {
name: word,
weight: 1
};
arr.push(obj);
}
return arr;
}, []);
console.log(data);
console.log(lines);
Highcharts.chart('container', {
series: [{
type: 'wordcloud',
data: data,
name: 'Occurrences'
}],
title: {
text: 'Wordcloud of Lorem Ipsum'
},
events: {
load: function () {
alert("hello");
}
}});
以下是Jsfiddle的链接:http://jsfiddle.net/2oq4njb3/10/ 因此,当wordcloud加载
时,警报永远不会被触发答案 0 :(得分:2)
根级别没有事件对象,它位于图表对象中。 https://api.highcharts.com/highcharts/chart.events
Highcharts.chart('container', {
series: [{
type: 'wordcloud',
data: data,
name: 'Occurrences'
}],
title: {
text: 'Wordcloud of Lorem Ipsum'
},
chart: {
events: {
load: function() {
alert("hello");
}
}
},
});