Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'axis-labels' into dev

Conflicts:

	examples/setting-options.html
  • Loading branch information...
commit 48e28c1cc71882f32631ba8547b1588e490b3899 2 parents f6450c3 + 93f66dd
@rfunduk authored
Showing with 24 additions and 2 deletions.
  1. +3 −1 examples/setting-options.html
  2. +21 −1 jquery.flot.js
View
4 examples/setting-options.html
@@ -59,7 +59,9 @@
color: "#BBB",
axis: 'x' } ],
backgroundColor: "#CCC"
- }
+ },
+ title: "Graph Settings Demo",
+ titleColor: "purple"
});
});
</script>
View
22 jquery.flot.js
@@ -104,6 +104,9 @@
mode: null, // one of null, "x", "y" or "xy"
color: "#e8cfac"
},
+ title: null,
+ titleFontSize: 20,
+ titleColor: 'black',
shadowSize: 4,
sortData: true
};
@@ -121,7 +124,8 @@
workarounds = {},
// buffer constants
RIGHT_SIDE_BUFFER = 10,
- BOTTOM_SIDE_BUFFER = 10;
+ BOTTOM_SIDE_BUFFER = 10,
+ TOP_SIDE_BUFFER = 20;
this.setData = setData;
this.setupGrid = setupGrid;
@@ -786,6 +790,10 @@
plotWidth = canvasWidth - plotOffset.left - plotOffset.right - RIGHT_SIDE_BUFFER;
+ if (options.title) {
+ plotOffset.top += TOP_SIDE_BUFFER;
+ }
+
// set width for labels; to avoid measuring the widths of
// the labels, we construct fixed-size boxes and put the
// labels inside them, the fixed-size boxes are easy to
@@ -965,6 +973,18 @@
}
function insertAxisLabels() {
+ if (options.title) {
+ yLocation = plotOffset.top - options.titleFontSize * 1.25;
+ xLocation = plotOffset.left;
+ color = options.titleColor ? options.titleColor : options.grid.color;
+ titleDiv = $("<div id='graph_title' style='color:" + color +
+ ";text-align:center;position:absolute;top:" + yLocation +
+ "px;left:" + xLocation + "px;font-weight:bold;font-size:" +
+ options.titleFontSize + "px;width:" + plotWidth + "px;'>" +
+ options.title + "</div>");
+ target.append(titleDiv);
+ }
+
if (options.xaxis.label) {
yLocation = plotOffset.top + plotHeight + (xaxis.labelHeight * 1.5);
xLocation = plotOffset.left;
Please sign in to comment.
Something went wrong with that request. Please try again.