Chart.js: Enable tick mirror option for X axes

Created on 12 Jul 2017  路  1Comment  路  Source: chartjs/Chart.js

First of all

Thanks for a GREAT library. Having a lot of fun using this. Thanks for everyones effort.

Issue

When I set the xAxis tick configuration to be mirror: true I don't see the ticks mirrored. I think my config is correct but I'm a newbie here so hopefully I haven't committed a school boy error!

Codepen reduction

https://codepen.io/benfrain/pen/xrmzdE

Config used

var drawChart = function() {
  var ctx = document.getElementById("chtChart").getContext("2d");
  myChart = new Chart(ctx, {
    type: "line",
    data: {
      labels: ["6", "5", "4", "3", "2", "Yesterday", "Today"],

      datasets: [
        {
          label: "metric",
          data: [3, 2, 6, 5, 3, 4, 8],
          backgroundColor: "rgba(74, 207, 165, 0.1)",
          borderColor: "rgb(74, 207, 165)",
          borderWidth: 2,
          lineTension: 0,
          pointBackgroundColor: "rgb(74, 207, 165)",
          yAxisID: "y-axis-0",
        },
      ],
    },
    options: {
      layout: {
        padding: {
          left: -10,
          right: 0,
          top: 10,
          bottom: 10,
        },
      },
      scales: {
        yAxes: [
          {
            ticks: {
              beginAtZero: false,
              mirror: true,
            },
            gridLines: {
              display: true,
              borderDash: [4, 4],
              color: "rgba(64,64,64,100)",
            },
          },
        ],
        xAxes: [
          {
            display: true,
            gridLines: {
              display: false,
            },
            ticks: {
              beginAtZero: true,
              mirror: true,
            },
          },
        ],
      },
      legend: {
        display: false,
      },
    },
  });
};

drawChart();

Expected

With that config I was expecting the xAxis to display inside the chart area

Current Behaviour

The tick are displaying outside the chart area

Context

Chrome or Safari
Chartjs v2.6.0

help wanted enhancement

Most helpful comment

I think at the moment on vertical axes support mirroring. Should not be hard to implement for horizontal axes as well.

>All comments

I think at the moment on vertical axes support mirroring. Should not be hard to implement for horizontal axes as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JAIOMP picture JAIOMP  路  3Comments

HeinPauwelyn picture HeinPauwelyn  路  3Comments

SylarRuby picture SylarRuby  路  3Comments

adriantombu picture adriantombu  路  3Comments

bytesnz picture bytesnz  路  3Comments