Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/around-titles #42

Merged
merged 5 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.1.3
* added `SideTitles` class to hold titles representation data, and used in `FlTitlesData` to show left, top, right, bottom titles, instead of legacy direct parameters, and implemented a reversed chart [sample](https://github.com/imaNNeoFighT/fl_chart/blob/feature/both-axis-titles/repo_files/documentations/line_chart.md#sample-6-source-code) using this update.

## 0.1.2
* added `preventCurveOverShooting` on BarData, check this [issue](https://github.com/imaNNeoFighT/fl_chart/issues/25)

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.1.2
fl_chart: ^0.1.3
```


Expand Down
47 changes: 25 additions & 22 deletions example/lib/bar_chart/samples/bar_chart_sample1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,32 @@ class BarChartSample1State extends State<BarChartSample1> {
),
titlesData: FlTitlesData(
show: true,
showHorizontalTitles: true,
showVerticalTitles: false,
horizontalTitlesTextStyle: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14),
horizontalTitleMargin: 16,
getHorizontalTitles: (double value) {
switch (value.toInt()) {
case 0:
return 'M';
case 1:
return 'T';
case 2:
return 'W';
case 3:
return 'T';
case 4:
return 'F';
case 5:
return 'S';
case 6:
return 'S';
bottomTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14),
margin: 16,
getTitles: (double value) {
switch (value.toInt()) {
case 0:
return 'M';
case 1:
return 'T';
case 2:
return 'W';
case 3:
return 'T';
case 4:
return 'F';
case 5:
return 'S';
case 6:
return 'S';
}
}
}),
),
leftTitles: SideTitles(showTitles: false,),
),
borderData: FlBorderData(
show: false,
),
Expand Down
88 changes: 46 additions & 42 deletions example/lib/bar_chart/samples/bar_chart_sample2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,48 +148,52 @@ class BarChartSample2State extends State<BarChartSample2> {
),
titlesData: FlTitlesData(
show: true,
showHorizontalTitles: true,
showVerticalTitles: true,
verticalTitlesTextStyle: TextStyle(
color: Color(0xff7589a2),
fontWeight: FontWeight.bold,
fontSize: 14),
verticalTitleMargin: 32,
verticalTitlesReservedWidth: 14,
getVerticalTitles: (value) {
if (value == 0) {
return "1K";
} else if (value == 10) {
return "5K";
} else if (value == 19) {
return "10K";
} else {
return "";
}
},
horizontalTitlesTextStyle: TextStyle(
color: Color(0xff7589a2),
fontWeight: FontWeight.bold,
fontSize: 14),
horizontalTitleMargin: 20,
getHorizontalTitles: (double value) {
switch (value.toInt()) {
case 0:
return 'Mn';
case 1:
return 'Te';
case 2:
return 'Wd';
case 3:
return 'Tu';
case 4:
return 'Fr';
case 5:
return 'St';
case 6:
return 'Sn';
}
},
bottomTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
color: const Color(0xff7589a2),
fontWeight: FontWeight.bold,
fontSize: 14),
margin: 20,
getTitles: (double value) {
switch (value.toInt()) {
case 0:
return 'Mn';
case 1:
return 'Te';
case 2:
return 'Wd';
case 3:
return 'Tu';
case 4:
return 'Fr';
case 5:
return 'St';
case 6:
return 'Sn';
}
},
),
leftTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
color: const Color(0xff7589a2),
fontWeight: FontWeight.bold,
fontSize: 14),
margin: 32,
reservedSize: 14,
getTitles: (value) {
if (value == 0) {
return '1K';
} else if (value == 10) {
return '5K';
} else if (value == 19) {
return '10K';
} else {
return '';
}
},
),
),
borderData: FlBorderData(
show: false,
Expand Down
25 changes: 25 additions & 0 deletions example/lib/line_chart/line_chart_page3.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
import 'samples/line_chart_sample6.dart';

class LineChartPage3 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
"LineChart (reversed)",
style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold, color: Colors.black),
),
SizedBox(height: 52,),
LineChartSample6(),
],
),
),
);
}
}
69 changes: 38 additions & 31 deletions example/lib/line_chart/samples/line_chart_sample1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,39 +71,46 @@ class LineChartSample1State extends State<LineChartSample1> {
show: false,
),
titlesData: FlTitlesData(
horizontalTitlesTextStyle: TextStyle(
color: Color(0xff72719b),
fontWeight: FontWeight.bold,
fontSize: 16,
bottomTitles: SideTitles(
showTitles: true,
reservedSize: 22,
textStyle: TextStyle(
color: const Color(0xff72719b),
fontWeight: FontWeight.bold,
fontSize: 16,
),
margin: 10,
getTitles: (value) {
switch(value.toInt()) {
case 2:
return 'SEPT';
case 7:
return 'OCT';
case 12:
return 'DEC';
}
return '';
},
),
horizontalTitleMargin: 10,
getHorizontalTitles: (value) {
switch(value.toInt()) {
case 2:
return "SEPT";
case 7:
return "OCT";
case 12:
return "DEC";
}
return "";
},
verticalTitlesTextStyle: TextStyle(
color: Color(0xff75729e),
fontWeight: FontWeight.bold,
fontSize: 14,
leftTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
color: Color(0xff75729e),
fontWeight: FontWeight.bold,
fontSize: 14,
),
getTitles: (value) {
switch(value.toInt()) {
case 1: return '1m';
case 2: return '2m';
case 3: return '3m';
case 4: return '5m';
}
return '';
},
margin: 8,
reservedSize: 30,
),
getVerticalTitles: (value) {
switch(value.toInt()) {
case 1: return "1m";
case 2: return "2m";
case 3: return "3m";
case 4: return "5m";
}
return "";
},
verticalTitleMargin: 8,
verticalTitlesReservedWidth: 30,
),
borderData: FlBorderData(
show: true,
Expand Down
63 changes: 35 additions & 28 deletions example/lib/line_chart/samples/line_chart_sample2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,43 @@ class LineChartSample2 extends StatelessWidget {
),
titlesData: FlTitlesData(
show: true,
horizontalTitlesTextStyle: TextStyle(
color: Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16
),
getHorizontalTitles: (value) {
switch(value.toInt()) {
case 2: return "MAR";
case 5: return "JUN";
case 8: return "SEP";
}
bottomTitles: SideTitles(
showTitles: true,
reservedSize: 22,
textStyle: TextStyle(
color: const Color(0xff68737d),
fontWeight: FontWeight.bold,
fontSize: 16
),
getTitles: (value) {
switch(value.toInt()) {
case 2: return 'MAR';
case 5: return 'JUN';
case 8: return 'SEP';
}

return "";
},
verticalTitlesTextStyle: TextStyle(
color: Color(0xff67727d),
fontWeight: FontWeight.bold,
fontSize: 15,
return '';
},
margin: 8,
),
leftTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
color: const Color(0xff67727d),
fontWeight: FontWeight.bold,
fontSize: 15,
),
getTitles: (value) {
switch(value.toInt()) {
case 1: return '10k';
case 3: return '30k';
case 5: return '50k';
}
return '';
},
reservedSize: 28,
margin: 12,
),
getVerticalTitles: (value) {
switch(value.toInt()) {
case 1: return "10k";
case 3: return "30k";
case 5: return "50k";
}
return "";
},
verticalTitlesReservedWidth: 28,
verticalTitleMargin: 12,
horizontalTitleMargin: 8,
),
borderData: FlBorderData(
show: true,
Expand Down
47 changes: 27 additions & 20 deletions example/lib/line_chart/samples/line_chart_sample3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,35 @@ class LineChartSample3 extends StatelessWidget {
),
titlesData: FlTitlesData(
show: true,
getHorizontalTitles: (value) {
return weekDays[value.toInt()];
},
getVerticalTitles: (value) {
switch (value.toInt()) {
case 0:
return "";
case 1:
return "1k colories";
case 2:
return "2k colories";
case 3:
return "3k colories";
}
leftTitles: SideTitles(
showTitles: true,
getTitles: (value) {
switch (value.toInt()) {
case 0:
return '';
case 1:
return '1k colories';
case 2:
return '2k colories';
case 3:
return '3k colories';
}

return "";
},
horizontalTitlesTextStyle: TextStyle(
color: Colors.deepOrange,
fontWeight: FontWeight.bold,
return '';
},
textStyle: const TextStyle(color: Colors.black, fontSize: 10),
),
verticalTitlesTextStyle: TextStyle(color: Colors.black, fontSize: 10)),
bottomTitles: SideTitles(
showTitles: true,
getTitles: (value) {
return weekDays[value.toInt()];
},
textStyle: const TextStyle(
color: Colors.deepOrange,
fontWeight: FontWeight.bold,
),
)
),
),
),
),
Expand Down
Loading