I'm doing some work with a lovely bubble cloud example made by Jim Vallandingham and I've run into a bit of an issue. (The code was initially Coffeescript which I converted to Javascript; please let me know if there's any errors in the conversion! Everything seems to be running fine.)
The cloud is supposed to swap between data from various .csv files, but unfortunately always defaults to a particular one, even when a different file is chosen in the drop-down menu. I've discovered that the reason is the failure to pass the "if (!text) { text = texts[0]; }" test in the code below, as when I manipulate the value of texts here the visualization changes. Something's clearly not quite working with the decodeURIComponent attempt to grab the URL and change it to the new , but unfortunately as I am still a total novice in Javascript I have absolutely no idea what to change in order to fix the chart. I am currently hosting the file on a local server, if that matters. The original visualization seems to work fine, though I've no idea if the code matches exactly. Any ideas? Source code I'm using (in Coffescript) is here. Please let me know if you need me to post any more of the Javascript document to know what's going on.
texts = [
{
key: "sherlock",
file: "top_sherlock.csv",
name: "The Adventures of Sherlock Holmes"
}, {
key: "aesop",
file: "top_aesop.csv",
name: "Aesop's Fables"
}, {
key: "alice",
file: "alice.csv",
name: "Alice's Adventures in Wonderland"
}, {
key: "gulliver",
file: "top_gulliver.csv",
name: "Gulliver's Travels"
}
];
$(function() {
var display, key, plot, text;
plot = Bubbles();
display = function(data) {
return plotData("#vis", data, plot);
};
key = decodeURIComponent(location.search).replace("?", "");
text = texts.filter(function(t) {
return t.key === key;
})[0];
if (!text) {
text = texts[0];
}