Search code examples
javascriptdojodojox.charting

dojox/charting/Chart2D : how to format the label of minor tick?


I am using dojo Chart2D to plot a graph having milliseconds values along the X axis. To display the minor tick values I want to convert the milliseconds value to hh:mm:ss:msec format. I can do it easily overriding tickFormat() method in D3. But I am stuck here with Chart2D.


Solution

  • While adding the axis to the chart, we can use the attribute "labelFunc" which should be function taking 3 arguments:

    1) text is the already pre-formatted text. Pre-formatting is done using dojo/number is available, Date.toFixed otherwise.

    2) value is the raw axis value.

    3) precision is the requested precision to be applied. and returns the label. eg:

    chart.addAxis("x", {
        ...,
        labelFunc: function(text, value, precision) {
            return "axisLabel";
        }
    });