Faried Nawaz
unread,Nov 29, 2010, 8:28:45 AM11/29/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Flotr Javascript Plotting Library
Here's how I solved this. It was pretty obvious, once I took a break
from the keyboard for a short while.
I have my server-side code generate two JS expressions:
var currentplot = [[0,19.230000],[1,19.550000],[2,19.700000],
[3,19.870000],[4,19.630000],[5,19.600000],[6,19.530000],
[7,19.370000]];
xaxis = ["Nov 15 2010","Nov 16 2010","Nov 22 2010","Nov 23 2010","Nov
24 2010","Nov 25 2010","Nov 26 2010","Nov 29 2010"];
Options:
var currentopts = {xaxis: {labelsAngle: 45, tickFormatter:
xaxisformatter},
yaxis: {autoscaleMargin: 1.1},
mouse: {track: true, trackFormatter:
currentformatter, trackDecimals: 2}};
Formatters:
function xaxisformatter(t)
{
return xaxis[parseInt(t, 10)];
}
function currentformatter(loc)
{
var datestr = xaxisformatter(loc.x);
var price = loc.y;
// volumeplot is the data for another chart on the page
var volume = volumeplot[loc.x - 1][1];
return '(' + datestr + ' Price: ' + price + ' Volume: ' + volume +
')';
}