diff --git a/examples/real-data.html b/examples/real-data.html
index 83fb134..5d9b656 100644
--- a/examples/real-data.html
+++ b/examples/real-data.html
@@ -83,8 +83,8 @@
Flot Examples
if (data.length > 0)
$.plot($("#placeholder"), data, {
- yaxis: { min: 0 },
- xaxis: { tickDecimals: 0 }
+ yaxis: { min: 0, label: "Budget" },
+ xaxis: { tickDecimals: 0, label: "Year" }
});
}
diff --git a/jquery.flot.js b/jquery.flot.js
index 18e2281..cdef969 100644
--- a/jquery.flot.js
+++ b/jquery.flot.js
@@ -160,6 +160,7 @@ BOTTOM_SIDE_BUFFER = 5;
// normalize the data given by the call to $.plot. If we're
// going to be monitoring mousemove's then sort the data
function sortData(x, y) {
+ if (!x || !y) return 0;
if (x[0] > y[0]) return 1;
else if( x[0] < y[0]) return -1;
else return 0;
@@ -374,8 +375,9 @@ BOTTOM_SIDE_BUFFER = 5;
setTicks(yaxis, options.yaxis);
setSpacing();
- insertLabels();
+ insertTickLabels();
insertLegend();
+ insertAxisLabels();
}
function setRange(axis, axisOptions) {
@@ -930,7 +932,7 @@ BOTTOM_SIDE_BUFFER = 5;
}
}
- function insertLabels() {
+ function insertTickLabels() {
target.find(".tickLabels").remove();
var i, tick;
@@ -960,6 +962,45 @@ BOTTOM_SIDE_BUFFER = 5;
target.append(html);
}
+
+ function insertAxisLabels() {
+ target.find('.axislabel').remove();
+
+ if (options.xaxis.label) {
+ yLocation = plotOffset.top + plotHeight + xaxis.labelHeight + (xaxis.labelHeight * 0.25);
+ xLocation = plotOffset.left;
+ target.append("" +
+ options.xaxis.label + "
");
+ }
+ if (options.yaxis.label) {
+ var element;
+ if ($.browser.msie) {
+ element = "" + options.yaxis.label + "";
+ }
+ else {
+ // we'll use svg instead
+ var element = document.createElement('object');
+ element.setAttribute('type', 'image/svg+xml');
+ console.log( $('.xaxis').height() );
+ xAxisHeight = $('.xaxis:first').height();
+ string = '' + options.yaxis.label + '';
+ element.setAttribute('data', 'data:image/svg+xml,' + string);
+ }
+
+ xLocation = -(plotOffset.left);
+ yLocation = plotOffset.top;
+ var yAxisLabel = $("");
+ target.append(yAxisLabel);
+ }
+
+ target.find('.yaxis').append(element);
+ }
function drawSeries(series) {
if (series.lines.show || (!series.bars.show && !series.points.show && !series.deltas.show))