[Chartjs]-How to add second Y-axis for Bar and Line chart in Chart.js?

7👍

To show a Line Chart with two Y axis, @khertan made a pull request to add this feature >> https://github.com/nnnick/Chart.js/pull/1355

You can grab the modified Chart.js file here >> https://github.com/khertan/Chart.js/tree/9edcc71f97361bb45c8fe93d07acb1917c2b4807

You’ll only need to add the option to your options variable:

var options = {
    ...
    scaleUse2Y: true,
    ...
};

And then instantiate a normal Line chart:

var chart = new Chart(ctx).Line(data, options);

Problem is that if you’re using an extension like StackedBar, for example, it will probably break… That must be the reason why it hasn’t been merged with master’s branch of Chart.js yet. Patience for the 2.0 version release.

Leave a comment