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免费挂下载(透视)好像是真的辅助安装(有挂细节)-哔哩哔哩该软件可以轻松...
今日!wepoker模拟器哪个... 今日!wepoker模拟器哪个好用(透视)总是有辅助平台(有挂总结)-哔哩哔哩1、用户打开应用后不用...
透视脚本!pokemmo辅助官... 透视脚本!pokemmo辅助官网(透视)好像是真的辅助插件(真的有挂)-哔哩哔哩1、进入游戏-大厅左...
据监测!wepoker手机助手... 据监测!wepoker手机助手(透视)原来是真的辅助平台(有挂规律)-哔哩哔哩一、wepoker手机...
透视脚本!wpk可以作必弊吗(... 透视脚本!wpk可以作必弊吗(透视)一直真的有辅助神器(有挂秘笈)-哔哩哔哩透视脚本!wpk可以作必...
针对!如何判断wpk辅助软件的... 针对!如何判断wpk辅助软件的真假(透视)确实存在有辅助辅助器(有挂教程)-哔哩哔哩1、不需要AI权...
透视讲解!newpoker脚本... 透视讲解!newpoker脚本(透视)一贯是真的辅助平台(确实有挂)-哔哩哔哩1、进入到newpok...
今日!werplan怎么作必弊... 今日!werplan怎么作必弊(透视)确实存在有辅助神器(有挂规律)-哔哩哔哩进入游戏-大厅左侧-新...
这一现象值得深思!wepoke... 这一现象值得深思!wepoker辅助器安装包定制(透视)总是真的有辅助安装(有挂神器)-哔哩哔哩1、...
更值得关注的是!wepoker... 更值得关注的是!wepoker私人局辅助器怎么用(透视)本来有辅助软件(有人有挂)-哔哩哔哩1、we...