Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: paulasmuth/fnordmetric
base: 8a2fd6f73f
...
head fork: paulasmuth/fnordmetric
compare: 689e802ac6
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 08, 2012
@kunalmodi kunalmodi allow widgets with html embedded bf4edff
Commits on Apr 21, 2012
Paul Asmuth Merge pull request #66 from kunalmodi/add-html
embed external html charts in widgets
689e802
View
1  lib/fnordmetric.rb
@@ -152,6 +152,7 @@ def self.embedded(opts={})
require "fnordmetric/bars_widget"
require "fnordmetric/toplist_widget"
require "fnordmetric/pie_widget"
+require "fnordmetric/html_widget"
require "fnordmetric/namespace"
require "fnordmetric/gauge_modifiers"
require "fnordmetric/gauge_calculations"
View
28 lib/fnordmetric/html_widget.rb
@@ -0,0 +1,28 @@
+class FnordMetric::HtmlWidget < FnordMetric::Widget
+ def data
+ super.merge(
+ :html => @opts[:html]
+ )
+ end
+
+ def add_gauges(gauges)
+ @gauges = []
+ @tick = 0
+
+ if !gauges.blank?
+ error! "initializing a html widget with gauges is void"
+ end
+ end
+
+ def data_gauges
+ {}
+ end
+
+ def default_range(now=Time.now)
+ 0..0
+ end
+
+ def has_tick?
+ false
+ end
+end
View
27 pub/fnordmetric.js
@@ -178,6 +178,31 @@ var FnordMetric = (function(){
};
+ var htmlWidget = function(){
+ function render(opts){
+
+ opts.elem.append(
+ $('<div class="headbar small"></div>').html(opts.title)
+ ).css({
+ 'marginBottom': 20,
+ 'overflow': 'hidden'
+ });
+
+ var container = $('<div></div>')
+ .addClass('html_container')
+ .html(opts.html);
+
+ opts.elem.append(container);
+ }
+
+ function updateValues(opts){}
+ function updatedisplay(opts, diff_factor){}
+
+ return {
+ render: render
+ };
+ }
+
var numbersWidget = function(){
@@ -604,7 +629,6 @@ var FnordMetric = (function(){
};
-
var pieWidget = function(){
function render(opts){
@@ -1078,6 +1102,7 @@ var FnordMetric = (function(){
if(widget.klass=='NumbersWidget'){ numbersWidget().render(widget); }
if(widget.klass=='ToplistWidget'){ toplistWidget().render(widget); }
if(widget.klass=='PieWidget'){ pieWidget().render(widget); }
+ if(widget.klass=="HtmlWidget") { htmlWidget().render(widget); }
};
function resizeWidget(wkey){

No commit comments for this range

Something went wrong with that request. Please try again.