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辅... 刚刚!wepokerplus辅助,德扑之星私人局辅助器,总是真的有挂(确实有挂)1、任何德扑之星私人...
玩家必备攻略!陕西三代二破解,... 玩家必备攻略!陕西三代二破解,微信小程序中至上饶510k辅助器,详细器(确实有挂)一、微信小程序中至...
黑科技攻略!wepoker私人... 黑科技攻略!wepoker私人局怎么玩,德扑之星私人局辅助器,原来是有挂(有挂方式)小薇(辅助器软件...
实测发现!微友助手破解版,广东... 实测发现!微友助手破解版,广东雀神挂机怎么样,详细脚本(有挂技术)在进入广东雀神挂机怎么样软件靠谱后...
据悉!拱趴大菠萝挂,德普之星透... 据悉!拱趴大菠萝挂,德普之星透视辅助软件下载,竟然是有挂(真是有挂)德普之星透视辅助软件下载能透视中...
玩家必备教程!关春天凑一桌辅助... 玩家必备教程!关春天凑一桌辅助,山西扣点点挂手机挂,详细插件(有挂方略)山西扣点点挂手机挂辅助器是一...
现有关情况通报如下!wejok... 现有关情况通报如下!wejoker手机版透视脚本,德普之星透视辅助,确实是真的有挂(有挂技巧)1)德...
最新技巧!九游辅助工具,微信小... 最新技巧!九游辅助工具,微信小程序雀神广东智能辅助,详细技巧(确实有挂)暗藏猫腻,小编详细说明微信小...
2026版攻略!wepoker... 2026版攻略!wepoker辅助器免费,德普之星透视辅助软件是真的吗,其实存在有挂(有挂技术)1、...
科技通报!吉祥填大坑有什么诀窍... 科技通报!吉祥填大坑有什么诀窍,天天微友辅助,详细器(有挂解密)吉祥填大坑有什么诀窍破解侠是真的助透...