Last updated:
0 purchases
flutter xchart
flutter_xchart #
简易图表,支持柱状图,曲线图,折线图等
用法 #
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('XChart'),
),
body: Center(
child: XChart(
yAxisHeight: 150.w,
yData: ["500", "400", "300", "200", "100", "0"],
xCount: 5,
xItemBuild: (params) {///构建柱状图
double maxHeight = params["maxHeight"];
double margin = params["margin"];
int index = params["index"];
int curIndex = params["curIndex"];
int xWidth = params["xWidth"];
double xItemWidth = xWidth / 5;
Widget bar = getBar(maxHeight,margin,index,curIndex,xItemWidth);
Widget tag = getTag(index,curIndex,xItemWidth);
return {
"bar":bar,
"tag":tag,
};
},
popBuild: (params){///构建图表弹窗
double maxHeight = params["maxHeight"];
double margin = params["margin"];
int curIndex = params["curIndex"];
int xWidth = params["xWidth"];
double xItemWidth = xWidth / 5;
Widget popWindow = getPopWindow(maxHeight,margin,curIndex,xItemWidth);
return {
"widget": popWindow,
"leftOffset": 25.w,
"topOffset": 25.w,
"popWidth": 100,
"popHeight": 100,
};
},
lineChartBuild: (){///构建曲线图折线图
List<LineChartBean> lineData = [];
return {
"lineData":lineData,
};
},
limitLineBuild: (){///构建限制线
List<LimitLineBean> lineData = [];
return {
"lineData":lineData,
};
},
),
),
),
);
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.