Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trade-chart.js

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trade-chart.js

一个交易图表插件,支持分时图,蜡烛图,二元期权

  • 1.1.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
2
Weekly downloads
 
Created
Source

trade-chart.js 文档

一个轻量级的交易图表,基于 canvas 搭建,支持基础 K 线:分时图,蜡烛图,支持二元期权图表

引入

import TradeChart from 'trade-chart.js';
import 'trade-chart.js/dist/built.css';

使用

const chart = new TradeChart(option);

配置

配置名称配置说明可选值类型
mode模式pc,mobilestring
originalWidth画布初始宽度/number
originalHeight画布初始高度/number
cPadding坐标轴距与画布边的距离/number
data历史行情数据{ close: number; high: number; low: number; open: number }object
container图表容器 id/string
priceDigitnumber保留的小数位数/number
tSpace字体间距/number
interval周期1m,5m,15m,30m,1h,1dstring
legendColor图例颜色/string
axisColor坐标轴颜色/string
downColor跌的颜色/string
upColor涨的颜色/string
chartType图表类型,暂支持分时图、蜡烛图line,candlestring
yAxisDirectionY 坐标轴的摆放位置left,rightstring
chartSeries图表系列,暂支持二元期权图和普通行情图option,normalstring
optionConf二元期权图表的配置详情见二元期权图表的配置object
loadMoreCallback图表分页加载更多的回调函数/function
timeCheckErrorHandler时间检查失败的处理/function

二元期权的专属配置

配置名称配置说明可选值类型
purchaseTime购买时间/number
deliveryTime交割时间/number

配置示例

let option = {
  mode: 'pc', //模式,现有mobile和pc
  originalWidth: 400, //画布宽度
  originalHeight: 300, //画布高度
  cPadding: 5,
  data: this.bars,
  container: 'chart_container',
  priceDigitnumber: this.priceDigitNumber,
  tSpace: 30, //字体间距
  interval: this.option.interval || '1m',
  legendColor: '#858ea1',
  axisColor: '#141B36',
  downColor: '#e81d5a',
  upColor: '#03a478',
  chartType: this.option.chartType || 'line',
  yAxisDirection: 'right',
  chartSeries: 'option',
  optionConf: {
    purchaseTime: 50,
    deliveryTime: 10
  },
  loadMoreCallback: () => {
    console.log('加载下一页');
  },
  timeCheckErrorHandler: () => {
    conosle.log('服务器响应超时');
  }
};

API

chart.subscribeBars(time,close)

订阅数据,传入两个值,当前时间和当前收盘价,每次收到新数据都需要执行一次.

chart.mark(status)

二元期权图专属,下单时调用,传入状态,看涨为"up",看跌为"down".

Keywords

FAQs

Package last updated on 02 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc