Chart
Trace: » Get Started with Pylons » Progressbar » Conditions » Entourage MQ » Chart

Chart

Provides the means to create various forms of charts using very little markup.

Demo

View in a new window...

Source Code

This example demonstrates the creation of a chart with three rows, the second row has content that is fetched from a remote source when it's header is clicked on.

<div control="chart[property=rows,type=line,height=400,width=400]" on="l:line_1 then render" style="float:left">
</div>
<div control="chart[property=rows,type=bar]" on="l:bar_1 then render" style="float:left">
</div>
<div control="chart[property=rows,type=pie]" on="l:pie_1 then render " style="float:left">
</div>
 
<script>
$MQL('l:app.compiled',function() {
        $MQ('l:line_1',{'rows':[{name:'coke',value:10},{name:'pepsi',value:5},{name:'tab',value:3}]});
        $MQ('l:pie_1',{'rows':[{name:'coke',value:10},{name:'pepsi',value:5},{name:'tab',value:3}]});
        $MQ('l:bar_1',{'rows':[{name:'coke',value:10},{name:'pepsi',value:5},{name:'tab',value:3}]});                              
});
</script>

Script Example

In this sample, a chart with the name of 'myChart' is created with some initial properties. The function argument of createControl is called when the widget renders, and a dataset is added to it.

Create the control…

App.createControl(
	'myChart',
	'chart',
	{
		type:'bar',
		property:'rows'
	},
	function()
	{
		var d = [{name:'coke',value:10},{name:'pepsi',value:5},{name:'tab',value:3}]
		this.render({'rows':d})
	}
);

Get the handle to an instance of the control…

App.getControl('myChart','chart',function()
{
	var d = [{name:'coke',value:10},{name:'pepsi',value:5},{name:'tab',value:3}];
	this.render({'rows':d})
});

Options

The accordion control is made up of a container div and a single level of divs within that container which will constitute it's rows when it is rendered. The control tag on the div indicates what kind of widget the div will become. The widget identity can accept the following initial parameters…

Initial options supported by the widget.

Option Description Default Type
type Enumerated value, or property on payload to find value. null String
title Title displayed at the top of the chart. null String
color Specifies the base color of the chart or the color for each bar/slice/line. You can provide a single hex color or csv color list. #477398 String
angle Angle for '3D' graphs, bar and pie (in degrees) 15 Int
thickness Thickness of '3D' graphs (in pixels). 15 Int
width The width of the chart (in pixels). 400 Int
height The height of the chart (in pixels) 360 Int
chartMode sub type for bar and line charts clustered String
barOrientation “vertical” or “horizontal” orientation for a bar chart horizontal String
rotateXAxisLabel “true” or “false”. If “true” x axis labels are rotated by 90 degrees. false Bool
rotateYAxisLabel “true” or “false”. If “true” y axis labels are rotated by 90 degrees. false Bool
legend “true” or “false”. If “true” a legend will be displayed. false Bool
brightness_step How much the brightness of the chart increases 15 Int
font-size Font size (in pixels). 11 Int
property The property of the message to use to populate the chart. null String
chartTitles Array property name that contains the titles for the legend and labels composite bar charts. null Array
fillAlpha Specifies the opacity of the shaded area under a line in a line chart (percentage) 30 Int
indicator Enable a mouseover bubble to show the value of every line at a given x value on a line graph false Bool
margin-top Specifies the space between the top of the chart and the start of the line or bar chart (pixels) 80 Int
margin-left Specifies the space between the left of the chart and the start of the line or bar chart (pixels) 50 Int
margin-right Specifies the space between the right of the chart and the start of the line or bar chart (pixels) 50 Int
margin-bottom Specifies the space between the bottom of the chart and the start of the line or bar chart (pixels) 50 Int
legendHighlight Specifies whether the lines on the line chart will be 'highlighted' when one mouses over a legend value for that line. true Bool
background-color The initial background color. #FFFFFF String
radius The initial Radius 90 Int
precision The initial precision 2 Int
innerRadius Specifies the radius of the 'hole' in the center of the pie chart (pixels) 30 Int
animation The animation effect to use true Bool
oneBalloon Specifies whether an indicator balloon will be shown for all lines or only the line closest to the mouse pointer on the line graph. Possible values are 'true' or 'false'. false Bool
xAxisLabel Label for the X axis null String
xAxisYPosition 0 Int
xAxisXPosition 0 Int
yAxisLabel null String
yAxisYPosition 0 Int
yAxisXPosition 0 Int
dataValueMax 0 Int

Actions/JavaScript API

Functions either accept a single argument such as an integer or a string, otherwise they accept a one dimensional object literal. Any function that can be called as an action accepts the same parameters but in the action parameter format.

Function Action Description
render(obj) render Renders the chart with a specified dataset. If this function is called as an action, the dataset is retrieved from the message that invoked it.
execute(obj) execute Rebuilds the chart using the initial settings, and any additional that are specified from a either a message or an object.
ui/widgetchart.txt · Last modified: 2009/03/10 13:48 by kwhinnery