Commit 3360d274 authored by olau@iola.dk's avatar olau@iola.dk

Option to have the grid on top of the data, important for image plots, and a...

Option to have the grid on top of the data, important for image plots, and a bug fix, patch by Paul Kienzle

git-svn-id: https://flot.googlecode.com/svn/trunk@197 1e0a6537-2640-0410-bfb7-f154510ff394
parent 00051008
...@@ -507,6 +507,7 @@ Customizing the grid ...@@ -507,6 +507,7 @@ Customizing the grid
grid: { grid: {
show: boolean show: boolean
aboveData: boolean
color: color color: color
backgroundColor: color/gradient or null backgroundColor: color/gradient or null
tickColor: color tickColor: color
...@@ -524,8 +525,11 @@ The grid is the thing with the axes and a number of ticks. "color" is ...@@ -524,8 +525,11 @@ The grid is the thing with the axes and a number of ticks. "color" is
the color of the grid itself whereas "backgroundColor" specifies the the color of the grid itself whereas "backgroundColor" specifies the
background color inside the grid area. The default value of null means background color inside the grid area. The default value of null means
that the background is transparent. You can also set a gradient, see that the background is transparent. You can also set a gradient, see
the gradient documentation below. You can turn off the whole grid the gradient documentation below.
including tick labels by setting "show" to false.
You can turn off the whole grid including tick labels by setting
"show" to false. "aboveData" determines whether the grid is drawn on
above the data or below (below is default).
"tickColor" is the color of the ticks and "labelMargin" is the spacing "tickColor" is the color of the ticks and "labelMargin" is the spacing
between tick labels and the grid. Note that you can style the tick between tick labels and the grid. Note that you can style the tick
......
...@@ -109,6 +109,8 @@ Changes: ...@@ -109,6 +109,8 @@ Changes:
- Navigation plugin for panning and zooming a plot. - Navigation plugin for panning and zooming a plot.
- More configurable grid.
Bug fixes: Bug fixes:
...@@ -149,7 +151,7 @@ Bug fixes: ...@@ -149,7 +151,7 @@ Bug fixes:
- Made the heuristic for determining how many ticks to aim for a bit - Made the heuristic for determining how many ticks to aim for a bit
smarter. smarter.
- Fix for uneven axis margins (report and patch by Paul Kienzle) and - Fix for uneven axis margins (report and patch by Paul Kienzle) and
snapping to ticks. snapping to ticks (concurrent report and patch by lifthrasiir).
Flot 0.5 Flot 0.5
-------- --------
......
...@@ -81,9 +81,10 @@ ...@@ -81,9 +81,10 @@
}, },
grid: { grid: {
show: true, show: true,
aboveData: false,
color: "#545454", // primary color used for outline and labels color: "#545454", // primary color used for outline and labels
backgroundColor: null, // null for transparent, else color backgroundColor: null, // null for transparent, else color
tickColor: "#dddddd", // color used for the ticks tickColor: "rgba(0,0,0,0.15)", // color used for the ticks
labelMargin: 5, // in pixels labelMargin: 5, // in pixels
borderWidth: 2, // in pixels borderWidth: 2, // in pixels
borderColor: null, // set if different from the grid color borderColor: null, // set if different from the grid color
...@@ -1015,13 +1016,20 @@ ...@@ -1015,13 +1016,20 @@
} }
function draw() { function draw() {
if (options.grid.show) ctx.clearRect(0, 0, canvasWidth, canvasHeight);
var grid = options.grid;
if (grid.show && !grid.aboveData)
drawGrid(); drawGrid();
for (var i = 0; i < series.length; ++i) for (var i = 0; i < series.length; ++i)
drawSeries(series[i]); drawSeries(series[i]);
executeHooks(hooks.draw, [ctx]); executeHooks(hooks.draw, [ctx]);
if (grid.show && grid.aboveData)
drawGrid();
} }
function extractRange(ranges, coord) { function extractRange(ranges, coord) {
...@@ -1057,7 +1065,6 @@ ...@@ -1057,7 +1065,6 @@
var i; var i;
ctx.save(); ctx.save();
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
ctx.translate(plotOffset.left, plotOffset.top); ctx.translate(plotOffset.left, plotOffset.top);
// draw background, if any // draw background, if any
......
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