cancel
Showing results for 
Search instead for 
Did you mean: 

Usage of vizSelection?

Former Member
0 Kudos

Dear Gurus,

Requirement:

I am trying to select particular data set in viz frame on click of a button, using vizselection Property,

I count not find any example, and just found small documentation about this

https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.viz.ui5.controls.VizFrame.html#vizSe...

and i tried to apply and it didn't work.

index,html

<!DOCTYPE HTML>

<html>

  <head>

  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

  <script src="resources/sap-ui-core.js"

  id="sap-ui-bootstrap"

  data-sap-ui-libs="sap.m"

  data-sap-ui-theme="sap_bluecrystal">

  </script>

  <!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->

  <script>

  sap.ui.localResources("vizchart");

  var app = new sap.m.App({initialPage:"idmain1"});

  var page = sap.ui.view({id:"idmain1", viewName:"vizchart.main", type:sap.ui.core.mvc.ViewType.XML});

  app.addPage(page);

  app.placeAt("content");

  </script>

  </head>

  <body class="sapUiBody" role="application">

  <div id="content"></div>

  </body>

</html>

main.view.xml

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"   xmlns:viz="sap.viz.ui5.controls"

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

  <Page title="Title">

  <content>

  <Button text="select store 24-Seven" press="onPress"/>

  <viz:Popover id="idPopOver"></viz:Popover>

            <viz:VizFrame id="idVizFrameStackedColumn" uiConfig="{applicationSet:'fiori'}" height="100%" width="100%"></viz:VizFrame>

  </content>

  </Page>

</core:View>

main.controller.js

