[Chartjs]-Chart js Labels and Grouping labels

4👍

This is referenced here:
https://github.com/chartjs/Chart.js/issues/2138

The bulk of it is creating a 2nd axis. I’ve omitted some of the setup here but you can find a JS Fiddle below:

    options: {
        scales: {
            xAxes:[ {
                id: 'time',
                type: 'category',
                ticks: {
                    callback: function(label) {
                        var labelArray = label.split("|");
                        return  labelArray[0] + "/" + labelArray[1];
                    }
                }
            },
            {
                id: 'partGroup',
                type: 'category',
                gridLines: {
                    drawOnChartArea: false // only want the grid lines for one axis to show up
                },
                ticks: {
                    callback: function(label) {
                        var labelArray = label.split("|");
                        return labelArray[0] === "10" && labelArray[1] == "2015" ?      labelArray[2] : "";
                    }
                }

            }


             ]
        }
    }

Here’s a Fiddle with your data

Leave a comment