您好,我在画那个图形的时候,当我把那个单元格拉大之后,他不会按照比例变大,并且在其他单元格显示的时候会有问题。 var sheet = spread.getActiveSheet();
var spreadNS = GC.Spread.Sheets;
var CustomBase = spreadNS.CellTypes.Base;
var oldPaint = spreadNS.CellTypes.Base.prototype.paint;
// x1 相对于画布的x坐标。 y1 相对于画布的y坐标。 a1 单元格的宽度。 b1 高度
CustomBase.prototype.paint = function (context, value, x1, y1, a1, b1, style, ctx) {
if (!context) {
return;
}
if (this.showEffect) {
context.save();
let base = a1 > b1 ? b1 / 2 : a1 / 2;
context.beginPath();
context.moveTo((x1 + a1) / 1.05, y1 * 1.6);//zuo
context.lineTo((x1 + a1 - base) / 1.05, y1 * 1.6);//you
context.lineTo(((x1 + a1) * 2 - base) / (1.05 * 2), y1 * 2);//xia
context.fillStyle = 'black';
context.fill();
context.closePath();
context.restore();
}
oldPaint.apply(this, [context, value, x1, y1, a1, b1, style, ctx]);
};
var myCellType = new spreadNS.CellTypes.Text();
myCellType.showEffect = true;
// 动态添加图形,a row, b col
sheet.setCellType(a, b, myCellType);
,刚开始做,对那几个x1,y1,a1,b1,还不是很熟。,
|
|