doubao6681 2019-04-25 08:24
浏览 209
已采纳

如何创建没有列数据类型的tableau wdc?

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);
})();
  • 写回答

1条回答 默认 最新

  • drr25281 2019-04-29 15:50
    关注

    With the WDC you are creating an Extract directly and you need to tell Tableau the dataType. It isn't an optional property.

    When Tableau imports a text file it makes its best guess as to the column type but you cannot let Tableau decide the column type with the WDC.

    In either case, you can still change the data type after you load the data when you are building the Viz.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?