imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.86k stars 1.78k forks source link

minY value is overlapped #1755

Open Reeganantony opened 1 month ago

Reeganantony commented 1 month ago

In My project I set the minY value is -1, but the interval is 10000. so it overlapped with 0. How to give space to the minY value

Screenshots

overlapping_issue1

Versions

baiama commented 1 month ago

Same for me

gauravkakad1 commented 1 month ago

any update on this ?

Reeganantony commented 1 month ago

Nope!

imaNNeo commented 1 month ago

Please provide me with your reproducible code, I mean a minimal version of the issue that I can run.

Reeganantony commented 4 weeks ago
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';

class BarChartSample5 extends StatefulWidget {
  @override
  State<BarChartSample5> createState() => _BarChartSample5State();
}

class _BarChartSample5State extends State<BarChartSample5> {
  final List<double> data = [-1, 12, 52, 58, 154, 26, 1000];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Line chart'),
      ),
      body: Container(
        height: 600,
        child: Padding(
          padding: EdgeInsets.all(16.0),
          child: LineChart(
            LineChartData(
              gridData: FlGridData(
                show: true,
                horizontalInterval: 100 / 5,
                getDrawingHorizontalLine: (value) {
                  return FlLine(
                    color: Colors.grey.withOpacity(0.5),
                    strokeWidth: 1.3,
                  );
                },
                getDrawingVerticalLine: (value) {
                  return FlLine(
                    color: Colors.grey.withOpacity(0.5),
                    strokeWidth: 1.3,
                  );
                },
              ),
              // Set up the X axis
              titlesData: FlTitlesData(
                // bottomTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
                topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
                rightTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
                leftTitles: AxisTitles(
                    sideTitles: SideTitles(
                  showTitles: true,
                  reservedSize: 50,
                  getTitlesWidget: (value, meta) {
                    if (value < 0) {
                      return Text('OFF');
                    }
                    return Text(value.round().toString());
                  },
                )),
              ),
              // Set up the Y axis
              minY: -1,
              borderData: FlBorderData(show: true),
              lineBarsData: [
                LineChartBarData(
                  spots:
                      data.asMap().entries.map((e) => FlSpot(e.key.toDouble(), e.value)).toList(),
                  isCurved: true,
                  color: Colors.blue,
                  barWidth: 4,
                  isStrokeCapRound: true,
                  dotData: FlDotData(show: false),
                  belowBarData: BarAreaData(show: false),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

In this example, in the left tile -1 value is overlapped with 0.