I am trying to use tableau wdc for the first time. I used the source from tableau tutorial.I want to create schema with no column data type.I want to work my code like tableau works the text file.I think when text file is directly run on tableau, tableau automatically defines the data type of the columns of text files. Here is my code.
javascript
(function () {
var myConnector = tableau.makeConnector();
myConnector.getSchema = function (schemaCallback) {
var cols = [{
id: "id",
dataType: tableau.dataTypeEnum.string
}, {
id: "mag",
dataType: tableau.dataTypeEnum.float
// dataType: tableau.dataTypeEnum.string
}, {
id: "title",
dataType: tableau.dataTypeEnum.string
}, {
id: "location",
dataType: tableau.dataTypeEnum.geometry
//dataType: tableau.dataTypeEnum.string
}];
var tableSchema = {
id: "earthquakeFeed",
columns: cols
};
schemaCallback([tableSchema]);
};
myConnector.getData = function(table, doneCallback) {
$.getJSON("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson", function(resp) {
var feat = resp.features,
tableData = [];
// Iterate over the JSON object
for (var i = 0, len = feat.length; i < len; i++) {
tableData.push({
"id": feat[i].id,
"mag": feat[i].properties.mag,
"title": feat[i].properties.title,
"location": feat[i].geometry
});
}
table.appendRows(tableData);
doneCallback();
});
};
$(document).ready(function () {
$("#submitButton").click(function () {
tableau.connectionName = "USGS Earthquake Feed";
tableau.submit();
});
});
tableau.registerConnector(myConnector);
})();