问题描述
我想使用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 (将#修改为@)