Things i've made

Looking for more? See a list of everything i've made.

Wednesday, June 22, 2011

Gtk Chart Annotations

If you haven't already seen, I wrote a charting widget for Gtk/Cairo. Over the last fews days I have been adding annotations into the package. Annotations allow you to add arbitrary lines, circles, stars, images, text, etc to a chart. Annotations can be used to add non-data information to a chart like trend lines, and resistance and support, or, you can add purely visual elements like images to enhance the readability of the chart.

Annotations on a chart
The initial annotations implemented include:

  • Horizontal and vertical lines
  • Box, Circle, and Star
  • Value Tag - similar to an end marker
  • Text with arbitrary rotation
  • Images
You could be asking yourself what the difference is between annotations and just drawing on the chart canvas. Well, the most important and obvious difference is that annotations can be defined in chart space. That is, you can add an annotation at a given x,y coordinate on X and Y axis and the chart will draw it in the correct location regardless of zoom, changes to data, changes to axis, and so on. Alternatively it is possible to specify locations in pixel coordinates instead of data coordinates.

The "tag" annotation looks identical to an end marker and can appear on the axis, just like an end marker, or appear anywhere within the plot. This allows you to highlight specific Y values or x,y coordinates on a chart.

Most annotations allow customization of line color, width, pattern, fill color, transparency, basically enough to give you a few options when you want to capture some aspect of a chart.

1 comment:

Note: Only a member of this blog may post a comment.