Update Stockchart yAxis Labels Changes Positions and Label Precision

107 views Asked by At

I am working on a stock chart that is using compare: 'percent' or 'value' or 'none'. The user can toggle these settings. That works except trying to update the yAxis labels such that the "%" character is not appended. I can remove this by doing:

chart.yAxis[0].update({
    labels: {
        formatter: function () {
            return this.value;
        }
    }
});

However the position and precision of the yAxis label is then altered. It is no longer just above its tick mark - it is now more towards the right of the plot area. The values prior were to two decimal places and now they are to three decimal places. The numeric format I can deal with but I am unable to move the position of the label to its initial state of just above the tick mark inside the plot area.

I just want to remove the suffix but keep the other options the same.

Representative fiddle.

1

There are 1 answers

0
Paweł Fus On BEST ANSWER

Looks like default options are lost when updating axis. Simple workaround: http://jsfiddle.net/33cu0o9c/3/

    chart.yAxis[0].update({
        labels: {
            align: "right",
            x: 0,
            formatter: function () {
                return this.value;
            }
        }
    });

And bug is reported here.