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

相关内容

热门资讯

随着!pokemmo脚本辅助下... 随着!pokemmo脚本辅助下载,微信小程序透视挂,一贯存在有辅助工具(哔哩哔哩)pokemmo脚本...
推出新举措!约局吧辅助器,潮友... 推出新举措!约局吧辅助器,潮友会鱼虾蟹破解,都是真的是有辅助技巧(哔哩哔哩)进入游戏-大厅左侧-新手...
受玩家影响!拱趴大菠萝有挂吗,... 您好,拱趴大菠萝有挂吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩...
近期!约局吧德州真的有透视挂吗... 近期!约局吧德州真的有透视挂吗,微信微乐小程序修改器,其实真的有辅助教程(哔哩哔哩)1、全新机制【约...
目前!wepoker私人定制透... 目前!wepoker私人定制透视,pokeplus脚本,竟然是真的有辅助工具(哔哩哔哩)1、poke...
长期以来!we poker免费... 长期以来!we poker免费辅助器,新玉海楼茶苑脚本,切实真的有辅助教程(哔哩哔哩)1、起透看视 ...
今天下午!hhpoker有没有... 今天下午!hhpoker有没有辅助,随意玩5元流量包,好像存在有辅助工具(哔哩哔哩)1、不需要AI权...
据权威媒体报道!wepoker... 据权威媒体报道!wepoker有透视功能吗,天酷辅助器,竟然是真的有辅助技巧(哔哩哔哩)1)天酷辅助...
值得注意的是!德普之星私人局辅... 值得注意的是!德普之星私人局辅助免费,赣牌圈破解器,其实有辅助攻略(哔哩哔哩)1)德普之星私人局辅助...
受玩家影响!hhpoker真能... 受玩家影响!hhpoker真能买到挂吗,潮汕来物局游戏源码,一直是真的有辅助脚本(哔哩哔哩)潮汕来物...