- static double angle=0.0;
-
- const double segment_angle =
- slices[i].magnetude / total_magnetude * 2 * M_PI ;
-
- const double label_x = centre_x -
- radius * sin(angle + segment_angle/2.0);
-
- const double label_y = centre_y +
- radius * cos(angle + segment_angle/2.0);
-
- /* Fill the segment */
- draw_segment(ch,
- centre_x, centre_y, radius,
- angle, segment_angle,
- data_colour[i % N_CHART_COLOURS]);
-
- /* Now add the labels */
- if ( label_x < centre_x )
- {
- pl_line_r(ch->lp, label_x, label_y,
- left_label, label_y );
- pl_moverel_r(ch->lp,0,5);
- pl_alabel_r (ch->lp, 0, 0, ds_cstr (&slices[i].label));
- }
- else
- {
- pl_line_r(ch->lp,
- label_x, label_y,
- right_label, label_y
- );
- pl_moverel_r(ch->lp,0,5);
- pl_alabel_r (ch->lp, 'r', 0, ds_cstr (&slices[i].label));
- }
-
- angle += segment_angle;