function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tdevmantdevman 

JSON array from .csv

the following is from the documentation. let's say the opportunty.name is an externalid (unique) and let's say i have .csv file called c:\oppcommisionpercent.csv  that has columns of  name, commissionpercent. The y axis of the dashboard should a calculate the commission amount which would be the opportunity.amount * commissionpercent  which basically multiplies the commission% with the opportunity amount.  I think this is possible passing a JSON array into the <apex:/chart> component.. .been playing around but any ideas would be great

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_charting_example.htm

 

public class OppsController {

// Get a set of Opportunities

public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
}
return setCon;
}
set;
}

public List<Opportunity> getOpportunities() {
return (List<Opportunity>) setCon.getRecords();
}
}

<apex:page controller="OppsController">
<apex:chart data="{!Opportunities}" width="600" height="400">
<apex:axis type="Category" position="left" fields="Name" title="Opportunities"/>
<apex:axis type="Numeric" position="bottom" fields="Amount" title="Amount"/>
<apex:barSeries orientation="horizontal" axis="bottom" xField="Name" yField="Amount"/>
</apex:chart>
<apex:dataTable value="{!Opportunities}" var="opp">
<apex:column headerValue="Opportunity" value="{!opp.name}"/>
<apex:column headerValue="Amount" value="{!opp.amount}"/>
</apex:dataTable>
</apex:page>

 

sf_evolutionsf_evolution

Hi tdevman,

 

Is your CSV coming from an HTTP callout?

 

If so, what happens when you replace your SOQL with the callout, convert the CSV to JSON, deserialize into an array of some class List<> type, and then create a list of Oppys with the data from the class list?

 

 

 ...OR, if Oppy's are totally unrelated and you just want to chart data, upload your CSV to a documents folder, and have your controller read that, parse it, and have your charting object use that data.