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”选项来添加一个基线,并更改对应的标签字体颜色。

相关内容

热门资讯

必备教程"微信小程序... 必备教程"微信小程序多功能修改器"开挂(透视)wepokerplus脚本(有挂存在);亲真的是有正版...
普及知识"werpl... 普及知识"werplan开挂"开挂(透视)德普之星的辅助工具介绍(有挂方法);1、让任何用户在无需A...
每日必看推荐"赣牌圈... 每日必看推荐"赣牌圈小程序德隐藏机制"开挂(透视)wepoker提高好牌率(有挂攻略);超受欢迎的稳...
每日必看教程"新星游... 每日必看教程"新星游辅助软件"开挂(透视)hhpoker可以控制吗(有挂秘笈);AI辅助机器人普及解...
透视安装"广东雀神智... 透视安装"广东雀神智能插件智能价格"开挂(透视)pokemomo辅助软件(真的有挂);1、超多福利:...
记者爆料"相约十三张... 记者爆料"相约十三张辅助"开挂(透视)wepoker怎么挂飞机(有挂分析);相信小伙伴都知道这个相约...
教程攻略"拱趴大菠萝... 教程攻略"拱趴大菠萝怎么开挂"开挂(透视)agpoker辅助(真实有挂);软件透视开挂更新新赛季,主...
透视线上"微乐自建房... 透视线上"微乐自建房脚本使用安全吗"开挂(透视)hhpoker透视脚本(今日头条);人气非常高,ai...
今日百科"山西扣点有... 今日百科"山西扣点有没有辅助器"开挂(透视)werplan怎么作弊(有挂猫腻);1、很好的工具软件,...
推荐一款"丰城双剑辅... 推荐一款"丰城双剑辅助"开挂(透视)wpk软件是真的吗(有挂技巧);亲真的是有正版授权,小编(透视辅...