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
JP BlonshineJP Blonshine 

GoogleViz Line Chart Help

All -

 

So I have my data coming through correctly, and now I am trying to figure out displaying the X and Y axis correctly. With the following code, I am getting two lines. What I want is for the values to make one line. Channel Flow is the X-Axis and Channel Volume is the Y-Axis.

public with sharing class TestResultGraphConroller {

	
	public TestResultGraphConroller(ApexPages.StandardController stdController){
	}
	
	public String getTestResult(){
        return getTestResult(null);
    }
    
    public String getTestResult(List<Id> ids){
        
        GoogleViz gv = new GoogleViz();
                
        gv.cols = new list<GoogleViz.col> { 
            new GoogleViz.Col('col1','Channel Volume','number'),
            new GoogleViz.Col('Col2','Channel Flow','number')
        };
                
        string query = 'SELECT Id, Channel_Volume__c, Channel_Flow__c, Name FROM Trial_Data__c';
        
        // The unit testing path.
        if(ids != null && ids.size() > 0){
            query += ' AND Id IN :ids';
        }        
        
        query += ' ORDER BY Id ASC';
        
        decimal numTestResults = 0.01;                   
        for(Trial_Data__c td : Database.query(query)){  
            GoogleViz.row r = new GoogleViz.row();
            r.cells.add ( new GoogleViz.cell( td.Channel_Volume__c));
            r.cells.add ( new GoogleViz.cell( td.Channel_Flow__c));
                            
            gv.addRow( r );
            
            numTestResults++;
            }

        return gv.toJsonString();
    }  

 I am so close....but yet so far.

 

Regards,

 

JP

Richie DRichie D

Hi,

 

The best advice I can give is to go to the Google Playground and work out what you need to put in the page and work back to the data you need to build in the Controller/VF. You can always paste in what you already have and see what changes you need from where you are currently at.

 

It can be very frustrating trying to get everything sorted correctly and this now the way I approach chart generation. 

 

Good luck!

Rich.