3

在此处输入图像描述 折线图(

    LineChartData(
    minX: 0,
    maxX: 40,
    minY: 0,

    lineBarsData: [
    LineChartBarData(

    spots: fl,
    isCurved: true,
    barWidth: 5,
    )
    ]
    )

),

这是我在 x 轴上的代码值重叠。我正在使用 fl_charts 进行颤动,是否有任何选项可以指定轴值之间的间隔?

4

1 回答 1

2

LineChartData(minX: 0, maxX: 40,

                        gridData: FlGridData(
                          show: false,
                        ),
                        titlesData: FlTitlesData(
                          bottomTitles: SideTitles(
                            showTitles: true,
                            reservedSize: 22,
                            getTextStyles: (value) => const TextStyle(
                              color: CColors.pink,
                              fontWeight: FontWeight.bold,
                              fontSize: 16,
                            ),
                            margin: 10,
                            getTitles: (value) {
                              if(value.toInt() % 5 == 0){
                                return '${value.toInt()}';
                              }else{
                                return '';
                              }},
                          ),
                          leftTitles: SideTitles(
                            showTitles: true,
                            getTextStyles: (value) => const TextStyle(
                              color: CColors.pink,
                              fontWeight: FontWeight.bold,
                              fontSize: 14,
                            ),
                            getTitles: (value) {
                              if(value.toInt() % 25 == 0){
                                return '${value.toInt()}';
                              }else{
                                return '';
                              }
                              },
                              margin: 8,
                              reservedSize: 30,
                            ),
                          ),
                        borderData: FlBorderData(
                          show: true,

                        ),
                        lineBarsData: [
                          LineChartBarData(

                            spots: fl,
                            colors: [CColors.pink],
                            barWidth: 5,
                          ),
                        ],
                      ),
于 2021-03-25T05:21:50.730 回答