用KLineChart绘制股票行情K线图
- 先看效果
- 集成过程
- 集成到系统
先看效果
用klinechart开源代码集成到系统中,展示的K线图效果。
集成过程
KlineChart源码地址:
https://github.com/klinecharts/KLineChart
KlineChart提供了多种行情分析指标
集成到系统
/** @odoo-module **/import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import {Component, onMounted, onWillStart} from "@odoo/owl";export class KlineChartReport extends Component {static template = "quantization_base.KlineChartReport";setup() {this.orm = useService("orm");this.actionService = useService("action");this.kline_data_list = this.props.action.kline_data_list || [];onMounted(this._renderKlineChart);}_renderKlineChart () {var chart = klinecharts.init('kline_chart_1');chart.setPriceVolumePrecision(4, 4)chart.applyNewData(this.generated(), true)}generated () {return this.kline_data_list.map(function (data) {return {timestamp: new Date(data[0]).getTime(),open: +data[1],high: +data[2],low: +data[3],close: +data[4],volume: Math.ceil(+data[5])}})}
}