Im using fl_charts for line chart and I have dateTime as X axis values but it seems FlSpot takes double as value.
Here is my code,
LineChartBarData(
spots: graphValues
.map(
(e) => FlSpot(
e['x'],
e['y'],//DateTime value
),
)
.toList(),
isCurved: true,
color: Colors.red,
dotData: const FlDotData(
show: false,
),
barWidth: 1,
belowBarData: BarAreaData(
show: true,
gradient: LinearGradient(
colors: [
color222E65.withOpacity(.6),
Colors.transparent
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
),
How to use DateTime or String as values in this chart.
Just convert the
DateTimeintomicrosecondsSinceEpochand intodouble. like this,