EJSC.Chart.onYAxisNeedsTicks

 

Definition

 

array onYAxisNeedsTicks( float y_min, float y_max, 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 ] to be returned which defines exactly where to put the tick marks and labels.  In addition, null may be returned in order to skip custom ticks for the current draw and use the chart's build in tick controls.

 

Sends:

       y_min - The current minimum y value visible on the chart.

       y_max - The current maximum y value visible on the chart.

       chart - The chart that triggered the event.

 

Notes

 

To use the label formatter already assigned to the chart, set label to null (i.e. [y_min, null])
To use on a chart with bins (text instead of numbers), simply send in the bin (i.e. ["First Bin", null])

 

 

Example

 

A typical event handler may look like the following:

 

function doYAxisNeedsTicks(y_min, y_max, chart) {

 

       // Display 3 tick marks, one at y_min, one at y_max and one directly in between

       var result = new Array();

 

       result.push( [y_min, null] );

       result.push( [y_min + ((y_max - y_min) / 2), null] );

       result.push( [y_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;

}