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
      }
    }]
  }
};

相关内容

热门资讯

透视工具"xpoke... 透视工具"xpoker辅助怎么用"详细辅助力荐教程(有用技巧)是一款可以让一直输的玩家,快速成为一个...
每日必看推荐!wepoker透... 每日必看推荐!wepoker透视辅助下载,wepoker游戏的安装教程,揭秘教程(有挂技巧);实战中...
透视好友"hhpok... 透视好友"hhpoker软件可以玩吗"详细辅助插件教程(破解版内购技巧);支持2-10人实时对战,虚...
一分钟揭秘!wepoker有辅... 一分钟揭秘!wepoker有辅助插件吗,wepoker辅助器最新版本更新内容,安装教程(有挂技巧);...
透视黑科技"clou... 这是一款非常优秀的cloudpoker外挂 ia辅助检测软件,能够让你了解到cloudpoker外挂...
透视软件!红龙poker透视工... 透视软件!红龙poker透视工具,we-poker靠谱吗,可靠技巧(有挂解说)亲,关键说明,红龙po...
透视真的"wpk透视... 透视真的"wpk透视工作室"详细辅助辅助教程(透视脚本下载技巧);支持多人共享记分板与复盘,通过邀请...
透视真的!hhpoker透视脚... 透视真的!hhpoker透视脚本,悦扑克脚本,必赢方法(有挂技巧);1、不需要AI权限,帮助你快速的...
透视黑科技"wepo... 透视黑科技"wepoker怎么看底牌"详细辅助透明挂教程(免费脚本方法)是一款可以让一直输的玩家,快...
透视了解!hhpoker辅助软... 透视了解!hhpoker辅助软件下载,约局吧德州可以透视吗,科技教程(有挂脚本)1、该软件可以轻松地...