From ff70b1099798d03886e178d708c7b51de396b826 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 24 Dec 2010 09:31:38 +0100 Subject: [PATCH] Recalculate the graph dimensions after the page has been loaded. --- share/collection.js | 30 +++++++++++++++++++++++++++++- share/style.css | 4 ++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/share/collection.js b/share/collection.js index 141acbd..e071f2f 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) /* {{{ */ @@ -423,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 = Math.round ((params.end - params.begin) / c4.config.width); $.getJSON ("collection.fcgi", params, function (data) @@ -630,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 (""); @@ -694,6 +720,8 @@ $(document).ready(function() { ); }); + graph_recalc_width (); + var i; for (i = 0; i < c4.instances.length; i++) { diff --git a/share/style.css b/share/style.css index d1db941..fbcd163 100644 --- a/share/style.css +++ b/share/style.css @@ -238,8 +238,8 @@ div.graph-img:hover div.graph-buttons .graph-json { clear: both; - width: 600px; - height: 300px; + width: 324px; + height: 200px; } div.footer -- 2.30.2