如何更改ng2-chart中的x轴标签

时间:2019-08-28 01:39:45

标签: angular angular6 ng2-charts

我正在使用ng2-charts开发Angular 6项目。但是,我想将x轴标签从[0 ... 60,70]更改为[0%... 80%,90%,100%] < / p>

这是chart.component.html文件的一部分,我在其中描述图表选项:

    <div style="display: block">
        <canvas baseChart
            [chartType]="chartType"
            [datasets]="chartDatasets"
            [labels]="chartLabels"
            [colors]="chartColors"
            [options]="chartOptions"
            [legend]="true"
            (chartHover)="chartHovered($event)"
            (chartClick)="chartClicked($event)">
        </canvas>
      </div>

这是chart.component.ts文件的一部分:

    public chartType: string = 'horizontalBar';

  public chartDatasets: Array<any> = [
    { data: [this.cok_iyi,this.iyi,this.orta,this.gelistirilmeli,this.diger] ,label: 'Cevaplar'}
  ];

  public chartLabels: Array<any> = ['Çok iyi(4)', 'İyi(3)', 'Orta(2)', 'Geliştirilmeli(1)', 'Bu konuda olumlu...'];

  public chartColors: Array<any> = [
    {
      backgroundColor: [
        'rgba(94, 140, 63, 1)',
        'rgba(59, 94, 125, 1)',
        'rgba(255, 206, 86, 1)',
        'rgba(71, 172, 173, 1)',
        'rgba(153, 102, 255, 1)',
        ],
      borderColor: [
        'rgba(94, 140, 63,1)',
        'rgba(59, 94, 125, 1)',
        'rgba(255, 206, 86, 1)',
        'rgba(71, 172, 173, 1)',
        'rgba(153, 102, 255, 1)',
        ],
      borderWidth: 2,
    }
  ];

  public chartOptions: any = {
    responsive: true
  };
  public chartClicked(e: any): void { }
  public chartHovered(e: any): void { }

我想将x轴标签从[0,...,60,70]更改为[0%,...,80%,90%,100%]

0 个答案:

没有答案