xLabel function (very useful for Date charts)

2 views
Skip to first unread message

eliot

unread,
Feb 7, 2008, 11:54:35 AM2/7/08
to plotkit

This is a patch that allows you to specify a function to determine how
a label should be displayed.
I'm using right now for date/time graphs and its working very well.

example usage : layout.xTickLabeler = function(z){ return new
Date(z); };

@@ -584,7 +584,10 @@
PlotKit.Layout.prototype._evaluateLineTicksForXAxis = function()
{
var pos = this.xscale * (xvalues[i] -
this.minxval);
if ((pos > 1.0) || (pos <
0.0))

continue;
- this.xticks.push([pos,
xvalues[i]]);
+ var temp =
xvalues[i];
+ if
( this.xTickLabeler )
+ temp =
this.xTickLabeler( temp );
+ this.xticks.push([pos,
temp ]);
tickCount+
+;
}
if (tickCount >
this.options.xNumberOfTicks)



Reply all
Reply to author
Forward
0 new messages