Flutter_k_chart 一个仿火币的flutter图表库包含深度图,支持各种指标及放大缩小、平移等操作

Overview

flutter_k_chart

License

介绍

一个仿火币的flutter图表库包含深度图,支持各种指标及放大缩小、平移等操作

webdemo演示 Demo v0.1.0:下载 APK

演示

chart_imge depth_image image1

简单用例

1.在 pubspec.yaml 中添加依赖

本项目数据来自火币openApi,火币的接口可能需要翻墙,接口失败后会加载本地json。由于项目没有很好的封装,建议使用本地方式使用

//本地导入方式
dependencies:
  flutter_k_chart:
    path: 项目路径

2.在布局文件中添加

import 'package:flutter_k_chart/flutter_k_chart.dart';
....
Container(
  height: 450,
  width: double.infinity,
  child: KChartWidget(
    datas,//数据
    isLine: isLine,//是否显示折线图
    mainState: _mainState,//控制主视图指标线
    secondaryState: _secondaryState,//控制副视图指标线
    volState: VolState.VOL,//控制成交量指标线
    fractionDigits: 4,//保留小数位数
  ),
 )
 
 //深度图使用
 Container(
   height: 230,
   width: double.infinity,
   child: DepthChart(_bids, _asks),
 )         

3.修改样式

可在chart_style.dart里面修改图表样式

4.数据处理

//接口获取数据后,计算数据
DataUtil.calculate(datas);
//更新最后一条数据
DataUtil.updateLastData(datas);
//添加数据
DataUtil.addLastData(datas,kLineEntity);

国际化 l10n

import 'package:flutter_k_chart/generated/l10n.dart' as k_chart;
MaterialApp(
      localizationsDelegates: [
        k_chart.S.delegate//国际化
      ],
);

5.修改日志

问题

使用中如果有问题可以加QQ群:114563912

请咖啡 ☕️

🙏 感谢 🙏

微信

You might also like...
Comments
  • Failed assertion: line 21 pos 12: '_current != null'

    Failed assertion: line 21 pos 12: '_current != null'

    Hy guys,

    How to resolve this issue?

    ======== Exception caught by widgets library ======================================================= The following assertion was thrown building Container(constraints: BoxConstraints(w=Infinity, h=450.0), margin: EdgeInsets(10.0, 0.0, 10.0, 0.0)): No instance of S was loaded. Try to initialize the S delegate before accessing S.current. 'package:flutter_k_chart/generated/l10n.dart': Failed assertion: line 21 pos 12: '_current != null'

    opened by monxarat 2
  • 计算BOLL,为什么要判断 < 19

    计算BOLL,为什么要判断 < 19

    static void calcBOLL(List dataList) { for (int i = 0; i < dataList.length; i++) { KLineEntity entity = dataList[i]; if (i < 19) { entity.mb = 0; entity.up = 0; entity.dn = 0; } else { int n = 20; double md = 0; for (int j = i - n + 1; j <= i; j++) { double c = dataList[j].close; double m = entity.MA20Price; double value = c - m; md += value * value; } md = md / (n - 1); md = sqrt(md); entity.mb = entity.MA20Price; entity.up = entity.mb + 2.0 * md; entity.dn = entity.mb - 2.0 * md; } } } 为什么要判断 i< 19?

    opened by deboLing 2
Owner
gwh
gwh