cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multi lines chart

Former Member
0 Likes
1,711

Would like to check is it possible to create a multi lines chart because no matter how I play with the feed item, it seems that I am only able to get a single line chart with the vizType : 'line'.

Something similar to what is below.

http://m.eet.com/media/1159896/coupling-a-supercapacitor-with-a-small-energy-harvesting-source-fig-6.jpg

View Entire Topic
Former Member
0 Likes

var oChart = new sap.viz.ui5.controls.VizFrame({

  vizType : 'line',

  vizProperties : {

  general : {

            layout : {

  padding : 12

  }

  },

  interaction : {

            selectability : {

  mode : 'NONE',

  plotStdSelection : false

  }

  },

  valueAxis : {

  title : {

  text : 'Leakage time (microAmps)'

  }

  },

  categoryAxis : {

  title : {

  text : 'Time (Hours)'

  }

  }

  },

  legendVisible : false

});

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

var data = {

  'Electrical' : [ {

  time : 20,

  current : 15,

  model: 'A'

        }, {

  time : 40,

  current : 14,

  model: 'A'

        }, {

  time : 60,

  current : 14,

  model: 'A'

        }, {

  time : 80,

  current : 14,

  model: 'A'

        }, {

  time : 100,

  current : 13,

  model: 'A'

  }, {

  time : 120, 

  current : 13,

  model: 'A'

  }, {

  time : 140, 

  current : 12,

  model: 'A'

  }, {

  time : 160,

  current : 12,

  model: 'A'

  }, {

  time : 180,

  current : 11,

  model: 'A'

  }, {

  time : 20,

  current : 15,

  model: 'B'

        }, {

  time : 40,

  current : 14,

  model: 'B'

        }, {

  time : 60,

  current : 14,

  model: 'B'

        }, {

  time : 80,

  current : 14,

  model: 'B'

        }, {

  time : 100,

  current : 13,

  model: 'B'

  }, {

  time : 120, 

  current : 13,

  model: 'B'

  }, {

  time : 140, 

  current : 12,

  model: 'B'

  }, {

  time : 160,

  current : 12,

  model: 'B'

  }, {

  time : 180,

  current : 11,

  model: 'B'

  }, {

  time : 20,

  current : 15,

  model: 'C'

        }, {

  time : 40,

  current : 14,

  model: 'C'

        }, {

  time : 60,

  current : 14,

  model: 'C'

        }, {

  time : 80,

  current : 14,

  model: 'C'

        }, {

  time : 100,

  current : 13,

  model: 'C'

  }, {

  time : 120, 

  current : 13,

  model: 'C'

  }, {

  time : 140, 

  current : 12,

  model: 'C'

  }, {

  time : 160,

  current : 12,

  model: 'C'

  }, {

  time : 180,

  current : 11,

  model: 'C'

  }, {

  time : 20,

  current : 15,

  model: 'D'

        }, {

  time : 40,

  current : 14,

  model: 'D'

        }, {

  time : 60,

  current : 14,

  model: 'D'

        }, {

  time : 80,

  current : 14,

  model: 'D'

        }, {

  time : 100,

  current : 13,

  model: 'D'

  }, {

  time : 120, 

  current : 13,

  model: 'D'

  }, {

  time : 140, 

  current : 12,

  model: 'D'

  }, {

  time : 160,

  current : 12,

  model: 'D'

  }, {

  time : 180,

  current : 11,

  model: 'D'

  }]

};

oModel.setData( data );

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

  dimensions : [ {

  axis : 1,

  name : 'time',

  value : "{time}"

  } ],

  measures : [  {

  name : 'model',

  value: '{model}'

  } , {

  name : 'current',

  value : '{current}'

  }],

  data : {

  path : "/Electrical"

  }

} );

oChart.setDataset( oDataset );

oChart.setModel( oModel );

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

  'uid' : "primaryValues",

  'type' : "Measure",

  'values' : [ 'model', 'current' ]

} );

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

  'uid' : "axisLabels",

  'type' : "Dimension",

  'values' : [ "time" ]

} );

oChart.addFeed( feedPrimaryValues );

oChart.addFeed( feedAxisLabels );

This is the code I am running and I just keep getting only a single line

saivellanki
Active Contributor
0 Likes

Beck,

Can you try something like this?


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

           dimensions: [{

                name: 'model',

                value: '{model}'

            }],

            measures: [{

                name: "time",

                value: "{time}"

  }, {

  name : 'current',  

  value : '{current}'

  }],

            data: {

                path: "/Electrical"

            }

        });

Sample: Plunker (I changed your model a bit)

Regards,

Sai Vellanki.

vijay_kumar49
Active Contributor
0 Likes

Please refer the example document and use "sap.viz.ui5.DualLine" using this API . it should be useful Example -1 and Example -2


Kindly let me know if you need any more information