【发布时间】:2018-01-21 21:00:28
【问题描述】:
我的代码似乎没有在 tableau Web 数据连接器模拟器中生成表格。我已经按照说明完成了他们展示的教程。
请参阅此处获取教程 -https://tableau.github.io/webdataconnector/docs/wdc_tutorial。
这可能是 json 的格式以及我尝试将其转换为表格的方式。
请参阅此处查看文档https://blockchain.info/api/charts_api
查看这里的 json https://api.blockchain.info/charts/total-bitcoins?timespan=all&format=json
我是 javascript 的新手,不知道为什么它不会运行...我可以让 html 页面在本地运行(按照说明)。
有人对我如何让这个(我的代码)工作有任何建议吗? 我查看了其他 WDC,但仍然没有任何运气。
(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();
});
});
})();
【问题讨论】:
标签: json tableau-api blockchain.info-api