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

相关内容

热门资讯

一分钟了解!红龙poker辅助... 一分钟了解!红龙poker辅助(辅助挂)确实是有挂(有挂方针)1、红龙poker辅助公共底牌简单,红...
技术分享!德普之星私人局辅助免... 技术分享!德普之星私人局辅助免费(辅助挂)切实是有挂(有挂神器)1、该软件可以轻松地帮助玩家将德普之...
一分钟教你!wepoker轻量... 一分钟教你!wepoker轻量版有透视吗(辅助挂)一贯是有挂(真的有挂)1、首先打开wepoker轻...
推荐一款!wepoker免费脚... 推荐一款!wepoker免费脚本咨询(辅助挂)本来有挂(今日头条)wepoker免费脚本咨询透视方法...
每日必备!wepokerplu... 每日必备!wepokerplus到底是挂了吗(辅助挂)好像真的有挂(有挂秘笈)1、游戏颠覆性的策略玩...
玩家必知教程!wpk有那种辅助... 玩家必知教程!wpk有那种辅助吗(辅助挂)本来存在有挂(有挂辅助)1、每一步都需要思考,不同水平的挑...
分享实测!wepoker网页版... 分享实测!wepoker网页版透视方法(辅助挂)都是真的有挂(有挂分析)1、wepoker网页版透视...
玩家实测!wpk插件辅助(辅助... 玩家实测!wpk插件辅助(辅助挂)总是是真的有挂(有挂技巧)1)wpk插件辅助有没有挂:进一步探索w...
查到实测!wepoker怎么看... 查到实测!wepoker怎么看牌型(辅助挂)真是是真的有挂(有挂总结)wepoker怎么看牌型脚本下...
一分钟教你!xpoker怎么作... 一分钟教你!xpoker怎么作弊(辅助挂)总是有挂(有挂方略)xpoker怎么作弊脚本下载中分为三种...