updateCoinGraph method
dynamic
updateCoinGraph(
- dynamic data,
- Coin coinData
)
Implementation
updateCoinGraph(data, Coin coinData) {
if (data.containsKey("k") == true &&
kChartCandles[kChartCandles.length - 1].time! < data["k"]["t"]) {
if (coinData.pairWith.toUpperCase() == "INR") {
kChartCandles.add(KLineEntity.fromCustom(
time: data["k"]["t"],
amount: double.parse(data["k"]["h"].toString()) * inrRate,
change: double.parse(data["k"]["v"].toString()),
close: double.parse(data["k"]["c"].toString()) * inrRate,
high: double.parse(data["k"]["h"].toString()) * inrRate,
low: double.parse(data["k"]["l"].toString()) * inrRate,
open: double.parse(data["k"]["o"].toString()) * inrRate,
vol: double.parse(data["k"]["v"].toString()),
ratio: double.parse(data["k"]["c"].toString())));
} else {
kChartCandles.add(KLineEntity.fromCustom(
time: data["k"]["t"],
amount: double.parse(data["k"]["h"].toString()),
change: double.parse(data["k"]["v"].toString()),
close: double.parse(data["k"]["c"].toString()),
high: double.parse(data["k"]["h"].toString()),
low: double.parse(data["k"]["l"].toString()),
open: double.parse(data["k"]["o"].toString()),
vol: double.parse(data["k"]["v"].toString()),
ratio: double.parse(data["k"]["c"].toString())));
}
} else if (data.containsKey("k") == true) {
if (coinData.pairWith.toUpperCase() == "INR") {
kChartCandles[kChartCandles.length - 1] = KLineEntity.fromCustom(
time: data["k"]["t"],
amount: double.parse(data["k"]["h"]) * inrRate,
change: double.parse(data["k"]["v"].toString()),
close: double.parse(data["k"]["c"]) * inrRate,
high: double.parse(data["k"]["h"]) * inrRate,
low: double.parse(data["k"]["l"]) * inrRate,
open: double.parse(data["k"]["o"]) * inrRate,
vol: double.parse(data["k"]["v"].toString()),
ratio: double.parse(data["k"]["c"].toString()));
} else {
kChartCandles[kChartCandles.length - 1] = KLineEntity.fromCustom(
time: data["k"]["t"],
amount: double.parse(data["k"]["h"].toString()),
change: double.parse(data["k"]["v"].toString()),
close: double.parse(data["k"]["c"].toString()),
high: double.parse(data["k"]["h"].toString()),
low: double.parse(data["k"]["l"].toString()),
open: double.parse(data["k"]["o"].toString()),
vol: double.parse(data["k"]["v"].toString()),
ratio: double.parse(data["k"]["c"].toString()));
}
}
update();
}