| use Raphael instead of Grafico since Grafico doesn't work well - reportable - F… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit b8ee111f12ef95eec333b448a14179d9aa7eef2f | |
| parent 18b0b6c2ab0fe1e0540365a2eecdd588e96d7aba | |
| Author: Marco Otte-Witte <[email protected]> | |
| Date: Thu, 13 May 2010 13:37:00 +0200 | |
| use Raphael instead of Grafico since Grafico doesn't work well | |
| Diffstat: | |
| M README.md | 4 ++-- | |
| M generators/reportable_grafico_asse… | 5 ----- | |
| M generators/reportable_grafico_asse… | 4 ++-- | |
| D generators/reportable_grafico_asse… | 80 ---------------------------… | |
| M lib/saulabs/reportable/report_tag_… | 19 +++---------------- | |
| M spec/other/report_tag_helper_spec.… | 18 ++++++------------ | |
| 6 files changed, 13 insertions(+), 117 deletions(-) | |
| --- | |
| diff --git a/README.md b/README.md | |
| @@ -72,7 +72,7 @@ If you want to use reportable's JavaScript graph output forma… | |
| ./script/generate reportable_grafico_assets | |
| -if you want to use [Grafico](http://grafico.kilianvalkhof.com/) or if you want… | |
| +if you want to use [Raphael](http://raphaeljs.com/) or if you want to use [jQu… | |
| ./script/generate reportable_jquery_flot_assets | |
| @@ -90,7 +90,7 @@ If you want to use reportable's JavaScript graph output forma… | |
| rails generate reportable_grafico_assets | |
| -if you want to use [Grafico](http://grafico.kilianvalkhof.com/) or if you want… | |
| +if you want to use [Raphael](http://raphaeljs.com/) or if you want to use [jQu… | |
| rails generate reportable_jquery_flot_assets | |
| diff --git a/generators/reportable_grafico_assets/reportable_grafico_assets_gen… | |
| @@ -10,10 +10,6 @@ if Saulabs::Reportable::IS_RAILS3 | |
| File.join(File.dirname(__FILE__), 'templates', 'raphael.min.js'), | |
| 'public/javascripts/raphael.min.js' | |
| ) | |
| - copy_file( | |
| - File.join(File.dirname(__FILE__), 'templates', 'grafico.min.js'), | |
| - 'public/javascripts/grafico.min.js' | |
| - ) | |
| readme(File.join(File.dirname(__FILE__), 'templates', 'NOTES')) | |
| end | |
| @@ -27,7 +23,6 @@ else | |
| record do |m| | |
| m.directory('public/javascripts') | |
| m.file('raphael.min.js', 'public/javascripts/raphael.min.js') | |
| - m.file('grafico.min.js', 'public/javascripts/grafico.min.js') | |
| m.readme('NOTES') | |
| end | |
| end | |
| diff --git a/generators/reportable_grafico_assets/templates/NOTES b/generators/… | |
| @@ -1,4 +1,4 @@ | |
| - ** Beware that Grafico depends on Prototype.js! | |
| - ** Also don't forget to include Raphael and Grafico as well as Prototype.js … | |
| + ** Beware that Raphael depends on Prototype.js! | |
| + ** Also don't forget to include Raphael as well as Prototype.js in your layo… | |
| diff --git a/generators/reportable_grafico_assets/templates/grafico.min.js b/ge… | |
| @@ -1,80 +0,0 @@ | |
| -var Grafico={Version:"0.9",Base:{},BaseGraph:{},Normaliser:{},LineGraph:{},Are… | |
| -Grafico.Base=Class.create({normaliseData:function(a){return $A(a).collect(func… | |
| -Grafico.Normaliser=Class.create({initialize:function(a,b){this.options={start_… | |
| -this.min;a=this.same_values?this.min-this.step*5:this.round(a,1);if(this.min>0… | |
| -(Math.log(a)/Math.LN10).round()-1)}}); | |
| -Grafico.BaseGraph=Class.create(Grafico.Base,{initialize:function(a,b,c){this.o… | |
| -draw_axis:true,datalabels:"",hover_color:"",watermark:false,watermark_location… | |
| -if(this.hasBaseLine()){this.flat_data.push(this.base_line);this.flat_data=this… | |
| -this.options.labels=$A($R(1,this.data_size));Object.extend(this.options,this.c… | |
| -this.y_padding=this.y_padding_top+this.y_padding_bottom;this.graph_width=this.… | |
| -this.top_value=this.value_labels.last();this.grid_start_offset=-1;this.paper=n… | |
| -this.globalBlockSet=this.paper.set();this.globalAreaLineSet=this.paper.set();t… | |
| -return this.normalized_base_line},getNormalizedRealData:function(){if(this.nor… | |
| -c=a.clientY+document.body.scrollTop-document.documentElement.scrollTop}return{… | |
| -b)}.bind(this))},paddingLeftOffset:function(){if(this.options.show_vertical_la… | |
| -this.drawGrid();this.options.watermark&&this.drawWatermark();this.options.show… | |
| -a.options.datalabels[b[0]],a.element,c)}.bind(a))},drawWatermark:function(){va… | |
| -b.src=a.src||a},drawGrid:function(){var a=this.paper.path().attr({stroke:this.… | |
| -for(d=0;d<c;d++){if(this.options.hide_empty_label_grid===true&&this.options.la… | |
| -1&&g.splice(0,this.options.odd_horizontal_offset)}if(this.options.stacked_fill… | |
| -"stroke-width":this.options.stroke_width+"px"});$A(g).each(function(k,m){var n… | |
| -this.options.draw_hovers){this.drawHover(j,d,e,b);this.globalHoverSet.toFront(… | |
| -2.5-1,b=this.options.height-this.y_padding_bottom,c=this.paper.path().attr({st… | |
| -this.x_padding_left,this.options.height-this.y_padding_bottom-a)},drawAxis:fun… | |
| -10)-0.5,parseInt(this.y_padding_top,10))},makeValueLabels:function(a){for(var … | |
| -Object.extend(k,f||{});a.each(function(m){if(this.options.draw_axis&&(this.opt… | |
| -"",c=0;c<this.value_labels.length;c++)this.value_labels[c]+=b;this.drawMarkers… | |
| -7)*-1],a)},drawHover:function(a,b,c,d){var e=this,f=this.options.stacked_fill|… | |
| -stroke:g},200):a.animate({stroke:g},200);l=e.getMousePos(l);h[0].attr({x:l.x-j… | |
| -h)})},function(){f==="fill"?a.animate({fill:d,stroke:d},200):a.animate({stroke… | |
| -c.attrs.y+d.height-this.options.height;e.translate(0,b*-1-1);f&&f.translate(0,… | |
| -b.height/2+c-1).lineTo(a.attrs.x,a.attrs.y+b.height/2+c*2).lineTo(a.attrs.x+c,… | |
| -if(typeof Array.prototype.max==="undefined")Array.prototype.max=function(){ret… | |
| -Array.prototype.remove=function(a,b){b=this.slice((b||a)+1||this.length);this.… | |
| -Raphael.el.lineTo=function(a,b){this._last={x:a,y:b};return this.attr({path:th… | |
| -Raphael.el.andClose=function(){return this.attr({path:this.attrs.path+"z"})}; | |
| -Grafico.LineGraph=Class.create(Grafico.BaseGraph,{chartDefaults:function(){ret… | |
| -"circle")this.drawGraphMarkers(a,c,d,e,g,h);else this.options.markers==="value… | |
| -b,c,d,e,f,g){a+=this.options.odd_horizontal_offset>1?this.options.odd_horizont… | |
| -6,j=this.step,i=this.options.stacked?this.graph_height/9:this.graph_height/3;b… | |
| -fill:this.options.hover_text_color,opacity:1});f=e.getBBox();c=this.drawRoundR… | |
| -Grafico.AreaGraph=Class.create(Grafico.LineGraph,{chartDefaults:function(){ret… | |
| -else this.options.markers==="value"&&this.drawGraphValueMarkers(a,c,d,e,g,h,j)… | |
| -Grafico.StackGraph=Class.create(Grafico.AreaGraph,{chartDefaults:function(){re… | |
| -Grafico.StreamGraph=Class.create(Grafico.StackGraph,{chartDefaults:function(){… | |
| -false?b[d][c]:(d+1)*b[d][c];a[c]=this.options.stream_line_smoothing==false?-su… | |
| -for(var d=a.collect(function(g){return g[1]}),e=0;e<d[0].length;e++)d[d.length… | |
| -bestMarkerPositions:function(){if(this.best_marker_positions==undefined)this.b… | |
| -fill:this.options.hover_text_color,opacity:1});c=b.getBBox();c=this.drawRoundR… | |
| -Grafico.BarGraph=Class.create(Grafico.BaseGraph,{chartDefaults:function(){retu… | |
| -this.bar_padding},calculateStep:function(){this.data_size=this.data_size===1?2… | |
| -e=h&&a===f.length-1?h:d<0?j:e;f=this.paper.rect(c-this.bar_width/2,b,this.bar_… | |
| -c=this.options.labels;if(this.options.label_max_size)for(var d=0;d<c.length;d+… | |
| -0.5,parseInt(b,10)+0.5);b-=this.graph_height;a.moveTo(this.x_padding_left-0.5,… | |
| -c=this.y_label_count;d=this.options.horizontalbar?this.graph_width/this.y_labe… | |
| -a.moveTo(parseInt(this.x_padding_left+this.graph_width,10)-0.5,this.y_padding_… | |
| -stroke:e,opacity:0});b.attr({"font-size":this.options.font_size,fill:this.opti… | |
| -Grafico.StackedBarGraph=Class.create(Grafico.BarGraph,{chartDefaults:function(… | |
| -b[c+1][d];return a},calculateCoords:function(a){var b=this.x_padding_left+this… | |
| -i){this.drawPlot(i,h,j[0],j[1],b,g,d,e,f)}.bind(this));if(this.options.datalab… | |
| -b=this.paper.rect(c-this.bar_width/2,b,this.bar_width,d).attr(f);d<0?b.attr({h… | |
| -1.5,d);a.attr({fill:e,"stroke-width":0,stroke:e,opacity:0});b.attr({"font-size… | |
| -200)})}}); | |
| -Grafico.HorizontalBarGraph=Class.create(Grafico.BarGraph,{chartDefaults:functi… | |
| -b[b.length-1];return a/b*this.graph_width},longestLabel:function(){return $A(t… | |
| -g=this.x_padding_left+f-0.5,h=this.options.bargraph_lastcolor,j=this.options.b… | |
| -bargraph2.attr({fill:k,"stroke-width":0,stroke:k});p.push(bargraph2,n);i<0&&ba… | |
| -e,this.graph_width,this.bar_width).attr({fill:k,"stroke-width":0,stroke:k,opac… | |
| -stroke:k},200);o.animate({opacity:0},200)})}e+=this.step}.bind(this))},drawFoc… | |
| -c=this.options.labels;if(this.options.label_max_size)for(var d=0;d<c.length;d+… | |
| -7)*-1])},drawMeanLine:function(a){var b=this.paper.path().attr(this.options.me… | |
| -Grafico.SparkLine=Class.create(Grafico.Base,{initialize:function(a,b,c){this.e… | |
| -this.options.acceptable_range?this.paper.rect(0,this.options.height-this.norma… | |
| -1,0.75).hex},normalise:function(a){var b=this.data.min()<0?this.data.max()-thi… | |
| -b)}this.drawLines(this.options.color,a);this.options.highlight&&this.showHighl… | |
| -1]+(b/2).round();var d=this.options.highlight.color||"#f00";if(typeof this.opt… | |
| -Grafico.SparkBar=Class.create(Grafico.SparkLine,{calculateStep:function(){retu… | |
| -showHighlight:function(){}}); | |
| -Grafico.SparkArea=Class.create(Grafico.SparkLine,{drawLines:function(a,b){var … | |
| -i);h.lineTo(j,this.options.height-i)}.bind(this));g.lineTo(j,this.options.heig… | |
| diff --git a/lib/saulabs/reportable/report_tag_helper.rb b/lib/saulabs/reportab… | |
| @@ -33,7 +33,7 @@ module Saulabs | |
| # | |
| # @example Rendering a sparkline tag for report data | |
| # | |
| - # <%= report_tag(User.registrations_report, :width => 200, :height => … | |
| + # <%= google_report_tag(User.registrations_report, :width => 200, :hei… | |
| # | |
| def google_report_tag(data, options = {}) | |
| options.reverse_merge!(Config.google_options) | |
| @@ -80,27 +80,14 @@ module Saulabs | |
| # | |
| # @example Rendering a sparkline tag for report data | |
| # | |
| - # <%= report_tag(User.registrations_report, {:width => 200, :height =>… | |
| + # <%= raphael_report_tag(User.registrations_report, {:width => 200, :h… | |
| # | |
| - def grafico_report_tag(data, options = {}, grafico_options = {}) | |
| - options.reverse_merge!(Config.grafico_options.slice(:width, :height, :… | |
| - options.reverse_merge!(:dom_id => "#{data.model_name.downcase}_#{data.… | |
| - grafico_options.reverse_merge!(Config.grafico_options.except(:width, :… | |
| - %Q{<div id="#{options[:dom_id]}" style="width: #{options[:width]}px; h… | |
| - <script type="text/javascript" charset="utf-8"> | |
| - new Grafico.AreaGraph( | |
| - $('#{options[:dom_id]}'), | |
| - { data: #{data.map{|d| eval options[:format], d[1].send(:binding) … | |
| - #{grafico_options.to_json}); | |
| - </script>} | |
| - end | |
| - | |
| def raphael_report_tag(data, options = {}, raphael_options = {}) | |
| options.reverse_merge!(Config.raphael_options.slice(:width, :height, :… | |
| options.reverse_merge!(:dom_id => "#{data.model_name.downcase}_#{data.… | |
| raphael_options.reverse_merge!(Config.raphael_options.except(:width, :… | |
| %Q{<div id="#{options[:dom_id]}" style="width:#{options[:width]}px;hei… | |
| - <script type="text/javascript"> | |
| + <script type="text\/javascript" charset="utf-8"> | |
| var graph = Raphael('#{options[:dom_id]}'); | |
| graph.g.linechart( | |
| -10, 4, #{options[:width]}, #{options[:height]}, | |
| diff --git a/spec/other/report_tag_helper_spec.rb b/spec/other/report_tag_helpe… | |
| @@ -6,26 +6,20 @@ describe Saulabs::Reportable::ReportTagHelper do | |
| @helper = TestHelper.new | |
| end | |
| - describe '#grafico_report_tag' do | |
| + describe '#raphael_report_tag' do | |
| data_set = Saulabs::Reportable::ResultSet.new([[DateTime.now, 1.0], [DateT… | |
| - it 'should not raise an error' do | |
| - lambda { | |
| - @helper.grafico_report_tag(data_set) | |
| - }.should_not raise_error | |
| - end | |
| - | |
| it 'should return a string' do | |
| - @helper.grafico_report_tag(data_set).class.should == String | |
| + @helper.raphael_report_tag(data_set).class.should == String | |
| end | |
| - it 'should contain div tag' do | |
| - @helper.grafico_report_tag(data_set).should =~ /^<div id=".*">.*<\/div>/ | |
| + it 'should contain a div tag' do | |
| + @helper.raphael_report_tag(data_set).should =~ /^<div id=".*">.*<\/div>/ | |
| end | |
| - it 'should contain script tag' do | |
| - @helper.grafico_report_tag(data_set).should =~ /<script type="text\/java… | |
| + it 'should contain a script tag' do | |
| + @helper.raphael_report_tag(data_set).should =~ /<script type="text\/java… | |
| end | |
| end |