首页 > 解决方案 > chart_flutter:如何使用 Flutter Chart 做折线图重叠 y 轴标签?

问题描述

谁能帮我解决这个问题?我正在使用 charts_flutter 库,希望图表与 y 轴标签重叠。

库:https ://pub.dev/packages/charts_flutter

在此处输入图像描述

我想要这样的结果: 在此处输入图像描述

这是我的代码:

TimeSeriesChart(
      seriesList,

      dateTimeFactory: const LocalDateTimeFactory(),
      animate: animate,
      domainAxis: DateTimeAxisSpec(
        renderSpec: GridlineRendererSpec(
            labelStyle: new TextStyleSpec(
                fontSize: MyDimens.chart_text_size, //
                color: labelColor),
            lineStyle: LineStyleSpec(
                thickness: 0, color: MaterialPalette.transparent)),
      ),
      primaryMeasureAxis: new NumericAxisSpec(
          tickFormatterSpec: simpleCurrencyFormatter,
          tickProviderSpec: new BasicNumericTickProviderSpec(
            zeroBound: false,
            dataIsInWholeNumbers: false,
            desiredTickCount: MyDimens.chart_desired_tick_count,
          ),
          renderSpec: new GridlineRendererSpec(
            // Tick and Label styling here.
            labelStyle: new TextStyleSpec(
                fontSize: MyDimens.chart_text_size, //
                color: labelColor),

            // Change the line colors to match text color.
            lineStyle: new LineStyleSpec(color: lineColor),
            labelAnchor: TickLabelAnchor.after,
            labelJustification: TickLabelJustification.inside,
          )),
    )

标签: flutterchartsflutter-dependencies

解决方案


设置zeroBound参数为true


推荐阅读