Skip to content

🛠️ 从 V8 到 V9

本文档将帮助你从 klinecharts 8.x 版本升级到 klinecharts 9.x 版本,如果你是 7.x 或者更老的版本,请先参考之前的升级文档升级到 8.x。

引入调整

不再区分klinecharts/index.blankklinecharts/index.simple,请统一使用import { ... } from 'klinecharts'

设计调整

shapeannotationtag合并成overlay,详情请查阅覆盖物

样式配置调整

  • 所有线的样式选项dash,更改为dasheddashValue更改为dashedValue
  • candle.tooltip.labelscandle.tooltip.values,合并为candle.tooltip.custom
  • xAxis.height变更为xAxis.sizexAxis.tickText.paddingTop变更为xAxis.tickText.marginStartxAxis.tickText.paddingBottom变更为xAxis.tickText.marginEnd
  • yAxis.height变更为yAxis.sizeyAxis.tickText.paddingTop变更为yAxis.tickText.marginStartyAxis.tickText.paddingBottom变更为yAxis.tickText.marginEnd
  • technicalIndicator.bar变更为indicator.barstechnicalIndicator.line变更为indicator.linestechnicalIndicator.circle变更为indicator.circles
  • 删除shapeannotationtag,请用overlay代替。

API调整

图表API

  • extension.addTechnicalIndicatorTemplate(template)变更为registerIndicator(template)
  • 删除extension.addShapeTemplate(template),请用registerOverlay(template)代替。

实例API

  • getDom({ paneId, position })变更为getDom(paneId, position),参数position选项变更为rootmainyAxis
  • getWidth()getHeight()合并成一个方法getSize(paneId, position)
  • setStyleOptions(styles)变更为setStyles(styles)
  • getStyleOptions()变更为getStyles()
  • setOffsetRightSpace(space)变更为setOffsetRightDistance(distance)
  • createTechnicalIndicator(value, isStack, paneOptions)变更为createIndicator(value, isStack, paneOptions)
  • overrideTechnicalIndicator(override, paneId)变更为overrideIndicator(override, paneId)
  • getTechnicalIndicatorByPaneId(paneId, name)变更为getIndicatorByPaneId(paneId, name)
  • removeTechnicalIndicator(paneId, name)变更为removeIndicator(paneId, name)
  • subscribeAction(type, callback)unsubscribeAction(type, callback),参数type选项变更为onZoomonScrollonCrosshairChangeonVisibleRangeChangeonPaneDrag
  • convertToPixel(value, finder)convertFromPixel(coordinate, finder),参数finder.absoluteYAxis变更为finder.absolute
  • 删除createShape(value, paneId)createAnnotation(annotation, paneId)createTag(tag, paneId),请用createOverlay(value, paneId)代替。
  • 删除removeShape(id)removeAnnotation(paneId, points)removeTag(paneId, tagId),请用removeOverlay(id)代替。
  • 删除setShapeOptions(options),请用overrideOverlay(override)代替。
  • 删除createHtml(html, paneId)removeHtml(paneId, htmlId),请通过getDom(paneId, position)获取到对应的dom后操作。
  • 删除getTechnicalIndicatorByPaneId(paneId, name)

图形辅助API

  • 所有的API都迁移至klinecharts.utils

自定义技术指标调整

  • 属性plots变更为figures,子项方法colorisStrokeisDashed合并成styles
  • 方法regeneratePlots(params)变更为regenerateFigures(params)
  • 方法calcTechnicalIndicator(kLineDataList, options)变更为calc(kLineDataList, indicator)
  • 方法createTooltipDataSource({ dataSource, viewport, crosshair, technicalIndicator, xAxis,yAxis, defaultStyles })变更为createTooltipDataSource({ kLineDataList, indicator, visibleRange, bounding, crosshair, defaultStyles, xAxis, yAxis }),返回值由[{ title: 'xxx', value: 'xxx', color: 'xxx' }, ...]变更为{ name: 'xxx', calcParamsText: 'xxx', values: [{ title: 'xxx', value: 'xxx', color: 'xxx' }, ...] }
  • 方法render({ ctx, dataSource, viewport, styles,xAxis, yAxis })变更为draw({ ctx, kLineDataList, indicator, visibleRange, bounding, barSpace, defaultStyles, xAxis, yAxis })
  • 删除属性shouldCheckParamCount