New Axes

    Once you have created your scale class, you need to register it with the global chart object so that it can be used.

    1. Chart.register(MyScale);
    2. // If the new scale is not extending Chart.Scale, the prototype can not be used to detect what
    3. // you are trying to register - so you need to be explicit:
    4. // Chart.registry.addScales(MyScale);

    Scale instances are given the following properties during the fitting process.

    1. {
    2. left: number, // left edge of the scale bounding box
    3. right: number, // right edge of the bounding box
    4. top: number,
    5. bottom: number,
    6. width: number, // the same as right - left
    7. height: number, // the same as bottom - top
    8. // Margin on each side. Like css, this is outside the bounding box.
    9. left: number,
    10. right: number,
    11. top: number,
    12. bottom: number
    13. },
    14. // Amount of padding on the inside of the bounding box (like CSS)
    15. paddingLeft: number,
    16. paddingRight: number,
    17. paddingTop: number,
    18. paddingBottom: number
    19. }

    Scale Interface

    Optionally, the following methods may also be overwritten, but an implementation is already provided by the Chart.Scale base class.

    1. {
    2. // Determine how much the labels will rotate by. The default implementation will only rotate labels if the scale is horizontal.
    3. calculateLabelRotation: function() {},
    4. // Fits the scale into the canvas.
    5. // this.maxWidth and this.maxHeight will tell you the maximum dimensions the scale instance can be. Scales should endeavour to be as efficient as possible with canvas space.
    6. // this.margins is the amount of space you have on either side of your scale that you may expand in to. This is used already for calculating the best label rotation
    7. // You must set this.minSize to be the size of your scale. It must be an object containing 2 properties: width and height.
    8. // You must set this.width to be the width and this.height to be the height of the scale
    9. fit: function() {},
    10. // Draws the scale onto the canvas. this.(left|right|top|bottom) will have been populated to tell you the area on the canvas to draw in
    11. // @param chartArea : an object containing four properties: left, right, top, bottom. This is the rectangle that lines, bars, etc will be drawn in. It may be used, for example, to draw grid lines.
    12. draw: function(chartArea) {}