feat:增加网络请求
This commit is contained in:
3063
lib/views/data.dart
Normal file
3063
lib/views/data.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:food_hub_app/api/session.dart';
|
||||
import 'package:food_hub_app/widgets/common/index.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
||||
@@ -23,8 +24,10 @@ class _LoginPage extends State<LoginPage> {
|
||||
{"title": "wechat", "icon": Icons.wechat},
|
||||
];
|
||||
|
||||
void loginClick(BuildContext context) {
|
||||
Navigator.pushNamed(context, '/home');
|
||||
void loginClick(BuildContext context) async {
|
||||
await loginApi("Cxx", "1232");
|
||||
|
||||
// Navigator.pushNamed(context, '/home');
|
||||
return;
|
||||
|
||||
// 表单校验通过才会继续执行
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:graphic/graphic.dart';
|
||||
|
||||
import 'data.dart';
|
||||
|
||||
class StatsPage extends StatefulWidget {
|
||||
const StatsPage({super.key});
|
||||
@@ -8,27 +10,91 @@ class StatsPage extends StatefulWidget {
|
||||
State<StatsPage> createState() => _StatsPage();
|
||||
}
|
||||
|
||||
class _StatsPage extends State<StatsPage>{
|
||||
class _StatsPage extends State<StatsPage> {
|
||||
var _smooth = false;
|
||||
var _stepped = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 月度做菜次数数据
|
||||
final List<FlSpot> spots = [
|
||||
FlSpot(0, 13), FlSpot(1, 32), FlSpot(2, 121),
|
||||
FlSpot(3, 31), FlSpot(4, 34), FlSpot(5, 45)
|
||||
];
|
||||
|
||||
// 月份标签
|
||||
final List<String> months = [
|
||||
'1月', '2月', '3月', '4月', '5月', '6月'
|
||||
];
|
||||
|
||||
return LineChart(
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: spots,
|
||||
),
|
||||
],
|
||||
return SingleChildScrollView(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
width: 350,
|
||||
height: 300,
|
||||
child: Chart(
|
||||
data: basicData,
|
||||
variables: {
|
||||
'genre': Variable(
|
||||
accessor: (Map map) => map['genre'] as String,
|
||||
),
|
||||
'sold': Variable(accessor: (Map map) => map['sold'] as num),
|
||||
},
|
||||
marks: [
|
||||
IntervalMark(
|
||||
label: LabelEncode(
|
||||
encoder: (tuple) => Label(tuple['sold'].toString()),
|
||||
),
|
||||
elevation: ElevationEncode(
|
||||
value: 0,
|
||||
updaters: {
|
||||
'tap': {true: (_) => 5},
|
||||
},
|
||||
),
|
||||
color: ColorEncode(
|
||||
value: Defaults.primaryColor,
|
||||
updaters: {
|
||||
'tap': {false: (color) => color.withAlpha(100)},
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
axes: [Defaults.horizontalAxis, Defaults.verticalAxis],
|
||||
selections: {'tap': PointSelection(dim: Dim.x)},
|
||||
tooltip: TooltipGuide(),
|
||||
crosshair: CrosshairGuide(),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(20, 40, 20, 5),
|
||||
child: const Text(
|
||||
'Transposed Bar Chart',
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 10),
|
||||
width: 350,
|
||||
height: 300,
|
||||
child: Chart(
|
||||
data: basicData,
|
||||
variables: {
|
||||
'genre': Variable(
|
||||
accessor: (Map map) => map['genre'] as String,
|
||||
),
|
||||
'sold': Variable(accessor: (Map map) => map['sold'] as num),
|
||||
},
|
||||
transforms: [Proportion(variable: 'sold', as: 'percent')],
|
||||
marks: [
|
||||
IntervalMark(
|
||||
position: Varset('percent') / Varset('genre'),
|
||||
label: LabelEncode(
|
||||
encoder: (tuple) => Label(tuple['sold'].toString()),
|
||||
),
|
||||
color: ColorEncode(
|
||||
variable: 'genre',
|
||||
values: Defaults.colors10,
|
||||
),
|
||||
modifiers: [StackModifier()],
|
||||
),
|
||||
],
|
||||
coord: PolarCoord(transposed: true, dimCount: 1, dimFill: 1.05),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user