X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=share%2Fcollection.js;h=7bcdc54fc0a01d01a6674a6d727bfabc2783b1be;hb=c08cfbb86fc765dc9aac1e8f22548aa05da722fc;hp=57de19dd44a9f8fe9575ed97762d2f40dfa26905;hpb=5e8d693f7093d0217dbf1132788a4575eb054895;p=collection4.git diff --git a/share/collection.js b/share/collection.js index 57de19d..7bcdc54 100644 --- a/share/collection.js +++ b/share/collection.js @@ -23,7 +23,12 @@ var c4 = { - instances: [] + instances: new Array (), + config: + { + width: 324, + height: 200 + } }; function value_to_string (value) /* {{{ */ @@ -358,6 +363,9 @@ function inst_get_chart_opts (inst, def) /* {{{ */ if (def.title) chart_opts.title = { text: def.title }; + if (def.vertical_label) + chart_opts.yAxis.title = { text: def.vertical_label }; + return (chart_opts); } /* }}} function chart_opts_get */ @@ -396,7 +404,10 @@ function inst_redraw (inst, def, data_list) /* {{{ */ } for (i = inst.chart.series.length - 1; i >= 0; i--) + { + series_array[i].visible = inst.chart.series[i].visible; inst.chart.series[i].remove (/* redraw = */ false); + } for (i = 0; i < series_array.length; i++) inst.chart.addSeries (series_array[i], /* redraw = */ false); @@ -417,6 +428,7 @@ function inst_fetch_data (inst, begin, end) /* {{{ */ params.action = "instance_data_json"; params.begin = begin || inst.begin; params.end = end || inst.end; + params.resolution = (params.end - params.begin) / c4.config.width; $.getJSON ("collection.fcgi", params, function (data) @@ -624,6 +636,26 @@ function zoom_out (graph_id) /* {{{ */ return (zoom_relative (graph_id, (-1.0 / 3.0), (1.0 / 3.0))); } /* }}} function zoom_earlier */ +function graph_recalc_width () /* {{{ */ +{ + var tmp; + + tmp = $("#layout-middle-center").width (); + if (!tmp) + return; + + if (tmp < 324) + tmp = 324; + + c4.config.width = tmp; + c4.config.height = Math.round (tmp / 1.61803398874989484820); + $(".graph-json").each (function () + { + $(this).width (c4.config.width); + $(this).height (c4.config.height); + }); +} /* }}} function graph_recalc_width */ + $(document).ready(function() { /* $("#layout-middle-right").html (""); */ $("#search-form").append (""); @@ -688,6 +720,8 @@ $(document).ready(function() { ); }); + graph_recalc_width (); + var i; for (i = 0; i < c4.instances.length; i++) {