Skip to content

Commit

Permalink
provided default size (square with 30% smaller than screen) for the F…
Browse files Browse the repository at this point in the history
…LChart, fixed issue #74.
  • Loading branch information
imaNNeo committed Oct 3, 2019
1 parent 1e2b834 commit d855c37
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/fl_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class _FlChartState extends AnimatedWidgetBaseState<FlChart> {
_touchInputNotifier.value = FlPanMoveUpdate(details.localPosition);
},
child: CustomPaint(
size: getDefaultSize(context),
painter: widget.chart.painter(
baseChartData: _baseChartDataTween.evaluate(animation),
targetBaseChartData: widget.chart.getData(),
Expand All @@ -98,6 +99,17 @@ class _FlChartState extends AnimatedWidgetBaseState<FlChart> {
);
}

Size getDefaultSize(BuildContext context) {
Size size = MediaQuery.of(context).size;
if (size.width < size.height) {
size = Size(size.width, size.width);
} else if (size.height < size.width) {
size = Size(size.height, size.height);
}
size *= 0.7;
return size;
}

void _releaseTouch() {
// bugFix to this issue: https://github.com/imaNNeoFighT/fl_chart/issues/64
// the problem is that wen user touches on screen we notify the touch result
Expand Down

0 comments on commit d855c37

Please sign in to comment.