f_b_kline 0.0.3+8
f_b_kline: ^0.0.3+8 copied to clipboard
Flutter has excellent neutral performance and easy access to the K line library! f_ b_ kline = flutter best kline
使用 #
持续更新中请尽量使用库依赖
DataAdapter不需要重新初始化 只需要一个adapter请做好内存管理
import 'package:f_b_kline/chart/export_k_chart.dart';
final DataAdapter adapter = DataAdapter();
......
retutrn Container(
margin: const EdgeInsets.only(top: 100),
width: double.maxFinite,
height: 400,
child: KChartWidget(
adapter,
config: KRunConfig(
dateFormatter: (int? value) {
return formatDate(
DateTime.fromMillisecondsSinceEpoch(value ?? 0));
},
mainValueFormatter: (number) {
return number?.toStringAsFixed(3) ?? '--';
},
volValueFormatter: (number) {
return number?.toStringAsFixed(3) ?? '--';
},
infoBuilder: (klineEntry) {
return <TextSpan, TextSpan>{
const TextSpan(text: 'Date'): TextSpan(
text: formatDate2(
DateTime.fromMillisecondsSinceEpoch(klineEntry.time ?? 0),
)),
const TextSpan(text: 'open'):
TextSpan(text: klineEntry.open.toStringAsFixed(3)),
const TextSpan(text: 'high'):
TextSpan(text: klineEntry.high.toStringAsFixed(3)),
const TextSpan(text: 'low'):
TextSpan(text: klineEntry.low.toStringAsFixed(3)),
const TextSpan(text: 'close'):
TextSpan(text: klineEntry.close.toStringAsFixed(3)),
const TextSpan(text: 'vol'):
TextSpan(text: klineEntry.vol.toStringAsFixed(3)),
};
},
),
),
),
)
......
adapter.resetData(data);
修改指数参数及配置信息 #
KStaticConfig 静态配置信息
...dart
...
KStaticConfig()
..mainMa1 = 10
..mainMa2 = 30
......
常用API #
///重置数据 当数据发生变化时调用
///[KLineEntity]数据模型
///更多API查看 [DataAdapter]
resetData(List<KLineEntity>? data, {bool resetTranslate = false})
///chart display type
/// [ChartGroupType] main display area
/// [ChartSenType] second type
/// [ChartDisplayType] time/kline
/// [MainDisplayType] boll / ma /none
changeType(dynamic type)
/// change chart display location
changeTranslate(double translate)