2017-02-14 5 views
1

スクリーンショットに表示されている凡例のタイトルを、すべての垂直バーの数のように変更するにはどうすればよいですか? Ex;合計:11SAPUI5で凡例のタイトルを列チャートのVizFrameに設定する方法

また、デフォルトの開始y軸値が500mから始まるのはなぜですか?どうすれば変更できますか?

サンプルScreenshot

enter image description here 下記のコントローラコード:

onInit: function() { 

//  1.Get the id of the VizFrame 
     var oVizFrame = this.getView().byId("idcolumn"); 

//  2.Create a JSON Model and set the data 
     var oModel = new sap.ui.model.json.JSONModel(); 
     var data = { 
     'Coaches' : [ 
     {"Name": "Singapore","Value": "1"}, 
     {"Name": "India","Value": "1"}, 
     {"Name": "Germany","Value": "2"}, 
     {"Name": "South Africa","Value": "1"}, 
     {"Name": "Turkey","Value": "0"}, 
     {"Name": "Japan","Value": "1"}, 
     {"Name": "China","Value": "2"}, 
     {"Name": "France","Value": "2"}, 
     {"Name": "ArgentinasdfsdfddfsdfsdAA","Value": "1"}, 
     ]}; 

     oModel.setData(data); 

     this.getView().setModel(oModel); 

//  3. Create Viz dataset to feed to the data to the graph 
     var oDataset = new sap.viz.ui5.data.FlattenedDataset({ 
     dimensions : [{ name : 'Country',value : "{Name}" }], 
     measures : [{ name : 'Total No of KFC Branches', value : '{Value}' }], 
     data : { path : "/Coaches" } 
     }); 

// Binding Model and Dataset to the Frame 
     oVizFrame.setDataset(oDataset); 
     oVizFrame.setModel(oModel); 
     oVizFrame.setVizType('column'); // column or bar 

//  4.Set Viz properties 
// Ref Link: https://sapui5.netweaver.ondemand.com/docs/vizdocs/index.html#reference/chartProperty/Charts/Bar%20%20(13)/Column%20Chart/ 
     oVizFrame.setVizProperties({ 
      title: { text : "KFC Statistics" }, 
      general: { background : { border : { top : { visible : true } } } }, 
      general: { background : { border : { bottom : { visible : true } } } }, 
      general: { background : { border : { right : { visible : true } } } }, 
      general: { background : { border : { left : { visible : true } } } }, 
      // valueAxis: { title : { text : "Totallll" }}, 
      legend: { isScrollable : true }, 
      legend: { visible : true }, 
      legend: { title : { visible : true } }, 
      legend: { title : { text : "All Measures" } }, 
      plotArea: { dataLabel : { visible : true} } 
     }); 

// Axis Specification 
     var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
      'uid': "valueAxis", 
      'type': "Measure", 
      'values': ["Total No of KFC Branches"] 
      }), 

      feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
       'uid': "categoryAxis", 
       'type': "Dimension", 
       'values': ["Country"] 
       });`enter code here` 

// Addition of Axis to Frame 
     oVizFrame.addFeed(feedValueAxis); 
     oVizFrame.addFeed(feedCategoryAxis);   

    } 

答えて

0

あなたがSAPUI5のどのバージョンを使用していますか? 私は1.44.5を使用していますし、あなたの例では、良さそうに見えます(スクリーンショットを参照)

enter image description here

そして、あなたはoVizFrame.setVizPropertiesに

yAxis: { scale: { fixedRange: true, minValue: 0, maxValue: 3 }} 

を追加することにより、y軸上の値を変更することができます。

"値の合計"を簡単に取得する方法がないため、他の問題はもっと複雑になります。

あなたは

//  3. Create Viz dataset to feed to the data to the graph 
    var coaches = oModel.getProperty("/Coaches"); 
    var ttl = 0; 
    for (var i = 0; i < coaches.length; i++) { 
     ttl += parseInt(coaches[i].Value); 
    } 
    var total = "Total " + ttl; 

    var oDataset = new FlattenedDataset({ 
     dimensions: [{ 
      name: 'Country', 
      value: "{Name}" 
     }], 
     measures: [{ 
      name: total, 
      value: '{Value}' 
     }], 
     data: { 
      path: "/Coaches" 
     } 
    }); 

// Axis Specification 
var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
    'uid': "valueAxis", 
    'type': "Measure", 
    'values': [total] 
}), 
を表示する前に、合計を計算する必要があります
関連する問題