Position of g.raphael piechart legend

807 views Asked by At

I am making a dynamic pie chart and is quite new to making charts with graphael

Is it possible to make the legend go all the way to the left in this example? I am using g.raphael and g.pie.js and the legendpos is set to "south".

Is there a way to make this be southwest? Example of my current chart can be seen at the following link: Example of pie chart

2

There are 2 answers

0
Dzarek On

I had the same problem. This solution is work but is not too much flexible:

var chart = Raphael(target, target.clientWidth, target.clientHeight);
var pChart = chart.piechart(w, h, rad, values, {legend: legend, legendpos: "south", minPercent: 0.01, legendothers: "Others"});
pChart.attr({"font-size": 16, "font-family": "Arial", "cx":"280", "x":"295"});

"cx" is attribute for x-pos of dot in legend and "x" is attribute for x-pos of text in legend.

0
db306 On

The code that positions the legend in your graph is located in a file named g.pie.js , you will need to get the uncompressed version in order to edit it.

tr = {
                east: [0, -bb.height / 2],
                west: [-bb.width - 2 * r - 20, -bb.height / 2],
                north: [-r - bb.width / 2, -r - bb.height - 10],
                south: [-r - bb.width / 2, r + 10]
            }[dir];

just add a new option:

southwest: [-bb.width - 2 * r - 20,r + 10]

I tested it and it works.