sap.ui.define([

              'sap/ui/core/mvc/Controller',

              'sap/ui/model/json/JSONModel',

              'sap/viz/ui5/controls/common/feeds/FeedItem',

              'sap/viz/ui5/data/FlattenedDataset',

              './ControllerOverall'

          ], function(Controller, JSONModel, FeedItem, FlattenedDataset, ControllerOverall) {

          "use strict";

          var StackedColumnController = Controller.extend("vizchart.main", {

        onInit: function() {

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

        var dataPath = "Model"

                  oVizFrame.setVizType('stacked_column');

                  oVizFrame.setUiConfig({

                      "applicationSet": "fiori"

                  });

                  var oPopOver = this.getView().byId("idPopOver");

                  oPopOver.connect(oVizFrame.getVizUid());

    var oModel = new sap.ui.model.json.JSONModel({

                          data : [ {

                                    country : 'China',

                                    year : '2001',

                                    product : 'Car',

                                    profit : 25

                          }, {

                                    country : 'China',

                                    year : '2002',

                                    product : 'Car',

                                    profit : 32

                          }, {

                                    country : 'France',

                                    year : '2001',

                                    product : 'Car',

                                    profit : 23

                          }, {

                                    country : 'France',

                                    year : '2002',

                                    product : 'Car',

                                    profit : 43

                          }, {

                                    country : 'Germany',

                                    year : '2001',

                                    product : 'Car',

                                    profit : 123

                          }, {

                                    country : 'Germany',

                                    year : '2002',

                                    product : 'Car',

                                    profit : 34

                          }, {

                                    country : 'USA',

                                    year : '2001',

                                    product : 'Car',

                                    profit : 14

                          }, {

                                    country : 'USA',

                                    year : '2002',

                                    product : 'Car',

                                    profit : 25

                          }, {

                                    country : 'China',

                                    year : '2001',

                                    product : 'Truck',

                                    profit : 34

                          }, {

                                    country : 'China',

                                    year : '2002',

                                    product : 'Truck',

                                    profit : 78

                          }, {

                                    country : 'France',

                                    year : '2001',

                                    product : 'Truck',

                                    profit : 45

                          }, {

                                    country : 'France',

                                    year : '2002',

                                    product : 'Truck',

                                    profit : 86

                          }, {

                                    country : 'Germany',

                                    year : '2001',

                                    product : 'Truck',

                                    profit : 34

                          }, {

                                    country : 'Germany',

                                    year : '2002',

                                    product : 'Truck',

                                    profit : 56

                          }, {

                                    country : 'USA',

                                    year : '2001',

                                    product : 'Truck',

                                    profit : 23

                          }, {

                                    country : 'USA',

                                    year : '2002',

                                    product : 'Truck',

                                    profit : 76

                          }, {

                                    country : 'China',

                                    year : '2001',

                                    product : 'Motorcycle',

                                    profit : 12

                          }, {

                                    country : 'China',

                                    year : '2002',

                                    product : 'Motorcycle',

                                    profit : 78

                          }, {

                                    country : 'France',

                                    year : '2001',

                                    product : 'Motorcycle',

                                    profit : 45

                          }, {

                                    country : 'France',

                                    year : '2002',

                                    product : 'Motorcycle',

                                    profit : 86

                          }, {

                                    country : 'Germany',

                                    year : '2001',

                                    product : 'Motorcycle',

                                    profit : 34

                          }, {

                                    country : 'Germany',

                                    year : '2002',

                                    product : 'Motorcycle',

                                    profit : 56

                          }, {

                                    country : 'USA',

                                    year : '2001',

                                    product : 'Motorcycle',

                                    profit : 23

                          }, {

                                    country : 'USA',

                                    year : '2002',

                                    product : 'Motorcycle',

                                    profit : 76

                          }, {

                                    country : 'China',

                                    year : '2001',

                                    product : 'Bicycle',

                                    profit : 12

                          }, {

                                    country : 'China',

                                    year : '2002',

                                    product : 'Bicycle',

                                    profit : 78

                          }, {

                                    country : 'France',

                                    year : '2001',

                                    product : 'Bicycle',

                                    profit : 45

                          }, {

                                    country : 'France',

                                    year : '2002',

                                    product : 'Bicycle',

                                    profit : 86

                          }, {

                                    country : 'Germany',

                                    year : '2001',

                                    product : 'Bicycle',

                                    profit : 34

                          }, {

                                    country : 'Germany',

                                    year : '2002',

                                    product : 'Bicycle',

                                    profit : 56

                          }, {

                                    country : 'USA',

                                    year : '2001',

                                    product : 'Bicycle',

                                    profit : 23

                          }, {

                                    country : 'USA',

                                    year : '2002',

                                    product : 'Bicycle',

                                    profit : 76

                          } ]

                });

                  var oDataset = new FlattenedDataset({

                      dimensions: [{

                          name: "country",

                          value: "{country}"

                      }, {

                        name: "year",

                        value: "{year}"

                      }],

                      measures: [{

                          name: 'profit',

                          value: '{profit}'

                      }],

                      data: {

                          path: "/data",

                          factory : function() {

                                    alert("factory function");

                          }

                      }

                  });

                  oVizFrame.setDataset(oDataset);

                  oVizFrame.setModel(oModel);

                  var feedValueAxis = new FeedItem({

                          'uid': "valueAxis",

                          'type': "Measure",

                          'values': ["profit"]

                      }),

                      feedCategoryAxis = new FeedItem({

                          'uid': "categoryAxis",

                          'type': "Dimension",

                          'values': ["country"]

                      }),

                      feedColor = new FeedItem({

        'uid': "color",

        'type': "Dimension",

        'values': ["year"]

        });

                  oVizFrame.addFeed(feedValueAxis);

                  oVizFrame.addFeed(feedCategoryAxis);

                  oVizFrame.addFeed(feedColor);

                  oVizFrame.setVizProperties({

                      general: {

                          layout: {

                              padding: 0.04

                          }

                      },

                      title: {

                          visible: false,

                          text: 'Revenue by City and Store Name'

                      }

                  });

          },

          onPress:function(){

          sap.m.MessageToast.show("selecting 24*7");

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

          var points = [{

              data : {

                  "Country" : "China",

                  "Year" : "2001",

                  "Product" : "Car",

                  "Profit" : 25

              }}, {

              data : {

                  "Country" : "China",

                  "Year" : "2001",

                  "Product" : "Trunk",

                  "Profit" : 34

              }}];

          var action = {

              clearSelection : true

          };

          /*var oVizFrame = this.byId('DueDateGridFrame');*/

          oVizFrame.vizSelection(points, action);

          }

 

//          onBeforeRendering: function() {

//

//          },

   

 

//          onAfterRendering: function() {

//

//          },

 

//          onExit: function() {

//

//          }

          });

          return StackedColumnController;

      });

Please let me know if any 1 had tried it.

Find the project in attachments.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

pek
Explorer
0 Kudos

Hi Siddhartha,

it might be a bit late but this is also for anyone googling for this.

It is easy to figure out how to use it if you look at the result of oVizFrame.vizSelection() without any arguments once after selecting the items you want to select in the chart by hand. This will give you the current selection in the same format you have to select it.

E.g. to select all entries where the country is "China" of the year "2001" points would need to look like this:

var points = [{ country: 'China', year: '2001' }]

I think the keys of the objects have to be the same as defined in the dimensions/measures of the flattened dataset.

0 Kudos

Hi Siddhartha,

Were you able to figure out the usage?

Please let me know if you did!

Thanks!

Former Member
0 Kudos

Hi Narayani,

The thread is still open:-)