Explorar o código

造价对比,画图方法调整

MaiXinRong %!s(int64=2) %!d(string=hai) anos
pai
achega
bb97b7938b
Modificáronse 1 ficheiros con 13 adicións e 8 borrados
  1. 13 8
      app/public/js/spreadjs_rela/spreadjs_zh.js

+ 13 - 8
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -2549,16 +2549,17 @@ const SpreadJsObj = {
              */
             // roundRect方法在Chrome99版本以后才支持
             const drawBarBefore99 = function (canvas, x, y, w, h, r, color) {
+                const rArr = r instanceof Array ? r : [r, r, r, r];
                 canvas.save();
                 // 设置偏移量
                 canvas.translate(0.5, 0.5);
                 canvas.strokeStyle = color;
                 canvas.beginPath();
-                canvas.moveTo(x+r, y);
-                canvas.arcTo(x+w, y, x+w, y+h, r);
-                canvas.arcTo(x+w, y+h, x, y+h, r);
-                canvas.arcTo(x, y+h, x, y, r);
-                canvas.arcTo(x, y, x+w, y, r);
+                canvas.moveTo(x+rArr[0], y);
+                canvas.arcTo(x+w, y, x+w, y+h, Math.min(rArr[1], w));
+                canvas.arcTo(x+w, y+h, x, y+h, Math.min(rArr[2], w));
+                canvas.arcTo(x, y+h, x, y, Math.min(rArr[3], w));
+                canvas.arcTo(x, y, x+w, y, Math.min(rArr[0], w));
                 canvas.stroke();
                 canvas.fillStyle = color;
                 canvas.fill();
@@ -2576,8 +2577,7 @@ const SpreadJsObj = {
                 canvas.fill();
                 canvas.restore();
             };
-            const drawSB = function (canvas, x, y, w, h, color) {
-                const r = ZhCalc.div(h, 2, 2);
+            const drawSB = function (canvas, x, y, w, h, r, color) {
                 canvas.save();
                 // 设置偏移量
                 canvas.translate(0.5, 0.5);
@@ -2631,7 +2631,12 @@ const SpreadJsObj = {
                     if (width < defaultR) continue;
                     const top = col.stackedBarCover ? startTop : startTop + height * i + i - 1;
                     //drawBarBefore99(canvas, left, top, width, height, ZhCalc.mul(height, defaultR, 2), bd.color);
-                    drawSB(canvas, left, top, width, height, bd.color);
+                    //drawBarBefore99(canvas, left, top, width, height, [0, 0, ZhCalc.div(height, 2, 2), 0], bd.color);
+                    if (col.stackedBarCover) {
+                        drawSB(canvas, left, top, width, height, ZhCalc.div(height, 2, 2), bd.color);
+                    } else {
+                        drawBarBefore99(canvas, left, top, width, height, ZhCalc.mul(height, defaultR, 2), bd.color);
+                    }
                 }
             };