Add an extra pixel to ensure that the lines cleanly join both top and
bottom ticks. Also apply the sub-pixel offset only in the necessary
direction, so the lines don't start a pixel off from where they should.
The axis color now controls the color of the axis line, instead of its
ticks and labels, while the tickColor controls the tick color. This
makes a little more sense and provides the minor feature of being able
to change the axis line color separately from that of its ticks. Pull
request #917 ought to be easier to merge now, too.
This allows us to reuse the canvas elements without having to retain the
rest of the Canvas object, which should really be reset when the plot is
reconstructed. It's also a little simpler, and the Canvas constructor
just feels like the right place for this code.
The tickLabel class is deprecated in favor of flot-tick-label, but we'll
continue to use it until the release of version 1.0.0, for
backwards-compatibility.
Previously the cache was divided only by layer, with entries keyed on a
string built from the text and style. Now the style has its own tier in
the cache, i.e. layers > styles > text > info.
This introduces some complexity, since the nested for loops are ugly,
but at the same time we avoid having to create the cache-key strings.
More importantly it solves the problem of uniqueness that exists when we
try to join strings that may contain arbitrary text. It also allows a
further optimization in the canvas plugin, which can now set text style
and color just once per distinct style, instead of with every string.
This lets users 'namespace' text more naturally, i.e. placing x-axis
labels in a different container from y-axis labels, providing more
flexibility when it comes to styling and interactivity.
Internally the text cache now has a second tier: layers > text > info.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
The primary canvas uses position: absolute while the overlay canvas does
not. This can cause the two to get out of alignment in rare cases when
floating elements are placed near the plot placeholder. There doesn't
appear to be any reason why the overlay can't also be
absolutely-positioned, so I've just removed the flag entirely.
* If either color or width is object, normalize the other to object
* Only draw each border if its width is greater than 0
* Set strokeStyle and lineWidth _before_ calling ctx.beginPath()
Pull request #50 inadvertently broke the behavior of axis.tickDecimals,
which previously added precision up to the given value. The broken code
effectively ignored the setting for values with less precision. This
fix brings back the old behavior.
The recent changes to add retina support included a call to getContext
made before excanvas/flashcanvas had a chance to register their hooks;
fixed by moving that code up a few lines.
As the size of the variation increases, the resulting colors approach
white and black. To avoid this we now reset the variation when it gets
too large. This results in repeated colors, but that's much better than
a list full of whites and blacks.
Check whether an axis has a generator, rather than a mode. In most cases
this is functionally the same, but it also handles the case where an
axis mode plug-in specifies only the formatter, and expects to use the
default base-10 generator.
Added a legend 'sorted' option that allows sorting of legend entries
independent of series order. It accepts either null/false, true,
'ascending', 'descending' or a comparator function.
adding shutdown() methods to the plot (based on patch by Ryley
Breiddal, issue 269). This prevents a memory leak in Chrome and
hopefully makes replotting faster for those who are using $.plot
instead of .setData()/.draw(). Also update jQuery to 1.5.1 to prevent
IE leaks fixed some time ago in jQuery.
git-svn-id: https://flot.googlecode.com/svn/trunk@317 1e0a6537-2640-0410-bfb7-f154510ff394
padding on the placeholder by hardcoding the placeholder padding to 0
(reported by adityadineshsaxena, Matt Sommer, Daniel Atos and some
other people, issue 301)
git-svn-id: https://flot.googlecode.com/svn/trunk@314 1e0a6537-2640-0410-bfb7-f154510ff394
no longer needed, and possibly misleading - hopefully, nobody else has
used it yet; also refactor getAxes() and remove annoying
backwards-compatibility stuff in it, it probably didn't help anything
and prevents one from using getAxes() in the obvious way
git-svn-id: https://flot.googlecode.com/svn/trunk@310 1e0a6537-2640-0410-bfb7-f154510ff394
the version comment at the top of jquery.flot.js is included in the
minified output (suggested by arockinit)
git-svn-id: https://flot.googlecode.com/svn/trunk@308 1e0a6537-2640-0410-bfb7-f154510ff394
(reported by Ofri Raviv, and patches and analysis by Jan and Tom
Paton, issue 334 and 467)
git-svn-id: https://flot.googlecode.com/svn/trunk@307 1e0a6537-2640-0410-bfb7-f154510ff394
implicit assumptions madness and support turning axes on and off
(suggested by Time Tuominen in issue 466), this adds axis.show and
axis.reserveSpace - still need to figure out what to do about the
public axis-snarfing API and get it documented.
git-svn-id: https://flot.googlecode.com/svn/trunk@302 1e0a6537-2640-0410-bfb7-f154510ff394