summaryrefslogtreecommitdiffstats
path: root/plugins/impstats/pygal-tooltips.js
diff options
context:
space:
mode:
authorAndre Lorbach <alorbach@adiscon.com>2013-07-03 13:21:46 +0200
committerAndre Lorbach <alorbach@adiscon.com>2013-07-03 13:21:46 +0200
commit7b16f5c49766fb8d08835e2f2839d4514dc29f9a (patch)
tree707e2d4a3615fd70d883fc3e920d21b59bdeb81b /plugins/impstats/pygal-tooltips.js
parent1d22bd58d4a19d63294fb89f4f7a054e7220074a (diff)
downloadrsyslog-7b16f5c49766fb8d08835e2f2839d4514dc29f9a.tar.gz
rsyslog-7b16f5c49766fb8d08835e2f2839d4514dc29f9a.tar.bz2
rsyslog-7b16f5c49766fb8d08835e2f2839d4514dc29f9a.zip
Finished statslog graph and splitter script.
Also added needed javascript files, so they can be included into the svg files. This removes dependencies on external sources. The statslog-splitter can now automatically generated SVG or PNG charts together with an index.html in the output directory. This helps taking a quick view on all generated stats data.
Diffstat (limited to 'plugins/impstats/pygal-tooltips.js')
-rw-r--r--plugins/impstats/pygal-tooltips.js121
1 files changed, 121 insertions, 0 deletions
diff --git a/plugins/impstats/pygal-tooltips.js b/plugins/impstats/pygal-tooltips.js
new file mode 100644
index 00000000..7b183de1
--- /dev/null
+++ b/plugins/impstats/pygal-tooltips.js
@@ -0,0 +1,121 @@
+<html>
+<head><title>301 Moved Permanently</title></head>
+<body bgcolor="white">
+<center><h1>301 Moved Permanently</h1></center>
+<hr><center>nginx</center>
+</body>
+</html>
+// Generated by CoffeeScript 1.6.3
+(function() {
+ var get_translation, init, padding, r_translation, tooltip_timeout;
+
+ padding = 5;
+
+ tooltip_timeout = 0;
+
+ r_translation = /translate\((\d+)[ ,]+(\d+)\)/;
+
+ get_translation = function($elt) {
+ return (r_translation.exec($elt.attr('transform')) || []).slice(1);
+ };
+
+ init = function(ctx) {
+ var tooltip, untooltip;
+ $vg('.text-overlay .series', ctx).hide();
+ $vg('.reactive', ctx).hover((function() {
+ return $vg(this).addClass('active');
+ }), (function() {
+ return $vg(this).removeClass('active');
+ }));
+ $vg('.activate-serie', ctx).hover((function() {
+ var num;
+ num = this.id.replace('activate-serie-', '');
+ $vg('.text-overlay .serie-' + num, ctx).show();
+ return $vg('.serie-' + num + ' .reactive', ctx).addClass('active');
+ }), function() {
+ var num;
+ num = this.id.replace('activate-serie-', '');
+ $vg('.text-overlay .serie-' + num, ctx).hide();
+ return $vg('.serie-' + num + ' .reactive', ctx).removeClass('active');
+ });
+ $vg('.tooltip-trigger', ctx).hover((function() {
+ return tooltip($vg(this));
+ }), (function() {
+ return untooltip();
+ }));
+ tooltip = function($elt) {
+ var $label, $rect, $text, $tooltip, $value, current_x, current_y, h, target, w, x, x_elt, xlink, y, y_elt, _ref;
+ clearTimeout(tooltip_timeout);
+ $tooltip = $vg('#tooltip', ctx).css({
+ opacity: 1
+ });
+ $text = $tooltip.find('text');
+ $label = $tooltip.find('tspan.label');
+ $value = $tooltip.find('tspan.value');
+ $rect = $tooltip.find('rect');
+ if ($elt.siblings('.tooltip').size()) {
+ $label.text($elt.siblings('.tooltip').text());
+ $value.text('');
+ } else {
+ $label.text($elt.siblings('.label').text());
+ $value.text($elt.siblings('.value').text());
+ }
+ xlink = $elt.siblings('.xlink').text() || null;
+ target = $elt.parent().attr('target');
+ if (xlink) {
+ $tooltip.find('a').attr('href', xlink).attr('target', target);
+ }
+ $text.attr('x', padding);
+ $text.attr('y', padding + this.config.tooltip_font_size);
+ $value.attr('x', padding);
+ $value.attr('dy', $label.text() ? this.config.tooltip_font_size + padding : 0);
+ w = $text.width() + 2 * padding;
+ h = $text.height() + 2 * padding;
+ $rect.attr('width', w);
+ $rect.attr('height', h);
+ x_elt = $elt.siblings('.x');
+ y_elt = $elt.siblings('.y');
+ x = parseInt(x_elt.text());
+ if (x_elt.hasClass('centered')) {
+ x -= w / 2;
+ } else if (x_elt.hasClass('left')) {
+ x -= w;
+ }
+ y = parseInt(y_elt.text());
+ if (y_elt.hasClass('centered')) {
+ y -= h / 2;
+ } else if (y_elt.hasClass('top')) {
+ y -= h;
+ }
+ _ref = get_translation($tooltip), current_x = _ref[0], current_y = _ref[1];
+ if (current_x === x && current_y === y) {
+ return;
+ }
+ return $tooltip.attr('transform', "translate(" + x + " " + y + ")");
+ };
+ return untooltip = function() {
+ return tooltip_timeout = setTimeout((function() {
+ return $vg('#tooltip', ctx).css({
+ opacity: 0
+ });
+ }), 1000);
+ };
+ };
+
+ this.init_svg = function(ctx) {
+ return init($vg(ctx));
+ };
+
+ $vg(function() {
+ var $charts;
+ $charts = $vg('.pygal-chart');
+ if ($charts.size()) {
+ return $charts.each(function() {
+ return init_svg(this);
+ });
+ } else {
+ return init();
+ }
+ });
+
+}).call(this);