2017-09-19 54 views
0

我想加上我的對話框SAP UI5一個維茲圖表,但是沒有什麼被顯示出來。這是我的代碼,有人可以幫忙!我在印刷機上添加了一個工作正常的對話框。即使我把警報在各個部分只是爲了檢查代碼是否正常運行。沒有錯誤,我仍然沒有看到對話框中的圖表。VizChart在對話框中SAP UI5

pressTemp: function() { 
     var oView = this.getView(); 
     var oDialog = oView.byId("helloSiteDialog"); 

     // create dialog lazily 
     if (!oDialog) { 

      // create dialog via fragment factory 
      oDialog = sap.ui.xmlfragment(oView.getId(), "Hari_At_Work.view.HelloSiteDialog", this); 
      var oVizFrame = this.getView().byId("idVizFrame"); 

      oVizFrame.destroyDataset(); 
      oVizFrame.destroyFeeds(); 

      console.log("chart here"); 

      //New dataset 
      oVizFrame.setDataset(new sap.viz.ui5.data.FlattenedDataset({ 
       dimensions: [{ 
        name: 'Timeline', 
        value: "{Country}" 
       }], 
       measures: [{ 
        name: 'Value', 
        value: '{revenue}' 
       }], 
       data : { 
    path : "/businessData" 
} 
      })); 

      alert("Dataset found"); 

      //Add feeds 
      oVizFrame.addFeed(new sap.viz.ui5.controls.common.feeds.FeedItem({ 
       uid: "categoryAxis", 
       type: "Dimension", 
       values: ["Timeline"] 
      })); 

      oVizFrame.addFeed(new sap.viz.ui5.controls.common.feeds.FeedItem({ 
       uid: "valueAxis", 
       type: "Measure", 
       values: ["Value"] 
      })); 

     // oVizFrame.setModel(sap.ui.getCore().getModel()); 

      var oModel = new sap.ui.model.json.JSONModel({ 
       businessData: [{ 
        Country: "Canada", 
        revenue: 410.87, 
        profit: -141.25, 
        population: 34789000 
       }, { 
        Country: "China", 
        revenue: 338.29, 
        profit: 133.82, 
        population: 1339724852 
       }, { 
        Country: "France", 
        revenue: 487.66, 
        profit: 348.76, 
        population: 65350000 
       }, { 
        Country: "Germany", 
        revenue: 470.23, 
        profit: 217.29, 
        population: 81799600 
       }, { 
        Country: "India", 
        revenue: 170.93, 
        profit: 117.00, 
        population: 1210193422 
       }, { 
        Country: "United States", 
        revenue: 905.08, 
        profit: 609.16, 
        population: 313490000 
       }] 
      }); 

      oVizFrame.setModel(oModel); 
      alert("Model found"); 

      oView.addDependent(oDialog); 

     } 

     oDialog.open(); 
    // oVizFrame.invalidate(); 

    }, 

我的片段XML代碼:

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:l="sap.ui.layout" xmlns:viz.feeds="sap.viz.ui5.controls.common.feeds" 
xmlns:viz.data="sap.viz.ui5.data" xmlns:viz="sap.viz.ui5.controls" xmlns:fb="sap.ui.comp.filterbar"> 




<Dialog id="helloSiteDialog" title="Temperature Trend"> 


    <viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}" 
      height='100%' width="100%" vizType='column'> 
      <viz:dataset> 
       <viz.data:FlattenedDataset data="{/businessData}"> 
        <viz.data:dimensions> 
         <viz.data:DimensionDefinition name="Name" 
          value="{Country}" /> 
        </viz.data:dimensions> 
        <viz.data:measures> 
         <viz.data:MeasureDefinition name="Revenue" 
          value="{revenue}" /> 
         <viz.data:MeasureDefinition name="Cost" 
          value="{Cost}" /> 
        </viz.data:measures> 
       </viz.data:FlattenedDataset> 
      </viz:dataset> 

      <viz:feeds> 
       <viz.feeds:FeedItem id='valueAxisFeed' uid="valueAxis" type="Measure" 
        values="Revenue" /> 
       <viz.feeds:FeedItem id='categoryAxisFeed' uid="categoryAxis" type="Dimension" 
        values="Name" /> 
      </viz:feeds> 
     </viz:VizFrame> 




    <beginButton> 
     <Button text="Close" press="onCloseSiteDialog"/> 
    </beginButton> 
</Dialog> 

回答

-1

而且粘貼視圖和片段code..I已經試過你code.The地圖顯示了我plunkr.Are你看樣在控制檯中出現任何錯誤? Plunk of vizframe

我已經popover.so在代碼改變用於僅

oDialog.openBy(btn); 
+0

片段具有隻是一個正常VizChart代碼與'ID = 「idVizFrame」'。我的觀點實際上與控制無關。所有事情都發生在新聞採訪中。比如考慮點擊按鈕。 – daisy

+0

您的代碼看起來不錯.. –

+0

雅,它的代碼罰款。正如我所說,它的工作,如果我在不同的視圖(頁面)中使用它。但在對話框中沒有出現。要求是在對話框中顯示它! – daisy