Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

belowBarData does not fit the size of the line chart's start and end #1628

Open
ManuelRauber opened this issue Apr 9, 2024 · 0 comments
Open

Comments

@ManuelRauber
Copy link

Hi,

I'm trying to create a Sparkline chart that has belowBarData enabled with a color.

However, the start and end of the belowBarData's color does not fit the size of the chart.

Here is how the Widget looks like:

image

As you can see the line's a bit wider than the belowBarData color:

image

I would expect that the belowBarData's color is also underneath the caps.

class Sparkline extends StatelessWidget {
  final List<double> data;

  const Sparkline({
    super.key,
    required this.data,
  });

  @override
  Widget build(final BuildContext context) => LineChart(
        LineChartData(
          minY: 0,
          gridData: const FlGridData(
            show: false,
          ),
          borderData: FlBorderData(
            show: false,
          ),
          titlesData: const FlTitlesData(
            show: false,
          ),
          lineTouchData: const LineTouchData(
            enabled: false
          ),
          lineBarsData: [
            LineChartBarData(
              color: const Color(0xFF17B26A),
              spots: data
                  .mapIndexed((final index, final e) => FlSpot(index.toDouble(), e))
                  .toList(growable: false),
              dotData: const FlDotData(
                show: false,
              ),
              barWidth: 4,
              isStrokeCapRound: true,
              isStrokeJoinRound: true,
              belowBarData: BarAreaData(
                color: Colors.red,
                show: true,
              ),
            ),
          ],
        ),
      );
}

// Example call:
Sparkline(data: [2, 3.1, 3.5, 2.8, 5.4, 9.2, 2.4, 3.5, 5.4, 7, ]);
  • Flutter: 3.19.4
  • fl_chart: 0.67.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant