QGIS Charts – Plotting Pie-Chart Coordinates in QGIS

chart;qgis

I have a map of a region and I am plotting pie-charts (as diagrams) over every country in that region in QGIS (1.9.0). I also need to connect those pie-charts with lines (which I am creating in the Mapping Toolbox of MATLAB as a separate shapefile).

Can you please tell me if there is a way of knowing in advance what coordinates of a country QGIS shows its pie-chart at? Also, can I capture those coordinates automatically (even before the pie-charts are drawn) just as I would normally do using the Coordinate Capture plugin? That way, I can create the lines from one point to another before even plotting the pie-charts.

Best Answer

QGIS uses the PAL library to determine the "best" diagram position, which places diagrams, based on render context information such as DPI, zoom level...

To get diagrams to render at the same place every time, you can either use the placement method "Over Point" which will always put the diagrams over the centroid of the polygon.

enter image description here

Or you can specify the place, where you want to put the diagram yourself with "Data defined position" using attributes.

enter image description here

I don't think there is a way to dynamically intercept the (PAL-calculated) diagram position before they are drawn in order to adjust your line nodes.

Hint: To manually define x and y attributes for placement, you can first "prepare" them with labels. Label your layer with whatever attribute and enable data defined placement. Then use the "move label" tool to position your labels, wherever you would like to have the diagrams placed. Now disable labeling and enable diagrams with data defined placement.