Skip to Content
author's profile photo Former Member
Former Member

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

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on May 18, 2015 at 09:13 AM

    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=&quot;application/jso…

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.