The redraw flag starts out as true, then is immediately set to false on
draw. If labels are enabled, drawPie calls drawLabels, which calls
drawLabel for each label. Any label that can't fit sets redraw back to
true, so the whole process can repeat.
This isn't the most obvious mechanism, and forces one to remember to do
things like setting redraw back to true after drawing, so the plot can
redraw itself on resize or when setting new data.
Instead we now have drawPie return true when it drew successfully, and
false otherwise, which the same happening in drawLabels and drawLabel.
Instead of checking the flag, we now just check the return value.
This has the added benefit of slightly improving performance in the case
where several redraws are necessary, since it now short-circuits out of
the draw loop as soon as one label fails to fit.
In plugins we should never add hooks conditionally; the condition should
remain within individual hooks, so the plugin can be toggled at any
time.
Ideally we should also 'inline' the hook functions, since they're used
nowhere else. But since that would involve a lot of code changes, we'll
put it off until the broader cleanup effort scheduled for 0.9.0.
After shrinking the global example placeholder size, ones with
additional content within the demo area needed to be tweaked
individually, to prevent the other content from wrapping down or
extending off the side of the container.
Since the Canvas .text object is jQuery-wrapped, it was not preserved as
expected when clearing the canvas of junk. I've replaced the selection
with one based on element classes.
Instead of giving the axis its own font property, we simply look at its
options, where the font comes from in the first place. A separate
property is unnecessary and inconsistent with the way other axis options
are handled.
Added explicit border-spacing to compensate for global removal of
padding. Flot should really take care of this itself; layout-critical
styles shouldn't depend on the user-agent defaults.
Slightly widened the page to account for the fact that most people have
widescreen monitors these days. Also made text larger and more legible,
and created a nice 'clipping' effect for the placeholder.
To improve organization with the increasing number of examples, every
example page is now the index of its own subdirectory, which contains
all the files specific to that example.
The base implementation uses the new drawText and getTextInfo methods to
draw text in HTML. Canvas rendering has been moved to overrides of
these methods within the canvas-render plugin.
These methods provide a common way to draw HTML text above a canvas.
The getTextInfo method generates div HTML for text with a given font
style/class and angle, measures the element's dimensions, and saves
everything in a cache. The drawText method takes the resulting entry,
finishes generating the inline styles necessary to position the div, and
adds the result to a buffer. The render method dumps the buffer into an
overlay and expires unused cache entries.
Moved canvas creation and size management into a new Canvas class.
This is the first step towards a more object-oriented architecture.
Since we create multiple canvases, and have to maintain several
module-global variables to track their properties, they are the ideal
place to start.
This commit also removes sizing code that was duplicated between
makeCanvas and resizeCanvas.
Thus, prevent it from becoming topmost (it may cause strange looks if
original series is not topmost: some part of it becomes topmost and
overwrites some lines and points that should be above it instead).