From 63f68a76345fdac2d48a67d5a7b3f4131a3bb6ad Mon Sep 17 00:00:00 2001 From: Frank Wuerthwein Date: Sun, 3 May 2009 15:29:13 +0000 Subject: Add checked option --- src/lib/rrdFlot.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lib/rrdFlot.js b/src/lib/rrdFlot.js index 57fdf4c..e7f2ceb 100644 --- a/src/lib/rrdFlot.js +++ b/src/lib/rrdFlot.js @@ -36,12 +36,13 @@ * with each element being a graph_option * The defaults for each element are * { - * title: ds_name // this is what is displayed at the radio button - * label: ds_name // this is what is displayed in the legend - * color: ds_index - * lines: { show:true } // see Flot docs for detail - * yaxis: 1 // can be 1 or 2 - * stack: 'none' // other options are 'positive' and 'negative' + * title: ds_name // this is what is displayed at the radio button + * checked: first_ds_in_list? //boolean + * label: ds_name // this is what is displayed in the legend + * color: ds_index // see Flot docs for details + * lines: { show:true } // see Flot docs for details + * yaxis: 1 // can be 1 or 2 + * stack: 'none' // other options are 'positive' and 'negative' * } */ @@ -202,19 +203,24 @@ rrdFlot.prototype.populateDScb = function() { var ds=this.rrd_file.getDS(i); var name=ds.getName(); var title=name; + var checked=(i==0); // only first checked by default if (this.ds_graph_options[name]!=null) { var dgo=this.ds_graph_options[name]; if (dgo['title']!=null) { // if the user provided the title, use it title=dgo['title']; } + if (dgo['checked']!=null) { + // if the user provided the title, use it + checked=dgo['checked']; + } } var cb_el = document.createElement("input"); cb_el.type = "checkbox"; cb_el.name = "ds"; cb_el.value = name; - cb_el.checked = cb_el.defaultChecked = (i==0); + cb_el.checked = cb_el.defaultChecked = checked; form_el.appendChild(cb_el); form_el.appendChild(document.createTextNode(title)); form_el.appendChild(document.createElement('br')); -- cgit v1.2.3