Fix #5752 - text changes and word document fixes
authorEdward <edward@roojs.com>
Mon, 25 Feb 2019 05:26:32 +0000 (13:26 +0800)
committerEdward <edward@roojs.com>
Mon, 25 Feb 2019 05:26:32 +0000 (13:26 +0800)
g.bar.overlay.js
g.pie.sector.js

index 6ae0cfc..d61c217 100644 (file)
@@ -73,10 +73,12 @@ if (typeof(Raphael) == 'undefined') {
             
         
         opts.axis = opts.axis || "";
-        opts.baroffset = opts.baroffset || 50;
+        opts.baroffset = opts.baroffset || 10;
         opts.asixxheight = opts.asixxheight || 100;
         opts.asixywidth = opts.asixywidth || 100;
         opts.axisxlabels = opts.axisxlabels || [];
+        opts.legendheight = opts.legendheight || 80;
+        opts.legends = opts.legends || 100;
         
         // background
         paper.rect(0, 0, width, height).attr({ stroke: "none", fill: (opts.background || "#F0F4F7") });
@@ -84,11 +86,11 @@ if (typeof(Raphael) == 'undefined') {
         
         // bar border
         var barwidth = Math.floor((width - x - opts.asixywidth - opts.baroffset) / barsteps);
-        var barheight = height - y - opts.asixxheight || 100;
-        var path = ["M", x + 1, y, "l", 0, barheight]
+        var barheight = height - y - opts.asixxheight - opts.legendheight || 100;
+        var path = ["M", x + 1, y + opts.legendheight, "l", 0, barheight]
         
         for (var i = 0; i < barsteps; i++) {
-            path = path.concat(["M", x + (i * barwidth), y + 1, "l", barwidth, 0, "l", 0, barheight]);
+            path = path.concat(["M", x + (i * barwidth), y + opts.legendheight + 1, "l", barwidth, 0, "l", 0, barheight]);
         }
         
         paper.path(path).attr({ stroke: "#fff", "stroke-width": 2 });
@@ -106,30 +108,54 @@ if (typeof(Raphael) == 'undefined') {
             
         });
         
+        values.forEach(function(value,i) {
+            if (!Raphael.is(value, "array")) {
+                value = [value];
+            }
+            
+            paper.circle(x + (i * 400) + 8, y + 10, 8).attr({ fill: colors[i%colors.length], "stroke": "#fff" });
+            
+            paper.text(x + (i * 400) + 18, y + 8, opts.legends[i%opts.legends.length]).attr({ 
+                "font-size": "14",
+                "font-family": "'Fontin Sans', Fontin-Sans, sans-serif",
+                "font-weight": "bold",
+                "text-anchor": "start",
+                fill : "#0C014D"
+            });
+        });
+        
         //bars
         var unit = barheight / max;
-        var indicator = [];
+        
         values.forEach(function(value,i) {
-            if (!Raphael.is(values[0], "array")) {
+            if (!Raphael.is(values, "array")) {
                 value = [value];
             }
-    
+            
             value.forEach(function(v,k)  {
-                paper.rect(x + 1 + (k * barwidth) , y + (max - v) * unit, barwidth - 2, v * unit).attr({ stroke: "none", fill: colors[i%colors.length] });
-                paper.rect(x + 1 + (k * barwidth) + barwidth / 4 , y + (max - v) * unit - 42, barwidth / 2, 30, 5).attr({ stroke: "none", fill: "#0C014D" });
-                indicator = indicator.concat(["M", x + 1 + (k * barwidth) + barwidth / 4 + 10, y + (max - v) * unit - 12, "l", 5, 10, "l", 5, -10]);
-                paper.text(x + 1 + (k * barwidth) + barwidth / 2, y + (max - v)  * unit - 28, Roo.util.Format.number(v, 0)).attr({ 
+                if(v == 0) {
+                    return;
+                }
+                
+                paper.rect(x + 1 + (k * barwidth) , y + opts.legendheight + 1 + (max - v) * unit, barwidth - 2, v * unit).attr({ stroke: "none", fill: colors[i%colors.length] });
+                
+                var indicator_y = y + opts.legendheight + (max - v) * unit - 42;
+                
+                if(i == 0) {
+                    indicator_y = y + opts.legendheight - 42;
+                }
+                
+                paper.rect(x + 1 + (k * barwidth) + 8 , indicator_y, barwidth - 16, 30, 5).attr({ stroke: "none", fill: colors[i%colors.length] });
+                paper.path(["M", x + 1 + (k * barwidth) + barwidth / 4 + 10, indicator_y + 30, "l", 5, 10, "l", 5, -10]).attr({ stroke: "none", fill: colors[i%colors.length] });
+                paper.text(x + 1 + (k * barwidth) + barwidth / 2, indicator_y + 14, Roo.util.Format.number(v, 0)).attr({ 
                     "font-size": "16",
                     "font-family": "'Fontin Sans', Fontin-Sans, sans-serif",
                     "font-weight": "bold",
                     fill : "#fff"
                 });
             });
-            
         });
         
-        paper.path(indicator).attr({ stroke: "none", fill: "#0C014D" });
-        
         var ax = (opts.axis + "").split(/[,\s]+/),
             axis = paper.set();
         
@@ -138,7 +164,7 @@ if (typeof(Raphael) == 'undefined') {
             chartinst.rightAxis(
                 width - opts.asixywidth,
                 height - opts.asixxheight,
-                height - y - opts.asixxheight,
+                height - y - opts.asixxheight - opts.legendheight,
                 max,
                 opts.axisystep || 10,
                 opts.asixywidth,
@@ -175,7 +201,7 @@ if (typeof(Raphael) == 'undefined') {
         return new MVBarchart(this, x, y, width, height, values, opts);
     };
     
-    MVBarchart.prototype.rightAxis = function (x, y, length, max, steps, ewidth, paper)
+    MVBarchart.prototype.rightAxis = function (x, y, length, max, steps, asixxheight, paper)
     {
 //        Roo.log('Right Axis');
 //        Roo.log([x, y, length, max, steps, ewidth]);
@@ -193,14 +219,14 @@ if (typeof(Raphael) == 'undefined') {
         for(var i = 0; i <= steps; i++) {
             
             if(i != 0) {
-                paper.text(x + (ewidth / 2), Y + 15, label).attr({ 
+                paper.text(x + (asixxheight / 2), Y + 15, label).attr({ 
                     "font-size": "20",
                     "font-family": "'Fontin Sans', Fontin-Sans, sans-serif",
                     "font-weight": "bold",
                     "text-anchor": "end",
                     fill : color
                 });
-                path = path.concat(["M", x, Y, "l", (ewidth / 2), 0]);
+                path = path.concat(["M", x, Y, "l", (asixxheight / 2), 0]);
                 
             }
             
index 5b60526..9f7deb7 100644 (file)
@@ -109,7 +109,7 @@ Roo = typeof(Roo) != 'undefined' ? Roo:  (imports ? imports.seed.Roo.Roo: {});
         
         for (var i = 0; i < len; i++) {
             
-            paper.circle(ix, iy, 6).attr({ fill: opts.colors && opts.colors[i] || chartinst.colors[i] || "#3E66BC" });
+            paper.circle(ix, iy, 6).attr({ fill: opts.colors && opts.colors[i] || chartinst.colors[i] || "#3E66BC", "stroke": "#fff" });
             
             var text = (values[i].others) ? opts.others : opts.legend[i] || values[i];