Commit Graph

300 Commits (e037f5ca56cf3c9b09880745d7f6929d8d53c881)

Author SHA1 Message Date
David Schnur e037f5ca56 Updated version number to 0.8.1-alpha. 13 years ago
David Schnur 0f83ac3d5c Fixed missing semicolons. 13 years ago
David Schnur bad589c0a7 Update version number to 0.8.0 final. 13 years ago
David Schnur 209fe5336a Always recalculate tickDecimals and tickSize.
Resolves #1000.  In Flot 0.7 we only calculated tickDecimals and
tickSize once, when creating the tickGenerator for the first time.  This
meant that calls to setupGrid failed to recalculate the values, as
reported in #860.  #861 fixed the problem by moving calculation into
tickGenerator, but this turned out to cause a new problem, since the
function doesn't run when an explicit ticks array is provided.

This commit solves both by always recalculating the values outside of
the tickGenerator function.  As far as I can tell the only reason it
wasn't done this way from the beginning was to avoid unnecessary work in
the case where tickGenerator is already provided in the options.  But
the extra work is negligible, and it's actually more consistent for the
properties to always be set.
13 years ago
David Schnur aefe4e729b Round text coordinates consistently.
The core implementation used parseInt, which was originally to catch
text values, but really only stayed due to its side-effect of flooring
the values.  The canvas implementation has never rounded coordinates.
This led to various one-pixel rendering glitches between the two
implementations.  I've fixed the problem by consistently rounding
coordinates to the nearest whole number.
13 years ago
David Schnur bceb4bfca2 Added lineHeight to the font-spec object.
Line height is a core font property - it can be specified as part of the
unified 'font' definition - and we therefore need to give users access
to it when they're manually defining the font.
13 years ago
David Schnur 55e671b795 Fix incorrect default for xaxes/yaxes tickColor.
The way in which xaxes/yaxes inherit options from xaxis/yaxis resulted
in a minor bug, where tickColor defaulted to the xaxis/yaxis color
instead of the color for its axis.  Fixed by applying the default before
extending the per-axis options, resolving #984.

There's still some questionable behavior here; this section should be
revisited for 0.9, especially with an eye towards removing some of the
code that only exists for backwards-compatibility.
13 years ago
David Schnur 4e8d8535e0 Move time-specific options into the time plugin. 13 years ago
David Schnur df0875e549 Replace the stylesheet hack with inline styles.
The purpose of the stylesheet hack was to provide a default without
having to use inline styles on containers.  We can do this much more
neatly by instead just giving the inline styles to a parent container,
leaving users free to customize the children.
13 years ago
David Schnur 5741f26756 Short-circuit when removing all highlights.
There's no need to continue in the function when all highlights are
being cleared.
13 years ago
David Schnur eee071c47d Fix highlight and unhighlight inconsistency.
The unhighlight method retrieved the point differently from highlight,
and incorrectly.  It now matches the behavior of highlight.
13 years ago
David Schnur aeddf4e385 Avoid an unnecessary intermediate variable. 13 years ago
David Schnur 4e9c0c0b53 Ensure that axis lines align with their ticks.
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.
13 years ago
David Schnur 0594a49158 Update version number to 0.8.0-beta. 13 years ago
David Schnur 3cd7a51026 Axis and tick color options now make more sense.
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.
13 years ago
David Schnur a0b05a4bab Switch to semantic versioning. 13 years ago
David Schnur 53ce9ad123 Move canvas reuse up into the Canvas constructor.
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.
13 years ago
martinqt 1e6c45bd95 Update js files 13 years ago
David Schnur 60ed6b2963 Merge pull request #935 from dnschnur/canvas-text
Moved canvas text support into a plugin.
13 years ago
David Schnur 0df6bc4a66 Add back legacy styles for tick label containers.
These styles are deprecated, but we'll continue to use them until the
release of version 1.0.0, for backwards-compatibility.
13 years ago
David Schnur bb0acac9c7 Give tick labels the 'tickLabel' class.
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.
13 years ago
David Schnur e354071741 Minor cleanup of text-style color defaults. 13 years ago
David Schnur ab6e4a95bd Skip NaN values in axis min/max calculations.
Resolves #489.
13 years ago
David Schnur a2dd0645aa Break text styles into their own cache tier.
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.
13 years ago
David Schnur 77e50b175d Allow text to be divided between multiple layers.
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.
13 years ago
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 51e14f6a27 Added a 'reverse' sorted option.
This orders the legend entries in reverse order of their series.
13 years ago
David Schnur 49cce02be9 Add the plot function as a chainable property.
Resolves #734 and #816.
13 years ago
David Schnur ad823de836 Merge pull request #937 from jamiehs/issue-842-cherry-pick
Fix inability to set the point lineWidth to 0.
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
Sean Jordan f6f764eb2d Fixing bug with default tickFormatter
Change-Id: If53fdb1bf9563834c58cf2b569d0e1a6a7155eb8
13 years ago
Jamie Hamel-Smith c833511431 Adding a fix for the inability to set the point line width to 0. It's a bit of a hack, but it seems like an acceptable workaround. 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 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
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 29476b8911 Merge pull request #911 from dnschnur/series-zero-option
Added a series 'zero' option to control automatic scaling.
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
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