Strange rounding when the x values are 0
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 7.6k
- Forks
- 2k
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
i get List values from backend where all values are above 0 or 0 and when isCurved param set true, i see unexpected rounding
**To Reproduce**
```
LineChart(
LineChartData(
borderData: FlBorderData(
show: true,
border: Border(
bottom: BorderSide(
color: context.colors.outlineVariantTint)),
),
lineTouchData: LineTouchData(
enabled: true,
getTouchedSpotIndicator: (barData, spotIndexes) =>
spotIndexes.isNotEmpty
? spotIndexes
.map(
(e) => TouchedSpotIndicatorData(
FlLine(
color: context
.colors.outlineVariantTint),
FlDotData(
show: true,
getDotPainter: (spot, percent,
barData, index) =>
FlDotCirclePainter(
radius: 8,
color: context.colors.surface,
strokeWidth: 1.5,
strokeColor:
context.colors.primary,
),
),
),
)
.toList()
: [],
touchTooltipData: LineTouchTooltipData(
getTooltipColor: (touchedSpot) =>
context.colors.surface,
tooltipBorder: BorderSide(
color: context.colors.outlineVariantTint),
tooltipRoundedRadius: 10,
getTooltipItems:
(List lineBarsSpot) =>
lineBarsSpot.isNotEmpty
? lineBarsSpot
.map(
(lineBarSpot) =>
LineTooltipItem(
'${lineBarSpot.y.toInt()} m',
AppTextStyles.body2(context),
),
)
.toList()
: [],
),
),
lineBarsData: [
LineChartBarData(
spots: List.generate(
items.length,
(index) => FlSpot(
index.toDouble(),
items[index].value.toInt() / 60,
),
growable: false),
isCurved: true,
curveSmoothness: 0.2,
barWidth: 2,
color: context.colors.primary,
dotData: const FlDotData(show: false),
),
],
// minY: -2,
// minX: 0,
titlesData: FlTitlesData(
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
interval: _interval,
getTitlesWidget: (value, meta) =>
periodType == PeriodEntityResType.month &&
value == 0
? Transform.translate(
offset: const Offset(15, 0),
child: _bottomTitlesManager(
value, meta, context))
: _bottomTitlesManager(
value, meta, context),
),
),
rightTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, meta) =>
rightTitles(value, meta, context),
reservedSize: 60,
),
),
topTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
leftTitles: const AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
),
gridData: FlGridData(
show: true,
drawVerticalLine: false,
getDrawingHorizontalLine: (value) => FlLine(
color: context.colors.outlineVariantTint,
strokeWidth: 1,
),
),
),
),
```
**Screenshots**

**Versions**
fl_chart: ^0.67.0
sdk: 3.19.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin by running the supplied LineChart reproduction with isCurved enabled and x values starting at 0, then compare the rendered curve with the screenshot. The report names no source file or test, so trace the line-chart rendering path from this example; done means the zero-valued x data no longer produces the reported rounding while curved lines still render correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100