绘制:
1.在pubspec.yaml中引入:fl_chart: 0.55.2
2.绘制:
import 'package:jade/utils/JadeColors.dart';
import 'package:util/easy_loading_util.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class MyLineChart extends StatefulWidget {
const MyLineChart({
Key key}) : super(key: key);
State<MyLineChart> createState() => _MyLineChartState();
}
class _MyLineChartState extends State<MyLineChart> {
List<Color> gradientColors = [
Colors.yellow,
Colors.yellow,
];
//进入后默认显示指示竖线和轨迹球的点
FlSpot _defaultShowFlSpot = FlSpot(8, 4);
//进入页面时默认显示的点上的竖线显隐开关
bool _showSpotLine = true;
List<String> get weekDays => const ['10.21', '10.22', '10.23', '10.24', '10.25', '10.26', '10.27'];
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
AspectRatio(
aspectRatio: 1.70,
child: Padding(
padding: EdgeInsets.only(
right: 40.w,
),
child: LineChart(mainData())
),
),
],
),
);
}
LineChartData mainData() {
return LineChartData(
//网格
gridData: FlGridData(
show: true,
drawVerticalLine: false,
horizontalInterval: 1,
verticalInterval: 1,
getDrawingHorizontalLine: (value) {
return FlLine(
color: JadeColors.lightGrey,
strokeWidth: 1,
);
},
getDrawingVerticalLine: