simpleWordsCloud/js/display.js

30 lines
1 KiB
JavaScript
Raw Normal View History

2020-11-15 21:51:28 +01:00
var list = [['foo', 12], ['bar', 6], ['asd', 2], ['bar', 6], ['gert', 10]];
//document.getElementById('my_canvas').innerHTML = 'test';
//WordCloud(document.getElementById('my_canvas'), { list: list } );
console.log(list);
var oReq = new XMLHttpRequest(); // New request object
oReq.onload = function() {
//var weightFactor = function()
// This is where you handle what to do with the response.
// The actual data is found on this.responseText
2020-11-22 15:10:22 +01:00
var list = JSON.parse(this.responseText);
2020-11-15 21:51:28 +01:00
console.log(list);
var options = {};
2020-11-22 15:10:22 +01:00
options.list = list;
options.shuffle = true;
options.rotateRatio = 0.5;
options.weightFactor = 50;
options.minSize = 4;
options.drawOutOfBound = true;
2020-11-15 21:51:28 +01:00
options.backgroundColor = 'rgba(255, 255, 255, 0)';
2020-11-22 15:10:22 +01:00
options.color = 'random-light';
2020-11-15 21:51:28 +01:00
WordCloud(document.getElementById('my_canvas'), options );
};
var urlParams = new URLSearchParams(window.location.search);
var id = urlParams.get('id');
oReq.open("get", "get.php?id=" + id, true);
oReq.send();