EJSC.Axis.onNeedsTicks
See Also
Definition
array onNeedsTicks( float min, float max, EJSC.Axis axis, EJSC.Chart chart)
Description
This event is triggered whenever the axis ticks need to be redrawn / recalculated. It expects an array of [ float y, string label, object grid_options, object tick_options ] to be returned which defines exactly where to put the tick marks and labels and how to draw the grid lines and ticks. In addition, null may be returned in order to skip custom ticks for the current draw and use the chart's built in tick controls.
min: The current minimum value visible on the chart for the axis. max: The current maximum y value visible on the chart for the axis. axis: The axis which needs ticks. chart: The chart that triggered the event.
Notes
Example
A typical event handler may look like the following:
function doBottomAxisNeedsTicks(min, max, axis, chart) {
// Display 3 tick marks, one at min, one at max and one directly in between var result = new Array();
result.push( [min, null] ); result.push( [min + ((max - min) / 2), null] ); result.push( [max, null] );
// Given a chart with a min and max of 0 and 100, the resulting array looks like: // [ // [0, null], // [50, null], // [100, null] // ] return result; }
The following is a more advanced example showing how to control the grid lines and tick marks.
function doAdvancedBottomAxisNeedsTicks(min, max, axis, chart) {
// Display 5 tick marks, draw the grid lines for the whole numbers and the tick // marks for the fractional numbers var result = [ [ 0.0, null, { show: true }, { show: false } ], [ 0.5, null, { show: false }, { show: true } ], [ 1.0, null, { show: true }, { show: false } ], [ 1.5, null, { show: false }, { show: true } ], [ 1.0, null, { show: true }, { show: false } ] ];
return result; } |