Skip to content

Instantly share code, notes, and snippets.

@robbyrussell
Created October 8, 2008 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robbyrussell/15458 to your computer and use it in GitHub Desktop.
Save robbyrussell/15458 to your computer and use it in GitHub Desktop.
example of building line graph with ProtoChart
// 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