fl_chart icon indicating copy to clipboard operation
fl_chart copied to clipboard

minY value is overlapped

Open Reeganantony opened this issue 1 year ago • 4 comments

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

  • Flutter : 3.22.0
  • fl_chart: ^0.69.0

Reeganantony avatar Sep 25 '24 10:09 Reeganantony

Same for me

baiama avatar Oct 04 '24 07:10 baiama

any update on this ?

gauravkakad1 avatar Oct 16 '24 12:10 gauravkakad1

Nope!

Reeganantony avatar Oct 18 '24 06:10 Reeganantony

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

imaNNeo avatar Oct 20 '24 09:10 imaNNeo

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.

Reeganantony avatar Oct 23 '24 07:10 Reeganantony