Commit Graph

587 Commits (4203a66eba482027b3e92c56aff44ce69aa9dfb4)
 

Author SHA1 Message Date
David Schnur 4203a66eba Add text to its actual layer before measuring it.
The getTextInfo method previously added new text to the top-level
container when measuring it.  Now it adds the text to the text layer,
just as it will be when rendered, so that parent-child CSS rules can
resolve correctly.

This also avoids having to safe a reference to the top-level container,
since it wasn't used anywhere else.
13 years ago
David Schnur e7de873524 Factor out text layer creation to its own method.
This sets the stage for allowing the use of multiple layers.
13 years ago
David Schnur a036aa962a Reverse cache key order to ensure uniqueness.
Also switch from dashes to pipes, and remove the angle for now, since we
don't currently support rotated text.
13 years ago
David Schnur a9a31644c7 Replace drawText with add and remove methods.
Every cache element now contains the actual text element instead of just
its HTML, plus a flag indicating whether it is visible.  The addText and
removeText methods control the state of this flag, and the render method
uses it to manage elements within the text container.  So where we
previously used drawText to actually render text, now we add each string
once, then let the render method take care of drawing them as necessary.

This dramatically improves performance by eliminating the need to clear
and re-populate HTML text on every drawing cycle.  Since the elements
are now static between add/remove calls, this also allows users to add
interactivity, as they could in 0.7.  Finally, it eliminates the need
for a separate 'hot' cache.

I also removed the unnecessary 'dimensions' object; it's easier and
faster to store the width and height at the top level of the info
object.
13 years ago
David Schnur 5d7086968f Simplify creation of the cached element. 13 years ago
David Schnur ff0e5c1b1a Move cached hasOwnProperty to the top level. 13 years ago
David Schnur 73baa2b9e3 Cache actual elements instead of buffering HTML.
This significantly improves performance, since we already create the
elements when measuring them, and that effort is now no longer wasted.
We must take care to detach, rather than remove, when clearing the text
layer, so we can add the elements back later if necessary.
13 years ago
David Schnur 98b6361aa9 Preserve canvas elements on re-plot.
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.
13 years ago
David Schnur d2642e80cf Fixed missing/superfluous semicolons. 13 years ago
David Schnur c36b344677 Replace axis.font with options.font.
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.
13 years ago
David Schnur a0529ee8b1 Moved canvas tick rendering into a plugin.
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.
13 years ago
David Schnur 3b2d43bf65 Provide a way for plugins to override classes. 13 years ago
David Schnur edc2bbd992 Added methods to draw and measure text.
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.
13 years ago
David Schnur 42d5592add Added a basic frame for the canvas-drawing plugin. 13 years ago
David Schnur a9be4d559d Abstract-out canvas creation into an object.
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.
13 years ago
David Schnur f66c9ae3d6 Renamed the 'canvas' variable to 'surface'.
Renaming the variable gives us room to create a new class called Canvas.
13 years ago
David Schnur 36bfcbf08a Merge pull request #929 from hizhengfu/master
Fix an error in plot offset calculation.
13 years ago
hizhengfu 3c1d04cbd1 Correction calculation error margin
Correction calculation error margin
13 years ago
David Schnur f06fe931ea Merge pull request #861 from thecountofzero/master
Ensure that tickSize updates on subsequent calls to setupGrid.
13 years ago
David Schnur 92a833ce00 Cleaned up jQuery plugins site manifest.
Fixed jQuery version dependency (we require 1.2.6, not 1.3.2) and
whitespace.
13 years ago
David Schnur 4df443bd00 Updated Bower component.json version info.
Flot's semver is 0.8.0-alpha, and it (for now) requires jQuery 1.2.6,
not 1.3.2.
13 years ago
David Schnur a665f6793c Merge pull request #843 from ralphholzmann/bower
Adding component.json for bower.
13 years ago
David Schnur a60dbbfd1f Updated credits for sub-pixel rendering fixes. 13 years ago
David Schnur 29476b8911 Merge pull request #911 from dnschnur/series-zero-option
Added a series 'zero' option to control automatic scaling.
13 years ago
David Schnur be6fc4e41d Draw selection on half-pixels to avoid aliasing.
Adapted from pull request #17.
13 years ago
David Schnur 4a35faff61 Merge pull request #925 from danxshap/master
Always draw crosshair on half-pixels to prevent aliasing.
13 years ago
Daniel Shapiro 1bee76632d Draw crosshair on half-pixels to prevent aliasing 13 years ago
David Schnur 620b05a7e1 Merge pull request #923 from NIA/patch-1
Add passing offsets over plotpan event
13 years ago
David Schnur 2c64f82a4f Added the new 'zero' option to the changelog. 13 years ago
David Schnur 151e96fb27 Expand documentation of the point format options. 13 years ago
David Schnur 1e685b0446 Documented the zero option for bars and lines. 13 years ago
David Schnur 790bbaf55f Mirror the zero option to the categories plugin.
Due to limitations in our plugin architecture, the categories plugin
duplicates code from Flot's core for adding a dummy point to snap the y
axis to zero.  We can get rid of this duplication in 0.9; for now we'll
just update the duplicate to match the change in core that introduced
the new 'zero' option.
13 years ago
David Schnur 6412dafc6e Restrict zero to bars and filled lines only.
This also includes a tweak to zero's default.  Previously zero only
received a value if lines were visible; now it always receives a value,
matching the behavior of other contextual options.
13 years ago
Ivan Novikov c8630d1849 Add passing offsets over plotpan event
Unified this behavior with plotzoom event as in pull #34 flot/flot@1b6c4e933a
13 years ago
David Schnur 3c0bcefc5a Fixed jQuery 1.2.6 mouseleave issue from #920.
Use bind, rather than .mouseleave, because we officially still support
jQuery 1.2.6, which doesn't define a shortcut for mouseenter or
mouseleave.  This was a bug/oversight that was fixed somewhere around
1.3.x.  We can return to using .mouseleave when we drop support for
1.2.6.
13 years ago
David Schnur f2fa1b869e Updated credits for #918 pie percentage errors. 13 years ago
David Schnur 1cd2cd9490 Merge pull request #918 from jtward/patch-1
Change evaluation order for calculating percentage.
13 years ago
James Ward f6198f5db2 Change evaluation order for calculating percentage
Rounding errors are introduced when calculating the percentage when the total is 100 (for example if percentages have already been calculated). Calculating (total/100) first eliminates the error in this case.
13 years ago
David Schnur b6924a96d9 Update auto-scaling to support the zero option.
Added a format option 'autoscale' that controls whether the given point
is considered when determining an automatic scale.

