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") });
// 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 });
});
+ 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();
chartinst.rightAxis(
width - opts.asixywidth,
height - opts.asixxheight,
- height - y - opts.asixxheight,
+ height - y - opts.asixxheight - opts.legendheight,
max,
opts.axisystep || 10,
opts.asixywidth,
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]);
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]);
}