Browse Source

Merge pull request #1101 in VISUAL/fineui from ~FAY/fineui:master to master

* commit '65a273c0253ee7d59c962d6e7a35dda0e476786a':
  CHART-10293 换成canvas测宽度
es6
guy 5 years ago
parent
commit
a5f9ddbb60
  1. 8
      src/core/platform/web/dom.js

8
src/core/platform/web/dom.js

@ -125,14 +125,16 @@
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";

Loading…
Cancel
Save