Lasso Soft Inc. > Home

[google_chart]

Linkgoogle_chart
AuthorRandy Phillips
CategoryUtility
Version8.5.x
LicensePublic Domain
Posted17 Oct 2008
Updated18 Oct 2008
More by this author...

Description

The purpose of this tag is to access the most commonly used charts from Google's Chart API. It generates a URL request to Google with specified parameters and returns a chart of your data as a PNG file.

Refer to Google's Chart API for chart type codes, marker type codes, etc.
Docs @ http://code.google.com/apis/chart/

Note: This ctag does not incorporate all the chart types and features available in the API. I have only accessed the most common types of charts, i.e., bar, pie, line, etc.  I thought adding the entire API would have made the tag unduly complex. I may do an advanced chart tag later.

Sample Usage

google_chart(
	-title='Vertical Bar Chart', 
	-size='475x250', 
	-type='bvg', 
	-legend=true, 
	-legendPos='l', 
	-data=map('Exp' = '40,30,20', 'Income' = '40,60,59.5', 'Debt' = '20,10,40.5'),
	-axis=map('x' = 'Jan,Feb,Mar', 'y' = '0,25,50,75,100', 't' = 'A,B,C', 'r' = '0,50,100'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	-grid=array(25,25)
	);

google_chart(
	-title='3D Pie Chart', 
	-size='475x250', 
	-type='p3', 
	-legend=true, 
	-legendPos='r', 
	-data=map('Exp' = '40', 'Income' = '40', 'Debt' = '20'),
	-colors=array('cc0000')
	);
		
google_chart(	
	-title='Google Meter',
	-size='475x250', 
	-type='gom',  
	-data=map('Debt-O-Meter' = '45'),
	-colors=array('ffffff', 'cc0000')
	);
	
google_chart(
	-title='Line Chart', 
	-size='475x250', 
	-type='lc', 
	-legend=true, 
	-legendPos='l', 
	-data=map('Exp' = '40,30,20', 'Income' = '40,60,59.5', 'Debt' = '20,10,40.5'),
	-axis=map('x' = 'Jan,Feb,Mar', 'r' = '0,25,50,75,100'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	-marker='d',
	-markerColor='cc0000',
	-markerSize='12',
	-grid=array(0,25)
	);


google_chart(
	-title='Horizontal Stacked Bar Chart', 
	-size='500x175', 
	-type='bhs', 
	-legend=true, 
	-legendPos='t', 
	-data=map('Exp' = '40,30,20', 'Income' = '40,60,59.5', 'Debt' = '20,10,40.5'),
	-axis=map('y' = 'Jan,Feb,Mar', 'x' = '0,25,50,75,100'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	-grid=array(25,25)
	);
	
google_chart(
	-title='Basic Pie Chart', 
	-size='475x250', 
	-type='p', 
	-legend=true, 
	-legendPos='r', 
	-data=map('Exp' = '40', 'Income' = '40', 'Debt' = '20'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	);
	

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

/*
Author: Randy Phillips
Date: 10/15/2008
Purpose: To access Google's Chart API.
Refer to Google's Chart API for chart type codes, marker type codes, etc.
Docs @ http://code.google.com/apis/chart/
Note: This ctag does not incorporate all the chart types and features available in the API
I have only accessed the most common types of charts, bar, pie, line, etc. 
I felt that adding the entire API would have made the tag unduly complex for charts that may rarely be used.

Examples
---------------------------------------------------------------------------------------
google_chart(
	-title='Vertical Bar Chart', 
	-size='475x250', 
	-type='bvg', 
	-legend=true, 
	-legendPos='l', 
	-data=map('Exp' = '40,30,20', 'Income' = '40,60,59.5', 'Debt' = '20,10,40.5'),
	-axis=map('x' = 'Jan,Feb,Mar', 'y' = '0,25,50,75,100', 't' = 'A,B,C', 'r' = '0,50,100'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	-grid=array(25,25)
	);

google_chart(
	-title='3D Pie Chart', 
	-size='475x250', 
	-type='p3', 
	-legend=true, 
	-legendPos='r', 
	-data=map('Exp' = '40', 'Income' = '40', 'Debt' = '20'),
	-colors=array('cc0000')
	);
		
google_chart(	
	-title='Google Meter',
	-size='475x250', 
	-type='gom',  
	-data=map('Debt-O-Meter' = '45'),
	-colors=array('ffffff', 'cc0000')
	);
	
google_chart(
	-title='Line Chart', 
	-size='475x250', 
	-type='lc', 
	-legend=true, 
	-legendPos='l', 
	-data=map('Exp' = '40,30,20', 'Income' = '40,60,59.5', 'Debt' = '20,10,40.5'),
	-axis=map('x' = 'Jan,Feb,Mar', 'r' = '0,25,50,75,100'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	-marker='d',
	-markerColor='cc0000',
	-markerSize='12',
	-grid=array(0,25)
	);


google_chart(
	-title='Horizontal Stacked Bar Chart', 
	-size='500x175', 
	-type='bhs', 
	-legend=true, 
	-legendPos='t', 
	-data=map('Exp' = '40,30,20', 'Income' = '40,60,59.5', 'Debt' = '20,10,40.5'),
	-axis=map('y' = 'Jan,Feb,Mar', 'x' = '0,25,50,75,100'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	-grid=array(25,25)
	);
	
google_chart(
	-title='Basic Pie Chart', 
	-size='475x250', 
	-type='p', 
	-legend=true, 
	-legendPos='r', 
	-data=map('Exp' = '40', 'Income' = '40', 'Debt' = '20'),
	-colors=array('666666', 'cccccc', 'cc0000'),
	);
	
*/

define_tag( 
        'chart', -namespace='google_',
        -req='type', 
        -req='data', -type='map', 
        -opt='size',
        -opt='title',
        -opt='legend', -type='boolean', 
        -opt='legendPos',
        -opt='colors', -type='array',
        -opt='grid', -type='array', 
        -opt='axis', -type='map', 
        -opt='marker',
        -opt='markerColor',
        -opt='markerSize',
        -encodenone 
    ); 
    
    !local_defined('size') ? local('size') = '250x100';
    !local_defined('legend') ? local('legend') = array;
    !local_defined('colors') ? local('colors') = array;
    !local_defined('grid') ? local('grid') = array;
    !local_defined('title') ? local('title') = string;
    !local_defined('legend') ? local('legend') = false;
    !local_defined('legendPos') ? local('legendPos') = string;
    !local_defined('axis') ? local('axis') = map;
    !local_defined('marker') ? local('marker') = string;
    !local_defined('markerColor') ? local('markerColor') = 'cc0000';
    !local_defined('markerSize') ? local('markerSize') = '8';
    
    local('imgURL') = '' + #title + '';
    
     return(#imgURL); 
     
/define_tag;

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft