google / charts

https://pub.dev/packages/charts_flutter
Apache License 2.0
2.81k stars 1.2k forks source link

Negative series points are drawn outside the bounds of the domain axis #790

Open Stephen-Ross opened 2 years ago

Stephen-Ross commented 2 years ago

Expected Behaviour Any series that has a point which would cross the domain axis should stop drawing the line between points at the point where it crosses the axis line.

Actual Behaviour The line between the positive point and the negative point continues for a bit underneath the domain axis line for a few pixels which is unusual for the user when they are expecting the line to stop on the axis.

You can see this between points 2 and 3 and then from 3 to 4: image

Steps to Reproduce Example code

...

@override
Widget build(BuildContext context) {
    return charts.LineChart(
        [
            charts.Series<_Test, num>(
                id: 'Test',
                data: [
                    _Test(0, 1),
                    _Test(1, 3),
                    _Test(2, -1),
                    _Test(3, 5),
                    _Test(4, 2),
                ],
                domainFn: (_Test test, _) => test.x,
                measureFn: (_Test test, _) => test.y,
                measureLowerBoundFn: (_, __) => 0,
                measureOffsetFn: (_, __) => 0,
            ),
        ],
        primaryMeasureAxis: const charts.NumericAxisSpec(
            showAxisLine: true,
            viewport: charts.NumericExtents(0, 10),
        ),
    );
}

...

class _Test {
  final int x;

  final int y;

  _Test(this.x, this.y);
}

I can't see if there is an offset that is being applied to the domain axis line. If someone is able to show a method of stopping this happening it would be appreciated.