diff --git a/g.bar.js b/g.bar.js index b0834b7..2bf2935 100644 --- a/g.bar.js +++ b/g.bar.js @@ -299,7 +299,12 @@ if (j == multi - 1) { var label = paper.labelise(labels[i], tot, total); - L = paper.text(bars[i * (multi || 1) + j].x, y + height - barvgutter / 2, label).attr(txtattr).insertBefore(covers[i * (multi || 1) + j]); + if (opts.cufont) { + L = paper.print(bars[j][i].x, y + height - barvgutter / 2, label, opts.cufont); + } else { + L = paper.text(bars[j][i].x, y + height - barvgutter / 2, label).attr({ "text-anchor": "start" }); + } + L.attr(chartinst.txtattr).attr({ fill: opts.legendcolor || "#000" }).insertBefore(covers[i * (multi || 1) + j]); var bb = L.getBBox(); @@ -317,10 +322,19 @@ for (var j = 0; j < (multi || 1); j++) { var label = paper.labelise(multi ? labels[j] && labels[j][i] : labels[i], multi ? values[j][i] : values[i], total); - L = paper.text(bars[i * (multi || 1) + j].x, isBottom ? y + height - barvgutter / 2 : bars[i * (multi || 1) + j].y - 10, label).attr(txtattr).insertBefore(covers[i * (multi || 1) + j]); + if (opts.cufont) { + L = paper.print(bars[j][i].x, isBottom ? y + height - barvgutter / 2 : bars[j][i].y - 10, label, opts.cufont); + } else { + L = paper.text(bars[j][i].x, isBottom ? y + height - barvgutter / 2 : bars[j][i].y - 10, label).attr({ "text-anchor": "middle" }); + } + L.attr(chartinst.txtattr).attr({ fill: opts.legendcolor || "#000" }).insertBefore(covers[i * (multi || 1) + j]); var bb = L.getBBox(); + if (opts.cufont) { + L.translate(-bb.width/2, 0); + } + if (bb.x - 7 < l) { L.remove(); } else { @@ -537,7 +551,12 @@ A = isRight ? "end" : "start", L; - this.labels.push(L = paper.text(X, bars[i * (multi || 1) + j].y, label).attr(txtattr).attr({ "text-anchor": A }).insertBefore(covers[0])); + if (opts.cufon) { + L = paper.print(X, bars[j][i].y, label, opts.cufont); + } else { + L = paper.text(X, bars[j][i].y, label).attr({ "text-anchor": "start" }); + } + this.labels.push(L.attr(chartinst.txtattr).attr({ fill: opts.legendcolor || "#000" }).insertBefore(covers[0])); if (L.getBBox().x < x + 5) { L.attr({x: x + 5, "text-anchor": "start"}); diff --git a/g.pie.js b/g.pie.js index df2afb3..d6442f5 100644 --- a/g.pie.js +++ b/g.pie.js @@ -214,7 +214,12 @@ labels[j] = chartinst.labelise(labels[j], values[i], total); chart.labels.push(paper.set()); chart.labels[i].push(paper[mark](x + 5, h, 5).attr({ fill: clr, stroke: "none" })); - chart.labels[i].push(txt = paper.text(x + 20, h, labels[j] || values[j]).attr(chartinst.txtattr).attr({ fill: opts.legendcolor || "#000", "text-anchor": "start"})); + if (opts.cufont) { + txt = paper.print(x + 20, h, labels[j] || values[j], opts.cufont); + } else { + txt = paper.text(x + 20, h, labels[j] || values[j]).attr({ "text-anchor": "start" }); + } + chart.labels[i].push(txt.attr(chartinst.txtattr).attr({ fill: opts.legendcolor || "#000" })); covers[i].label = chart.labels[i]; h += txt.getBBox().height * 1.2; } diff --git a/g.raphael.js b/g.raphael.js index f49ffb5..efac102 100644 --- a/g.raphael.js +++ b/g.raphael.js @@ -44,15 +44,13 @@ Raphael.el.popup = function (dir, size, x, y) { dir = dir == null ? 'up' : dir; size = size || 5; bb = this.getBBox(); + bb.x = bb.x2-bb.width; bb.y = bb.y2-bb.height; x = typeof x == 'number' ? x : (center ? bb.x + bb.width / 2 : bb.x); y = typeof y == 'number' ? y : (center ? bb.y + bb.height / 2 : bb.y); cw = Math.max(bb.width / 2 - size, 0); ch = Math.max(bb.height / 2 - size, 0); - this.translate(x - bb.x - (center ? bb.width / 2 : 0), y - bb.y - (center ? bb.height / 2 : 0)); - bb = this.getBBox(); - var paths = { up: [ 'M', x, y,