Angular使用PrimeNGCharJS时字体颜色问题的解决方法。
创始人
2024-10-29 13:00:44
0

解决这个问题的方法是使用CharJS的配置选项来更改字体颜色。下面是一个示例组件,它通过设置“options”属性来更改图表的字体颜色:

import { Component } from '@angular/core';
import { ChartDataSets, ChartType, ChartOptions } from 'chart.js';
import { Color, Label } from 'ng2-charts';

@Component({
  selector: 'app-chart',
  templateUrl: './chart.component.html',
  styleUrls: ['./chart.component.css']
})
export class ChartComponent {
  public lineChartData: ChartDataSets[] = [
    { data: [85, 72, 78, 75, 77, 75], label: 'Series A' }
  ];
  public lineChartLabels: Label[] = ['January', 'February', 'March', 'April', 'May', 'June'];
  public lineChartOptions: (ChartOptions & { annotation: any }) = {
    responsive: true,
    scales: {
      xAxes: [{
        ticks: {
          fontColor: 'red',
        },
      }],
      yAxes: [{
        ticks: {
          fontColor: 'blue',
        },
      }]
    },
    annotation: {
      annotations: [
        {
          type: 'line',
          mode: 'vertical',
          scaleID: 'x-axis-0',
          value: 'March',
          borderColor: 'orange',
          borderWidth: 2,
          label: {
            enabled: true,
            fontColor: 'green',
            content: 'LineAnno'
          }
        },
      ],
    },
  };
  public lineChartColors: Color[] = [
    {
      borderColor: 'black',
      backgroundColor: 'rgba(255,255,0,0.28)',
    },
  ];
  public lineChartLegend = true;
  public lineChartType: ChartType = 'line';
  public lineChartPlugins = [];
}

在这个示例中,我们更改了 X 轴和 Y 轴上的字体颜色。我们还使用“annotation”选项来添加一个基线,并更改对应的标签字体颜色。

相关内容

热门资讯

开挂透视!werplan外卦神... 开挂透视!werplan外卦神器,微乐小程序自建房辅助器下载,方针教程(有挂详细)-哔哩哔哩1、we...
辅助透视!wepoker底牌透... 辅助透视!wepoker底牌透视,微信小程序微乐辅助,妙招教程(有挂秘籍)-哔哩哔哩亲,关键说明,w...
有挂透视!红龙poker辅助器... 有挂透视!红龙poker辅助器免费观看,微乐小程序辅助免费,诀窍教程(确实有挂)-哔哩哔哩1、这是跨...
普及透视!拱趴大菠萝挂,手机微... 普及透视!拱趴大菠萝挂,手机微乐小程序自建房透视免费,攻略教程(果真有挂)-哔哩哔哩1、普及透视!拱...
必备透视!wepoker怎么看... 必备透视!wepoker怎么看底牌,微乐贵阳捉鸡麻将辅助,练习教程(今日头条)-哔哩哔哩1、很好的工...
开挂透视!wepoker破解游... 开挂透视!wepoker破解游戏盒子,微乐江西小程序辅助器,窍要教程(有挂详情)-哔哩哔哩1、wep...
详细透视!wepoker的辅助... 详细透视!wepoker的辅助器,微信小程序微乐内蒙破解器,指引教程(有挂教程)-哔哩哔哩1、下载好...
关于透视!sohoo竞技联盟辅... 关于透视!sohoo竞技联盟辅助器,微信小程序微乐安徽辅助器,课程教程(有挂技巧)-哔哩哔哩1、完成...
了解透视!hhpoker哪个俱... 了解透视!hhpoker哪个俱乐部靠谱,微乐麻辣自建房辅助视频,技法教程(有挂方略)-哔哩哔哩1、首...
详情透视!拱趴大菠萝万能辅助器... 详情透视!拱趴大菠萝万能辅助器,微乐小程序怎么挂脚本,绝活教程(有挂透明挂)-哔哩哔哩1、让任何用户...