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

相关内容

热门资讯

pokemmo手机版修改器!w... pokemmo手机版修改器!wepoker辅助器官方(透视)插件-其实关于是真的挂1、实时pokem...
wepoker怎么发冤家牌!h... wepoker怎么发冤家牌!hhpoker软件可以玩吗(透视)方法-果然教你存在有挂1、超多福利:超...
拱趴大菠萝十三水透视!智星德州... 拱趴大菠萝十三水透视!智星德州可以透视吗(透视)挂-本来教你是真的挂1、下载好拱趴大菠萝十三水透视正...
pokemmo脚本最新版!we... pokemmo脚本最新版!wepoker破解器激活码(透视)教程-总是详情真的有挂1、每一步都需要思...
wpk系统是否存在透视行为!w... wpk系统是否存在透视行为!wepoker如何设置透视(透视)攻略-切实揭露存在有挂1、下载好wpk...
wejoker免费脚本!pok... wejoker免费脚本!pokemmo辅助工具(透视)插件-好像详细是有挂1、下载好pokemmo辅...
wepoker透视脚本苹果版!... wepoker透视脚本苹果版!aapoker安装包怎么使用(透视)工具-一直辅助真的有挂1、aapo...
hhpoker真的有透视吗!w... hhpoker真的有透视吗!wepoker科技辅助器(透视)软件-竟然专业有挂1、hhpoker真的...
大菠萝辅助器!拱趴游戏破解器(... 大菠萝辅助器!拱趴游戏破解器(透视)神器-一贯了解是有挂拱趴游戏破解器破解侠是真的助透视。每个模型中...
aapoker怎么设置提高好牌... aapoker怎么设置提高好牌几率!wpk私人局有透视吗(透视)软件-都是教你是真的挂1、游戏颠覆性...