Carl Worth [Thu, 7 Nov 2013 21:24:30 +0000 (13:24 -0800)]
Add support for a new TIMELINE style for drawing a data-set.
For the TIMELINE style, each (X,Y) pair represents (start,stop) time
in the X dimension for a timeline bar to be drawn. The recently added
"_named" variant of add_data is also useful for supplying a name to be
drawn on the bar.
With multiple timelines within a chart, each one is positioned at a
different integer position along the Y axis, (and the Y axis range
computation is changed to preserve this).
There's only minimal cleverness to avoid collision of timeline label,
(the vertical position is cycled unconditionally).
More clever approaches would not change the vertical position if there
is no possibility of conflict, and would also reset to the top
position as soon as possible.
Other potential improvements to the TIMELINE style include:
* Ensuring that a timeline label is visible whenever any portion of
a timeline bar is visible.
* Eliminating the rendering of numbers and ticks on the Y axis.
Carl Worth [Thu, 7 Nov 2013 21:22:00 +0000 (13:22 -0800)]
Force an identity matrix when creating a pango layout
I've been seeing strange effects in the font rendering when zooming in
dramatically. Inter-character and inter-word spacing was becoming
radically large or radically close to zero, (with overlapping
characters, etc.).
I assume the problem has something to do with numbers outside the
representable range of Pango's fixed-width implementation, (see "pango
units"). Simply setting an identity matrix before creating the layout
and selecting the font clears up all problems that I have seen so far.
Carl Worth [Thu, 7 Nov 2013 21:19:39 +0000 (13:19 -0800)]
Fix 0.0 value on axis to be 0.0.
I recently saw cases where the %g format was cauing a value that
should be 0.0 on the axis to appear as something insane like 5.58e-17.
If the value is within a thousandth of a sub-step, (a sub-step is the
space between two minor ticks on the axis), of 0.0 then force it to be
truly 0.0.
Carl Worth [Thu, 7 Nov 2013 21:14:56 +0000 (13:14 -0800)]
acre-x: Fix zooming so that zoom-in and zoom-out use the same amounts
The intent was always that one zoom-in followed by one zoom-out, (or
vice versa) would lead to the original zoom level. But the zoom-out
code had some incorrect arithmetic in it such that zooming out was
much faster than zooming in.
Carl Worth [Thu, 7 Nov 2013 21:13:22 +0000 (13:13 -0800)]
acre-x: Don't redraw for unrecognized keypresses.
Until we add double-buffering, any unnecessary redrawing causes
annoying blinking. Eliminating redraws from unknown keypresses fixes
at least some, (but likely not that many).
Carl Worth [Thu, 7 Nov 2013 17:48:53 +0000 (09:48 -0800)]
Add the notion of a style for each data set.
There's no real change here yet, since the only style offered so far
is the default ACRE_STYLE_LINE, (which is the same as how acre has
always drawn things). But things will get more interesting as new
styles are added in the future.
Carl Worth [Thu, 7 Nov 2013 13:32:32 +0000 (05:32 -0800)]
Silence pango warning if X or Y-axis label is unset.
Pango emits an annoying warning if we pass it a NULL string, (though
it seems to do the right thing regardless). Quiet it down by passing
it an empty string instead.
Carl Worth [Thu, 7 Nov 2013 03:34:54 +0000 (19:34 -0800)]
Drop the "tick avoidance" code.
This didn't always work, (plotted lines could still run into the ticks
after zooming), so it just provided inconsistent padding around the
edges of the chart.
Carl Worth [Thu, 7 Nov 2013 03:30:28 +0000 (19:30 -0800)]
Use cairo_clip to trim out any out-of-view data
Previously, we were simply not drawing line segments where one
endpoint of the segment was outside the bounds of the chart. This had
the problem of omitting a (potentially large) portion of the line
segment that should be visible.
We get the correct result, and more easily, by simply calling
cairo_clip.
Carl Worth [Wed, 6 Nov 2013 22:00:34 +0000 (14:00 -0800)]
Keep track of data ranges as data is added
This avoids the need to loop over the data to find its range just
before drawing. This is in preparation for code that will allow for a
custom viewing range (such as for zooming) rather than always
displaying all available data.
Carl Worth [Tue, 27 Jan 2009 19:48:46 +0000 (11:48 -0800)]
Add some distinguishing colors for the datasets
This is quite cheesy for now. It's just three hard-coded, primary colors.
(Much nicer would be to take N evenly-spaced colors from a percpetually
linear space.) But this gives us parity with the functionality of the
original motorsim plot, so it's enough for getting us closer to being
able to replace that.
Carl Worth [Tue, 27 Jan 2009 19:43:53 +0000 (11:43 -0800)]
Shrink title font size a bit.
When comparing an acre-made plot to a similar motorsim plot,
it became clear that the acre title font was too large, (but
also the original motorsim title font was too small). Attempt
to find a happy medium.
Carl Worth [Tue, 27 Jan 2009 16:12:39 +0000 (08:12 -0800)]
Add minor ticks
For now, do 5 divisions of each major tick, regardless of whether the
major tick spacing is 1, 2.5, 5, or 10. Also, we don't yet fix the
axes to guarantee integer spacing of the minor ticks.
Carl Worth [Tue, 27 Jan 2009 15:34:23 +0000 (07:34 -0800)]
Remove code duplication for X and Y ticks
I knew this code was repeated, and fortunately it wasn't as hard to
share it as I thought it might be. Adding minor-tick rendering will
be much easier now that this is shared.
Carl Worth [Tue, 27 Jan 2009 07:17:42 +0000 (23:17 -0800)]
Finish adjustment of tick positions for pixel-snapping.
This is the final step of adjusting the axis ranges so that
the ticks aligne nicely with integer pixel boundaries. Notably
we don't round the ticks at all while drawing them---instead
we only adjust the axis ranges so that when we draw the ticks
at their numerical positions they will look good.
Carl Worth [Sun, 25 Jan 2009 17:30:50 +0000 (04:30 +1100)]
Cleverly adjust axis ranges for integer tick spacing.
This will help avoid one of my major pet peeves with chartting
packages, which is non-pixel-aligned ticks. This is part of
the problem solved, (integer spacing between ticks), but we
still need integer alignment.
Carl Worth [Sun, 25 Jan 2009 16:46:16 +0000 (03:46 +1100)]
Remove bogus 0.5 offset when setting up data transform.
I think my intuition here had been to provide at least some padding
between the frame and data. But we should do that explicitly (and
correctly) rather than just throwing in a 0.5 offset.
Carl Worth [Sun, 25 Jan 2009 07:18:49 +0000 (18:18 +1100)]
Add preliminary implementation of acre
This is a simple chart-drawing library using cairo. We will use
this to replace the image-magick and perl-using csv2png script,
(and then also use this to do interactive charts within a GUI).