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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序