From 5458fe24111e44e86035410d771a3b0182b4cbbb Mon Sep 17 00:00:00 2001 From: James White Date: Sun, 13 Apr 2014 18:44:56 +0100 Subject: [PATCH 1/4] Add missing sample data --- data-sample.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data-sample.php b/data-sample.php index 0846efb..da6e408 100644 --- a/data-sample.php +++ b/data-sample.php @@ -21,6 +21,9 @@ function opcache_get_status() { 'blacklist_misses' => 0, 'blacklist_miss_ratio' => 0, 'opcache_hit_rate' => 99.81178017119, + 'oom_restarts' => 0, + 'manual_restarts' => 0, + 'hash_restarts' => 0, ), 'scripts' => array ( From 465c1fe0c9a50a44642b9138ae0c21d7e98637d6 Mon Sep 17 00:00:00 2001 From: James White Date: Sun, 13 Apr 2014 18:47:18 +0100 Subject: [PATCH 2/4] Remove line breaks --- data-sample.php | 138 ++++++++++++++++-------------------------------- 1 file changed, 46 insertions(+), 92 deletions(-) diff --git a/data-sample.php b/data-sample.php index da6e408..5ee18fd 100644 --- a/data-sample.php +++ b/data-sample.php @@ -32,8 +32,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/faq.inc', 'hits' => 9, 'memory_consumption' => 5680, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345905, ), @@ -42,8 +41,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/downloads.php', 'hits' => 86, 'memory_consumption' => 9488, - 'last_used' => 'Sat Mar 16 12:03:47 2013 - ', + 'last_used' => 'Sat Mar 16 12:03:47 2013', 'last_used_timestamp' => 1363460627, 'timestamp' => 1355102402, ), @@ -52,8 +50,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/languages.inc', 'hits' => 5605, 'memory_consumption' => 16984, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1362994804, ), @@ -62,8 +59,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/header.inc', 'hits' => 9, 'memory_consumption' => 20352, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1357938001, ), @@ -72,8 +68,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/getting-started.inc', 'hits' => 9, 'memory_consumption' => 1936, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345409, ), @@ -82,8 +77,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/faq.php', 'hits' => 122, 'memory_consumption' => 5152, - 'last_used' => 'Sat Mar 16 12:06:15 2013 - ', + 'last_used' => 'Sat Mar 16 12:06:15 2013', 'last_used_timestamp' => 1363460775, 'timestamp' => 1363345906, ), @@ -92,8 +86,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/footer.inc', 'hits' => 9, 'memory_consumption' => 1976, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1347648001, ), @@ -102,8 +95,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/site.inc', 'hits' => 5605, 'memory_consumption' => 63488, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1354724402, ), @@ -112,8 +104,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/mirrors.inc', 'hits' => 5605, 'memory_consumption' => 96160, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363419613, ), @@ -122,8 +113,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/refs.basic.vartype.inc', 'hits' => 9, 'memory_consumption' => 5032, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345844, ), @@ -132,8 +122,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/layout.inc', 'hits' => 5605, 'memory_consumption' => 145704, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1356610801, ), @@ -142,8 +131,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/sites.php', 'hits' => 73, 'memory_consumption' => 2024, - 'last_used' => 'Sat Mar 16 12:10:10 2013 - ', + 'last_used' => 'Sat Mar 16 12:10:10 2013', 'last_used_timestamp' => 1363461010, 'timestamp' => 1354724402, ), @@ -152,8 +140,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/search.php', 'hits' => 3083, 'memory_consumption' => 19728, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1347648005, ), @@ -162,8 +149,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/langref.inc', 'hits' => 49, 'memory_consumption' => 7416, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345411, ), @@ -172,8 +158,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/index.inc', 'hits' => 132, 'memory_consumption' => 4680, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345409, ), @@ -182,8 +167,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/docs.php', 'hits' => 73, 'memory_consumption' => 4536, - 'last_used' => 'Sat Mar 16 12:04:36 2013 - ', + 'last_used' => 'Sat Mar 16 12:04:36 2013', 'last_used_timestamp' => 1363460676, 'timestamp' => 1347648000, ), @@ -192,8 +176,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/shared-manual.inc', 'hits' => 122, 'memory_consumption' => 107688, - 'last_used' => 'Sat Mar 16 12:06:15 2013 - ', + 'last_used' => 'Sat Mar 16 12:06:15 2013', 'last_used_timestamp' => 1363460775, 'timestamp' => 1357938001, ), @@ -202,8 +185,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/mozopensearch.inc', 'hits' => 14, 'memory_consumption' => 1232, - 'last_used' => 'Sat Mar 16 12:00:34 2013 - ', + 'last_used' => 'Sat Mar 16 12:00:34 2013', 'last_used_timestamp' => 1363460434, 'timestamp' => 1347648001, ), @@ -212,8 +194,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/ip-to-country.inc', 'hits' => 5605, 'memory_consumption' => 21840, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1347648001, ), @@ -222,8 +203,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/version.inc', 'hits' => 775, 'memory_consumption' => 7880, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363321202, ), @@ -232,8 +212,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/errors.inc', 'hits' => 691, 'memory_consumption' => 59888, - 'last_used' => 'Sat Mar 16 12:10:33 2013 - ', + 'last_used' => 'Sat Mar 16 12:10:33 2013', 'last_used_timestamp' => 1363461033, 'timestamp' => 1347648001, ), @@ -242,8 +221,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/countries.inc', 'hits' => 5605, 'memory_consumption' => 31184, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363419614, ), @@ -252,8 +230,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/error.php', 'hits' => 691, 'memory_consumption' => 61952, - 'last_used' => 'Sat Mar 16 12:10:33 2013 - ', + 'last_used' => 'Sat Mar 16 12:10:33 2013', 'last_used_timestamp' => 1363461033, 'timestamp' => 1347648000, ), @@ -262,8 +239,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/refs.basic.text.inc', 'hits' => 9, 'memory_consumption' => 3312, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345831, ), @@ -272,8 +248,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/loadavg.inc', 'hits' => 3775, 'memory_consumption' => 12184, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1354738801, ), @@ -282,8 +257,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/prepend.inc', 'hits' => 5605, 'memory_consumption' => 23432, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1347648001, ), @@ -292,8 +266,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/o.php', 'hits' => 1, 'memory_consumption' => 13424, - 'last_used' => 'Sat Mar 16 18:11:21 2013 - ', + 'last_used' => 'Sat Mar 16 18:11:21 2013', 'last_used_timestamp' => 1363482681, 'timestamp' => 1363482654, ), @@ -302,8 +275,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/pregen-events.inc', 'hits' => 1141, 'memory_consumption' => 840, - 'last_used' => 'Sat Mar 16 12:15:07 2013 - ', + 'last_used' => 'Sat Mar 16 12:15:07 2013', 'last_used_timestamp' => 1363461307, 'timestamp' => 1363419615, ), @@ -312,8 +284,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/opcache.php', 'hits' => 0, 'memory_consumption' => 13944, - 'last_used' => 'Sun Mar 17 01:22:31 2013 - ', + 'last_used' => 'Sun Mar 17 01:22:31 2013', 'last_used_timestamp' => 1363508551, 'timestamp' => 1363508542, ), @@ -322,8 +293,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/refs.calendar.inc', 'hits' => 9, 'memory_consumption' => 2264, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345437, ), @@ -332,8 +302,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/manual/en/toc/security.inc', 'hits' => 19, 'memory_consumption' => 5352, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363345419, ), @@ -342,8 +311,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/pregen-news.inc', 'hits' => 1161, 'memory_consumption' => 57896, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363419615, ), @@ -352,8 +320,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/my.php', 'hits' => 34, 'memory_consumption' => 22640, - 'last_used' => 'Sat Mar 16 12:15:15 2013 - ', + 'last_used' => 'Sat Mar 16 12:15:15 2013', 'last_used_timestamp' => 1363461315, 'timestamp' => 1354724402, ), @@ -362,8 +329,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/pregen-confs.inc', 'hits' => 678, 'memory_consumption' => 1400, - 'last_used' => 'Sat Mar 16 12:02:49 2013 - ', + 'last_used' => 'Sat Mar 16 12:02:49 2013', 'last_used_timestamp' => 1363460569, 'timestamp' => 1363419615, ), @@ -372,8 +338,7 @@ function opcache_get_status() { 'full_path' => '/var/www/index.php', 'hits' => 1, 'memory_consumption' => 744, - 'last_used' => 'Sat Mar 16 12:01:20 2013 - ', + 'last_used' => 'Sat Mar 16 12:01:20 2013', 'last_used_timestamp' => 1363460480, 'timestamp' => 1358644238, ), @@ -382,8 +347,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/index-stable.php', 'hits' => 679, 'memory_consumption' => 22208, - 'last_used' => 'Sat Mar 16 12:02:49 2013 - ', + 'last_used' => 'Sat Mar 16 12:02:49 2013', 'last_used_timestamp' => 1363460569, 'timestamp' => 1347648003, ), @@ -392,8 +356,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/conferences/index.php', 'hits' => 462, 'memory_consumption' => 3872, - 'last_used' => 'Sat Mar 16 12:15:07 2013 - ', + 'last_used' => 'Sat Mar 16 12:15:07 2013', 'last_used_timestamp' => 1363461307, 'timestamp' => 1347648000, ), @@ -402,8 +365,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/support.php', 'hits' => 73, 'memory_consumption' => 1912, - 'last_used' => 'Sat Mar 16 12:06:40 2013 - ', + 'last_used' => 'Sat Mar 16 12:06:40 2013', 'last_used_timestamp' => 1363460800, 'timestamp' => 1347648005, ), @@ -412,8 +374,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/op.php', 'hits' => 0, 'memory_consumption' => 1448, - 'last_used' => 'Sun Mar 17 01:34:33 2013 - ', + 'last_used' => 'Sun Mar 17 01:34:33 2013', 'last_used_timestamp' => 1363509273, 'timestamp' => 1363509263, ), @@ -422,8 +383,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/posttohost.inc', 'hits' => 342, 'memory_consumption' => 3824, - 'last_used' => 'Sat Mar 16 12:09:18 2013 - ', + 'last_used' => 'Sat Mar 16 12:09:18 2013', 'last_used_timestamp' => 1363460958, 'timestamp' => 1347648001, ), @@ -432,8 +392,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/langchooser.inc', 'hits' => 5605, 'memory_consumption' => 23784, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1347648001, ), @@ -442,8 +401,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/manual-lookup.inc', 'hits' => 624, 'memory_consumption' => 26648, - 'last_used' => 'Sat Mar 16 12:10:33 2013 - ', + 'last_used' => 'Sat Mar 16 12:10:33 2013', 'last_used_timestamp' => 1363461033, 'timestamp' => 1354750802, ), @@ -452,8 +410,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/mailing-lists.php', 'hits' => 342, 'memory_consumption' => 31576, - 'last_used' => 'Sat Mar 16 12:09:18 2013 - ', + 'last_used' => 'Sat Mar 16 12:09:18 2013', 'last_used_timestamp' => 1363460958, 'timestamp' => 1361200802, ), @@ -462,8 +419,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/last_updated.inc', 'hits' => 5605, 'memory_consumption' => 840, - 'last_used' => 'Sat Mar 16 12:16:31 2013 - ', + 'last_used' => 'Sat Mar 16 12:16:31 2013', 'last_used_timestamp' => 1363461391, 'timestamp' => 1363419675, ), @@ -472,8 +428,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/include/email-validation.inc', 'hits' => 342, 'memory_consumption' => 9168, - 'last_used' => 'Sat Mar 16 12:09:18 2013 - ', + 'last_used' => 'Sat Mar 16 12:09:18 2013', 'last_used_timestamp' => 1363460958, 'timestamp' => 1362175205, ), @@ -482,8 +437,7 @@ function opcache_get_status() { 'full_path' => '/var/www/phpweb/index.php', 'hits' => 679, 'memory_consumption' => 1840, - 'last_used' => 'Sat Mar 16 12:02:49 2013 - ', + 'last_used' => 'Sat Mar 16 12:02:49 2013', 'last_used_timestamp' => 1363460569, 'timestamp' => 1347648003, ), From f88da005fc772830654841c3bb797aed62419426 Mon Sep 17 00:00:00 2001 From: James White Date: Sun, 13 Apr 2014 18:51:39 +0100 Subject: [PATCH 3/4] Prevent D3 error when incorrect data is attempted to be drawn --- opcache.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/opcache.php b/opcache.php index e111e52..25454e2 100644 --- a/opcache.php +++ b/opcache.php @@ -581,11 +581,22 @@ function set_text(t) { } function change() { - if (typeof dataset[this.value] !== 'undefined') { + // Filter out any zero values to see if there is anything left + var remove_zero_values = dataset[this.value].filter(function(value) { + return value > 0; + }); + + // Skip if the value is undefined for some reason + if (typeof dataset[this.value] !== 'undefined' && remove_zero_values.length > 0) { + $('#graph').find('> svg').show(); path = path.data(pie(dataset[this.value])); // update the data path.transition().duration(750).attrTween("d", arcTween); // redraw the arcs - set_text(this.value); + // Hide the graph if we can't draw it correctly, not ideal but this works + } else { + $('#graph').find('> svg').hide(); } + + set_text(this.value); } function arcTween(a) { From 01e52c8facbe6c107826cf5e9e2e86a8d6d5912e Mon Sep 17 00:00:00 2001 From: James White Date: Sun, 13 Apr 2014 18:52:38 +0100 Subject: [PATCH 4/4] Code alignment fixes --- opcache.php | 78 ++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/opcache.php b/opcache.php index 25454e2..9af6d25 100644 --- a/opcache.php +++ b/opcache.php @@ -538,17 +538,17 @@ function toggleVisible(head, row) { var arc = d3.svg.arc().innerRadius(radius - 20).outerRadius(radius - 50); var svg = d3.select("#graph").append("svg") - .attr("width", width) - .attr("height", height) - .append("g") - .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); + .attr("width", width) + .attr("height", height) + .append("g") + .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); var path = svg.selectAll("path") - .data(pie(dataset.memory)) - .enter().append("path") - .attr("fill", function(d, i) { return colour(i); }) - .attr("d", arc) - .each(function(d) { this._current = d; }); // store the initial values + .data(pie(dataset.memory)) + .enter().append("path") + .attr("fill", function(d, i) { return colour(i); }) + .attr("d", arc) + .each(function(d) { this._current = d; }); // store the initial values d3.selectAll("input").on("change", change); set_text("memory"); @@ -574,8 +574,8 @@ function set_text(t) { } else if (t === "restarts") { d3.select("#stats").html( ""+ - ""+ - "
Memory"+dataset[t][0]+"
Manual"+dataset[t][1]+"
Keys"+dataset[t][2]+"
" + "Manual"+dataset[t][1]+""+ + "Keys"+dataset[t][2]+"" ); } } @@ -609,23 +609,23 @@ function arcTween(a) { function size_for_humans(bytes) { if (bytes > 1048576) { - return (bytes/1048576).toFixed(2) + ' MB'; + return (bytes/1048576).toFixed(2) + ' MB'; } else if (bytes > 1024) { - return (bytes/1024).toFixed(2) + ' KB'; + return (bytes/1024).toFixed(2) + ' KB'; } else return bytes + ' bytes'; } var w = window.innerWidth, - h = window.innerHeight, - x = d3.scale.linear().range([0, w]), - y = d3.scale.linear().range([0, h]); + h = window.innerHeight, + x = d3.scale.linear().range([0, w]), + y = d3.scale.linear().range([0, h]); var vis = d3.select("#partition") - .style("width", w + "px") - .style("height", h + "px") - .append("svg:svg") - .attr("width", w) - .attr("height", h); + .style("width", w + "px") + .style("height", h + "px") + .append("svg:svg") + .attr("width", w) + .attr("height", h); var partition = d3.layout.partition() .value(function(d) { return d.size; }); @@ -633,27 +633,27 @@ function size_for_humans(bytes) { root = JSON.parse('getD3Scripts()); ?>'); var g = vis.selectAll("g") - .data(partition.nodes(root)) - .enter().append("svg:g") - .attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; }) - .on("click", click); + .data(partition.nodes(root)) + .enter().append("svg:g") + .attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; }) + .on("click", click); var kx = w / root.dx, ky = h / 1; g.append("svg:rect") - .attr("width", root.dy * kx) - .attr("height", function(d) { return d.dx * ky; }) - .attr("class", function(d) { return d.children ? "parent" : "child"; }); + .attr("width", root.dy * kx) + .attr("height", function(d) { return d.dx * ky; }) + .attr("class", function(d) { return d.children ? "parent" : "child"; }); g.append("svg:text") - .attr("transform", transform) - .attr("dy", ".35em") - .style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; }) - .text(function(d) { return d.name; }) + .attr("transform", transform) + .attr("dy", ".35em") + .style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; }) + .text(function(d) { return d.name; }) d3.select(window) - .on("click", function() { click(root); }) + .on("click", function() { click(root); }) function click(d) { if (!d.children) return; @@ -664,16 +664,16 @@ function click(d) { y.domain([d.x, d.x + d.dx]); var t = g.transition() - .duration(d3.event.altKey ? 7500 : 750) - .attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; }); + .duration(d3.event.altKey ? 7500 : 750) + .attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; }); t.select("rect") - .attr("width", d.dy * kx) - .attr("height", function(d) { return d.dx * ky; }); + .attr("width", d.dy * kx) + .attr("height", function(d) { return d.dx * ky; }); t.select("text") - .attr("transform", transform) - .style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; }); + .attr("transform", transform) + .style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; }); d3.event.stopPropagation(); }