options as $option) $total_votes += $option->votes; $options_percentages = []; foreach ($poll->options as $option) $options_percentages[] = $option->votes / $total_votes; function percentage_pos_x($r, $percentage) { return round($r * sin(2 * M_PI * $percentage), 2); } function percentage_pos_y($r, $percentage) { return -1*round($r * cos(2 * M_PI * $percentage), 2); } //TODO Improve by showing values in the colors. ?> options as $index => $option): ?> 0 0.5 ? 1 : 0) ?> 1 L0 0" fill="">