javascript - SAPUI5 - [50053] - 尺寸绑定(bind)不完整

标签 javascript sapui5

我正在尝试使用 JSON 数据在 SAPUI5 上创建条形图,但出现此错误:[50053] - 维度绑定(bind)不完整。根据不同的帖子,错误与 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>

最佳答案

您能告诉我为什么要向数据集(维度 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);

关于javascript - SAPUI5 - [50053] - 尺寸绑定(bind)不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51538712/

相关文章:

javascript - 隐藏表中的特定行?

javascript - 使用 Jquery 同时将 html 和 text 设置为一个元素

javascript - SAPUI5中如何将属性值传递给init方法?

sapui5 - 如何在 sapui5 中打开媒体源?

css - 在 Eclipse 中使用 HTML5 CSS

javascript - 为什么 onBeforeFirstShow 有效?

javascript - webpack - 转译 1 ts 文件而不捆绑它(2 个条目)

字符串问题的javascript分配

javascript - jsp中隐藏动态div

javascript - 如何更改单选按钮位置并添加行分隔符