You need to sign in to do that
Don't have an account?
Marry Stein
Create Apex Chart related to Group By Statement
Hey Guys,
i have created a controller to generate a query which summarize the monthly revenue of each user. Now, i want to create a visualforce page which shows one chart for each user. Is there a way to do that in visualforce without to create a separate query for each user ? I don't want to customize the controller for new employees.
Thanks for your help guys !
Greetings Marry
Try this aggrigate SOQL
By the way, is it one huge page with plenty of charts (one per user) or one page with one chart for the connected user?
yes alain, i want to create one huge page with plenty of charts .
thanks for your reply raj but unfortunately that is not what i want to do. Sorry for that. I have to define my question more clear.
Greetings Marry
Here is a sample with plenty of charts.
Responsive design:
It is random but based on data stored in one object and still a POC (proof of concept, how does that work with 151 charts on the same page?).
The complete Visualforce page has only the code below using google chart : https://developers.google.com/chart/
(unleash your creativity)
The secret of this miracle is the "dynamic component" because the controller ChartGenerator is still short:
One Component.Apex.PageBlock is build dynamically with many charts:
And now the most important part is the component: mygooglechartcmp which does almost all the work with remote calls in javascript. The controller itself is short and easy to write. Init with random values in the new object Contact_Task__c
There are many alternatives for your problem. Given that "google chart" is only in javascript, the dynamic component could be useless but I am trying new things to see the results.
There is one request (@RemoteAction) for each chart indeed but that is always the case with charts (what happens with 151 charts on the same page?).
The idea of using google chart could be considered to be a valid option at least (only the client side needed and reduced use of the view state).
The strength of the google charts (client side, javascript) is to give users controls to manipulate what data they show natively.
You can imagine only two charts on the page and a drop down on each with all the users (for comparison).
https://developers.google.com/chart/interactive/docs/gallery/controls
Greetings Marry
You also know chart.js ( I retrieved an old question ). You know these techniques with charts in javascript.
Here is an interesting question below with <apex:chart> and data from javascript:
https://developer.salesforce.com/forums/?id=9060G0000005ldaQAA
<apex:chart data="dataArray"
<script> var dataArray = new Array();
That could work as simply as this sample but you will not find this kind of data feeding in the documentation of Salesforce.
If you use only javascript remote calls and the technique above, you can solve your problem with only the client side and it is a good technique to reduce the view state use.
Now, we need to put all together.
If you post some code of your current development, we can improve it together.
i apologize for the late response (i was sick). I think i have to learn javascript remote first. i have never used it before. I love the simplicity of the action function.
Greetings Marry