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

如何创建没有列数据类型的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.

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

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化