score:0

there is not problem with option for x-axis.

i bet there is a problem with dataset.

dataset of x and y should be specified.

following snippet will help you.

var ctx2 = document.getelementbyid("mychart2");
      var mychart = new chart(ctx2, {
        type: "bar",
        data: {
          datasets: [
            {
              label: "us dates",
              data: [
                {
                  x: "04/01/2014",
                  y: 175,
                },
                {
                  x: "10/01/2014",
                  y: 175,
                },
                {
                  x: "04/01/2015",
                  y: 178,
                },
                {
                  x: "10/01/2015",
                  y: 178,
                },
              ],
              backgroundcolor: "rgba(255, 99, 132, 0.2)",
              bordercolor: "rgba(255, 99, 132, 1)",
              borderwidth: 2,
            },
            {
              label: "uk dates",
              data: [
                {
                  x: "04/01/2014",
                  y: 143,
                },
                {
                  x: "10/1/2014",
                  y: 175,
                },
                {
                  x: "04/01/2015",
                  y: 165,
                },
                {
                  x: "10/1/2015",
                  y: 178,
                },
              ],
              backgroundcolor: "rgba(99, 255, 132, 0.2)",
              bordercolor: "rgba(99, 255, 132, 1)",
              borderwidth: 2,
            },
          ],
        },
        options: {
          responsive: true,
          title: {
            display: true,
            text: "chart.js time scale",
          },
          scales: {
            xaxes: [
              {
                type: "time",
                position: "bottom",
                time: {
                  displayformats: { day: "mm/yy" },
                  tooltipformat: "dd/mm/yy",
                  unit: "month",
                },
              },
            ],
            yaxes: [
              {
                scalelabel: {
                  display: true,
                  labelstring: "value",
                },
              },
            ],
          },
        },
      });

Related Query

More Query from same tag