procedure TForm1.FormCreate(Sender: TObject);
function MakeRSRect( X, Y, W, H: TRSChartValueType ): TRSRect;
begin
// make a rect which contains Left, Top, Width, Height centered around
// X, Y instead of the usual Left, Top, Right, Bottom
result := RSRect( X-(W/2), Y-(H/2), W, H );
end;
var
Bar: TRSBarChart;
Pie: TRSPieChart;
begin
// fill in Chart in Chart
// make up a bunch of minor centers
// Even better way would be to vary the size of the pie by the size of sales
// but to keep it simple we will make them constant
// Miami, Fla. 25 46 80 12 12:00 noon
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -80.12, 25.46, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Miami, Florida, USA' ).SubChart as TRSPieChart;
Pie.Caption := 'Miami, Florida, USA';
CreateRandomInfo( Pie );
// Los Angeles, Calif. 34 3 118 15 9:00 a.m
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -118.15, 34.3, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Los Angeles, California, USA' ).SubChart as TRSPieChart;
Pie.Caption := 'Los Angeles, California, USA';
CreateRandomInfo( Pie );
// Montreal, Que., Can. 45 30 73 35 12:00 noon
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -73.35, 45.3, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Montreal, Quebec, Canada' ).SubChart as TRSPieChart;
Pie.Caption := 'Montreal, Quebec, Canada';
CreateRandomInfo( Pie );
// Amsterdam, Netherlands 52 22 N 4 53 E 6:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( 4.53, 52.22, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Amsterdam, Netherlands' ).SubChart as TRSPieChart;
Pie.Caption := 'Amsterdam, Netherlands';
CreateRandomInfo( Pie );
// Athens, Greece 37 58 N 23 43 E 7:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( 23.43, 37.58, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Athens, Greece' ).SubChart as TRSPieChart;
Pie.Caption := 'Athens, Greece';
CreateRandomInfo( Pie );
// Berlin, Germany 52 30 N 13 25 E 6:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( 13.25, 52.30, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Berlin, Germany' ).SubChart as TRSPieChart;
Pie.Caption := 'Berlin, Germany';
CreateRandomInfo( Pie );
// Cairo, Egypt 30 2 N 31 21 E 7:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect(31.21 , 30.2, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Cairo, Egypt' ).SubChart as TRSPieChart;
Pie.Caption := 'Cairo, Egypt';
CreateRandomInfo( Pie );
// Hong Kong, China 22 20 N 114 11 E 1:00 a.m.1
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( 114.11, 22.20, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Hong Kong, China' ).SubChart as TRSPieChart;
Pie.Caption := 'Hong Kong, China';
CreateRandomInfo( Pie );
// Jakarta, Indonesia 6 16 S 106 48 E midnight
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( 106.48, -6.16, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Jakarta, Indonesia' ).SubChart as TRSPieChart;
Pie.Caption := 'Jakarta, Indonesia';
CreateRandomInfo( Pie );
// La Paz, Bolivia 16 27 S 68 22 W 1:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -68.22, -16.27, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'La Paz, Bolivia' ).SubChart as TRSPieChart;
Pie.Caption := 'La Paz, Bolivia';
CreateRandomInfo( Pie );
// London, England 51 32 N 0 5 W 5:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -0.5, 51.32, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'London, England' ).SubChart as TRSPieChart;
Pie.Caption := 'London, England';
CreateRandomInfo( Pie );
// Madrid, Spain 40 26 N 3 42 W 6:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -3.42, 40.26, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Madrid, Spain' ).SubChart as TRSPieChart;
Pie.Caption := 'Madrid, Spain';
CreateRandomInfo( Pie );
// Mexico City, Mexico 19 26 N 99 7 W 11:00 a.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -99.7, 19.26, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Mexico City, Mexico' ).SubChart as TRSPieChart;
Pie.Caption := 'Mexico City, Mexico';
CreateRandomInfo( Pie );
// Moscow, Russia 55 45 N 37 36 E 8:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( 37.36, 55.45, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Moscow, Russia' ).SubChart as TRSPieChart;
Pie.Caption := 'Moscow, Russia';
CreateRandomInfo( Pie );
// Santiago, Chile 33 28 S 70 45 W 1:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( -70.45, -33.28, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Santiago, Chile' ).SubChart as TRSPieChart;
Pie.Caption := 'Santiago, Chile';
CreateRandomInfo( Pie );
// Tokyo, Japan 35 40 N 139 45 E 2:00 a.m.1
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect( 139.45, 35.40, SubChartSizeDiv2, SubChartSizeDiv2 ), ss3DRectangle, 'Tokyo, Japan' ).SubChart as TRSPieChart;
Pie.Caption := 'Tokyo, Japan';
CreateRandomInfo( Pie );
// Now, major centers
// New York, N.Y. 40 47 73 58 12:00 noon
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect(-73.58, 40.47, SubChartSize, SubChartSize), ss3DRectangle, 'North America' ).SubChart as TRSPieChart;
Pie.Caption := 'New York, N.Y., USA';
CreateRandomInfo( Pie );
Bar := SalesWorldWide.Values.Add( TRSBarChart, MakeRSRect(-73.58+SubChartSizeDiv2, 40.47+SubChartSizeDiv2, SubChartSize, SubChartSize), ss3DRectangle, '' ).SubChart as TRSBarChart;
Bar.Caption := 'New York, N.Y., USA';
CreateRandomInfo( Bar, Pie );
// Rio de Janeiro, Brazil 22 57 S 43 12 W 2:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect(-43.12, -22.57, SubChartSize, SubChartSize), ss3DRectangle, 'South America' ).SubChart as TRSPieChart;
Pie.Caption := 'Rio de Janeiro, Brazil';
CreateRandomInfo( Pie );
Bar := SalesWorldWide.Values.Add( TRSBarChart, MakeRSRect(-43.12+SubChartSizeDiv2, -22.57+SubChartSizeDiv2, SubChartSize, SubChartSize), ss3DRectangle, '' ).SubChart as TRSBarChart;
Bar.Caption := 'Rio de Janeiro, Brazil';
CreateRandomInfo( Bar, Pie );
// Paris, France 48 48 N 2 SubChartSize E 6:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect(2.20, 48.00, SubChartSize, SubChartSize), ss3DRectangle, 'Europe' ).SubChart as TRSPieChart;
Pie.Caption := 'Paris, France';
CreateRandomInfo( Pie );
Bar := SalesWorldWide.Values.Add( TRSBarChart, MakeRSRect(2.20+SubChartSizeDiv2*1.5, 48.00+SubChartSizeDiv2*0.3, SubChartSize, SubChartSize), ss3DRectangle, '' ).SubChart as TRSBarChart;
Bar.Caption := 'Paris, France';
CreateRandomInfo( Bar, Pie );
// Beijing, China 39 55 N 116 25 E 1:00 a.m.1
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect(116.25, 39.55, SubChartSize, SubChartSize), ss3DRectangle, 'Asia' ).SubChart as TRSPieChart;
Pie.Caption := 'Beijing, China';
CreateRandomInfo( Pie );
Bar := SalesWorldWide.Values.Add( TRSBarChart, MakeRSRect(116.25+SubChartSizeDiv2*1.5, 39.55+SubChartSizeDiv2*0.3, SubChartSize, SubChartSize), ss3DRectangle, '' ).SubChart as TRSBarChart;
Bar.Caption := 'Beijing, China';
CreateRandomInfo( Bar, Pie );
// Johannesburg, South Africa 26 12 S 28 4 E 7:00 p.m.
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect(28.40, -26.12, SubChartSize, SubChartSize), ss3DRectangle, 'Africa' ).SubChart as TRSPieChart;
Pie.Caption := 'Johannesburg, South Africa';
CreateRandomInfo( Pie );
Bar := SalesWorldWide.Values.Add( TRSBarChart, MakeRSRect(28.40+SubChartSizeDiv2*1.5, -26.12+SubChartSizeDiv2*0.3, SubChartSize, SubChartSize), ss3DRectangle, '' ).SubChart as TRSBarChart;
Bar.Caption := 'Johannesburg, South Africa';
CreateRandomInfo( Bar, Pie );
// Perth, Australia 31 57 S 115 52 E 1:00 a.m.1
Pie := SalesWorldWide.Values.Add( TRSPieChart, MakeRSRect(115.52, -31.57, SubChartSize, SubChartSize), ss3DRectangle, 'Australia' ).SubChart as TRSPieChart;
Pie.Caption := 'Perth, Australia';
CreateRandomInfo( Pie );
Bar := SalesWorldWide.Values.Add( TRSBarChart, MakeRSRect(115.52+SubChartSizeDiv2*1.5, -31.57+SubChartSizeDiv2*0.3, SubChartSize, SubChartSize), ss3DRectangle, '' ).SubChart as TRSBarChart;
Bar.Caption := 'Perth, Australia';
CreateRandomInfo( Bar, Pie );
end;
procedure TForm1.CreateRandomInfo(Pie: TRSPieChart);
Var
Strs: TStrings;
begin
Pie.Values.Add(Random(100)+10, 'Retail', clGreen);
Pie.Values.Add(Random(100)+10, 'Consultation', clRed);
Pie.Values.Add(Random(100)+10, 'Government', clYellow);
Pie.Values.Add(Random(100)+10, 'Education', clBlue);
Pie.Values.Add(Random(100)+10, 'Wholesale', clWhite);
Strs := TStringList.Create;
Strs.Add('Regional Office='+Pie.Caption);
Strs.Add('Address='+Addresses[Random(10)]);
Strs.Add('');
Strs.Add('Director='+Names[Random(10)]);
Strs.Add('');
Strs.Add('Num Employees='+IntToStr(Random(1000)));
Strs.Add('Sales Volume='+IntToStr(Random(100000)));
Pie.Tag := Integer(Strs);
end;
procedure TForm1.CreateRandomInfo(Bar: TRSBarChart; Pie: TRSPieChart);
var
Strs: TStrings;
begin
Bar.Values.Add(Random(100), 'Secretarial', clGreen);
Bar.Values.Add(Random(100), 'Engineering', clRed);
Bar.Values.Add(Random(100), 'Marketing', clYellow);
Bar.Values.Add(Random(100)+10, 'Sales', clBlue);
Bar.Values.Add(Random(100)+10, 'Management', clWhite);
Bar.Values.Add(Random(100), 'Research', clWhite);
Strs := TStringList.Create;
Strs.Assign( TStrings(Pie.Tag) );
Bar.Tag := Integer(Strs);
end;
|