summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Wuerthwein <fkw@ucsd.edu>2009-02-20 03:59:32 +0000
committerFrank Wuerthwein <fkw@ucsd.edu>2009-02-20 03:59:32 +0000
commit73ddf7698ed8a4b8adbc87c4dce750c7d959aa02 (patch)
treea04a78ec3982327eba5778d5172093085028eae8
parent352f0130b5d50591c8445ab100a8dabcd4de54f4 (diff)
Add costumizable legend
-rw-r--r--src/lib/rrdFlot.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/lib/rrdFlot.js b/src/lib/rrdFlot.js
index dbdd8cf..18cd857 100644
--- a/src/lib/rrdFlot.js
+++ b/src/lib/rrdFlot.js
@@ -30,7 +30,11 @@ function rrdFlot(html_id, rrd_file, ds_description, layout_opts) {
this.html_id=html_id;
this.rrd_file=rrd_file;
this.ds_description=ds_description;
- this.layout_ops=layout_opts;
+ if (layout_opts!=null) {
+ this.layout_opts=layout_opts;
+ } else {
+ this.layout_opts={};
+ }
this.selection_range=new rrdFlotSelection();
@@ -180,10 +184,26 @@ rrdFlot.prototype.bindFlotGraph = function(flot_obj) {
var graph_jq_id="#"+this.graph_id;
var scale_jq_id="#"+this.scale_id;
+ var legend_position="nw"; // choose a reasonable default
+ if (this.layout_opts.legend_position!=null) {
+ legend_position=this.layout_opts.legend_position;
+ }
+
+ var legend_columns=3; // choose a reasonable default
+ if (this.layout_opts.legend_columns!=null) {
+ legend_columns=this.layout_opts.legend_columns;
+ }
+
+ var legend_fraction=0.25; // choose a reasonable default
+ if (this.layout_opts.legend_fraction!=null) {
+ legend_fraction=this.layout_opts.legend_fraction;
+ }
+
var graph_options = {
- legend: {show:true},
+ legend: {show:true, position:legend_position,noColumns:legend_columns},
lines: {show:true},
xaxis: { mode: "time", min:flot_obj.min, max:flot_obj.max },
+ yaxis: { autoscaleMargin: legend_fraction},
selection: { mode: "x" },
};
var scale_options = {