如何使用数百个点绘制股票图或折线图?我已禁用常规折线图中的动画,但仍然过于沉重和缓慢。
如何使用数百个点绘制股票图或折线图?我已禁用常规折线图中的动画,但仍然过于沉重和缓慢。
Ext.define('cci.view.wavemon.Flot', {
extend: 'Ext.Component',
alias: 'widget.cci-flot',
/**
* @cfg {number[][]} data The data to be drawn when it gets rendered
*/
data: null,
/**
* @cfg {object} flotOptions
* The options to be passed in to $.plot
*/
flotOptions: null,
/**
* @property
* The Flot object used to render the chart and to manipulate it in the future. It will only
* be available after the first resize event
* You may not set this property but you are free to call methods on it
*/
flot: null,
initComponent: function() {
this.callParent(arguments);
// The only time that we're guaranteed to have dimensions is after the first resize event
this.on('resize', function(comp) {
if (!this.flot) {
this.flot = $.plot(this.getTargetEl().dom, this.data, this.flotOptions);
} else {
// Flot knows to look at the containers size and resize itself
this.flot.resize();
}
}, this);
}
});
这里有一个完整的示例,介绍如何为Sencha Charts创建股票折线图:
http://dev.sencha.com/deploy/touch-charts-1.0.0/examples/Stock/
正如您所见,该示例轻松处理了超过100个数据点。
该示例是针对触摸图表的,但API与Sencha的ExtJS 4几乎相同。复制并粘贴图表实例化代码即可完成工作。