flutter - 使用 fl_chart 包在线性图表中绘制底部标题时导致错误的原因
问题描述
错误说明“RangeError(索引):无效值:不在包含范围 0..11:15 内”
列表元素示例
getDays = [30 Aug, 31 Aug, 01 Sep, 02 Sep, 03 Sep, 04 Sep, 05 Sep, 06 Sep, 07 Sep, 08 Sep, 09 Sep, 10 Sep]
较短的列表会导致错误。但是更长的列表也没关系。
bottomTitles: SideTitles(
showTitles: true,
reservedSize: 5,
textStyle: const TextStyle(
color: Color(0xff68737d),
fontSize: 12,
fontWeight: FontWeight.bold),
getTitles: (value) {
//value from x point
if (value.toInt() % 5 == 0) {
return '${widget._healthPresenter.getDays[value.toInt()]}';
}
return '';
},
margin: 10,
)
解决方案
推荐阅读
- android-studio - 生成签名的 APK 在构建菜单 android studio 中无效
- amazon-web-services - 如何从我的应用程序向我的客户的 SSO 进行身份验证
- python - 在 while 循环中使用 if 语句
- c++ - 在 C++ 中使用另一个向量对一个向量进行 Lambda 排序
- .net - 使用超链接将 RDLC 渲染为 PDF
- matlab - 将归一化滤波器转换为实频滤波器
- excel - 将文件嵌入特定列并向下一行插入另一个文件
- asp.net - 如何更改 Url.Action() 使用的根 URL?
- java - 我们是否需要在 Spring Boot 中为每个表编写实体类?
- amazon-web-services - 在 aws 上创建 https 重定向的步骤