无法在 Syncfusion 图表中使用日期分组标签

问题描述 投票:0回答:1

我正在尝试创建一个像这样的图表,需要对日期范围进行分组标签。

我尝试过使用多级标签,但我无法自定义其设计以使其看起来符合要求。对我来说,理想的解决方案是找到一种对主要 x 轴标签进行分组的方法,而不是使用多级标签。任何人请帮助我。这是我的代码:

      SizedBox(
      height: 30.h,
      child: SfCartesianChart(
        onAxisLabelTapped: ((axisLabelTapArgs) => print(axisLabelTapArgs.value)),
        plotAreaBorderWidth: 0,
        primaryYAxis: ChartHelper.buildNumericYAxis(textTheme),
        primaryXAxis: ChartHelper.buildDateTimeXAxis(),
        enableAxisAnimation: true,
        zoomPanBehavior: ChartHelper.buildZoomPanBehavior(),
        series: <ChartSeries>[
          if (provider.showPainCurve) ChartHelper.buildPainCurve(),
          if (provider.showBleedingCurve) ChartHelper.buildBleedingCurve(),
        ],
      ),
    ),

      static DateTimeAxis buildDateTimeXAxis() {
return DateTimeAxis(

  axisLine: const AxisLine(width: 0),
  labelIntersectAction: AxisLabelIntersectAction.hide,
  enableAutoIntervalOnZooming: false,
  interval: 1,
  autoScrollingMode: AutoScrollingMode.end,
  isVisible: true,
  autoScrollingDelta: 20,
  autoScrollingDeltaType: DateTimeIntervalType.days,
  majorGridLines: const MajorGridLines(
    width: 0.5,
    color: Color(0xFFFFDBCE),
  ),
  majorTickLines: const MajorTickLines(size: 0, width: 0),
  labelStyle: const TextStyle(height: 0, color: Colors.transparent),
);

}

flutter syncfusion syncfusion-chart
1个回答
0
投票

我们了解您需要根据查询对多个系列的 x 轴标签进行分组,目前没有选项使用 DateTimeAxis 对 x 轴标签进行分组。但是,您可以使用 Category Axis 中的 arrangeByIndex 属性对多个系列的 x 轴标签进行分组。 Category Axis是基于索引实现的,因此如果启用arrangeByIndex属性,多个系列的x轴标签将根据其索引分组在一起。

分享了下面有关类别轴中的arrangeByIndex的用户指南文档和示例浏览器链接,供您参考。

UG:https://help.syncfusion.com/flutter/cartesian-charts/axis-types#indexed-category-axis

SB:https://flutter.syncfusion.com/#/cartesian-charts/axis-types/category/arranged-by-index

如果您还有疑问,请回复我们。

问候,

哈里·哈拉·苏丹。 K.

© www.soinside.com 2019 - 2024. All rights reserved.