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

相关内容

热门资讯

WPK有透视指南!aapoke... WPK有透视指南!aapoker辅助插件工具,德州微扑克其实存在有透视挂攻略1、进入到aapoker...
WPK安卓学习!wpk辅助工具... WPK安卓学习!wpk辅助工具,德州微扑克真是真的有辅助攻略WPK安卓学习!wpk辅助工具,德州微扑...
WPK作弊学习!wejoker... 您好,wejoker辅助脚本这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】...
WPK有透视指南!黑侠破解we... WPK有透视指南!黑侠破解wepoker,德州微扑克真是存在有透视挂攻略1、点击下载安装,黑侠破解w...
WPK靠谱经验!wepoker... WPK靠谱经验!wepoker开脚本视频,德州微扑克果然真的有透视攻略1、不需要AI权限,帮助你快速...
WPK脚本攻略!wepoker... WPK脚本攻略!wepoker有辅助工具吗,德州微扑克切实存在有开挂技巧wepoker有辅助工具吗透...
WPK靠谱学习!wepoker... WPK靠谱学习!wepoker脚本下载,德州微扑克其实有透视挂工具在进入wepoker脚本下载软件靠...
WPK官网绝活!wepoker... WPK官网绝活!wepoker作弊辅助,德州微扑克本来是有开挂appWPK官网绝活!wepoker作...
WPK俱乐部模板!wepoke... WPK俱乐部模板!wepoker透视脚本是什么,德州微扑克其实真的是有透视技巧1、wepoker透视...
WPK透视版模板!wepoke... WPK透视版模板!wepoker买脚本靠谱吗,德州微扑克切实真的有辅助器插件1、点击下载安装,wep...