简体   繁体   English

Treemap 导致 Uncaught Type Error: Undefined is not a function

[英]Treemap Causes Uncaught Type Error: Undefined is not a function

I'm creating a SAPUI5 prototype version of a system that currently exists in Silverlight.我正在创建当前存在于 Silverlight 中的系统的 SAPUI5 原型版本。

Within the current Silverlight application we have a page which contains a Data Table, a bar chart and a Treemap which all display different representations of the same data.在当前的 Silverlight 应用程序中,我们有一个页面,其中包含一个数据表、一个条形图和一个树状图,它们都显示相同数据的不同表示。

In SAPUI5, I've replicated the Data Table and Bar Chart successfully, but I cannot get the Treemap to display, all I get is the Uncaught Type Error: Undefined is not a function error on the line where I try to create the Treemap.在 SAPUI5 中,我已经成功复制了数据表和条形图,但是我无法显示树状图,我得到的只是未捕获的类型错误:未定义不是我尝试创建树状图的行上的函数错误。

    var oModel = new sap.ui.model.odata.ODataModel(
            "../../../services/PCPVCarlineModelYear.xsodata/",
            false);
    
var treemapDataset = new sap.viz.ui5.data.FlattenedDataset({

            dimensions : [ {
            axis : 1, // must be 1 for x-axis. 2 for y-axis
            name : 'Carline',
            value : "{Carline}"
        }],

        measures : [ {
            group : 1,
            name : 'NumberOfVINs',
            value : '{NumberOfVINs}'
        }],

        data : {
            path : "/PCPVCarlineModelYear"
        }
    });
    

    var oTreemap = new sap.viz.ui5.types.Treemap({
        dataset : treemapDataset
    });
    
    oTreemap.setModel(oModel);
    
    return oTreemap;

The Undefined is not a function error occurs on the var oTreemap = new sap.viz.ui5.Treemap({ line.var oTreemap = new sap.viz.ui5.Treemap({ line.

If I change the code from Treemap to Bar , then it displays a Bar chart correctly, just not the Treemap.如果我将代码从Treemap更改为Bar ,那么它会正确显示条形图,而不是 Treemap。

Also, with the index.html page, I have the following script block declared in order to load the correct libraries:此外,对于index.html页面,我声明了以下脚本块以加载正确的库:

    <script src="/sap/ui5/1/resources/sap-ui-core.js"
            id="sap-ui-bootstrap"
            data-sap-ui- libs="sap.ui.commons,sap.ui.table,sap.viz,sap.viz.ui5"
            data-sap-ui-theme="sap_hcb"
            data-sap-ui-modules="sap.ui.core.plugin.DeclarativeSupport">
    </script>

Can anyone suggest what I may be doing wrong?谁能建议我可能做错了什么?

Thanks very much,非常感谢,

Martyn.马丁。

Which version of SAPUI5 are you using?您使用的是哪个版本的 SAPUI5? Version 1.14 has the Treemap , 1.12 doesn't. 1.14 版有Treemap ,1.12 没有。

You could run the same test as here: Link (click on "run with JS")您可以运行与此处相同的测试:链接(单击“使用 JS 运行”)

The example returns the code of the Treemap constructor - what does it return when you load your own copy/sap-ui-core.js of UI5?该示例返回Treemap构造函数的代码 - 当您加载自己的 UI5 副本/sap-ui-core.js 时它返回什么?

Or alternatively, instead of loading UI5 from your own server, you could try loading it from Link (just like in my jsbin snippet) Does the Treemap work then?或者,不是从您自己的服务器加载 UI5,您可以尝试从Link加载它(就像在我的 jsbin 代码段中一样) 那么 Treemap 工作吗?

Regards Andreas问候安德烈亚斯

Give a cross check with the case , in JavaScript the uppercase and lower case are treated differently.对 case 进行交叉检查,在 JavaScript 中,大写和小写的处理方式不同。

I was facing the same problem the mistake was instead of sap.m.Page() i was writing sap.m.page();sap.m.Page()了同样的问题,错误是我在写sap.m.page();而不是sap.m.page();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM