Skip to content

Commit a9ef15d

Browse files
committed
Change the epoch timestamp unit from seconds to milliseconds
1 parent ae82aef commit a9ef15d

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

example/lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class _MyAppState extends State<MyApp> {
6969
"高": "${candle.high?.toStringAsFixed(2)}",
7070
"低": "${candle.low?.toStringAsFixed(2)}",
7171
},
72-
timeLabel: (timestamp, count) => "<Date>",
7372
priceLabel: (price) => "${price.round()} 💎",
7473
),
7574
),

example/lib/mock_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ class MockDataTesla {
11141114

11151115
static List<CandleData> get candles => _rawData
11161116
.map((row) => CandleData(
1117-
timestamp: row[0],
1117+
timestamp: row[0] * 1000,
11181118
open: row[1]?.toDouble(),
11191119
high: row[2]?.toDouble(),
11201120
low: row[3]?.toDouble(),

lib/src/interactive_chart.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class _InteractiveChartState extends State<InteractiveChart> {
247247
}
248248

249249
String defaultTimeLabel(int timestamp, int visibleDataCount) {
250-
final date = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000)
250+
final date = DateTime.fromMillisecondsSinceEpoch(timestamp)
251251
.toIso8601String()
252252
.split("T")
253253
.first
@@ -266,7 +266,7 @@ class _InteractiveChartState extends State<InteractiveChart> {
266266

267267
Map<String, String> defaultOverlayInfo(CandleData candle) {
268268
final date = intl.DateFormat.yMMMd()
269-
.format(DateTime.fromMillisecondsSinceEpoch(candle.timestamp * 1000));
269+
.format(DateTime.fromMillisecondsSinceEpoch(candle.timestamp));
270270
return {
271271
"Date": date,
272272
"Open": candle.open?.toStringAsFixed(2) ?? "-",

0 commit comments

Comments
 (0)