【问题标题】:How to create chart.js vertical bar chat with rounded corners in angular 6?如何在角度 6 中创建带有圆角的 chart.js 垂直条形图?
【发布时间】:2018-09-08 09:32:00
【问题描述】:

我使用 angular 6 并且有一个垂直条形图。我想让酒吧的角落变圆!我该怎么做?

这里是部分代码:

.ts

ngAfterViewInit() {

    this.canvas = document.getElementById('barChart');
    this.ctx = this.canvas.getContext('2d');
    let myChart = new Chart(this.ctx, {
      type: 'bar',
      data: {
        labels: this.my_labels,
        datasets: [
          {
            label: '',
            fill: false,
            backgroundColor: [
              '#2699fb',
              '#2699fb',
              '#2699fb',
            ],
            borderWidth: 1,
            data: [12000, 18000, 65000],
          }
        ]
      },
      options: {
        responsive: false,
        legend: {
          display: false
        }
      }
    });
}

【问题讨论】:

标签: javascript typescript chart.js bar-chart angular6


【解决方案1】:

您可以安装 chartjs-top-round-bar。执行以下步骤:-

1. Install the plugin - npm i chartjs-top-round-bar.

2. Import in TS - import 'chartjs-top-round-bar';.

3. Add in the option while creating Chart -


           let myChart = new Chart(this.ctx, { 
                                   type: 'roundedBar', 
                                   data: { 
                                           labels: ['label 1'], 
                                           datasets: [{label: 'Label 1', data}]
                                   }, 
                                   options: { 
                                             barRoundness: 0.3
                                   }
                          }

我希望这会有所帮助。

【讨论】:

  • 您面临什么问题?这似乎对我有用。
猜你喜欢
  • 2015-10-13
  • 1970-01-01
  • 2018-05-04
  • 1970-01-01
  • 2020-08-17
  • 1970-01-01
  • 2016-08-06
  • 2020-02-13
  • 1970-01-01
相关资源
最近更新 更多