MCPcopy Create free account
hub / github.com/MapServer/MapServer / msDrawPieChart

Function msDrawPieChart

mapchart.c:219–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219int msDrawPieChart(mapObj *map, imageObj *image,
220 pointObj *center, float diameter,
221 float *values, styleObj **styles, int numvalues)
222{
223 int i;
224 double dTotal=0.,start=0;
225
226 for(i=0;i<numvalues;i++)
227 {
228 if(values[i]<0.) {
229 msSetError(MS_MISCERR, "cannot draw pie charts for negative values", "msDrawPieChart()");
230 return MS_FAILURE;
231 }
232 dTotal+=values[i];
233 }
234
235 for(i=0; i < numvalues; i++)
236 {
237 float angle = values[i];
238 if(angle==0) continue; /*no need to draw. causes artifacts with outlines*/
239 angle*=360.0/dTotal;
240 msDrawPieSlice(&map->symbolset,image, center, styles[i], diameter/2., start, start+angle);
241
242 start+=angle;
243 }
244 return MS_SUCCESS;
245}
246
247int getNextShape(mapObj *map, layerObj *layer, float *values, styleObj **styles, shapeObj *shape) {
248 int status;

Callers 1

msDrawPieChartLayerFunction · 0.85

Calls 2

msSetErrorFunction · 0.85
msDrawPieSliceFunction · 0.85

Tested by

no test coverage detected