[Chartjs]-How can I hide tick marks on Chart.js?

2πŸ‘

βœ…

It’s easier to do this by clearing out the tick marks after they have been drawn. You can do this by extending the chart.


Preview

enter image description here


Script

Chart.types.Line.extend({
    name: "LineAlt",
    initialize: function () {
        Chart.types.Line.prototype.initialize.apply(this, arguments);

        var scale = this.scale;
        var originalDraw = scale.draw;
        scale.draw = function () {
            originalDraw.apply(this, arguments);
            ctx.clearRect(scale.calculateX(0), scale.endPoint, scale.width, 5);
            ctx.clearRect(scale.calculateX(0), scale.endPoint + 1, -5, -scale.height);
        }
    }
});

and then

...
new Chart(ctx).LineAlt(data);

Fiddle – http://jsfiddle.net/m9k5goaL/

Leave a comment