rails_admin_charts 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ab3bec3e6ef8cd9acb173349d19554e0941d9ae
4
- data.tar.gz: 710ad5c05dddbab6f3b2074b4f3f814dd8d0e2bc
3
+ metadata.gz: 266b332b8541fb9ac4387da769b9f78874f02bb8
4
+ data.tar.gz: ca477c107656fb0b679197761cd1fb6af0a7ca89
5
5
  SHA512:
6
- metadata.gz: 96bc0b24f7d6016b80d71a10211cb4ee416c0be86ada20778fc55c037a0362258358540e7b57f4abf8b54c1a03749fe548a547baa5b84e115d14da7f1c259f63
7
- data.tar.gz: a01f81057979b78a62528b6104a459b092a46a1a8cbca4b60dbe5467bf04a8a358dece6adc40c655f0c7c491a68a57ab4decf6a53955c4d4f2744f13d9a999ce
6
+ metadata.gz: 72b8f394ad3ee3c257478fa8f9d68aa887148069027e7a2862e54c4732cde4a3db0fc0369fc3d09a1c54a1399286a5d5fc646b0ba2f7db82c80c634564c1bc37
7
+ data.tar.gz: e4730588c82e9cfa863fd099078f0c956042737b726a27ce6ca7548e64a1dfa814a22d18665b046c14f8af67f79b22519d2c5b496cabf3e34e9ca4edebb187de
data/README.md CHANGED
@@ -16,6 +16,7 @@ In your RailsAdmin initializer (`app/config/initializers/rails_admin.rb`), enabl
16
16
 
17
17
  ```ruby
18
18
  config.actions do
19
+ all # NB: comment out this line for RailsAdmin < 0.6.0
19
20
  charts
20
21
  end
21
22
  ```
@@ -48,4 +49,21 @@ The data displayed in the chart can be altered by overriding the class method `g
48
49
  end
49
50
  ```
50
51
 
52
+ You can set custom categories by overriding the method `xaxis`
53
+
54
+ ```ruby
55
+ def self.xaxis
56
+ ['cat a', 'cat b', 'cat c' 'cat d', 'cat e', 'cat f', 'cat g', 'cat h']
57
+ end
58
+ ```
59
+
60
+ You can set label rotation by overriding the method `label_rotation`
61
+ It expects a string `-45` or `-90`
62
+
63
+ ```ruby
64
+ def self.label_rotation
65
+ "-45"
66
+ end
67
+ ```
68
+
51
69
  This project uses MIT-LICENSE.
@@ -4,25 +4,43 @@
4
4
  $(document).ready(function() {
5
5
  chart = new Highcharts.Chart({
6
6
  chart: {
7
- renderTo: 'growth_rate'
7
+ <% if @abstract_model.model.chart_type == "column" %>
8
+ type: 'column',
9
+ <% end %>
10
+ renderTo: 'growth_rate'
8
11
  },
9
12
  title: {
10
13
  text: '<%= @abstract_model.to_s.pluralize %>'
11
14
  },
12
15
  xAxis: {
13
- type: 'datetime'
16
+ labels: {
17
+ <% if @abstract_model.model.label_rotation == "-45" %>
18
+ rotation: -45,
19
+ <% elsif @abstract_model.model.label_rotation == "-90" %>
20
+ rotation: -90,
21
+ <% end %>
22
+ align: 'right'
23
+ },
24
+ <% if @abstract_model.model.xaxis == "datetime" %>
25
+ type: 'datetime'
26
+ <% elsif @abstract_model.model.chart_type == "pie" %>
27
+ <% else %>
28
+ categories: <%=raw @abstract_model.model.xaxis.to_json %>
29
+ <% end %>
30
+
14
31
  },
32
+
15
33
  // yAxis: {
16
34
  // title: {
17
35
  // text: 'Counts'
18
36
  // }
19
37
  // },
20
- tooltip: {
21
- formatter: function() {
22
- return ''+
23
- Highcharts.dateFormat('%e. %b', this.x) +' -> '+ this.y;
24
- }
25
- },
38
+ <%#tooltip: {%>
39
+ <%#formatter: function() {%>
40
+ <%#return ''+%>
41
+ <%#Highcharts.dateFormat('%e. %b', this.x) +' -> '+ this.y;%>
42
+ <%#}%>
43
+ <%#},%>
26
44
  plotOptions: {
27
45
  spline: {
28
46
  lineWidth: 4,
@@ -44,7 +62,15 @@
44
62
  }
45
63
  }
46
64
  },
47
- series: <%=raw @abstract_model.model.graph_data(100.days.ago).to_json %>,
65
+ <% if @abstract_model.model.chart_type == "pie" %>
66
+ series: [{
67
+ type: 'pie',
68
+ name: 'Number of <%= @abstract_model.to_s.pluralize %>',
69
+ data: <%=raw @abstract_model.model.graph_data(100.days.ago).to_json %>
70
+ }],
71
+ <% else %>
72
+ series: <%=raw @abstract_model.model.graph_data(100.days.ago).to_json %>,
73
+ <% end %>
48
74
  navigation: {
49
75
  menuItemStyle: {
50
76
  fontSize: '10px'
@@ -53,4 +79,4 @@
53
79
  });
54
80
  });
55
81
  });
56
- </script>
82
+ </script>
@@ -28,6 +28,18 @@ module RailsAdminCharts
28
28
  }
29
29
  ]
30
30
  end
31
+
32
+ def xaxis
33
+ "datetime"
34
+ end
35
+
36
+ def label_rotation
37
+ "0"
38
+ end
39
+
40
+ def chart_type
41
+ ""
42
+ end
31
43
  end
32
44
  end
33
45
 
@@ -22,7 +22,7 @@ module RailsAdmin
22
22
  end
23
23
 
24
24
  register_instance_option :link_icon do
25
- 'icon-bar-chart'
25
+ 'icon-bar-chart fa fa-bar-chart-o'
26
26
  end
27
27
  end
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminCharts
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_charts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Geraghty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-24 00:00:00.000000000 Z
11
+ date: 2013-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails