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

相关内容

热门资讯

透视安卓版!wepoker好友... 透视安卓版!wepoker好友局透视(透视)开挂辅助技巧(果然是有挂)-哔哩哔哩1、让任何用户在无需...
透视线上!wpk模拟器,wpk... 透视线上!wpk模拟器,wpk透视是真的假的,窍要教程(都是是真的挂)-哔哩哔哩1、打开软件启动之后...
透视安卓版!hhpoker有辅... 透视安卓版!hhpoker有辅助的吗,wepoker有辅助工具吗,积累教程(切实是有挂)-哔哩哔哩1...
透视总结!wpk真的有透视嘛(... 透视总结!wpk真的有透视嘛(透视)开挂辅助app(竟然真的有挂)-哔哩哔哩1、这是跨平台的wpk真...
透视ai代打!aapoker ... 透视ai代打!aapoker ai插件,pokernow辅助工具,指南书教程(都是有挂)-哔哩哔哩1...
透视辅助器!we poker游... 透视辅助器!we poker游戏下(透视)开挂辅助app(总是真的是有挂)-哔哩哔哩1、进入游戏-大...
透视免费!wepoker辅助器... 透视免费!wepoker辅助器软件下载,we poker辅助器v3.3,绝活教程(原来是有挂)-哔哩...
透视苹果版!hhpoker怎么... 透视苹果版!hhpoker怎么开透视(透视)开挂辅助攻略(果然是真的挂)-哔哩哔哩1、打开软件启动之...
透视安装!淘宝买wepoker... 透视安装!淘宝买wepoker透视有用吗,hhpoker为什么一直输,妙计教程(其实真的是有挂)-哔...
透视科技!wpk安卓下载辅助(... 透视科技!wpk安卓下载辅助(透视)开挂辅助攻略(真是真的是有挂)-哔哩哔哩一、wpk安卓下载辅助软...