cancel
Showing results for 
Search instead for 
Did you mean: 

How to set default selection on pie chart when page loads?

Former Member
0 Kudos

Hey Folks,

I am trying to set the default selection for my pie chart on "onAfterRendering" Event of my controller so that when view loads there is default Selection of one of the slices of pie chart.

I tried with the following below code :-

View Code


"pieChartData":[

  {

  "days":">=15 Days",

  "value":"35"

  },

  {

  "days":"16-30 Days",

  "value":"65"

  },

  {

  "days":"31-45 Days",

  "value":"95"

  },

  {

  "days":"<45 Days",

  "value":"15"

  }

  ],

var pieChartDataSet = new sap.viz.ui5.data.FlattenedDataset("paymentAgingReport",{

  dimensions:[{axis:1, name:'Days', value:'{days}'}],

  measures:[{name:'Payments Due', value:'{value}'}],

  data:{path:"/pieChartData"}

  });

var pieChart = new sap.viz.ui5.Pie("reportChart",{

   id : "pie",

   width : "100%",

   height : "250px",

   dataset: pieChartDataSet,

   selectData:oController.onSelectPieChart,

  

   });

Controller Code

onAfterRendering: function() {

  var data = [{"days":"31-45 Days", "value":"95"}];

  sap.ui.getCore().byId("agingReportChart").selection(data);

  },

But i checked while debugging, it is returning me false.

And i am also using the Tokens so that when user clicks on the slices of the pie chart, he get "Tokens" on the toolbar like filter. So i want to implement, when he closes any of the token then only that section of chart should become unselected.

Could you please help me in achieving this??

Thanks & Regards,

Deepak

Accepted Solutions (1)

Accepted Solutions (1)

seVladimirs
Active Contributor
0 Kudos

Hi,

You are passing wrong array to method "selection". See correct array example below.


      var data = [{

                             data: {"Days": "31-45 Days", "Payments Due":"95"}

                           }];

Code snippet - JS Bin - Collaborative JavaScript Debugging&lt;/title&gt; &lt;link rel=&quot;alternate&quot; type=&q...

More information about Pie's selection method - JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.viz.ui5.core.BaseChart

Regards,

Vladimir

Message was edited by: Vladimirs Semikins

Answers (0)