Question

I'm creating a SAPUI5 prototype version of a system that currently exists in Silverlight.

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.

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.

    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.

If I change the code from Treemap to Bar, then it displays a Bar chart correctly, just not the Treemap.

Also, with the index.html page, I have the following script block declared in order to load the correct libraries:

    <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.

Was it helpful?

Solution

Which version of SAPUI5 are you using? Version 1.14 has the Treemap, 1.12 doesn't.

You could run the same test as here: Link (click on "run with 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?

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?

Regards Andreas

OTHER TIPS

Give a cross check with the case , in JavaScript the uppercase and lower case are treated differently.

I was facing the same problem the mistake was instead of sap.m.Page() i was writing sap.m.page();

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top