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

相关内容

热门资讯

透视资料!aapoker透视方... 透视资料!aapoker透视方法,aapoker辅助工具安全吗(透视)原来是有脚本器(哔哩哔哩)1、...
透视课程!wepoker黑侠辅... 透视课程!wepoker黑侠辅助器正版下载,wepoker私人局俱乐部怎么进(透视)原来是真的挂(哔...
透视要领!aapoker脚本,... 透视要领!aapoker脚本,aapoker如何设置胜率(透视)切实是真的透视脚本(哔哩哔哩)aap...
透视举措!菠萝德普辅助器免费版... 透视举措!菠萝德普辅助器免费版在哪里,拱趴大菠萝挂哪里(透视)原来真的有挂(哔哩哔哩)1、菠萝德普辅...
透视资料!wpk模拟器是什么,... 透视资料!wpk模拟器是什么,wpk辅助是什么(透视)本来真的有脚本教程(哔哩哔哩)进入游戏-大厅左...
透视经验!werplan免费挂... 透视经验!werplan免费挂下载,poker world辅助器(透视)总是存在有挂(哔哩哔哩)1、...
透视妙计!wpk可以作必弊吗,... 透视妙计!wpk可以作必弊吗,wpk模拟器(透视)本来有透视器(哔哩哔哩)1、每一步都需要思考,不同...
透视步骤!wepoker怎么破... 透视步骤!wepoker怎么破解游戏,德扑之心免费透视(透视)真是存在有挂(哔哩哔哩)wepoker...
透视积累!wepoker透视方... 透视积累!wepoker透视方法,wepoker挂(透视)好像真的有脚本器(哔哩哔哩)1、起透看视 ...
透视练习!拱趴大菠萝万能挂,拱... 透视练习!拱趴大菠萝万能挂,拱趴大菠萝作必弊方法(透视)总是是真的挂(哔哩哔哩)拱趴大菠萝作必弊方法...