score:2

Accepted answer

you can define the layout with negative left padding as follows:

options: {
    layout: {
      padding: {
        left: -10
      }
    },
    ...

please have a look at the following code snippet where the chart canvas is defined with a border in order to emphasize the alignment with the preceding text.

var mychart = new chart(document.getelementbyid('mychart'), {
  type: 'horizontalbar',
  data: {
    labels: ['1', '2'],
    datasets: [{
      label: 'money in',
      data: [5, 19],
      backgroundcolor: ['rgb(0,51,160)', 'rgb(26,121,191)'],
      borderwidth: 0
    }]
  },
  options: {
    layout: {
      padding: {
        left: -10
      }
    },
    scales: {
      yaxes: [{
        ticks: {
          fontcolor: 'white',
          mirror: true,
          beginatzero: true,
          fontsize: 17,
          padding: -9,
          z: 1
        },
        gridlines: {
          display: false
        }
      }],
      xaxes: [{
        gridlines: {
          display: false
        },
        ticks: {          
          beginatzero: true,
          display: false
        }
      }]
    },
    legend: {
      display: false
    }
  }
});
canvas{ 
  max-width: 300px;
  border: 1px solid #000;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.9.3/chart.bundle.js"></script> 
<p>text here</p>
<canvas id="mychart" width="400" height="150"></canvas>


Related Query

More Query from same tag