我在 Syncfusion Flutter 图表中遇到倒转条的问题。当使用对数 y 轴且数据值均小于 1 时,条形图似乎向下而不是向上增长。这在视觉上具有误导性,并且不能准确代表我的数据。
这是我的代码片段:
class Values {
final String x;
final double y;
Values(this.x, this.y);
}
List<Values> getChartData() {
return [
Values('CFI', 0.3),
Values('CC', 0.1),
Values('BLC', 0.03),
Values('BDA', 0.01),
];
}
SfCartesianChart(
title: ChartTitle(text: "Bar Graph"),
primaryXAxis: const CategoryAxis(
title: AxisTitle(
text: 'Headers',
textStyle: TextStyle(color: Color.fromARGB(255, 4, 20, 63)),
),
),
primaryYAxis: const LogarithmicAxis(
title: AxisTitle(
text: 'Values',
textStyle: TextStyle(color: Color.fromARGB(255, 4, 20, 63)),
),
),
series: <CartesianSeries>[
ColumnSeries<Values, String>(
dataSource: getChartData(),
xValueMapper: (Values course, _) => course.x,
yValueMapper: (Values course, _) => course.y,
dataLabelSettings: DataLabelSettings(isVisible: true),
color: Color.fromARGB(255, 4, 20, 63),
pointColorMapper: (Values data, _) => data.y < 20 ? Colors.red : Color.fromARGB(255, 4, 20, 63),
),
],
)
最初,我尝试在 Syncfusion Flutter 图表中设置对数轴的 isInverted 属性来反转条形。这成功地翻转了条形,但也翻转了 y 轴本身。现在,y 轴显示从最高到最低的值,这不是所需的行为。
我注意到 y 轴上低于 1 的值是以倒转的方式绘制的。为了解决这个问题,我尝试将对数轴的最小值设置为图表中的最低数据点。然而,这并没有解决倒杠问题。