maybe it's a silly question, but I wasn't able to figure it out by myself and I haven't found an approriate answer yet.
I'm building a website and I need to dynamically create tag-clouds from user inputs and store the resulting images on the webserver.
I'm creating the tagclouds with the d3cloud-library (https://github.com/jasondavies/d3-cloud).
This is the div, where the tagcloud will be displayed and the draw function:
<div id="cloud"></div>
...
function draw(words) {
d3.select("#cloud")
.append("svg")
.attr("width", 850)
.attr("height", 350)
.attr("class", "wordcloud")
.append("g")
// without the transform, words words would get cutoff to the left and top, they would
// appear outside of the SVG area
.attr("transform", "translate(320,200)")
.selectAll("text")
.data(words)
.enter().append("text")
.style("font-size", function(d) {
return d.size + "px";
})
.style("fill", function(d, i) {
return color(i);
})
.attr("transform", function(d) {
return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
})
.text(function(d) {
return d.text;
});
Is it possible to encode the resulting tag-cloud-image with base64 and store it into a variable? I need to send it to a server in a later step. I know how the sending part works, my problem is just to get the encoded image-data.
regards