У меня есть простая диаграмма облака слов, которую я делаю: https://jsfiddle.net/kbhx64Ln/
Она начинается с 15 максимальных элементов в облаке. Тем не менее, я хотел бы динамически обновлять это число, основываясь на таймере. У меня есть:
$(document).ready(function() {
var cnt = 0;
var interval = setInterval(function() {
cnt += 1;
console.log("drawing: " + cnt);
draw(cnt);
}, 3000);
});
anychart.onDocumentReady(function() {
draw(15);
});
function draw(maxItems) {
// create data
var data = "Tyger, tyger, burning bright " +
"In the forests of the night, " +
"What immortal hand or eye " +
"Could frame thy fearful symmetry? " +
"In what distant deeps or skies " +
"Burnt the fire of thine eyes? " +
"On what wings dare he aspire? " +
"What the hand dare seize the fire? " +
"And what shoulder and what art " +
"Could twist the sinews of thy heart? " +
"And, when thy heart began to beat, " +
"What dread hand and what dread feet? " +
"What the hammer? what the chain? " +
"In what furnace was thy brain? " +
"What the anvil? what dread grasp " +
"Dare its deadly terrors clasp? " +
"When the stars threw down their spears, " +
"And watered heaven with their tears, " +
"Did He smile His work to see? " +
"Did He who made the lamb make thee? " +
"Tyger, tyger, burning bright " +
"In the forests of the night, " +
"What immortal hand or eye " +
"Dare frame thy fearful symmetry? ";
// create a chart
var chart = anychart.tagCloud();
// set the parsing mode and configure parsing settings
chart.data(data, {
mode: "by-word",
maxItems: maxItems,
ignoreItems: [
"the",
"and",
"he",
"or",
"of",
"in",
"thy",
]
});
// set the chart title
chart.title("Tag Cloud Chart: Data (Parsing Text)");
// set the container id
chart.container("container");
// initiate drawing the chart
chart.draw();
}
Кажется, что я могу начать с любого номера maxItems, но не могу обновить этот номер. Что я делаю не так?
РЕДАКТИРОВАТЬ: Кажется, я также не могу изменить ignoreItems
. Любое решение для этого?