Chartjs-Implementing horizontal bar chart

0👍

Inside the renderChart method of your bar-chart component, the chart is currently created as follows:

this.bar_chart = new Chart(this.dataCtx, {
  type: 'bar',
  ...

This will always create a vertical bar chart. It should be rewritten as follows in order to consider the type provided by the @Input() decorator.

this.bar_chart = new Chart(this.dataCtx, {
  type: this.type,
  ...

Probably this.bar_chart is then no longer an appropriate name and should be amended to avoid future misunderstandings.

Leave a comment