My code does not seem to generate a table in the tableau web data connector simulator. I have followed the instructions and worked off the tutorial they showed.
See here for the tutorial -https://tableau.github.io/webdataconnector/docs/wdc_tutorial.
It could be the way the json is formatted and how i have tried to turn it onto a table.
see here for the docs https://blockchain.info/api/charts_api
see here for the json https://api.blockchain.info/charts/total-bitcoins?timespan=all&format=json
I am a newb at javascript and havent got a clue why it wont run... i can get the html page to run locally (as per the instructions).
Does anyone have any suggestions as to how i can get this (my code) to work? I have looked at other WDCs but am still not having any luck.
(function () {
var myConnector = tableau.makeConnector();
myConnector.getSchema = function (schemaCallback) {
var cols = [{
id: "x",
alias: "date",
dataType: tableau.dataTypeEnum.float
}, {
id: "y",
alias: "values",
dataType: tableau.dataTypeEnum.float
}];
var tableSchema = {
id: "bitcoin"
alias: "total bitcoin"
columns: cols
};
schemaCallback([tableSchema]);
};
myConnector.getData = function(table, doneCallback) {
$.getJSON("https://api.blockchain.info/charts/total-bitcoins?timespan=all&format=json", function(resp) {
var feat = resp.features,
tableData = [];
// Iterate over the JSON object
for (var i = 0, len = feat.length; i < len; i++) {
tableData.push({
"x": feat[i].values.x,
"y": feat[i].values.y
});
}
table.appendRows(tableData);
doneCallback();
});
};
tableau.registerConnector(myConnector);
$(document).ready(function() {
$("#submitButton").click(function() {
tableau.connectionName = "Bitcoin";
tableau.submit();
});
});
})();