The lines & bars 'zero' option controls whether autoscale is set on the
dummy point that is inserted to create the series lower-bound.
13 years ago
David Schnur 126cb072fc Added a 'zero' option for lines and bars.
Area and bar plots normally use a minimum of zero, since their purpose
is to show size, and using an auto-scaled minimum distorts the plot's
meaning.  But this behavior is undesirable in cases where the plot type
is used in more of a decorative sense.

The zero option provides a way to control this behavior.  It defauls to
true for bars and filled lines.
13 years ago
David Schnur d7c58b59f3 Enforce left-to-right canvas layout orientation.
When the placeholder has (or inherits) the HTML 'dir' attribute or CSS
'direction' we get unexpected results from text metrics, resulting in
visual glitches on the axes.

The suggested solution in #716 was to set ltr on the placeholder, but
this introduces its own problems, since the user probably *does* expect
rtl on items like the legend.  So we'll instead set ltr only on the
canvases.

We should review this behavior at some point; rtl is something we need
to handle, not work around.  It also needs to be kept in mind as we move
canvas-text into a plugin.  But for now this solution at least ensures
consistent behavior.
13 years ago
David Schnur a6414cac60 Prevent color generation with all fixed indexes.
As pointed out in a comment to #832, initializing maxIndex to zero
results in the creation of a single color even when all indexes are
fixed.
13 years ago
David Schnur 88e0567b46 Tweak comparison order for clarity. 13 years ago
David Schnur 61c1cad92f Clarify comments describing color generation. 13 years ago
David Schnur c22f3f753c Added credits for #910 pie redraw fixes. 13 years ago
David Schnur f0652fd067 Merge pull request #910 from dnschnur/pie-resize-fix
Allow the pie chart to redraw on resize or update.
13 years ago
David Schnur d09b278601 Allow the pie to redraw on resize or update.
When a pie's labels don't fit within its container, the pie is redrawn
with a smaller radius until the labels fit, or a fixed number of retry
attempts are exhausted. The redraw flag was not reset on success,
however, which prevented the pie from being redrawn again after a resize
or update.
13 years ago
David Schnur 02c701b057 Check dimensions on draw, not just on startup.
Previously the container dimensions were checked only once, which
prevented the pie from changing in size as its container was resized.
13 years ago
David Schnur 715a093316 Updated credits for #905 jQuery 1.9 compatibility. 13 years ago
David Schnur 761b5f1149 Merge pull request #905 from anthonyryan1/master
Eliminate uses of $.browser, since it is no longer present in jQuery 1.9, and some of the cases were no longer necessary anyway.
13 years ago