Skip to content
Extraits de code Groupes Projets
Valider 01a4327c rédigé par zhitomirskiyi's avatar zhitomirskiyi
Parcourir les fichiers

use google API instead of highcharts due to licensing

parent 41993fe5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -23,7 +23,7 @@ gem 'haml', '3.0.25' ...@@ -23,7 +23,7 @@ gem 'haml', '3.0.25'
gem 'will_paginate', '3.0.pre2' gem 'will_paginate', '3.0.pre2'
#Statistics #Statistics
gem 'lazy_high_charts', :git => 'git://github.com/xiaods/lazy_high_charts.git', :ref => 'c63f49ce10e1dad8a0b7' gem 'googlecharts'
#Uncatagorized #Uncatagorized
gem 'roxml', :git => 'git://github.com/Empact/roxml.git', :ref => '7ea9a9ffd2338aaef5b0' gem 'roxml', :git => 'git://github.com/Empact/roxml.git', :ref => '7ea9a9ffd2338aaef5b0'
......
...@@ -184,6 +184,7 @@ GEM ...@@ -184,6 +184,7 @@ GEM
gem_plugin (0.2.3) gem_plugin (0.2.3)
gherkin (2.3.3) gherkin (2.3.3)
json (~> 1.4.6) json (~> 1.4.6)
googlecharts (1.6.0)
haml (3.0.25) haml (3.0.25)
hashie (0.4.0) hashie (0.4.0)
highline (1.6.1) highline (1.6.1)
...@@ -382,6 +383,7 @@ DEPENDENCIES ...@@ -382,6 +383,7 @@ DEPENDENCIES
fastercsv (= 1.5.4) fastercsv (= 1.5.4)
fixture_builder (~> 0.2.0) fixture_builder (~> 0.2.0)
fog fog
googlecharts
haml (= 3.0.25) haml (= 3.0.25)
http_accept_language! http_accept_language!
jammit (= 0.5.4) jammit (= 0.5.4)
......
...@@ -9,15 +9,17 @@ class StatisticsController < ApplicationController ...@@ -9,15 +9,17 @@ class StatisticsController < ApplicationController
def show def show
@statistic = Statistic.where(:id => params[:id]).first @statistic = Statistic.where(:id => params[:id]).first
@distribution = @statistic.distribution_as_array @distribution = @statistic.distribution_as_array
@h = LazyHighCharts::HighChart.new('graph') do |f| @google_chart_url = Gchart.line( :size => '700x400',
f.series(:name=>'Posts on day', :data=> @distribution) :title => "Posts on day",
f.options[:x_axis][:categories] = (0..@distribution.length-1).to_a.map{|ind| ind%10==0 ? ind : ' '} :bg => 'efefef',
:legend => ['Posts'],
:data => @distribution,
:max_value => 1,
:axis_with_labels => ['x','y'],
:axis_labels => [(0..@distribution.length-1).to_a.map{|d| d%10==0 ? d : ''},
(0..10).to_a.map!{|int| int.to_f/10}]
)
f.options[:title] = "Posts on day"
f.options[:y_axis] = {:max => 1}
f.options[:y_axis][:title] = {:text => "% Users"}
f.options[:x_axis][:title] = {:text => "Posts"}
end
end end
def generate_single def generate_single
......
...@@ -2,15 +2,11 @@ ...@@ -2,15 +2,11 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
- content_for :head do %h3 Viewing statistic
= javascript_include_tag 'vendor/highcharts.js'
%h1 Viewing statistic %h2
%h3
= "Users in sample: #{@statistic.users_in_sample}" = "Users in sample: #{@statistic.users_in_sample}"
= image_tag(@google_chart_url)
= high_chart("posts_per_day", @h)
%br %br
= link_to 'all statistics', statistics_path = link_to 'all statistics', statistics_path
......
Ce diff est replié.
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter