/KLineChart

📈Lightweight k-line chart built with html5 canvas . Zero dependencies. Support mobile(基于html5 canvas的轻量级k线图,无第三方依赖,支持移动端).

Primary LanguageJavaScriptMIT LicenseMIT

KLineChart(English|中文)

npm version Build Status Codacy Badge size types License

📈Lightweight k-line chart built with html5 canvas. Support technical indicator and parameter setting, support for graphic markup, custom style.

Browser Support

The chart is based on canvas. In theory, as long as it supports canvas, it is the same on mobile.

Installing

Using npm:

$ npm install klinecharts

Using yarn:

$ yarn add klinecharts

API

klinecharts

klinecharts.init(document.getElementById('divDomId'))
klinecharts.dispose(document.getElementById('divDomId'))
klinecharts.version()

klinecharts instance

setStyleOptions(options)
getStyleOptions()
setTechnicalIndicatorParams(technicalIndicatorType, params)
getTechnicalIndicatorParamOptions()
setPrecision(pricePrecision, volumePrecision)
setTimezone(timezone)
resize()
setOffsetRightSpace(space)
setDataSpace(space)
clearData()
getDataList()
applyNewData(dataList, more)
applyMoreData(dataList, more)
updateData(data)
loadMore(cb)
setCandleStickChartType(chartType)
setCandleStickTechnicalIndicatorType(technicalIndicatorType)
setTechnicalIndicatorType(tag, technicalIndicatorType)
addTechnicalIndicator(technicalIndicatorType, height)
removeTechnicalIndicator(tag)
addGraphicMark(graphicMarkType)
removeAllGraphicMark()
getConvertPictureUrl(includeFloatLayer, includeGraphicMark, type)

Data Source

Data source requires KLineData array.

The single data format is as follows:

{ open, close, high, low, volume, turnover, timestamp }

Style Config

Used to configure the style of the chart. Here is the details.

Technical Indicator

type MA VOL MACD BOLL KDJ
params [5,10,30,60] [5,10,20] [12,26,9] [20] [9,3,3]
type RSI BIAS BRAR CCI DMI
params [6,12,24] [6,12,24] [26] [13] [14,6]
type CR PSY DMA TRIX OBV
params [26,10,20,40,60] [12] [10,50,10] [12,20] [30]
type VR WR MTM EMV SAR
params [24,30] [13,34,89] [6,10] [14,9] [2,2,20]

Graphic Mark

  • Horizontal straight line
  • Vertical straight line
  • Straight line
  • Parallel straight line
  • Horizontal ray
  • Vertical ray
  • Ray
  • Horizontal line segment
  • Vertical line segment
  • Line segment
  • Price line
  • Price channel line
  • Fibonacci line

Hot Key

  • shift + ← can be used to shift left.
  • shift + → can be used to shift right.
  • shift + ↑ can be used to zoom out.
  • shift + ↓ can be used to zoom in.

Samples

https://liihuu.github.io/kline

License

MIT