Commit 2015ca3a authored by olau@iola.dk's avatar olau@iola.dk

Added more members to the Plot object + a few cleanups

git-svn-id: https://flot.googlecode.com/svn/trunk@57 1e0a6537-2640-0410-bfb7-f154510ff394
parent 47eb2cb0
...@@ -513,6 +513,37 @@ members: ...@@ -513,6 +513,37 @@ members:
- getPlotOffset() - getPlotOffset()
Gets the offset that the grid has within the canvas as an object Gets the offset that the grid has within the canvas as an object
with the members left, right, top, bottom. I.e., if you draw a with the members "left", "right", "top", "bottom". I.e., if you draw a
circle on the canvas with the center placed at (left, top), its circle on the canvas with the center placed at (left, top), its
center will be at the top-most, left corner of the grid. center will be at the top-most, left corner of the grid.
- setData(data)
You can use this to reset the data used. Note that axis scaling,
ticks, legend etc. will not be recomputed (use setupGrid() to do
that). You'll probably want to call draw() afterwards.
- getData()
Returns the data currently used. The data series returned are
normalized with missing settings filled in. So for instance to
find out what color Flot has assigned to the data series, you
could do this:
var series = plot.getData();
for (var i = 0; i < series.length; ++i)
alert([i].color);
- setupGrid()
Recalculate and set axis scaling, ticks, legend etc.
Note that because of the drawing model of the canvas, this
function will immediately redraw (actually reinsert in the DOM)
the labels and the legend, but not the actual tick lines because
they're drawn on the canvas. You need to call draw() to get the
canvas redrawn.
- draw()
Redraws the canvas.
...@@ -15,6 +15,11 @@ Support for colored background areas via grid.coloredAreas. Specify an ...@@ -15,6 +15,11 @@ Support for colored background areas via grid.coloredAreas. Specify an
array of { x1, y1, x2, y2 } objects or a function that returns these array of { x1, y1, x2, y2 } objects or a function that returns these
given { xmin, xmax, ymin, ymax }. given { xmin, xmax, ymin, ymax }.
More members on the plot object (report by Chris Davies and others).
"getData" for inspecting the assigned settings on data series (e.g.
color) and "setData", "setupGrid" and "draw" for updating the contents
without a total replot.
The default number of ticks to aim for is now dependent on the size of The default number of ticks to aim for is now dependent on the size of
the plot in pixels. Support for customizing tick interval sizes the plot in pixels. Support for customizing tick interval sizes
directly with axis.minTickSize and axis.tickSize. directly with axis.minTickSize and axis.tickSize.
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
scaled.</p> scaled.</p>
<script id="source" language="javascript" type="text/javascript"> <script id="source" language="javascript" type="text/javascript">
var plot;
$(function () { $(function () {
var d1 = []; var d1 = [];
for (var i = 0; i < 14; i += 0.5) for (var i = 0; i < 14; i += 0.5)
...@@ -30,7 +31,7 @@ $(function () { ...@@ -30,7 +31,7 @@ $(function () {
// a null signifies separate line segments // a null signifies separate line segments
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]]; var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
$.plot($("#placeholder"), [ d1, d2, d3 ]); plot = $.plot($("#placeholder"), [ d1, d2, d3 ]);
}); });
</script> </script>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment