SAPUI5-[50053]-不完整的尺寸绑定

时间:2018-07-26 12:19:04

标签: javascript sapui5

我正在尝试使用JSON数据在SAPUI5上创建条形图,并且出现以下错误:[50053]-尺寸标注绑定不完整。根据不同的帖子,错误与FeedvaluesAxis和数据集中的名称相关联。就我而言,当我查看代码时,这两个名称是相似的。

我的Bar.Controller.js:

    sap.ui.controller("dataxml.Bar", {


onInit: function() {


        var oVizFrame = this.getView().byId("idcolumn");


        var oModel = new sap.ui.model.json.JSONModel();
        var data = [{
            "orderid":"1",
            "productname":"Coca",
            "price":"5",
            "launchdate": "20180505",
            "categorie":"1"
    },{
            "orderid":"2",
            "productname":"Ice Tea",
            "price":"8",
            "launchdate": "20180505",
            "categorie":"1"
    },{
            "orderid":"3",
            "productname":"Pepsi",
            "price":"4",
            "launchdate": "20180506",
            "categorie":"1"
    },{
            "orderid":"4",
            "productname":"Coca",
            "price":"5",
            "launchdate": "20180506",
            "categorie":"1"
    },{
            "orderid":"6",
            "productname":"Mango",
            "price":"1",
            "launchdate": "20180605",
            "categorie":"1"
    }]
        oModel.setData(data);


        var oDataset = new sap.viz.ui5.data.FlattenedDataset({
            dimensions : [{
                    name : "orderid",
                    value : "{orderid}"},{
                    name : "productname",
                    value : "{productname}"},{
                    name : "launchdate",
                    value : "{launchdate}"}],

            measures : [{
                name : "price",
                value : "{price}"},{
                name : "category",
                value : "{category}"
                }],

            data : {
                path : "/"
            }
        });     
        oVizFrame.setDataset(oDataset);
        oVizFrame.setModel(oModel); 


        oVizFrame.setVizType('column');
        oVizFrame.setVizProperties({
            plotArea: {
                colorPalette : d3.scale.category20().range()
                }});

        var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
              'uid': "valueAxis",
              'type': "Measure",
              'values': ["price"]
            }), 
            feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
              'uid': "categoryAxis",
              'type': "Dimension",
              'values': ["productname"]
            });
        oVizFrame.addFeed(feedValueAxis);
        oVizFrame.addFeed(feedCategoryAxis);

        }

我的index.html:

    <html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

    <script src="resources/sap-ui-core.js"
            id="sap-ui-bootstrap"
            data-sap-ui-libs="sap.m"
            data-sap-ui-theme="sap_bluecrystal">
    </script>
    <!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->

    <script>
            sap.ui.localResources("dataxml");
            var app = new sap.m.App({initialPage:"idBar1"});
            var page = sap.ui.view({id:"idBar1", viewName:"dataxml.Bar", type:sap.ui.core.mvc.ViewType.XML});
            app.addPage(page);
            app.placeAt("content");
    </script>

</head>
<body class="sapUiBody" role="application">
    <div id="content"></div>
</body>

我的bar.view.xml:

    <core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" controllerName="dataxml.Bar" 
    xmlns:viz="sap.viz.ui5.controls"
xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Bar char">
    <content>
    <FlexBox justifyContent="Center" alignItems="Start">                
      <items>
        <viz:VizFrame xmlns="sap.viz" id="idcolumn">
        </viz:VizFrame>         
     </items> 
    </FlexBox>
    </content>
</Page>

1 个答案:

答案 0 :(得分:1)

您能告诉我为什么要向数据集(维度3和度量2)和提要(维度1和度量1)添加不同数量的维度和度量吗?您可以尝试像这样添加其余部分吗?

顺便说一句,模型数据显示为“ 类别”,数据集为“ 类别”?这也可能有所作为。

    var feedValueAxis1 = new sap.viz.ui5.controls.common.feeds.FeedItem({
            'uid': "valueAxis",
            'type': "Measure",
            'values': ["price"]
        });

        var feedValueAxis2 = new sap.viz.ui5.controls.common.feeds.FeedItem({
            'uid': "valueAxis",
            'type': "Measure",
            'values': ["category"]
        });

        var feedCategoryAxis1 = new sap.viz.ui5.controls.common.feeds.FeedItem({
            'uid': "categoryAxis",
            'type': "Dimension",
            'values': ["orderid"]
        });

        var feedCategoryAxis2 = new sap.viz.ui5.controls.common.feeds.FeedItem({
            'uid': "categoryAxis",
            'type': "Dimension",
            'values': ["productname"]
        });

        var feedCategoryAxis3 = new sap.viz.ui5.controls.common.feeds.FeedItem({
            'uid': "categoryAxis",
            'type': "Dimension",
            'values': ["launchdate"]
        });

        oVizFrame.addFeed(feedValueAxis1);
        oVizFrame.addFeed(feedValueAxis2);
        oVizFrame.addFeed(feedCategoryAxis1);
        oVizFrame.addFeed(feedCategoryAxis2);
        oVizFrame.addFeed(feedCategoryAxis3);