You need to sign in to do that
Don't have an account?
display pie chart in loop
Hi ,
I have some doubts .
I have some data which contains %complete and status [complete or incomplete] as both fields.
I created custom class and add this these 2 fields in this class.
Then I created 2 objects of this class and assign values and then added these 2 objects in custom list.
Then I want to loop out the list and create pie chart and display it in different row.
I am able to do it , but here 2 charts are coming in only one row and this is not expected , I want each row contains only one pie chart.
Below is code snippet for controller:
public class TestGraph
{
Public List<PieWedgeData> getData{get;set;}
Public List<Show> s{get;set;}
Public List<PieWedgeData> getData1{get;set;}
public TestGraph()
{
getData = new List<PieWedgeData>();
PieWedgeData obj = new PieWedgeData('complete',40);
PieWedgeData obj1 = new PieWedgeData('incomplete',60);
getData.add(obj);
getData.add(obj1);
Show objs = new Show();
objs.displayname = 'public site 1';
objs.placedata = getData;
s=new List<Show> ();
s.add(objs);
getData1 = new List<PieWedgeData>();
PieWedgeData obj3 = new PieWedgeData('complete',10);
PieWedgeData obj2 = new PieWedgeData('incomplete',90);
getData1.add(obj3);
getData1.add(obj2);
Show objs1 = new Show();
objs1.displayname = 'public site 2';
objs1.placedata = getData1;
s.add(objs1);
}
public class PieWedgeData
{
public String name { get; set; }
public Decimal data { get; set; }
public PieWedgeData(String name, Decimal data)
{
this.name = name;
this.data = data;
}
}
public class Show
{
public String displayname {get;set;}
public List<PieWedgeData> placedata {get;set;}
}
}
below is visualforce code :
<apex:page controller="TestGraph">
<apex:PageBlock >
<apex:pageBlockTable value="{!s}" var="wrap" align="CENTER">
<apex:column headerValue="Name" value="{!wrap.displayname}"/>
<apex:column headerValue="% Complete">
<apex:chart height="200" width="300" data="{!wrap.placedata}" >
<apex:pieSeries dataField="data" labelField="name" showInLegend="true" highlight="true"/>
</apex:chart>
</apex:column>
</apex:pageBlockTable>
</apex:PageBlock>
</apex:page>
but in output of above result both charts are displaying in first row means in public site 1 row
where as per expectation second chart should come in another row means in public site 2 .
anyone please help me to resolve this issue.
Hi Abhishek,
I'm sorry this can't solve your problem but this might still help you save some time/effort.
Putting IDs into the VF page elements as below: (I tried using apex:repeat, evidently it doesn't make a difference)
<apex:page controller="TestGraph" id="TestGraph">
<table align="CENTER" id="Table">
<tr>
<th>Name</th>
<th>Complete</th>
</tr>
<apex:repeat value="{!s}" var="wrap" id="ChartNumber">
<tr>
<td>{!wrap.displayname}</td>
<td>
<apex:chart id="Chart" height="200" width="300" data="{!wrap.placedata}">
<apex:pieSeries dataField="data" labelField="name" showInLegend="true" highlight="true"/>
</apex:chart>
</td>
</tr>
</apex:repeat>
</table>
</apex:page>
this is what I note:
The generated html code puts a "renderTo":"TestGraph:ChartNumber:0:Chart" for both the repeating elements with IDs TestGraph:ChartNumber:0:Chart and TestGraph:ChartNumber:1:Chart.
I think this is a clear bug in SFDC in assigning Span IDs and you are better off opening a support ticket.
If this post solves(perhaps just helps) your problem kindly mark it as solution.
-Varun Yagain