A flutter chart package.
pubspec.yaml
add dependence
sweet_chart:
git:
url: git@github.com:zakiso/flutter-sweet-chart.git
@override
Widget build(BuildContext context) {
//define your lines set
var lines = [];
//define your data set
List<SweetPoint> points = [];
var rng = Random();
for (var i = 0; i < 7; i++) {
points.add(SweetPoint(
//title and subtitle will show on user tap the point
value: rng.nextInt(300), title: "title", subTitle: "subtitle"));
}
//define your chart line style,
//A chart can be include multiple lines
//so you can set different style for different line.
var lineStyle = LineStyle(
color: Colors.green[200]); // you can run the example for view more option.
SweetLine line = SweetLine(points, style: lineStyle);
lines.add(line);
// chart style
chartStyle = LineChartStyle(showXAxis: true, showYAxis: true);
return Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
height: 200,
child: SweetLineChart(
lines: lines,
chartStyle: chartStyle,
//you can custom x and y axis title
xTitles: {0: "18", 2: "20", 4: "30", 5: "08/01", 6: "02"},
yTitles: {0: "0k", 1: "5k", 5: "25k",6: "30k" },
),
);
}
- show or hide x or y axis
- Custom x or y axis title
- show curve or strait line
- Fill gradient color
- show popup tips on click point
- Multi line
- …..and so on
Want to get more info please download project and run it .
Welcome PR and star