我想创建一个饼图(或者更确切地说是一个环形图),它显示一个给定的值(比如1000欧元)已经用完了多少。我试过包裹了
馅饼
_
图表
和
平面
_
图表
虽然它们都能绘制出很好的图表,但我不能完全按照我想要的方式来显示它。到目前为止,我从两个包中得到的是这样的,其中较小的部分从环上的任何地方开始:
我希望它看起来像这样,其中较小的部分从顶部开始,并根据可用资金的使用量按顺时针方向填充空间,类似于进度指示器:
我试着旋转图表,但旋转度总是取决于较小的部分占据了多少空间,我不知道如何计算。
发布于 2021-02-18 19:56:48
我在这里找到了一个解决方案:
https://stackoverflow.com/a/54709279/11487803
它们使用具有多个CircularProgressIndicator的堆栈来实现这一点,但也应该可以使用CircularPercentIndicator (您必须将背景颜色设置为透明才能看到后面的元素)
发布于 2021-02-18 19:17:56
The The The
进度指示器
软件包非常灵活,可以解决您的问题
要根据百分比选择不同的颜色,可以使用以下方法:
final double _profilePercentage = 0.25;
Color getProfileStatusColor() {
switch ((_profilePercentage * 100).toInt()) {
case 100:
return kSuccessColor;
case 75:
return kSuccessColor;
case 50:
return kAccentColor;
case 25:
return kErrorColor;
default:
return kGreyColor;
}
}
其中,小部件如下所示:
LinearPercentIndicator(
width: MediaQuery.of(context).size.width * 0.85 -
60.0,
animation: true,
lineHeight: 7.0,
animationDuration: 500,
percent: _profilePercentage,
linearStrokeCap: LinearStrokeCap.roundAll,
progressColor: getProfileStatusColor(),
),
https://stackoverflow.com/questions/66258416
复制相似问题