Skip to Content
0

vizFrame - change datalabel with Dataset value

Mar 16, 2017 at 09:58 AM

135

avatar image

I'm creating a report with vizFrame. It's showing the duration of jobs.

The HANA view looks like this:

JOBNAME : STATUS : START_DATE : DURATION
AB      : C      : 01-01-2017 : 4
AC      : E      : 01-02-2017 : 5Etc.

For now the dataLabel is showing the value of the duration column, wich is the measure for the Dataset. But I would like the dataLabel to show the Status of that job. On this page (https://archive.sap.com/discussions/thread/3851846)I found a simular question, but I'm unable to apply it to my code. I'm not sure how to get data data from the Status column, meaning this part:

oEvent.text = chartobj.getDataset().getModel().getData()["DEFECT_COUNTS"][oEvent.ctx._context_row_number].COUNT;

This is how my report looks for now:

This is my code:

<!DOCTYPE HTML>

<html>

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

<title>Test Charts with oData</title>


<script id="sap-ui-bootstrap" src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js" type="text/javascript" data-sap-ui-libs="sap.ui.core,sap.viz" data-sap-ui-theme="sap_goldreflection">
    </script>
    <script>
    var oModel = new sap.ui.model.odata.ODataModel('Jobs_Statistics.xsodata', true); //true=JSON false=XML performance JSON is sn
    
    var oDataset = new sap.viz.ui5.data.FlattenedDataset({
        dimensions: [{
            name: 'Start_Datum',
            value: "{START_DATUM_CHAR}"},
            {
            name: 'Data Mart',
            value: "{DATAMART}"}],
            
            
        measures: [{
            name: 'Doorlooptijd',
            value: "{DOORLOOPTIJD_IN_SEC}"}],
            
        data: {
            path: "/JOBS_STATS"},
    })
        
    var oVizFrame = new sap.viz.ui5.controls.VizFrame({
        height : "400px",
		width : "100%",
		vizType : "info/column"
    });
    
    oVizFrame.setModel(oModel);
    oVizFrame.setDataset(oDataset);
    
    oVizFrame.setVizProperties({
          plotArea: {
              dataLabel: {
                  visible: true, 
                  renderer: function(oEvent) {
                      //oEvent.text = 'tst';}
//How to deal with this part?????:
                      oEvent.text = oVizFrame.getDataset().getModel().getData()["/JOBS_STATS"][ctx._context_row_number]["STATUS"]}
              }
          },
          legend: {title: {visible: true}, label:{style:{color:'#FF0000'}}},
          title: {visible:true, text:'Statistieken rapportages'}
        });
    var feedPrimaryValues = new sap.viz.ui5.controls.common.feeds.FeedItem({
			'uid' : "valueAxis",
			'type' : "Measure",
			'values' : ["Doorlooptijd"]
		});
		
	var feedAxisLabels = new sap.viz.ui5.controls.common.feeds.FeedItem({
			'uid' : "categoryAxis",
			'type' : "Dimension",
			'values' : ["Start_Datum"]
		});
		
	var feedColor = new sap.viz.ui5.controls.common.feeds.FeedItem({
			'uid' : "color",
			'type' : "Dimension",
			'values' : ["Data Mart"]
		});
  
    oVizFrame.addFeed(feedPrimaryValues);
	oVizFrame.addFeed(feedAxisLabels);
	oVizFrame.addFeed(feedColor);
    oVizFrame.placeAt("content");

</script>

</head>
<body class="sapUiBody" role="application">
    <div id="content"></div>
</body>
</html>
test.jpg (31.9 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Srikanth KV Mar 16, 2017 at 04:01 PM
0

What is your model structure/hierarchy. from the code it seems like you are trying to access the attribute /JOB_STATS/0/STATUS, but your HANA view doesn't have the field called STATUS

put a console statement in render function for ctx._context_row_number

Share
10 |10000 characters needed characters left characters exceeded
Finn Tiebout Mar 18, 2017 at 09:29 AM
0

The second column in the hana view is the STATUS column. Not sure what you mean with the last sentence. I can't find any documentation about the ctx._context_row_number part just the example I linked.

Share
10 |10000 characters needed characters left characters exceeded