如何将chartjs-chart-financial与chart js集成

问题描述

我想使用chartjs-chart-financial绘制“烛台”图表。但是,chartjs-chart-financial尚未发布到npm。我在从https://github.com/chartjs/chartjs-chart-financial复制了仓库的目录中运行npm install,后跟gulp build。构建完成后,我在dist文件夹中看到chartjs-chart-financial.js。但是,对于如何将其与基础chart.js库集成起来,我一无所知,因此可以在图表上指定type: candlestick。我还没有遇到任何可以证明这一点的例子。

由于我在React中工作,因此我目前正在使用react-chartjs-2作为chart.js的包装:

import React,{ Component } from 'react';
import Chart from '../node_modules/chart.js/dist/chart';

class Financial extends Component {
    constructor() {
        super();
        this.myRef = React.createRef();
    }

    componentDidMount() {
        const ctx = this.myRef.current;
        this.myChart = new Chart(ctx,{
            type: 'bar',data: {
                labels: ["A","B","C"],datasets: [{
                    label: 'Test',data: [12,20,15],backgroundColor: 'gray'
                }]
            }
        });
    }
    
    render() {
        return (
            <canvas ref={this.myRef}/>
        );
    }
}

export default Financial;

如您所见,我现在正在渲染类型为bar的示例图表。我希望能够使用'candlestick'类型及其关联的数据集。

我将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...