本文主要是介绍Flutter-图表显示charts_flutter,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
引入插件:
charts_flutter: ^0.4.0
ChartFlutterBean
import 'package:charts_flutter/flutter.dart'; import 'package:myself_project/OrdinalSales%20.dart';class ChartFlutterBean {static List<Series<TimeSeriesSales, DateTime>> createSampleData0() {final data = [new TimeSeriesSales(new DateTime(2017, 9, 19), 15),new TimeSeriesSales(new DateTime(2017, 9, 26), 25),new TimeSeriesSales(new DateTime(2017, 10, 9), 20),new TimeSeriesSales(new DateTime(2017, 10, 10), 75),];return [new Series<TimeSeriesSales, DateTime>(id: 'Sales',colorFn: (_, __) => MaterialPalette.blue.shadeDefault,domainFn: (TimeSeriesSales sales, _) => sales.time,measureFn: (TimeSeriesSales sales, _) => sales.sales,data: data,),];}//条形图static List<Series<LinearSales, int>> createSampleData6() {final data = [new LinearSales(0, 5),new LinearSales(1, 25),new LinearSales(2, 100),new LinearSales(3, 75),];return [new Series<LinearSales, int>(id: 'Sales',colorFn: (_, __) => MaterialPalette.blue.shadeDefault,domainFn: (LinearSales sales, _) => sales.year,measureFn: (LinearSales sales, _) => sales.sales,data: data,)];}//多数据折线图static List<Series<LinearSales, int>> createSampleData5() {final myFakeDesktopData = [new LinearSales(0, 5),new LinearSales(1, 25),new LinearSales(2, 100),new LinearSales(3, 75),];var myFakeTabletData = [new LinearSales(0, 10),new LinearSales(1, 50),new LinearSales(2, 200),new LinearSales(3, 150),];var myFakeMobileData = [new LinearSales(0, 15),new LinearSales(1, 75),new LinearSales(2, 300),new LinearSales(3, 225),];return [new Series<LinearSales, int>(id: 'Desktop',colorFn: (_, __) => MaterialPalette.blue.shadeDefault,domainFn: (LinearSales sales, _) => sales.year,measureFn: (LinearSales sales, _) => sales.sales,data: myFakeDesktopData,),new Series<LinearSales, int>(id: 'Tablet',colorFn: (_, __) => MaterialPalette.red.shadeDefault,//dashPattern: [2, 2],domainFn: (LinearSales sales, _) => sales.year,measureFn: (LinearSales sales, _) => sales.sales,data: myFakeTabletData,),new Series<LinearSales, int>(id: 'Mobile',colorFn: (_, __) => MaterialPalette.green.shadeDefault,//dashPattern: [8, 3, 2, 3],domainFn: (LinearSales sales, _) => sales.year,measureFn: (LinearSales sales, _) => sales.sales,da
这篇关于Flutter-图表显示charts_flutter的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!