提交 7e3eb92d 编写于 作者: L lang

Add echarts.setCanvasCreator for node environment

上级 692d81a6
......@@ -915,6 +915,26 @@ define(function (require) {
return ComponentView.extend(opts);
};
/**
* ZRender need a canvas context to do measureText.
* But in node environment canvas may be created by node-canvas.
* So we need to specify how to create a canvas instead of using document.createElement('canvas')
*
* Be careful of using it in the browser.
*
* @param {Function} creator
* @example
* var Canvas = require('canvas');
* var echarts = require('echarts');
* echarts.setCanvasCreator(function () {
* // Small size is enough.
* return new Canvas(32, 32);
* });
*/
echarts.setCanvasCreator = function (creator) {
zrUtil.createCanvas = creator;
};
echarts.registerVisualCoding('echarts', require('./visual/seriesColor'));
echarts.registerPreprocessor(require('./preprocessor/backwardCompat'));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册