You need to sign in to do that
Don't have an account?
Mike 317
visualforce chart won't render
Hey,
I'm trying to create a narrow chart that will show the color status of an account. Data is populated in a related object weekly. Currently, I'm not getting an error, but nothing is rendering. Debug logs show my query is returning the records. I've never used charts before, so it's probably something silly i've missed. Any thoughts?
Page
Controller ext.
I'm trying to create a narrow chart that will show the color status of an account. Data is populated in a related object weekly. Currently, I'm not getting an error, but nothing is rendering. Debug logs show my query is returning the records. I've never used charts before, so it's probably something silly i've missed. Any thoughts?
Page
<apex:page standardcontroller="Account" extensions="ClientHealthExtension"> <apex:chart height="125" width="100%" data="{!trendData}"> <apex:axis type="Numeric" position="bottom" fields="week"/> <apex:axis type="Category" position="left" fields="xName"/> <apex:barSeries orientation="vertical" axis="bottom" xField="week" yField="xName"/> </apex:chart> </apex:page>
Controller ext.
public class ClientHealthExtension { private final Account acct; public Account acctName; public ID acctId; public List<Account> nameList; public ClientHealthExtension (ApexPages.StandardController stdController){ this.acct = (Account) stdController.getRecord(); acctId = acct.Id; nameList = [SELECT Name FROM Account WHERE Id=:acctId limit 1]; if(!nameList.isEmpty()){ acctName = nameList[0]; } } public List<Account_Trend__c> gettrendData(){ List<Account_Trend__c> trends = [SELECT Account_Name__c, Client_Health_Status_Indicator__c, CreatedDate FROM Account_Trend__c WHERE Account_Name__c =:acctName.Name ORDER BY CreatedDate]; system.debug('trends: '+trends); return trends; } // Wrapper class public class trendData { public String xName { get; set; } public String health { get; set; } public date week { get; set; } public ID xId { get; set; } public String xIso { get; set; } public trendData(String xName, String health, date week, ID xId, String xIso) { this.xName = xName; this.health = health; this.week = week; } } }
Try this, I have modified your gettrendData method to return a list of the wrapper object.
Refer this link
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_charting_example.htm
I've added your code and i'm getting an illegal List to List conversion. "Illegal conversion from List<ClientHealthExtension.trendData> to List<Account_Trend__c>"
Did I miss something? Here's the code with updates: