chart 0.1.4.2 → 0.1.4.3
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 +4 -4
- data/README.md +1 -1
- data/app/helpers/chart2_helper.rb +272 -0
- data/app/helpers/chart_helper.rb +0 -304
- data/app/helpers/google_helper.rb +307 -0
- data/app/helpers/highcharts_helper.rb +275 -0
- data/app/helpers/nvd3_helper.rb +460 -0
- data/lib/chart/version.rb +1 -1
- data/vendor/assets/javascripts/chart2.js +9773 -0
- data/vendor/assets/javascripts/google.js +147 -45
- data/vendor/assets/javascripts/nvd3.js +1174 -611
- metadata +7 -2
@@ -0,0 +1,307 @@
|
|
1
|
+
module GoogleHelper
|
2
|
+
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# Google Chart
|
6
|
+
def google_pie id=nil, size=nil
|
7
|
+
html = "<div id=\"piechart\" style=\"width: 900px; height: 500px;\"></div>".html_safe
|
8
|
+
script = javascript_tag do
|
9
|
+
<<-END.html_safe
|
10
|
+
google.charts.load('current', {'packages':['corechart']});
|
11
|
+
google.charts.setOnLoadCallback(drawChart);
|
12
|
+
function drawChart() {
|
13
|
+
|
14
|
+
var data = google.visualization.arrayToDataTable([
|
15
|
+
['Task', 'Hours per Day'],
|
16
|
+
['Work', 11],
|
17
|
+
['Eat', 2],
|
18
|
+
['Commute', 2],
|
19
|
+
['Watch TV', 2],
|
20
|
+
['Sleep', 7]
|
21
|
+
]);
|
22
|
+
|
23
|
+
var options = {
|
24
|
+
title: 'My Daily Activities'
|
25
|
+
};
|
26
|
+
|
27
|
+
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
|
28
|
+
|
29
|
+
chart.draw(data, options);
|
30
|
+
}
|
31
|
+
|
32
|
+
|
33
|
+
END
|
34
|
+
end
|
35
|
+
return html + script
|
36
|
+
end
|
37
|
+
|
38
|
+
def google_area id=nil, size=nil
|
39
|
+
html = "<div id=\"chart_div\" style=\"width: 900px; height: 500px;\"></div>".html_safe
|
40
|
+
script = javascript_tag do
|
41
|
+
<<-END.html_safe
|
42
|
+
google.charts.load('current', {'packages':['corechart']});
|
43
|
+
google.charts.setOnLoadCallback(drawChart);
|
44
|
+
function drawChart() {
|
45
|
+
var data = google.visualization.arrayToDataTable([
|
46
|
+
['Year', 'Sales', 'Expenses'],
|
47
|
+
['2013', 1000, 400],
|
48
|
+
['2014', 1170, 460],
|
49
|
+
['2015', 660, 1120],
|
50
|
+
['2016', 1030, 540]
|
51
|
+
]);
|
52
|
+
|
53
|
+
var options = {
|
54
|
+
title: 'Company Performance',
|
55
|
+
hAxis: {title: 'Year', titleTextStyle: {color: '#333'}},
|
56
|
+
vAxis: {minValue: 0}
|
57
|
+
};
|
58
|
+
|
59
|
+
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
|
60
|
+
chart.draw(data, options);
|
61
|
+
}
|
62
|
+
END
|
63
|
+
end
|
64
|
+
return html + script
|
65
|
+
end
|
66
|
+
|
67
|
+
def google_geochart id=nil, size=nil
|
68
|
+
html = "<div id=\"regions_div\" style=\"width: 900px; height: 500px;\"></div>".html_safe
|
69
|
+
script = javascript_tag do
|
70
|
+
<<-END.html_safe
|
71
|
+
google.charts.load('current', {'packages':['geochart']});
|
72
|
+
google.charts.setOnLoadCallback(drawRegionsMap);
|
73
|
+
|
74
|
+
function drawRegionsMap() {
|
75
|
+
|
76
|
+
var data = google.visualization.arrayToDataTable([
|
77
|
+
['Country', 'Popularity'],
|
78
|
+
['Germany', 200],
|
79
|
+
['United States', 300],
|
80
|
+
['Brazil', 400],
|
81
|
+
['Canada', 500],
|
82
|
+
['France', 600],
|
83
|
+
['RU', 700]
|
84
|
+
]);
|
85
|
+
|
86
|
+
var options = {};
|
87
|
+
|
88
|
+
var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
|
89
|
+
|
90
|
+
chart.draw(data, options);
|
91
|
+
}
|
92
|
+
END
|
93
|
+
end
|
94
|
+
return html + script
|
95
|
+
end
|
96
|
+
|
97
|
+
def google_gauge_charts id=nil, size=nil
|
98
|
+
html = "<div id=\"chart_div\" style=\"width: 400px; height: 120px;\"></div>".html_safe
|
99
|
+
script = javascript_tag do
|
100
|
+
<<-END.html_safe
|
101
|
+
google.charts.load('current', {'packages':['gauge']});
|
102
|
+
google.charts.setOnLoadCallback(drawChart);
|
103
|
+
function drawChart() {
|
104
|
+
|
105
|
+
var data = google.visualization.arrayToDataTable([
|
106
|
+
['Label', 'Value'],
|
107
|
+
['Memory', 80],
|
108
|
+
['CPU', 55],
|
109
|
+
['Network', 68]
|
110
|
+
]);
|
111
|
+
|
112
|
+
var options = {
|
113
|
+
width: 400, height: 120,
|
114
|
+
redFrom: 90, redTo: 100,
|
115
|
+
yellowFrom:75, yellowTo: 90,
|
116
|
+
minorTicks: 5
|
117
|
+
};
|
118
|
+
|
119
|
+
var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
|
120
|
+
|
121
|
+
chart.draw(data, options);
|
122
|
+
|
123
|
+
setInterval(function() {
|
124
|
+
data.setValue(0, 1, 40 + Math.round(60 * Math.random()));
|
125
|
+
chart.draw(data, options);
|
126
|
+
}, 13000);
|
127
|
+
setInterval(function() {
|
128
|
+
data.setValue(1, 1, 40 + Math.round(60 * Math.random()));
|
129
|
+
chart.draw(data, options);
|
130
|
+
}, 5000);
|
131
|
+
setInterval(function() {
|
132
|
+
data.setValue(2, 1, 60 + Math.round(20 * Math.random()));
|
133
|
+
chart.draw(data, options);
|
134
|
+
}, 26000);
|
135
|
+
}
|
136
|
+
|
137
|
+
END
|
138
|
+
end
|
139
|
+
return html + script
|
140
|
+
end
|
141
|
+
|
142
|
+
def google_bar id=nil, size=nil
|
143
|
+
html = "<div id=\"barchart_values\" style=\"width: 900px; height: 300px;\"></div>".html_safe
|
144
|
+
script = javascript_tag do
|
145
|
+
<<-END.html_safe
|
146
|
+
google.charts.load("current", {packages:["corechart"]});
|
147
|
+
google.charts.setOnLoadCallback(drawChart);
|
148
|
+
function drawChart() {
|
149
|
+
var data = google.visualization.arrayToDataTable([
|
150
|
+
["Element", "Density", { role: "style" } ],
|
151
|
+
["Copper", 8.94, "#b87333"],
|
152
|
+
["Silver", 10.49, "silver"],
|
153
|
+
["Gold", 19.30, "gold"],
|
154
|
+
["Platinum", 21.45, "color: #e5e4e2"]
|
155
|
+
]);
|
156
|
+
|
157
|
+
var view = new google.visualization.DataView(data);
|
158
|
+
view.setColumns([0, 1,
|
159
|
+
{ calc: "stringify",
|
160
|
+
sourceColumn: 1,
|
161
|
+
type: "string",
|
162
|
+
role: "annotation" },
|
163
|
+
2]);
|
164
|
+
|
165
|
+
var options = {
|
166
|
+
title: "Density of Precious Metals, in g/cm^3",
|
167
|
+
width: 600,
|
168
|
+
height: 400,
|
169
|
+
bar: {groupWidth: "95%"},
|
170
|
+
legend: { position: "none" },
|
171
|
+
};
|
172
|
+
var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
|
173
|
+
chart.draw(view, options);
|
174
|
+
}
|
175
|
+
|
176
|
+
END
|
177
|
+
end
|
178
|
+
return html + script
|
179
|
+
end
|
180
|
+
|
181
|
+
def google_bubble id=nil, size=nil
|
182
|
+
html = "<div id=\"series_chart_div\" style=\"width: 900px; height: 500px;\"></div>".html_safe
|
183
|
+
script = javascript_tag do
|
184
|
+
<<-END.html_safe
|
185
|
+
google.charts.load('current', {'packages':['corechart']});
|
186
|
+
google.charts.setOnLoadCallback(drawSeriesChart);
|
187
|
+
|
188
|
+
function drawSeriesChart() {
|
189
|
+
|
190
|
+
var data = google.visualization.arrayToDataTable([
|
191
|
+
['ID', 'Life Expectancy', 'Fertility Rate', 'Region', 'Population'],
|
192
|
+
['CAN', 80.66, 1.67, 'North America', 33739900],
|
193
|
+
['DEU', 79.84, 1.36, 'Europe', 81902307],
|
194
|
+
['DNK', 78.6, 1.84, 'Europe', 5523095],
|
195
|
+
['EGY', 72.73, 2.78, 'Middle East', 79716203],
|
196
|
+
['GBR', 80.05, 2, 'Europe', 61801570],
|
197
|
+
['IRN', 72.49, 1.7, 'Middle East', 73137148],
|
198
|
+
['IRQ', 68.09, 4.77, 'Middle East', 31090763],
|
199
|
+
['ISR', 81.55, 2.96, 'Middle East', 7485600],
|
200
|
+
['RUS', 68.6, 1.54, 'Europe', 141850000],
|
201
|
+
['USA', 78.09, 2.05, 'North America', 307007000]
|
202
|
+
]);
|
203
|
+
|
204
|
+
var options = {
|
205
|
+
title: 'Correlation between life expectancy, fertility rate ' +
|
206
|
+
'and population of some world countries (2010)',
|
207
|
+
hAxis: {title: 'Life Expectancy'},
|
208
|
+
vAxis: {title: 'Fertility Rate'},
|
209
|
+
bubble: {textStyle: {fontSize: 11}}
|
210
|
+
};
|
211
|
+
|
212
|
+
var chart = new google.visualization.BubbleChart(document.getElementById('series_chart_div'));
|
213
|
+
chart.draw(data, options);
|
214
|
+
}
|
215
|
+
|
216
|
+
END
|
217
|
+
end
|
218
|
+
return html + script
|
219
|
+
end
|
220
|
+
|
221
|
+
def google_calendar id=nil, size=nil
|
222
|
+
html = "<div id=\"calendar_basic\" style=\"width: 1000px; height: 350px;\"></div>".html_safe
|
223
|
+
script = javascript_tag do
|
224
|
+
<<-END.html_safe
|
225
|
+
google.charts.load("current", {packages:["calendar"]});
|
226
|
+
google.charts.setOnLoadCallback(drawChart);
|
227
|
+
|
228
|
+
function drawChart() {
|
229
|
+
var dataTable = new google.visualization.DataTable();
|
230
|
+
dataTable.addColumn({ type: 'date', id: 'Date' });
|
231
|
+
dataTable.addColumn({ type: 'number', id: 'Won/Loss' });
|
232
|
+
dataTable.addRows([
|
233
|
+
[ new Date(2015, 3, 13), 37032 ],
|
234
|
+
[ new Date(2015, 3, 14), 38024 ],
|
235
|
+
[ new Date(2015, 3, 15), 38024 ],
|
236
|
+
[ new Date(2015, 3, 16), 38108 ],
|
237
|
+
[ new Date(2015, 3, 17), 38229 ],
|
238
|
+
// Many rows omitted for brevity.
|
239
|
+
[ new Date(2016, 9, 4), 38177 ],
|
240
|
+
[ new Date(2016, 9, 5), 38705 ],
|
241
|
+
[ new Date(2016, 9, 12), 38210 ],
|
242
|
+
[ new Date(2016, 9, 13), 38029 ],
|
243
|
+
[ new Date(2016, 9, 19), 38823 ],
|
244
|
+
[ new Date(2016, 9, 23), 38345 ],
|
245
|
+
[ new Date(2016, 9, 24), 38436 ],
|
246
|
+
[ new Date(2016, 9, 30), 38447 ]
|
247
|
+
]);
|
248
|
+
|
249
|
+
var chart = new google.visualization.Calendar(document.getElementById('calendar_basic'));
|
250
|
+
|
251
|
+
var options = {
|
252
|
+
title: "Red Sox Attendance",
|
253
|
+
height: 350,
|
254
|
+
};
|
255
|
+
|
256
|
+
chart.draw(dataTable, options);
|
257
|
+
}
|
258
|
+
|
259
|
+
END
|
260
|
+
end
|
261
|
+
return html + script
|
262
|
+
end
|
263
|
+
|
264
|
+
def google_scatterchart id=nil, size=nil
|
265
|
+
html = "<div id=\"chart_div\" style=\"width: 900px; height: 500px;\"></div>".html_safe
|
266
|
+
script = javascript_tag do
|
267
|
+
<<-END.html_safe
|
268
|
+
google.charts.load('current', {'packages':['corechart']});
|
269
|
+
google.charts.setOnLoadCallback(drawChart);
|
270
|
+
function drawChart() {
|
271
|
+
var data = google.visualization.arrayToDataTable([
|
272
|
+
['Age', 'Weight'],
|
273
|
+
[ 8, 12],
|
274
|
+
[ 4, 5.5],
|
275
|
+
[ 11, 14],
|
276
|
+
[ 4, 5],
|
277
|
+
[ 3, 3.5],
|
278
|
+
[ 6.5, 7]
|
279
|
+
]);
|
280
|
+
var options = {
|
281
|
+
title: 'Age vs. Weight comparison',
|
282
|
+
hAxis: {title: 'Age', minValue: 0, maxValue: 15},
|
283
|
+
vAxis: {title: 'Weight', minValue: 0, maxValue: 15},
|
284
|
+
legend: 'none'
|
285
|
+
};
|
286
|
+
var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
|
287
|
+
chart.draw(data, options);
|
288
|
+
}
|
289
|
+
|
290
|
+
END
|
291
|
+
end
|
292
|
+
return html + script
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
# def google_area
|
298
|
+
# html = "".html_safe
|
299
|
+
# script = javascript_tag do
|
300
|
+
# <<-END.html_safe
|
301
|
+
# END
|
302
|
+
# end
|
303
|
+
# return html + script
|
304
|
+
# end
|
305
|
+
|
306
|
+
|
307
|
+
end
|
@@ -0,0 +1,275 @@
|
|
1
|
+
module HighchartsHelper
|
2
|
+
#
|
3
|
+
# Highcharts
|
4
|
+
def highcharts_line
|
5
|
+
html = "<div id=\"container\" style=\"min-width: 310px; height: 400px; margin: 0 auto\"></div>".html_safe
|
6
|
+
script = javascript_tag do
|
7
|
+
<<-END.html_safe
|
8
|
+
$(function () {
|
9
|
+
$('#container').highcharts({
|
10
|
+
title: {
|
11
|
+
text: 'Monthly Average Temperature',
|
12
|
+
x: -20 //center
|
13
|
+
},
|
14
|
+
subtitle: {
|
15
|
+
text: 'Source: WorldClimate.com',
|
16
|
+
x: -20
|
17
|
+
},
|
18
|
+
xAxis: {
|
19
|
+
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
20
|
+
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
21
|
+
},
|
22
|
+
yAxis: {
|
23
|
+
title: {
|
24
|
+
text: 'Temperature (°C)'
|
25
|
+
},
|
26
|
+
plotLines: [{
|
27
|
+
value: 0,
|
28
|
+
width: 1,
|
29
|
+
color: '#808080'
|
30
|
+
}]
|
31
|
+
},
|
32
|
+
tooltip: {
|
33
|
+
valueSuffix: '°C'
|
34
|
+
},
|
35
|
+
legend: {
|
36
|
+
layout: 'vertical',
|
37
|
+
align: 'right',
|
38
|
+
verticalAlign: 'middle',
|
39
|
+
borderWidth: 0
|
40
|
+
},
|
41
|
+
series: [{
|
42
|
+
name: 'Tokyo',
|
43
|
+
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
|
44
|
+
}, {
|
45
|
+
name: 'New York',
|
46
|
+
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
|
47
|
+
}, {
|
48
|
+
name: 'Berlin',
|
49
|
+
data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
|
50
|
+
}, {
|
51
|
+
name: 'London',
|
52
|
+
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
|
53
|
+
}]
|
54
|
+
});
|
55
|
+
});
|
56
|
+
END
|
57
|
+
end
|
58
|
+
return html + script
|
59
|
+
end
|
60
|
+
|
61
|
+
def highcharts_area
|
62
|
+
html = "<div id=\"container_area\" style=\"min-width: 310px; height: 400px; margin: 0 auto\"></div>".html_safe
|
63
|
+
script = javascript_tag do
|
64
|
+
<<-END.html_safe
|
65
|
+
$(function () {
|
66
|
+
$('#container_area').highcharts({
|
67
|
+
chart: {
|
68
|
+
type: 'area'
|
69
|
+
},
|
70
|
+
title: {
|
71
|
+
text: 'US and USSR nuclear stockpiles'
|
72
|
+
},
|
73
|
+
subtitle: {
|
74
|
+
text: 'Source: <a href="http://thebulletin.metapress.com/content/c4120650912x74k7/fulltext.pdf">' +
|
75
|
+
'thebulletin.metapress.com</a>'
|
76
|
+
},
|
77
|
+
xAxis: {
|
78
|
+
allowDecimals: false,
|
79
|
+
labels: {
|
80
|
+
formatter: function () {
|
81
|
+
return this.value; // clean, unformatted number for year
|
82
|
+
}
|
83
|
+
}
|
84
|
+
},
|
85
|
+
yAxis: {
|
86
|
+
title: {
|
87
|
+
text: 'Nuclear weapon states'
|
88
|
+
},
|
89
|
+
labels: {
|
90
|
+
formatter: function () {
|
91
|
+
return this.value / 1000 + 'k';
|
92
|
+
}
|
93
|
+
}
|
94
|
+
},
|
95
|
+
tooltip: {
|
96
|
+
pointFormat: '{series.name} produced <b>{point.y:,.0f}</b><br/>warheads in {point.x}'
|
97
|
+
},
|
98
|
+
plotOptions: {
|
99
|
+
area: {
|
100
|
+
pointStart: 1940,
|
101
|
+
marker: {
|
102
|
+
enabled: false,
|
103
|
+
symbol: 'circle',
|
104
|
+
radius: 2,
|
105
|
+
states: {
|
106
|
+
hover: {
|
107
|
+
enabled: true
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
},
|
113
|
+
series: [{
|
114
|
+
name: 'USA',
|
115
|
+
data: [null, null, null, null, null, 6, 11, 32, 110, 235, 369, 640,
|
116
|
+
1005, 1436, 2063, 3057, 4618, 6444, 9822, 15468, 20434, 24126,
|
117
|
+
27387, 29459, 31056, 31982, 32040, 31233, 29224, 27342, 26662,
|
118
|
+
26956, 27912, 28999, 28965, 27826, 25579, 25722, 24826, 24605,
|
119
|
+
24304, 23464, 23708, 24099, 24357, 24237, 24401, 24344, 23586,
|
120
|
+
22380, 21004, 17287, 14747, 13076, 12555, 12144, 11009, 10950,
|
121
|
+
10871, 10824, 10577, 10527, 10475, 10421, 10358, 10295, 10104]
|
122
|
+
}, {
|
123
|
+
name: 'USSR/Russia',
|
124
|
+
data: [null, null, null, null, null, null, null, null, null, null,
|
125
|
+
5, 25, 50, 120, 150, 200, 426, 660, 869, 1060, 1605, 2471, 3322,
|
126
|
+
4238, 5221, 6129, 7089, 8339, 9399, 10538, 11643, 13092, 14478,
|
127
|
+
15915, 17385, 19055, 21205, 23044, 25393, 27935, 30062, 32049,
|
128
|
+
33952, 35804, 37431, 39197, 45000, 43000, 41000, 39000, 37000,
|
129
|
+
35000, 33000, 31000, 29000, 27000, 25000, 24000, 23000, 22000,
|
130
|
+
21000, 20000, 19000, 18000, 18000, 17000, 16000]
|
131
|
+
}]
|
132
|
+
});
|
133
|
+
});
|
134
|
+
END
|
135
|
+
end
|
136
|
+
return html + script
|
137
|
+
end
|
138
|
+
|
139
|
+
def highcharts_bar
|
140
|
+
html = "<div id=\"container_bar\" style=\"min-width: 310px; height: 400px; margin: 0 auto\"></div>".html_safe
|
141
|
+
script = javascript_tag do
|
142
|
+
<<-END.html_safe
|
143
|
+
$(function () {
|
144
|
+
$('#container_bar').highcharts({
|
145
|
+
chart: {
|
146
|
+
type: 'bar'
|
147
|
+
},
|
148
|
+
title: {
|
149
|
+
text: 'Historic World Population by Region'
|
150
|
+
},
|
151
|
+
subtitle: {
|
152
|
+
text: 'Source: <a href="https://en.wikipedia.org/wiki/World_population">Wikipedia.org</a>'
|
153
|
+
},
|
154
|
+
xAxis: {
|
155
|
+
categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
|
156
|
+
title: {
|
157
|
+
text: null
|
158
|
+
}
|
159
|
+
},
|
160
|
+
yAxis: {
|
161
|
+
min: 0,
|
162
|
+
title: {
|
163
|
+
text: 'Population (millions)',
|
164
|
+
align: 'high'
|
165
|
+
},
|
166
|
+
labels: {
|
167
|
+
overflow: 'justify'
|
168
|
+
}
|
169
|
+
},
|
170
|
+
tooltip: {
|
171
|
+
valueSuffix: ' millions'
|
172
|
+
},
|
173
|
+
plotOptions: {
|
174
|
+
bar: {
|
175
|
+
dataLabels: {
|
176
|
+
enabled: true
|
177
|
+
}
|
178
|
+
}
|
179
|
+
},
|
180
|
+
legend: {
|
181
|
+
layout: 'vertical',
|
182
|
+
align: 'right',
|
183
|
+
verticalAlign: 'top',
|
184
|
+
x: -40,
|
185
|
+
y: 80,
|
186
|
+
floating: true,
|
187
|
+
borderWidth: 1,
|
188
|
+
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
|
189
|
+
shadow: true
|
190
|
+
},
|
191
|
+
credits: {
|
192
|
+
enabled: false
|
193
|
+
},
|
194
|
+
series: [{
|
195
|
+
name: 'Year 1800',
|
196
|
+
data: [107, 31, 635, 203, 2]
|
197
|
+
}, {
|
198
|
+
name: 'Year 1900',
|
199
|
+
data: [133, 156, 947, 408, 6]
|
200
|
+
}, {
|
201
|
+
name: 'Year 2012',
|
202
|
+
data: [1052, 954, 4250, 740, 38]
|
203
|
+
}]
|
204
|
+
});
|
205
|
+
});
|
206
|
+
END
|
207
|
+
end
|
208
|
+
return html + script
|
209
|
+
end
|
210
|
+
|
211
|
+
def highcharts_pie
|
212
|
+
html = "<div id=\"container_pie\" style=\"min-width: 310px; height: 400px; margin: 0 auto\"></div>".html_safe
|
213
|
+
script = javascript_tag do
|
214
|
+
<<-END.html_safe
|
215
|
+
$(function () {
|
216
|
+
$('#container_pie').highcharts({
|
217
|
+
chart: {
|
218
|
+
plotBackgroundColor: null,
|
219
|
+
plotBorderWidth: null,
|
220
|
+
plotShadow: false,
|
221
|
+
type: 'pie'
|
222
|
+
},
|
223
|
+
title: {
|
224
|
+
text: 'Browser market shares January, 2015 to May, 2015'
|
225
|
+
},
|
226
|
+
tooltip: {
|
227
|
+
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
|
228
|
+
},
|
229
|
+
plotOptions: {
|
230
|
+
pie: {
|
231
|
+
allowPointSelect: true,
|
232
|
+
cursor: 'pointer',
|
233
|
+
dataLabels: {
|
234
|
+
enabled: true,
|
235
|
+
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
|
236
|
+
style: {
|
237
|
+
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
},
|
242
|
+
series: [{
|
243
|
+
name: 'Brands',
|
244
|
+
colorByPoint: true,
|
245
|
+
data: [{
|
246
|
+
name: 'Microsoft Internet Explorer',
|
247
|
+
y: 56.33
|
248
|
+
}, {
|
249
|
+
name: 'Chrome',
|
250
|
+
y: 24.03,
|
251
|
+
sliced: true,
|
252
|
+
selected: true
|
253
|
+
}, {
|
254
|
+
name: 'Firefox',
|
255
|
+
y: 10.38
|
256
|
+
}, {
|
257
|
+
name: 'Safari',
|
258
|
+
y: 4.77
|
259
|
+
}, {
|
260
|
+
name: 'Opera',
|
261
|
+
y: 0.91
|
262
|
+
}, {
|
263
|
+
name: 'Proprietary or Undetectable',
|
264
|
+
y: 0.2
|
265
|
+
}]
|
266
|
+
}]
|
267
|
+
});
|
268
|
+
});
|
269
|
+
END
|
270
|
+
end
|
271
|
+
return html + script
|
272
|
+
end
|
273
|
+
|
274
|
+
|
275
|
+
end
|