lazy_high_charts 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/GEM_VERSION +1 -1
  4. data/MIT-LICENSE +1 -1
  5. data/README.md +53 -14
  6. data/lib/lazy_high_charts.rb +4 -0
  7. data/spec/dummy_nanoc/.gitignore +3 -0
  8. data/spec/dummy_nanoc/Gemfile +7 -0
  9. data/spec/dummy_nanoc/README.md +18 -0
  10. data/spec/dummy_nanoc/Rules +44 -0
  11. data/spec/dummy_nanoc/content/index.html +7 -0
  12. data/spec/dummy_nanoc/content/stylesheet.css +101 -0
  13. data/spec/dummy_nanoc/layouts/default.html +32 -0
  14. data/spec/dummy_nanoc/lib/default.rb +30 -0
  15. data/spec/dummy_nanoc/nanoc.yaml +59 -0
  16. data/spec/dummy_nanoc/output/index.html +42 -0
  17. data/spec/dummy_nanoc/output/style.css +101 -0
  18. data/spec/dummy_rails/.gitignore +20 -0
  19. data/spec/dummy_rails/Gemfile +20 -0
  20. data/spec/dummy_rails/README.md +9 -0
  21. data/spec/dummy_rails/Rakefile +7 -0
  22. data/spec/dummy_rails/app/assets/javascripts/application.js +20 -0
  23. data/spec/dummy_rails/app/assets/stylesheets/application.css.scss +13 -0
  24. data/spec/dummy_rails/app/controllers/application_controller.rb +83 -0
  25. data/spec/dummy_rails/app/helpers/application_helper.rb +3 -0
  26. data/spec/dummy_rails/app/mailers/.gitkeep +0 -0
  27. data/spec/dummy_rails/app/views/application/charts.erb +10 -0
  28. data/spec/dummy_rails/app/views/layouts/application.html.erb +12 -0
  29. data/spec/dummy_rails/config.ru +4 -0
  30. data/spec/dummy_rails/config/application.rb +25 -0
  31. data/spec/dummy_rails/config/boot.rb +11 -0
  32. data/spec/dummy_rails/config/database.yml +13 -0
  33. data/spec/dummy_rails/config/environment.rb +6 -0
  34. data/spec/dummy_rails/config/environments/development.rb +23 -0
  35. data/spec/dummy_rails/config/environments/production.rb +80 -0
  36. data/spec/dummy_rails/config/environments/test.rb +36 -0
  37. data/spec/dummy_rails/config/initializers/backtrace_silencers.rb +8 -0
  38. data/spec/dummy_rails/config/initializers/inflections.rb +16 -0
  39. data/spec/dummy_rails/config/initializers/mime_types.rb +6 -0
  40. data/spec/dummy_rails/config/initializers/secret_token.rb +8 -0
  41. data/spec/dummy_rails/config/initializers/session_store.rb +9 -0
  42. data/spec/dummy_rails/config/initializers/wrap_parameters.rb +15 -0
  43. data/spec/dummy_rails/config/locales/devise.en.yml +58 -0
  44. data/spec/dummy_rails/config/locales/en.yml +5 -0
  45. data/spec/dummy_rails/config/locales/simple_form.en.yml +26 -0
  46. data/spec/dummy_rails/config/routes.rb +6 -0
  47. data/spec/dummy_rails/db/migrate/20140224051640_create_users.rb +11 -0
  48. data/spec/dummy_rails/db/migrate/20140224063709_add_last_name_to_user.rb +5 -0
  49. data/spec/dummy_rails/db/migrate/20140225014314_create_log_data.rb +12 -0
  50. data/spec/dummy_rails/db/migrate/20140227015551_create_posts.rb +9 -0
  51. data/spec/dummy_rails/db/schema.rb +39 -0
  52. data/spec/dummy_rails/db/schema_migrations.json +1 -0
  53. data/spec/dummy_rails/lib/assets/.gitkeep +0 -0
  54. data/spec/dummy_rails/lib/templates/erb/scaffold/_form.html.erb +13 -0
  55. data/spec/dummy_rails/log/.gitkeep +0 -0
  56. data/spec/dummy_rails/public/404.html +26 -0
  57. data/spec/dummy_rails/public/422.html +26 -0
  58. data/spec/dummy_rails/public/500.html +25 -0
  59. data/spec/dummy_rails/public/favicon.ico +0 -0
  60. data/spec/dummy_rails/script/rails +6 -0
  61. data/spec/dummy_rails/test/fixtures/log_data.yml +9 -0
  62. data/spec/dummy_rails/test/fixtures/posts.yml +11 -0
  63. data/spec/dummy_rails/test/fixtures/users.yml +11 -0
  64. data/spec/dummy_rails/test/models/log_data_test.rb +7 -0
  65. data/spec/dummy_rails/test/models/post_test.rb +7 -0
  66. data/spec/dummy_rails/test/models/user_test.rb +7 -0
  67. data/spec/dummy_sinatra/Gemfile +7 -0
  68. data/spec/dummy_sinatra/README.md +9 -0
  69. data/spec/dummy_sinatra/app.rb +36 -0
  70. data/spec/dummy_sinatra/config.ru +0 -0
  71. data/spec/dummy_sinatra/views/index.erb +2 -0
  72. data/spec/dummy_sinatra/views/layout.erb +13 -0
  73. data/spec/spec_helper.rb +1 -0
  74. metadata +68 -2
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE HTML>
2
+ <html lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <meta charset="utf-8">
6
+ <title>A Brand New nanoc Site - Home</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <!-- you don't need to keep this, but it's cool for stats! --><meta name="generator" content="nanoc 3.6.7">
9
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
10
+ </head>
11
+ <body>
12
+ <div id="main">
13
+ <h1>A Brand New nanoc Site with a HighChart</h1>
14
+
15
+ <script type="text/javascript">
16
+ (function() {
17
+ var onload = window.onload;
18
+ window.onload = function(){
19
+ if (typeof onload == "function") onload();
20
+ var options = { "title": { "text": "Combination chart" },"legend": { "layout": "vertical","style": { } },"xAxis": { "categories": [ "Apples","Oranges","Pears","Bananas","Plums" ] },"yAxis": { "title": { "text": null },"labels": { } },"tooltip": { "enabled": true },"credits": { "enabled": false },"plotOptions": { "areaspline": { } },"chart": { "defaultSeriesType": "line","renderTo": "some_id" },"subtitle": { },"labels": { "items": [ { "html": "Total fruit consumption","style": { "left": "40px","top": "8px","color": "black" } } ] },"series": [{ "type": "column","name": "Jane","data": [ 3,2,1,3,4 ] },{ "type": "column","name": "John","data": [ 2,3,5,7,6 ] },{ "type": "column","name": "Joe","data": [ 4,3,3,9,0 ] },{ "type": "spline","name": "Average","data": [ 3,2.67,3,6.33,3.33 ] },{ "type": "pie","name": "Total consumption","data": [ { "name": "Jane","y": 13,"color": "red" },{ "name": "John","y": 23,"color": "green" },{ "name": "Joe","y": 19,"color": "blue" } ],"center": [ 100,80 ],"size": 100,"showInLegend": false }] };
21
+
22
+ window.chart_some_id = new Highcharts.Chart(options);
23
+
24
+ };
25
+ })()
26
+ </script><div id="some_id"></div>
27
+ </div>
28
+ <div id="sidebar">
29
+ <h2>Documentation</h2>
30
+ <ul>
31
+ <li><a href="http://nanoc.ws/docs/">Documentation</a></li>
32
+ <li><a href="http://nanoc.ws/docs/tutorial/">Getting Started</a></li>
33
+ </ul>
34
+ <h2>Community</h2>
35
+ <ul>
36
+ <li><a href="http://groups.google.com/group/nanoc/">Discussion Group</a></li>
37
+ <li><a href="irc://chat.freenode.net/#nanoc">IRC Channel</a></li>
38
+ <li><a href="http://github.com/nanoc/nanoc/wiki/">Wiki</a></li>
39
+ </ul>
40
+ </div>
41
+ </body>
42
+ </html>
@@ -0,0 +1,101 @@
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+
5
+ font-family: Georgia, Palatino, serif;
6
+ }
7
+
8
+ body {
9
+ background: #fff;
10
+ }
11
+
12
+ a {
13
+ text-decoration: none;
14
+ }
15
+
16
+ a:link,
17
+ a:visited {
18
+ color: #f30;
19
+ }
20
+
21
+ a:hover {
22
+ color: #f90;
23
+ }
24
+
25
+ #main {
26
+ position: absolute;
27
+
28
+ top: 40px;
29
+ left: 280px;
30
+
31
+ width: 500px;
32
+ }
33
+
34
+ #main h1 {
35
+ font-size: 40px;
36
+ font-weight: normal;
37
+
38
+ line-height: 40px;
39
+
40
+ letter-spacing: -1px;
41
+ }
42
+
43
+ #main p {
44
+ margin: 20px 0;
45
+
46
+ font-size: 15px;
47
+
48
+ line-height: 20px;
49
+ }
50
+
51
+ #main ul, #main ol {
52
+ margin: 20px;
53
+ }
54
+
55
+ #main li {
56
+ font-size: 15px;
57
+
58
+ line-height: 20px;
59
+ }
60
+
61
+ #main ul li {
62
+ list-style-type: square;
63
+ }
64
+
65
+ #sidebar {
66
+ position: absolute;
67
+
68
+ top: 40px;
69
+ left: 20px;
70
+ width: 200px;
71
+
72
+ padding: 20px 20px 0 0;
73
+
74
+ border-right: 1px solid #ccc;
75
+
76
+ text-align: right;
77
+ }
78
+
79
+ #sidebar h2 {
80
+ text-transform: uppercase;
81
+
82
+ font-size: 13px;
83
+
84
+ color: #333;
85
+
86
+ letter-spacing: 1px;
87
+
88
+ line-height: 20px;
89
+ }
90
+
91
+ #sidebar ul {
92
+ list-style-type: none;
93
+
94
+ margin: 20px 0;
95
+ }
96
+
97
+ #sidebar li {
98
+ font-size: 14px;
99
+
100
+ line-height: 20px;
101
+ }
@@ -0,0 +1,20 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ /public/assets
15
+ # Ignore all logfiles and tempfiles.
16
+ /log/*.log
17
+ /tmp
18
+
19
+ *.rdb
20
+ /public/uploads
@@ -0,0 +1,20 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lazy_high_charts.gemspec
4
+ gemspec :path => '../../'
5
+
6
+ # Use SCSS for stylesheets
7
+ gem "sass"
8
+ gem 'sass-rails', '~> 4.0.0'
9
+ # Use Uglifier as compressor for JavaScript assets
10
+ gem 'uglifier', '>= 1.3.0'
11
+ # Use CoffeeScript for .js.coffee assets and views
12
+ gem 'coffee-rails', '~> 4.0.0'
13
+ # Use jquery as the JavaScript library
14
+ gem 'jquery-rails'
15
+
16
+ gem "turbolinks"
17
+
18
+ group :test, :development do # This causes the plugins to NOT load
19
+ gem 'rails', '>= 3.2'
20
+ end
@@ -0,0 +1,9 @@
1
+ Ruby on Rails lazy high charts example
2
+ ==============================
3
+
4
+
5
+ A very simple proof-of-concept of using [lazy_high_charts](https://github.com/michelson/lazy_high_charts) with a Rails app.
6
+
7
+ ## USAGE:
8
+
9
+ bundle exec rails s
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,20 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
16
+ //= require turbolinks
17
+
18
+ //= require highcharts/highcharts
19
+ //= require highcharts/highcharts-more
20
+ //= require highcharts/highstock
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,83 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery
4
+
5
+ def charts
6
+ @chart = LazyHighCharts::HighChart.new('graph') do |f|
7
+ f.title({ :text=>"Combination chart"})
8
+ f.options[:xAxis][:categories] = ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
9
+ f.labels(:items=>[:html=>"Total fruit consumption", :style=>{:left=>"40px", :top=>"8px", :color=>"black"} ])
10
+ f.series(:type=> 'column',:name=> 'Jane',:data=> [3, 2, 1, 3, 4])
11
+ f.series(:type=> 'column',:name=> 'John',:data=> [2, 3, 5, 7, 6])
12
+ f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])
13
+ f.series(:type=> 'spline',:name=> 'Average', :data=> [3, 2.67, 3, 6.33, 3.33])
14
+ f.series(:type=> 'pie',:name=> 'Total consumption',
15
+ :data=> [
16
+ {:name=> 'Jane', :y=> 13, :color=> 'red'},
17
+ {:name=> 'John', :y=> 23,:color=> 'green'},
18
+ {:name=> 'Joe', :y=> 19,:color=> 'blue'}
19
+ ],
20
+ :center=> [100, 80], :size=> 100, :showInLegend=> false)
21
+ end
22
+
23
+ @chart2 = LazyHighCharts::HighChart.new('graph') do |f|
24
+ f.title(:text => "Population vs GDP For 5 Big Countries [2009]")
25
+ f.xAxis(:categories => ["United States", "Japan", "China", "Germany", "France"])
26
+ f.series(:name => "GDP in Billions", :yAxis => 0, :data => [14119, 5068, 4985, 3339, 2656])
27
+ f.series(:name => "Population in Millions", :yAxis => 1, :data => [310, 127, 1340, 81, 65])
28
+
29
+ f.yAxis [
30
+ {:title => {:text => "GDP in Billions", :margin => 70} },
31
+ {:title => {:text => "Population in Millions"}, :opposite => true},
32
+ ]
33
+
34
+ f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)
35
+ f.chart({:defaultSeriesType=>"column"})
36
+ end
37
+
38
+ @chart3 = LazyHighCharts::HighChart.new('pie') do |f|
39
+ f.chart({:defaultSeriesType=>"pie" , :margin=> [50, 200, 60, 170]} )
40
+ series = {
41
+ :type=> 'pie',
42
+ :name=> 'Browser share',
43
+ :data=> [
44
+ ['Firefox', 45.0],
45
+ ['IE', 26.8],
46
+ {
47
+ :name=> 'Chrome',
48
+ :y=> 12.8,
49
+ :sliced=> true,
50
+ :selected=> true
51
+ },
52
+ ['Safari', 8.5],
53
+ ['Opera', 6.2],
54
+ ['Others', 0.7]
55
+ ]
56
+ }
57
+ f.series(series)
58
+ f.options[:title][:text] = "THA PIE"
59
+ f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'})
60
+ f.plot_options(:pie=>{
61
+ :allowPointSelect=>true,
62
+ :cursor=>"pointer" ,
63
+ :dataLabels=>{
64
+ :enabled=>true,
65
+ :color=>"black",
66
+ :style=>{
67
+ :font=>"13px Trebuchet MS, Verdana, sans-serif"
68
+ }
69
+ }
70
+ })
71
+ end
72
+
73
+ @chart4 = LazyHighCharts::HighChart.new('column') do |f|
74
+ f.series(:name=>'John',:data=> [3, 20, 3, 5, 4, 10, 12 ])
75
+ f.series(:name=>'Jane',:data=>[1, 3, 4, 3, 3, 5, 4,-46] )
76
+ f.title({ :text=>"example test title from controller"})
77
+ f.options[:chart][:defaultSeriesType] = "column"
78
+ f.plot_options({:column=>{:stacking=>"percent"}})
79
+ end
80
+
81
+ render "charts" , layout: "application"
82
+ end
83
+ end
@@ -0,0 +1,3 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module ApplicationHelper
3
+ end
File without changes
@@ -0,0 +1,10 @@
1
+ <%= high_chart("my_id", @chart) %>
2
+
3
+ <%= high_chart("my_id2", @chart2) %>
4
+
5
+ <%= high_chart("my_id3", @chart3) do |c| %>
6
+ <%= raw "options.tooltip.formatter = function() {return '<b> YUPI!! '+ this.point.name +'</b>: '+ this.y +' %';}" %>
7
+ <%= raw "options.plotOptions.pie.dataLabels.formatter = function() { if (this.y > 5) return this.point.name; }" %>
8
+ <% end %>
9
+
10
+ <%= high_chart("my_id4", @chart4) %>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <%= yield %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_controller/railtie"
4
+ require "action_mailer/railtie"
5
+ require "sprockets/railtie"
6
+ require "rails/test_unit/railtie"
7
+
8
+ Bundler.require(*Rails.groups)
9
+
10
+ module Dummy
11
+ class Application < Rails::Application
12
+ # Settings in config/environments/* take precedence over those specified here.
13
+ # Application configuration should go into files in config/initializers
14
+ # -- all .rb files in that directory are automatically loaded.
15
+
16
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
17
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
18
+ # config.time_zone = 'Central Time (US & Canada)'
19
+
20
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
21
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
22
+ # config.i18n.default_locale = :de
23
+ end
24
+ end
25
+
@@ -0,0 +1,11 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'rubygems'
3
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
4
+
5
+ if File.exist?(gemfile)
6
+ ENV['BUNDLE_GEMFILE'] = gemfile
7
+ require 'bundler'
8
+ Bundler.setup
9
+ end
10
+
11
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,13 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ #adapter: sqlite3
8
+ database: ":memory:"
9
+ test:
10
+ adapter: sqlite3
11
+ database: db/test.sqlite3
12
+ pool: 5
13
+ timeout: 5000
@@ -0,0 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # Load the rails application
3
+ require File.expand_path('../application', __FILE__)
4
+
5
+ # Initialize the rails application
6
+ Dummy::Application.initialize!
@@ -0,0 +1,23 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Show full error reports and disable caching.
10
+ config.consider_all_requests_local = true
11
+ config.action_controller.perform_caching = false
12
+
13
+ # Don't care if the mailer can't send.
14
+ config.action_mailer.raise_delivery_errors = false
15
+
16
+ # Print deprecation notices to the Rails logger.
17
+ config.active_support.deprecation = :log
18
+
19
+ # Debug mode disables concatenation and preprocessing of assets.
20
+ # This option may cause significant delays in view rendering with a large
21
+ # number of complex assets.
22
+ config.assets.debug = true
23
+ end