You need to sign in to do that
Don't have an account?

I need a Visualforce Page with Apex controller on Account. The vf Page should display a chart between annual revenue and account name with a filter as industry in picklist
<!-- VF Page -->
<apex:page controller="Graph5" sidebar="false">
<apex:form >
<apex:pageblock title="Turnover" >
<apex:inputField value="{!myObject.Industry}">
<apex:actionSupport event="onchange" reRender="graphBlock" />
</apex:inputField>
<apex:pageBlockSection collapsible="false" columns="1" id="graphBlock">
<apex:chart height="350" width="450" data="{!GraphData}">
<apex:axis type="Numeric" position="bottom" fields="amount" title="Amount"/>
<apex:axis type="Category" position="left" fields="name" title="Account"/>
<apex:barSeries orientation="horizontal" axis="left" yField="name" xField="amount" colorSet="lightBlue"/>
</apex:chart>
<apex:chart height="400" width="600" data="{!GraphData}">
<apex:pieSeries donut="50" labelField="name" dataField="amount" >
<apex:chartLabel display="middle" orientation="vertical" font="bold 0px Helvetica"/>
</apex:pieSeries>
<apex:legend position="right"/>
</apex:chart>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
//Controller
public class Graph5
{
public Account myObject {
get {
if (myObject == null)
myObject = new Account();
return myObject;
}
set;
}
List<Account> myObjectList = [select Name, AnnualRevenue from Account where Account.Industry= :myobject.Industry];
public List<GraphWedgeData> getGraphData()
{
List<GraphWedgeData> data = new List<GraphWedgeData>();
for(Account a: myObjectList)
{
data.add(new GraphWedgeData(a.Name,a.AnnualRevenue));
}
return data;
}
public class GraphWedgeData
{
public String name{get; set;}
public Decimal amount{get; set;}
public GraphWedgeData(String name, Decimal amount)
{
this.name = name;
this.amount= amount;
}
}
}
<apex:page controller="Graph5" sidebar="false">
<apex:form >
<apex:pageblock title="Turnover" >
<apex:inputField value="{!myObject.Industry}">
<apex:actionSupport event="onchange" reRender="graphBlock" />
</apex:inputField>
<apex:pageBlockSection collapsible="false" columns="1" id="graphBlock">
<apex:chart height="350" width="450" data="{!GraphData}">
<apex:axis type="Numeric" position="bottom" fields="amount" title="Amount"/>
<apex:axis type="Category" position="left" fields="name" title="Account"/>
<apex:barSeries orientation="horizontal" axis="left" yField="name" xField="amount" colorSet="lightBlue"/>
</apex:chart>
<apex:chart height="400" width="600" data="{!GraphData}">
<apex:pieSeries donut="50" labelField="name" dataField="amount" >
<apex:chartLabel display="middle" orientation="vertical" font="bold 0px Helvetica"/>
</apex:pieSeries>
<apex:legend position="right"/>
</apex:chart>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
//Controller
public class Graph5
{
public Account myObject {
get {
if (myObject == null)
myObject = new Account();
return myObject;
}
set;
}
List<Account> myObjectList = [select Name, AnnualRevenue from Account where Account.Industry= :myobject.Industry];
public List<GraphWedgeData> getGraphData()
{
List<GraphWedgeData> data = new List<GraphWedgeData>();
for(Account a: myObjectList)
{
data.add(new GraphWedgeData(a.Name,a.AnnualRevenue));
}
return data;
}
public class GraphWedgeData
{
public String name{get; set;}
public Decimal amount{get; set;}
public GraphWedgeData(String name, Decimal amount)
{
this.name = name;
this.amount= amount;
}
}
}
All Answers