Angularng2-charts混合图表x轴问题
创始人
2024-10-28 16:30:18
0

在使用ng2-charts库创建混合图表时,可能会遇到x轴标签显示不完整的问题。一种解决方法是使用自定义x轴刻度标签,并将其传递给混合图表组件。

例如,可以在组件类中定义一个自定义刻度数组,以便在HTML模板文件中引用。

import { Component } from '@angular/core';
import { ChartDataSets, ChartOptions, ChartType } from 'chart.js';
import { Label } from 'ng2-charts';

@Component({
  selector: 'app-mixed-chart',
  template: `
    
` }) export class MixedChartComponent { public barLineData: ChartDataSets[]; public barLineLabels: Label[]; public barLineType: ChartType; public barLineOptions: ChartOptions; constructor() { this.barLineType = 'bar'; this.barLineData = [ { data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A', type: 'line', fill: false }, { data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B', type: 'bar' } ]; this.barLineLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July']; this.barLineOptions = { responsive: true, scales: { xAxes: [{ ticks: { autoSkip: false } }] } }; } }

在上述例子中,我们使用自定义x轴刻度标签,并将"autoSkip"设置为false,以便所有标签都会显示。

this.barLineLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];

this.barLineOptions = {
  responsive: true,
  scales: {
    xAxes: [{
      ticks: {
        autoSkip: false
      }
    }]
  }
};

相关内容

热门资讯

技巧辅助挂!hhpoker免费... 技巧辅助挂!hhpoker免费透视脚本,wepoker手机版透视脚本,手段教程(有挂详情)1、wep...
近年来!拱趴大菠萝十三水作弊,... 近年来!拱趴大菠萝十三水作弊,拱趴大菠萝万能挂图解,法门教程(存在有挂)1、拱趴大菠萝十三水作弊辅助...
黑科技技巧!we poker辅... 黑科技技巧!we poker辅助器v3.3,wepoker网页版透视方法,法子教程(有挂教学)在进入...
受玩家影响!wepoker开脚... 受玩家影响!wepoker开脚本视频,hhpoker辅助,妙计教程(揭秘有挂)1、很好的工具软件,可...
方法辅助挂!菠萝德州透视脚本,... 方法辅助挂!菠萝德州透视脚本,hhpoker是真的还是假的,窍要教程(有挂技巧)一、hhpoker是...
做出回应!wepoker辅助器... 做出回应!wepoker辅助器官方,wepoker脚本下载,模块教程(揭秘有挂)wepoker辅助器...
日前!菠萝辅助器免费版的特点,... 日前!菠萝辅助器免费版的特点,红龙poker辅助器免费观看,练习教程(有挂透视)1、全新机制【菠萝辅...
黑科技技巧!wepokerpl... 黑科技技巧!wepokerplus外挂,wepoker辅助软件视频,步骤教程(有挂规律)1、这是跨平...
在玩家背景下!wepoker一... 在玩家背景下!wepoker一直输的号能继续打吗,wepoker祈福有用吗,资料教程(发现有挂)在玩...
黑科技教程!wepoker有辅... 黑科技教程!wepoker有辅助吗,wepokerh5破解,项目教程(有挂规律)亲,关键说明,wep...