ApexCharts(柱状图)根据缩放级别对日期/柱状条进行分组或聚类。
创始人
2024-11-10 03:00:18
0

要根据缩放级别对日期/柱状条进行分组或聚类,您可以使用ApexCharts的grouping属性。

以下是一个示例代码,展示了如何使用ApexCharts实现该功能:

var options = {
  chart: {
    type: 'bar',
    height: 350,
    width: '100%',
  },
  series: [{
    name: 'Sales',
    data: [30, 40, 45, 50, 49, 60, 70, 91, 125]
  }],
  xaxis: {
    type: 'datetime',
    categories: ['2021-01-01', '2021-02-01', '2021-03-01', '2021-04-01', '2021-05-01', '2021-06-01', '2021-07-01', '2021-08-01', '2021-09-01'],
    labels: {
      datetimeFormatter: {
        year: 'yyyy',
        month: 'MMM \'yy',
        day: 'dd MMM',
      }
    }
  },
  plotOptions: {
    bar: {
      horizontal: false,
      columnWidth: '55%',
      endingShape: 'rounded'
    },
  },
  dataLabels: {
    enabled: false
  },
  stroke: {
    show: true,
    width: 2,
    colors: ['transparent']
  },
  fill: {
    opacity: 1
  },
  tooltip: {
    y: {
      formatter: function (val) {
        return "$" + val + " thousands"
      }
    }
  },
  grouping: {
    enabled: true,
    forced: true,
    groupBy: 'year', // 可以是 'year', 'month', 'day' 等
    groupDateTimeOffset: 0,
    groupIntervalFunc: undefined,
  }
}

var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();

在上面的代码中,我们首先定义了基本的ApexCharts配置,如图表类型、数据、x轴的日期格式等。然后,我们使用grouping属性启用了分组功能,并设置了分组的级别为年份(groupBy: 'year')。您可以根据需要将其更改为其他级别,如月份(groupBy: 'month')或天数(groupBy: 'day')等。

相关内容

热门资讯

玩家交流!wepoker有没有... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
解密关于!wepoker插件功... 解密关于!wepoker插件功能辅助器(辅助挂)本来有挂(详细教程辅助器)1、任何透视是真的假的的玩...
科技揭秘!wpk俱乐部辅助器(... 科技揭秘!wpk俱乐部辅助器(辅助挂)好像真的是有挂(发现有挂辅助工具)1、全新机制【ai辅助工具激...
热点推荐!fishpoker透... 热点推荐!fishpoker透视(辅助挂)一直是真的有挂(有人有挂辅助app)1、不需要AI权限,帮...
让我来分享经验!xpoker辅... 让我来分享经验!xpoker辅助器(辅助挂)原来是真的有挂(的确有挂辅助攻略)1、每一步都需要思考,...
一分钟揭秘!xpoker辅助神... 一分钟揭秘!xpoker辅助神器(辅助挂)好像真的有挂(有挂辅助辅助器)1、脚本辅助下载、免费透视脚...
必看攻略!pokemmo脚本辅... 必看攻略!pokemmo脚本辅助(辅助挂)切实是真的有挂(有挂技巧辅助软件)1、完成有辅助插件,帮助...
总算了解!hhpoker买挂(... 总算了解!hhpoker买挂(辅助挂)竟然存在有挂(有挂方法辅助工具)1、实时透视辅助更新:用户可以...
今日焦点!poker辅助器免费... 今日焦点!poker辅助器免费安装(辅助挂)一直真的是有挂(有挂教程辅助攻略)1、免费脚本咨询教程、...
重大通报!模拟器打开hhpok... 重大通报!模拟器打开hhpoker(辅助挂)真是存在有挂(详细教程辅助脚本)1、点击下载安装,脚本分...