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. A default config for the scale may be provided when registering the constructor. The first parameter to the register function is a string key that is used later to identify which scale type to use for a chart.

    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. margins: {
    10. right: Number,
    11. bottom: Number,
    12. },
    13. // Amount of padding on the inside of the bounding box (like CSS)
    14. paddingLeft: Number,
    15. paddingRight: Number,
    16. paddingTop: Number,
    17. paddingBottom: Number,
    18. }

    Scale Interface

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

    1. // Transform the ticks array of the scale instance into strings. The default implementation simply calls this.options.ticks.callback(numericalTick, index, ticks);
    2. convertTicksToLabels: function() {},
    3. // Determine how much the labels will rotate by. The default implementation will only rotate labels if the scale is horizontal.
    4. calculateTickRotation: function() {},
    5. // Fits the scale into the canvas.
    6. // 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.
    7. // 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
    8. // You must set this.minSize to be the size of your scale. It must be an object containing 2 properties: width and height.
    9. // You must set this.width to be the width and this.height to be the height of the scale
    10. fit: function() {},
    11. // 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
    12. // @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.