Skip to content

Commit

Permalink
Merge pull request #80 from imaNNeoFighT/feature/bar-area-cut-off-y
Browse files Browse the repository at this point in the history
Feature/bar area cut off y
  • Loading branch information
imaNNeo committed Oct 3, 2019
2 parents dd9014c + e6cddc8 commit b267a79
Show file tree
Hide file tree
Showing 13 changed files with 305 additions and 110 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.3.3
* BREAKING CHANGES
* added support for drawing below and above areas separately in LineChart
* added cutOffY feature in LineChart, see this [issue](https://github.com/imaNNeoFighT/fl_chart/issues/62)
* added `aboveBarData` in [LineChartBarData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#linechartbardata)
* `BelowBarData` class renamed to [BarAreaData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#barareadata) to reuse for both above and below are
* `belowSpotsLine` renamed to `spotsLine` in [BarAreaData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#barareadata)
* `cutOffY` and `applyCutOffY` fields is added in [BarAreaData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#barareadata) to handle cutting of drawing below or above area
* `BelowSpotsLine` renamed to [BarAreaSpotsLine](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#barareaspotsline), and inside it `heckToShowSpotBelowLine` renamed to `heckToShowSpotLine`

## 0.3.2
* provided default size (square with 30% smaller than screen) for the FLChart, fixed this [issue](https://github.com/imaNNeoFighT/fl_chart/issues/74).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Thank you all!

```kotlin
dependencies:
fl_chart: ^0.3.2
fl_chart: ^0.3.3
```


Expand Down
16 changes: 8 additions & 8 deletions example/lib/line_chart/samples/line_chart_sample1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class LineChartSample1State extends State<LineChartSample1> {
leftTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
color: Color(0xff75729e),
color: const Color(0xff75729e),
fontWeight: FontWeight.bold,
fontSize: 14,
),
Expand Down Expand Up @@ -202,7 +202,7 @@ class LineChartSample1State extends State<LineChartSample1> {
dotData: FlDotData(
show: false,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: false,
),
),
Expand All @@ -224,7 +224,7 @@ class LineChartSample1State extends State<LineChartSample1> {
dotData: FlDotData(
show: false,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: false,
colors: [
Color(0x00aa4cfc),
Expand All @@ -248,7 +248,7 @@ class LineChartSample1State extends State<LineChartSample1> {
dotData: FlDotData(
show: false,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: false,
),
),
Expand Down Expand Up @@ -286,7 +286,7 @@ class LineChartSample1State extends State<LineChartSample1> {
leftTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
color: Color(0xff75729e),
color: const Color(0xff75729e),
fontWeight: FontWeight.bold,
fontSize: 14,
),
Expand Down Expand Up @@ -356,7 +356,7 @@ class LineChartSample1State extends State<LineChartSample1> {
dotData: FlDotData(
show: false,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: false,
),
),
Expand All @@ -378,7 +378,7 @@ class LineChartSample1State extends State<LineChartSample1> {
dotData: FlDotData(
show: false,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: true,
colors: [
Color(0x33aa4cfc),
Expand All @@ -403,7 +403,7 @@ class LineChartSample1State extends State<LineChartSample1> {
dotData: FlDotData(
show: true,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: false,
),
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/line_chart/samples/line_chart_sample2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class _LineChartSample2State extends State<LineChartSample2> {
dotData: const FlDotData(
show: false,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: true,
colors: gradientColors.map((color) => color.withOpacity(0.3)).toList(),
),
Expand Down Expand Up @@ -235,7 +235,7 @@ class _LineChartSample2State extends State<LineChartSample2> {
dotData: const FlDotData(
show: false,
),
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: true,
colors: [
ColorTween(begin: gradientColors[0], end: gradientColors[1]).lerp(0.2).withOpacity(0.1),
Expand Down
23 changes: 11 additions & 12 deletions example/lib/line_chart/samples/line_chart_sample3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';

class LineChartSample3 extends StatelessWidget {

var weekDays = ['Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', ];
final weekDays = ['Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', ];

@override
Widget build(BuildContext context) {
Expand All @@ -13,12 +13,12 @@ class LineChartSample3 extends StatelessWidget {
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Average Line',
children: const <Widget> [
Text('Average Line',
style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold, fontSize: 16),),
const Text(' and ',
Text(' and ',
style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16),),
const Text('Indicators',
Text('Indicators',
style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold, fontSize: 16),),
],
),
Expand Down Expand Up @@ -71,7 +71,7 @@ class LineChartSample3 extends StatelessWidget {
),
lineBarsData: [
LineChartBarData(
spots: [
spots: const [
FlSpot(0, 1.3),
FlSpot(1, 1),
FlSpot(2, 1.8),
Expand All @@ -85,22 +85,22 @@ class LineChartSample3 extends StatelessWidget {
colors: [
Colors.orange,
],
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: true,
colors: [
Colors.orange.withOpacity(0.5),
Colors.orange.withOpacity(0.0),
],
gradientColorStops: [0.5, 1.0],
gradientFrom: Offset(0, 0),
gradientTo: Offset(0, 1),
belowSpotsLine: BelowSpotsLine(
gradientFrom: const Offset(0, 0),
gradientTo: const Offset(0, 1),
spotsLine: BarAreaSpotsLine(
show: true,
flLineStyle: const FlLine(
color: Colors.blue,
strokeWidth: 2,
),
checkToShowSpotBelowLine: (spot) {
checkToShowSpotLine: (spot) {
if (spot.x == 0 || spot.x == 6) {
return false;
}
Expand Down Expand Up @@ -188,5 +188,4 @@ class LineChartSample3 extends StatelessWidget {
],
);
}

}
20 changes: 16 additions & 4 deletions example/lib/line_chart/samples/line_chart_sample4.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class LineChartSample4 extends StatelessWidget {

@override
Widget build(BuildContext context) {

const cutOffYValue = 5.0;

return SizedBox(
width: 300,
height: 140,
Expand All @@ -14,7 +17,7 @@ class LineChartSample4 extends StatelessWidget {
lineTouchData: const LineTouchData(enabled: false),
lineBarsData: [
LineChartBarData(
spots: [
spots: const [
FlSpot(0, 4),
FlSpot(1, 3.5),
FlSpot(2, 4.5),
Expand All @@ -33,11 +36,19 @@ class LineChartSample4 extends StatelessWidget {
colors: [
Colors.purpleAccent,
],
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: true,
colors: [Colors.deepPurple.withOpacity(0.4)],
cutOffY: cutOffYValue,
applyCutOffY: true,
),
aboveBarData: BarAreaData(
show: true,
colors: [Colors.deepPurple.withOpacity(0.2)],
colors: [Colors.orange.withOpacity(0.6)],
cutOffY: cutOffYValue,
applyCutOffY: true,
),
dotData: FlDotData(
dotData: const FlDotData(
show: false,
),
),
Expand Down Expand Up @@ -73,6 +84,7 @@ class LineChartSample4 extends StatelessWidget {
return 'Nov';
case 11:
return 'Dec';
default: return '';
}
}
),
Expand Down
6 changes: 3 additions & 3 deletions example/lib/line_chart/samples/line_chart_sample5.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LineChartSample5 extends StatelessWidget {
LineChartData(
lineTouchData: const LineTouchData(enabled: false),
lineBarsData: [
LineChartBarData(
const LineChartBarData(
spots: [
FlSpot(0, 1),
FlSpot(1, 2),
Expand All @@ -25,7 +25,7 @@ class LineChartSample5 extends StatelessWidget {
],
isCurved: true,
barWidth: 4,
belowBarData: BelowBarData(
belowBarData: BarAreaData(
show: true,
),
dotData: FlDotData(show: false),
Expand Down Expand Up @@ -63,7 +63,7 @@ class LineChartSample5 extends StatelessWidget {
)
),
),
gridData: FlGridData(show: false),
gridData: const FlGridData(show: false),
borderData: FlBorderData(
show: true,
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/line_chart/samples/line_chart_sample6.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class LineChartSample6 extends StatelessWidget {
isCurved: true,
isStrokeCapRound: true,
barWidth: 10,
belowBarData: const BelowBarData(
belowBarData: const BarAreaData(
show: false,
),
dotData: FlDotData(
Expand All @@ -103,7 +103,7 @@ class LineChartSample6 extends StatelessWidget {
isCurved: true,
isStrokeCapRound: true,
barWidth: 10,
belowBarData: const BelowBarData(
belowBarData: const BarAreaData(
show: false,
),
dotData: FlDotData(
Expand Down
Loading

0 comments on commit b267a79

Please sign in to comment.