Skip to Content
avatar image
Former Member

Uncaught TypeError: Cannot read property 'setDataset' of undefined

Hello Experts,

I am getting some Unknown error 😔

Can any one help me to solve this ??

here is my view code:

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"

xmlns="sap.m" controllerName="demovizframe.V_chart"

xmlns:viz="sap.viz.ui5.controls"

xmlns:html="http://www.w3.org/1999/xhtml">

<Page title="Title">

<content>

<viz:VizFrame xmlns="sap.viz" id="idcolumn" >

</viz:VizFrame>

</content>

</Page>

</core:View>

my controller code :

var url2 ="http://xx.xx.xx.xx:8000/AC_ANALYTICS/Power111.xsodata/SENSOR_DETAILS1?$select=SO_TEXT_DT_MM_YYYY,HOUR,ATM_TEMPERATURE&$filter=SO_TEXT_DT_MM_YYYY eq '"+cval+"' &$format=json";

var salesModel2 = new sap.ui.model.json.JSONModel();

salesModel2.loadData(url2);

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

var oDataset = new sap.viz.ui5.data.FlattenedDataset({

dimensions : [{

name : 'HOUR',

value : "{HOUR}"}],

measures : [{

name : 'TEMP',

value : '{ATM_TEMPERATURE}'} ],

data : {

path : "/d/results"

}

});

oVizFrame.setDataset(oDataset);

oVizFrame.setModel(salesModel2);

oVizFrame.setVizType('line');

oVizFrame.setVizProperties({

plotArea: {

colorPalette : d3.scale.category20().range()

}});

var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({

'uid': "valueAxis",

'type': "Measure",

'values': ["TEMP"]

}),

feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({

'uid': "categoryAxis",

'type': "Dimension",

'values': ["HOUR"]

});

oVizFrame.addFeed(feedValueAxis);

oVizFrame.addFeed(feedCategoryAxis);

Thanks in Advance,

Bharath

setdata.png (37.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Apr 07, 2016 at 07:06 AM

    I think your oVizframe is undefined at the time you are trying to assign your dataset. When are you doing all the stuff in your controller? onInit/onBeforeRendering/onAfterRendering? The right time to do this would be onInit

    Add comment
    10|10000 characters needed characters exceeded