rchart 1.0.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +20 -0
- data/Rakefile +60 -0
- data/VERSION +1 -0
- data/examples/Point_Asterisk.png +0 -0
- data/examples/Point_Cd.png +0 -0
- data/examples/example1.rb +36 -0
- data/examples/example10.rb +23 -0
- data/examples/example11.rb +22 -0
- data/examples/example12.rb +56 -0
- data/examples/example13.rb +45 -0
- data/examples/example14.rb +37 -0
- data/examples/example15.rb +33 -0
- data/examples/example16.rb +40 -0
- data/examples/example17.rb +41 -0
- data/examples/example18.rb +38 -0
- data/examples/example19.rb +36 -0
- data/examples/example2.rb +36 -0
- data/examples/example20.rb +41 -0
- data/examples/example21.rb +56 -0
- data/examples/example3.rb +30 -0
- data/examples/example4.rb +30 -0
- data/examples/example5.rb +37 -0
- data/examples/example6.rb +26 -0
- data/examples/example7.rb +24 -0
- data/examples/example8.rb +24 -0
- data/examples/example9.rb +33 -0
- data/examples/logo.png +0 -0
- data/examples/softtones.txt +5 -0
- data/fonts/GeosansLight.ttf +0 -0
- data/fonts/MankSans.ttf +0 -0
- data/fonts/Silkscreen.ttf +0 -0
- data/fonts/pf_arma_five.ttf +0 -0
- data/fonts/tahoma.ttf +0 -0
- data/lib/rchart.rb +3270 -0
- data/lib/rdata.rb +239 -0
- data/lib/version.rb +19 -0
- data/test/helper.rb +10 -0
- data/test/test_rchart.rb +7 -0
- metadata +127 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
#Customizing plot graphs
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rchart'
|
5
|
+
|
6
|
+
p = Rdata.new
|
7
|
+
p.add_point([60,70,90,110,100,90],"Serie1")
|
8
|
+
p.add_point([40,50,60,80,70,60],"Serie2")
|
9
|
+
p.add_point(["Jan","Feb","Mar","Apr","May","Jun"],"Serie3")
|
10
|
+
p.add_serie("Serie1")
|
11
|
+
p.add_serie("Serie2")
|
12
|
+
|
13
|
+
p.set_abscise_label_serie("Serie3")
|
14
|
+
p.set_serie_name("Company A","Serie1")
|
15
|
+
p.set_serie_name("Company B","Serie2")
|
16
|
+
p.set_y_axis_name("Product sales")
|
17
|
+
p.set_y_axis_unit("k")
|
18
|
+
p.set_serie_symbol("Serie1","Point_Asterisk.png")
|
19
|
+
p.set_serie_symbol("Serie2","Point_Cd.png")
|
20
|
+
|
21
|
+
ch = Rchart.new(700,230)
|
22
|
+
ch.set_font_properties("tahoma.ttf",8)
|
23
|
+
ch.set_graph_area(65,30,650,200)
|
24
|
+
ch.draw_filled_rectangle(7,7,693,223,5,240,240,240)
|
25
|
+
ch.draw_rounded_rectangle(5,5,695,225,5,230,230,230)
|
26
|
+
ch.draw_graph_area(255,255,255,true)
|
27
|
+
|
28
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,150,150,150,true,0,2,true)
|
29
|
+
ch.draw_grid(4,true,230,230,230,20)
|
30
|
+
ch.set_font_properties("pf_arma_five.ttf",6)
|
31
|
+
title= "Comparative product sales for company A & B "
|
32
|
+
ch.draw_text_box(65,30,650,45,title,0,255,255,255,Rchart::ALIGN_RIGHT,true,0,0,0,30)
|
33
|
+
|
34
|
+
# Draw the line chart
|
35
|
+
ch.draw_line_graph(p.get_data,p.get_data_description)
|
36
|
+
ch.draw_plot_graph(p.get_data,p.get_data_description,3,2,255,255,255)
|
37
|
+
ch.draw_treshold(0,143,55,72,true,true)
|
38
|
+
ch.set_font_properties("tahoma.ttf",8)
|
39
|
+
ch.draw_legend(80,60,p.get_data_description,255,255,255)
|
40
|
+
|
41
|
+
ch.render_png("Example17")
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#Playing with background bis
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rchart'
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([9,9,9,10,10,11,12,14,16,17,18,18,19,19,18,15,12,10,9],"Serie1");
|
7
|
+
p.add_point([10,11,11,12,12,13,14,15,17,19,22,24,23,23,22,20,18,16,14],"Serie2");
|
8
|
+
p.add_point([4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"Serie3");
|
9
|
+
p.add_all_series()
|
10
|
+
p.remove_serie("Serie3")
|
11
|
+
p.set_abscise_label_serie("Serie3")
|
12
|
+
p.set_serie_name("January","Serie1");
|
13
|
+
p.set_serie_name("February","Serie2");
|
14
|
+
p.set_y_axis_name("Temperature");
|
15
|
+
p.set_y_axis_unit("°C");
|
16
|
+
p.set_x_axis_unit("h");
|
17
|
+
|
18
|
+
ch = Rchart.new(700,230)
|
19
|
+
ch.draw_graph_area_gradient(132,173,131,50,Rchart::TARGET_BACKGROUND);
|
20
|
+
ch.set_font_properties("tahoma.ttf",8)
|
21
|
+
ch.set_graph_area(120,20,675,190)
|
22
|
+
ch.draw_graph_area(213,217,221,false)
|
23
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_ADDALL,213,217,221,true,0,2,true)
|
24
|
+
ch.draw_graph_area_gradient(163,203,167,50);
|
25
|
+
ch.draw_grid(4,true,230,230,230,20)
|
26
|
+
|
27
|
+
ch.draw_stacked_bar_graph(p.get_data,p.get_data_description,70)
|
28
|
+
|
29
|
+
#Draw the title
|
30
|
+
title= " Average Temperatures during\r\n the first months of 2008 "
|
31
|
+
ch.draw_text_box(0,0,50,230,"#{title}",90,255,255,255,Rchart::ALIGN_BOTTOM_CENTER,true,0,0,0,30)
|
32
|
+
|
33
|
+
#Draw the legend
|
34
|
+
ch.set_font_properties("tahoma.ttf",8)
|
35
|
+
ch.draw_legend(610,10,p.get_data_description,236,238,240,52,58,82)
|
36
|
+
|
37
|
+
ch.add_border(2)
|
38
|
+
ch.render_png("Example18")
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#X versus Y char
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
#Compute the points
|
5
|
+
p = Rdata.new
|
6
|
+
i=0
|
7
|
+
while(i<=360)
|
8
|
+
p.add_point(Math.cos(i*Math::PI/180)*80+i,"Serie1")
|
9
|
+
p.add_point(Math.sin(i*Math::PI/180)*80+i,"Serie2")
|
10
|
+
i+=10
|
11
|
+
|
12
|
+
end
|
13
|
+
p.set_serie_name("Trigonometric function","Serie1")
|
14
|
+
p.add_serie("Serie1")
|
15
|
+
p.add_serie("Serie2")
|
16
|
+
p.set_x_axis_name("X Axis")
|
17
|
+
p.set_y_axis_name("Y Axis")
|
18
|
+
ch = Rchart.new(300,300)
|
19
|
+
ch.draw_graph_area_gradient(0,0,0,-100,Rchart::TARGET_BACKGROUND);
|
20
|
+
ch.set_font_properties("tahoma.ttf",8)
|
21
|
+
ch.set_graph_area(55,30,270,230)
|
22
|
+
ch.draw_xy_scale(p.get_data,p.get_data_description,"Serie1","Serie2",213,217,221,true,45)
|
23
|
+
ch.draw_graph_area(213,217,221,false)
|
24
|
+
ch.draw_graph_area_gradient(30,30,30,-50);
|
25
|
+
ch.draw_grid(4,true,230,230,230,20)
|
26
|
+
ch.set_shadow_properties(2,2,0,0,0,60,4)
|
27
|
+
|
28
|
+
ch.draw_xy_graph(p.get_data,p.get_data_description,"Serie1","Serie2",0)
|
29
|
+
ch.clear_shadow
|
30
|
+
|
31
|
+
title= "Drawing X versus Y charts trigonometric functions ";
|
32
|
+
ch.draw_text_box(0,280,300,300,"#{title}",0,255,255,255,Rchart::ALIGN_RIGHT,true,0,0,0,30)
|
33
|
+
ch.set_font_properties("pf_arma_five.ttf",6)
|
34
|
+
p.remove_serie("Serie2")
|
35
|
+
ch.draw_legend(160,5,p.get_data_description,0,0,0,0,0,0,255,255,255,false)
|
36
|
+
ch.render_png("example19")
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# an overlayed bar graph
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
#Dataset definition
|
5
|
+
|
6
|
+
p = Rdata.new
|
7
|
+
p.add_point([1,4,-3,2,-3,3,2,1,0,7,4,-3,2,-3,3,5,1,0,7],"Serie1")
|
8
|
+
p.add_point([0,3,-4,1,-2,2,1,0,-1,6,3,-4,1,-4,2,4,0,-1,6],"Serie2")
|
9
|
+
p.add_all_series()
|
10
|
+
p.set_abscise_label_serie
|
11
|
+
p.set_serie_name("January","Serie1")
|
12
|
+
p.set_serie_name("February","Serie2")
|
13
|
+
|
14
|
+
#Initialise the graph
|
15
|
+
ch = Rchart.new(700,230)
|
16
|
+
ch.set_font_properties("tahoma.ttf",8)
|
17
|
+
ch.set_graph_area(50,30,585,200)
|
18
|
+
ch.draw_filled_rounded_rectangle(7,7,693,223,5,240,240,240)
|
19
|
+
ch.draw_rounded_rectangle(5,5,695,225,5,230,230,230)
|
20
|
+
ch.draw_graph_area(255,255,255,true)
|
21
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,150,150,150,true,0,2,true)
|
22
|
+
ch.draw_grid(4,true,230,230,230,50)
|
23
|
+
|
24
|
+
#Draw the 0 line
|
25
|
+
ch.set_font_properties("tahoma.ttf",6)
|
26
|
+
ch.draw_treshold(0,143,55,72,true,true)
|
27
|
+
|
28
|
+
#Draw the bar graph
|
29
|
+
ch.draw_overlay_bar_graph(p.get_data,p.get_data_description)
|
30
|
+
|
31
|
+
#Finish the graph
|
32
|
+
ch.set_font_properties("tahoma.ttf",8)
|
33
|
+
ch.draw_legend(600,30,p.get_data_description,255,255,255)
|
34
|
+
ch.set_font_properties("tahoma.ttf",10)
|
35
|
+
ch.draw_title(50,22,"Example 2",50,50,50,585)
|
36
|
+
ch.render_png("example2")
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#Playing with shadow
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([9,9,9,10,10,11,12,14,16,17,18,18,19,19,18,15,12,10,9],"Serie1")
|
7
|
+
p.add_point([10,11,11,12,12,13,14,15,17,19,22,24,23,23,22,20,18,16,14],"Serie2")
|
8
|
+
p.add_point([4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"Serie3")
|
9
|
+
p.add_all_series
|
10
|
+
p.remove_serie("Serie3")
|
11
|
+
p.set_abscise_label_serie("Serie3")
|
12
|
+
p.set_serie_name("January","Serie1")
|
13
|
+
p.set_serie_name("February","Serie2")
|
14
|
+
p.set_y_axis_name("Temperature")
|
15
|
+
p.set_y_axis_unit("°C")
|
16
|
+
p.set_x_axis_unit("h")
|
17
|
+
|
18
|
+
ch = Rchart.new(700,230)
|
19
|
+
ch.draw_graph_area_gradient(90,90,90,90,Rchart::TARGET_BACKGROUND)
|
20
|
+
ch.set_fixed_scale(0,40,4)
|
21
|
+
ch.set_font_properties("pf_arma_five.ttf",6)
|
22
|
+
ch.set_graph_area(60,40,680,200)
|
23
|
+
ch.draw_graph_area(200,200,200,false)
|
24
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,213,217,221,true,0,2)
|
25
|
+
ch.draw_graph_area_gradient(40,40,40,-50)
|
26
|
+
ch.draw_grid(4,true,230,230,230,10)
|
27
|
+
|
28
|
+
# Draw the line chart
|
29
|
+
ch.set_shadow_properties(3,3,0,0,0,30,4)
|
30
|
+
ch.draw_cubic_curve(p.get_data,p.get_data_description)
|
31
|
+
ch.clear_shadow
|
32
|
+
ch.draw_plot_graph(p.get_data,p.get_data_description,4,2,-1,-1,-1,true)
|
33
|
+
|
34
|
+
ch.set_font_properties("MankSans.ttf",18)
|
35
|
+
ch.set_shadow_properties(1,1,0,0,0)
|
36
|
+
ch.draw_title(0,0,"Average temperatures",255,255,255,700,30,true)
|
37
|
+
ch.clear_shadow
|
38
|
+
|
39
|
+
ch.set_font_properties("tahoma.ttf",8)
|
40
|
+
ch.draw_legend(610, 5, p.get_data_description, 0,0,0,0,0,0,255,255,255,false)
|
41
|
+
ch.render_png("example20")
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#Two Y axis / shadow demonstration
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([110,101,118,108,110,106,104],"Serie1")
|
7
|
+
p.add_point([700,2705,2041,1712,2051,846,903],"Serie2")
|
8
|
+
p.add_point(["03 Oct","02 Oct","01 Oct","30 Sep","29 Sep","28 Sep","27 Sep"],"Serie3")
|
9
|
+
p.add_serie("Serie1")
|
10
|
+
p.set_abscise_label_serie("Serie3")
|
11
|
+
p.set_serie_name("SourceForge Rank","Serie1")
|
12
|
+
p.set_serie_name("Web Hits","Serie2")
|
13
|
+
|
14
|
+
|
15
|
+
ch = Rchart.new(660,230)
|
16
|
+
ch.draw_graph_area_gradient(90,90,90,90,Rchart::TARGET_BACKGROUND)
|
17
|
+
ch.set_font_properties("tahoma.ttf",8)
|
18
|
+
ch.set_graph_area(60,40,595,190)
|
19
|
+
ch.set_font_properties("tahoma.ttf",8)
|
20
|
+
# Draw the SourceForge Rank graph
|
21
|
+
p.set_y_axis_name("SourceForge Rank")
|
22
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,213,217,221,true,0,0)
|
23
|
+
ch.draw_graph_area_gradient(40,40,40,-50)
|
24
|
+
ch.draw_grid(4,true,230,230,230,10)
|
25
|
+
|
26
|
+
ch.set_shadow_properties(3,3,0,0,0,30,4)
|
27
|
+
ch.draw_cubic_curve(p.get_data,p.get_data_description)
|
28
|
+
ch.clear_shadow
|
29
|
+
ch.draw_filled_cubic_curve(p.get_data,p.get_data_description,0.1,30)
|
30
|
+
ch.draw_plot_graph(p.get_data,p.get_data_description,3,2,255,255,255)
|
31
|
+
ch.clear_scale
|
32
|
+
|
33
|
+
#draw 2nd graph
|
34
|
+
p.remove_serie("Serie1")
|
35
|
+
p.add_serie("Serie2")
|
36
|
+
p.set_y_axis_name("Web Hits")
|
37
|
+
|
38
|
+
ch.draw_right_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,213,217,221,true,0,0)
|
39
|
+
ch.draw_grid(4,true,230,230,230,10)
|
40
|
+
ch.set_shadow_properties(3,3,0,0,0,30,4)
|
41
|
+
ch.draw_cubic_curve(p.get_data,p.get_data_description)
|
42
|
+
ch.clear_shadow
|
43
|
+
ch.draw_filled_cubic_curve(p.get_data,p.get_data_description,0.1,30)
|
44
|
+
ch.draw_plot_graph(p.get_data,p.get_data_description,3,2,255,255,255)
|
45
|
+
ch.clear_scale
|
46
|
+
|
47
|
+
|
48
|
+
ch.set_font_properties("tahoma.ttf",8)
|
49
|
+
ch.draw_legend(530, 5, p.get_data_description, 0,0,0,0,0,0,255,255,255,false)
|
50
|
+
|
51
|
+
ch.set_font_properties("MankSans.ttf",18)
|
52
|
+
ch.set_shadow_properties(1,1,0,0,0)
|
53
|
+
ch.draw_title(0,0,"SourceForge ranking summary",255,255,255,660,30,true)
|
54
|
+
ch.clear_shadow
|
55
|
+
|
56
|
+
ch.render_png("example21")
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# A limits graph
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([1,4,-3,2,-3,3,2,1,0,7,4,-3,2,-3,3,5,1,0,7],"Serie1")
|
7
|
+
p.add_point([2,5,7,5,1,5,6,4,8,4,0,2,5,6,4,5,6,7,6],"Serie2")
|
8
|
+
p.add_all_series()
|
9
|
+
p.set_abscise_label_serie
|
10
|
+
p.set_serie_name("January","Serie1")
|
11
|
+
p.set_serie_name("February","Serie2")
|
12
|
+
|
13
|
+
ch = Rchart.new(700,230)
|
14
|
+
ch.set_font_properties("tahoma.ttf",8)
|
15
|
+
ch.set_graph_area(50,30,585,200)
|
16
|
+
ch.draw_filled_rounded_rectangle(7,7,693,223,5,240,240,240)
|
17
|
+
ch.draw_rounded_rectangle(5,5,695,225,5,230,230,230)
|
18
|
+
ch.draw_graph_area(255,255,255,true)
|
19
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,150,150,150,true,0,2,true)
|
20
|
+
ch.draw_grid(4,true,230,230,230,50)
|
21
|
+
ch.set_font_properties("tahoma.ttf",6)
|
22
|
+
ch.draw_treshold(0,143,55,72,true,true)
|
23
|
+
|
24
|
+
ch.draw_limits_graph(p.get_data,p.get_data_description,180,180,180)
|
25
|
+
|
26
|
+
ch.set_font_properties("tahoma.ttf",8)
|
27
|
+
ch.draw_legend(600,30,p.get_data_description,255,255,255)
|
28
|
+
ch.set_font_properties("tahoma.ttf",10)
|
29
|
+
ch.draw_title(50,22,"Example 3",50,50,50,585)
|
30
|
+
ch.render_png("example3")
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#A filled cubic curve graph
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([1,4,3,2,3,3,2,1,0,7,4,3,2,3,3,5,1,0,7],"Serie1")
|
7
|
+
p.add_point([1,4,2,6,2,3,0,1,5,1,2,4,5,2,1,0,6,4,2],"Serie2")
|
8
|
+
p.add_all_series()
|
9
|
+
p.set_abscise_label_serie
|
10
|
+
p.set_serie_name("January","Serie1")
|
11
|
+
p.set_serie_name("February","Serie2")
|
12
|
+
|
13
|
+
ch = Rchart.new(700,230)
|
14
|
+
ch.set_font_properties("tahoma.ttf",8)
|
15
|
+
ch.set_graph_area(50,30,585,200)
|
16
|
+
ch.draw_filled_rounded_rectangle(7,7,693,223,5,240,240,240)
|
17
|
+
ch.draw_rounded_rectangle(5,5,695,225,5,230,230,230)
|
18
|
+
ch.draw_graph_area(255,255,255,true)
|
19
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,150,150,150,true,0,2)
|
20
|
+
ch.draw_grid(4,true,230,230,230,50)
|
21
|
+
ch.set_font_properties("tahoma.ttf",6)
|
22
|
+
ch.draw_treshold(0,143,55,72,true,true)
|
23
|
+
|
24
|
+
ch.draw_filled_cubic_curve(p.get_data,p.get_data_description,0.1,50)
|
25
|
+
|
26
|
+
ch.set_font_properties("tahoma.ttf",8)
|
27
|
+
ch.draw_legend(600,30,p.get_data_description,255,255,255)
|
28
|
+
ch.set_font_properties("tahoma.ttf",10)
|
29
|
+
ch.draw_title(50,22,"Example 4",50,50,50,585)
|
30
|
+
ch.render_png("example4")
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Showing how to use labels
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([0,70,70,0,0,70,70,0,0,70],"Serie1")
|
7
|
+
p.add_point([0.5,2,4.5,8,12.5,18,24.5,32,40.5,50],"Serie2")
|
8
|
+
p.add_all_series()
|
9
|
+
p.set_abscise_label_serie
|
10
|
+
p.set_serie_name("January","Serie1")
|
11
|
+
p.set_serie_name("February","Serie2")
|
12
|
+
|
13
|
+
ch = Rchart.new(700,230)
|
14
|
+
ch.set_font_properties("../fonts/tahoma.ttf",8)
|
15
|
+
ch.set_graph_area(50,30,585,200)
|
16
|
+
ch.draw_filled_rounded_rectangle(7,7,693,223,5,240,240,240)
|
17
|
+
ch.draw_rounded_rectangle(5,5,695,225,5,230,230,230)
|
18
|
+
ch.draw_graph_area(255,255,255,true)
|
19
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,150,150,150,true,0,2)
|
20
|
+
ch.draw_grid(4,true,230,230,230,50)
|
21
|
+
ch.set_font_properties("../fonts/tahoma.ttf",6)
|
22
|
+
ch.draw_treshold(0,143,55,72,true,true)
|
23
|
+
|
24
|
+
#draw line graph
|
25
|
+
ch.draw_line_graph(p.get_data,p.get_data_description)
|
26
|
+
ch.draw_plot_graph(p.get_data, p.get_data_description,3,2,255,255,255)
|
27
|
+
|
28
|
+
# Set labels
|
29
|
+
ch.set_font_properties("../fonts/tahoma.ttf",8)
|
30
|
+
ch.set_label(p.get_data, p.get_data_description, "Serie1", "2","Daily incomes",221,230,174)
|
31
|
+
ch.set_label(p.get_data, p.get_data_description, "Serie2", "6","Production break",239,233,195)
|
32
|
+
|
33
|
+
ch.set_font_properties("../fonts/tahoma.ttf",8)
|
34
|
+
ch.draw_legend(600,30,p.get_data_description,255,255,255)
|
35
|
+
ch.set_font_properties("../fonts/tahoma.ttf",10)
|
36
|
+
ch.draw_title(50,22,"Example 5",50,50,50,585)
|
37
|
+
ch.render_png("example5")
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#A 3D exploded pie graph
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([10,2,3,5,3],"Serie1")
|
7
|
+
p.add_point(["January","February","March","April","May"],"Serie2")
|
8
|
+
p.add_all_series
|
9
|
+
p.set_abscise_label_serie("Serie2")
|
10
|
+
|
11
|
+
ch = Rchart.new(420,250)
|
12
|
+
ch.draw_filled_rounded_rectangle(7,7,413,243,5,240,240,240)
|
13
|
+
ch.draw_rounded_rectangle(5,5,415,245,5,230,230,230)
|
14
|
+
ch.create_color_gradient_palette(195,204,56,223,110,41,5)
|
15
|
+
ch.set_font_properties("tahoma.ttf",8)
|
16
|
+
ch.antialias_quality=0
|
17
|
+
|
18
|
+
|
19
|
+
ch.draw_basic_pie_graph(p.get_data, p.get_data_description, 180, 130,110)
|
20
|
+
ch.draw_pie_graph(p.get_data,p.get_data_description,180,130,110,Rchart::PIE_PERCENTAGE_LABEL,false,50,20,5)
|
21
|
+
ch.draw_pie_legend(330,15,p.get_data,p.get_data_description,250,250,250)
|
22
|
+
|
23
|
+
#Write the title
|
24
|
+
ch.set_font_properties("MankSans.ttf",10)
|
25
|
+
ch.draw_title(10,20,"Sales per month",100,100,100)
|
26
|
+
ch.render_png("example6")
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#Basic pie graph
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([10,2,3,5,3],"Serie1")
|
7
|
+
p.add_point(["January","February","March","April","May"],"Serie2")
|
8
|
+
p.add_all_series
|
9
|
+
p.set_abscise_label_serie("Serie2")
|
10
|
+
|
11
|
+
ch = Rchart.new(420,250)
|
12
|
+
ch.draw_filled_rounded_rectangle(7,7,413,243,5,240,240,240)
|
13
|
+
ch.draw_rounded_rectangle(5,5,415,245,5,230,230,230)
|
14
|
+
ch.create_color_gradient_palette(195,204,56,223,110,41,5)
|
15
|
+
ch.set_font_properties("tahoma.ttf",8)
|
16
|
+
ch.antialias_quality=0
|
17
|
+
|
18
|
+
ch.draw_basic_pie_graph(p.get_data, p.get_data_description, 180, 130,110)
|
19
|
+
ch.draw_pie_legend(330,15,p.get_data,p.get_data_description,250,250,250)
|
20
|
+
|
21
|
+
#Write the title
|
22
|
+
ch.set_font_properties("MankSans.ttf",10)
|
23
|
+
ch.draw_title(10,20,"Sales per month",100,100,100)
|
24
|
+
ch.render_png("example7")
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# 3D Pie graph
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([10,2,3,5,3],"Serie1")
|
7
|
+
p.add_point(["January","February","March","April","May"],"Serie2")
|
8
|
+
p.add_all_series
|
9
|
+
p.set_abscise_label_serie("Serie2")
|
10
|
+
|
11
|
+
ch = Rchart.new(420,250)
|
12
|
+
ch.draw_filled_rounded_rectangle(7,7,413,243,5,240,240,240)
|
13
|
+
ch.draw_rounded_rectangle(5,5,415,245,5,230,230,230)
|
14
|
+
ch.create_color_gradient_palette(195,204,56,223,110,41,5)
|
15
|
+
ch.set_font_properties("tahoma.ttf",8)
|
16
|
+
ch.antialias_quality=0
|
17
|
+
|
18
|
+
ch.draw_pie_graph(p.get_data,p.get_data_description,180,130,110,Rchart::PIE_PERCENTAGE_LABEL,false,50,20,5)
|
19
|
+
ch.draw_pie_legend(330,15,p.get_data,p.get_data_description,250,250,250)
|
20
|
+
|
21
|
+
#Write the title
|
22
|
+
ch.set_font_properties("MankSans.ttf",10)
|
23
|
+
ch.draw_title(10,20,"Sales per month",100,100,100)
|
24
|
+
ch.render_png("example8")
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Bar graph
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rchart'
|
4
|
+
|
5
|
+
p = Rdata.new
|
6
|
+
p.add_point([1,4,-3,2,-3,3,2,1,0,7,4],"Serie1")
|
7
|
+
p.add_point([3,3,-4,1,-2,2,1,0,-1,6,3],"Serie2")
|
8
|
+
p.add_point([4,1,2,-1,-4,-2,3,2,1,2,2],"Serie3")
|
9
|
+
p.add_all_series()
|
10
|
+
p.set_abscise_label_serie
|
11
|
+
p.set_serie_name("January","Serie1")
|
12
|
+
p.set_serie_name("February","Serie2")
|
13
|
+
p.set_serie_name("March","Serie3")
|
14
|
+
ch = Rchart.new(700,230)
|
15
|
+
|
16
|
+
ch.set_font_properties("tahoma.ttf",8)
|
17
|
+
ch.set_graph_area(50,30,680,200)
|
18
|
+
ch.draw_filled_rounded_rectangle(7,7,693,223,5,240,240,240)
|
19
|
+
ch.draw_rounded_rectangle(5,5,695,225,5,230,230,230)
|
20
|
+
ch.draw_graph_area(255,255,255,true)
|
21
|
+
ch.draw_scale(p.get_data,p.get_data_description,Rchart::SCALE_NORMAL,150,150,150,true,0,2,true)
|
22
|
+
ch.draw_grid(4,true,230,230,230,50)
|
23
|
+
ch.set_font_properties("tahoma.ttf",6)
|
24
|
+
ch.draw_treshold(0,143,55,72,true,true)
|
25
|
+
|
26
|
+
#Bar Graph
|
27
|
+
ch.draw_bar_graph(p.get_data,p.get_data_description)
|
28
|
+
|
29
|
+
ch.set_font_properties("tahoma.ttf",8)
|
30
|
+
ch.draw_legend(596,150,p.get_data_description,255,255,255)
|
31
|
+
ch.set_font_properties("tahoma.ttf",10)
|
32
|
+
ch.draw_title(50,22,"Example 9",50,50,50,585)
|
33
|
+
ch.render_png("example9")
|