Need some help?

I'm usually available for small jobs or problem solving with jQuery or css, at reasonable rates. Just get in touch.

Buy me a drink

If you've found this useful, particularly for commercial projects, you might consider making a small donation.

Drawing dynamic arcs with PHP

A few years ago I was managing a web project where part of the requirement was to render a coloured rainbow representing achievement against a number of dimensions. The (existing) solution used Flash to achieve this, but this caused our users a lot of issues because they (variously) had flash disabled, the wrong version etc etc

Our developers at the time had dismissed alternate versions as not possible. However, I had a little spare time one weekend and built a solution using PHP.

The code

This page is just a simple html form allowing the values to be entered as percentages. In the production system these would be calculated from a range of metrics, which I’m emulating here using the form. Then, these values are used to dynamically create the image using this PHP. The approach I’ve taken is to draw a series of concentric segments, decreasing in size, so the subsequent segments are drawn on top of the previous segments, resulting in the concentric arcs.


The demo

Here’s the result:

Rainbow chart

One response to “Drawing dynamic arcs with PHP”

  1. BRIKA says:

    Thanks, bon site

Useful? Interesting? Leave me a comment

I've yet to find a way of allowing code snippets to be pasted into Wordpress comments - so if you're trying to do this you'd be better off using the contact form.