Created
October 8, 2008 06:40
-
-
Save robbyrussell/15458 to your computer and use it in GitHub Desktop.
example of building line graph with ProtoChart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// line 1, requires an array of arrays (x,y) | |
var line_1 = [ [2000, 10000], | |
[2001, 13000], | |
[2002, 11245], | |
[2003, 11094], | |
[2003.4, 14392], // example with a dcimal in between a tick | |
[2004, 11000], | |
[2005, 10040], | |
[2006, 13590], | |
[2007, 14023], | |
[2008, 9400] | |
]; | |
// line 2... | |
var line_2 = [ [2000, 10000], [2001,11420], [2002,13240], [2003,11243], [2004,12300], [2005,12045], [2006,11050] , [2007,12034], [2008,11102] ]; | |
// the div here needs to be changed to replace the main graph | |
new Proto.Chart($('x_line_graph'), | |
[ | |
{data: line_1, label: "Fund XYZ"}, | |
{data: line_2, label: "S&P 500"} | |
], | |
{ | |
xaxis: { | |
min: 2000, | |
max: 2008, | |
ticks: [ | |
[2001, '2001'], | |
[2002, '2002'], | |
[2003, '2003'], | |
[2004, '2004'], | |
[2005, '2005'], | |
[2006, '2006'], | |
[2007, '2007'], | |
[2008, '2008'] | |
] | |
}, | |
yaxis: { | |
max: 15000 | |
}, | |
grid: { | |
drawYAxis: true, | |
drawXAxis: true | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment