The dynamic three-dimensional pie chart of Delphi Design Image

Source: Internet
Author: User

In the data comparison or presentation, an image of the chart is not only very intuitive, but also very vivid. This example introduces how to design the image of three-dimensional pie chart in Delphi.

Add a Tvtchart component and a TTimer component to the form where the Tvtchart component is used to display the pie chart, and the TTimer component is used to constantly change the data of the pie chart to achieve dynamic effects. The design-finished main interface is shown in Figure 1.

Figure 1 Main interface

The program first joins the math unit in the uses segment, and then adds the Randomize () statement during the initialization of the form, which causes the random number to be restarted each time the program is run, lest the same random number as the previous run.

In order to generate a dynamic pie chart, add the following code to the response process of the TTimer component: Procedure Tform1.timer1timer (Sender:tobject);

begin
 self.VtChart1.Row:=0;
 self.VtChart1.Column:=0;
 self.VtChart1.Data:=FloatToStr(Random(200));
end;

The TTimer component Interval property is set to 1000, that is, every 1000 milliseconds, the program changes the data in the 1th row, column 1th of the pie.

The program code is as follows:

unit Unit1;
interface
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, OleCtrls, VCFI, ExtCtrls, math;
type
 TForm1 = class(TForm)
 VtChart1: TVtChart;
 Timer1: TTimer;
 procedure Timer1Timer(Sender: TObject);
 procedure FormCreate(Sender: TObject);
private
 { Private declarations }
public
 { Public declarations }
end;
var
 Form1: TForm1;
 implementation
 {$R *.dfm}
 procedure TForm1.Timer1Timer(Sender: TObject);
begin
 self.VtChart1.Row:=0;
 self.VtChart1.Column:=0;
 self.VtChart1.Data:=FloatToStr(Random(200));
end;
procedure TForm1.FormCreate(Sender: TObject);
 begin
  Randomize();
 end;
end.

Save the file, and then press the F9 key to run the program. The pie chart changes as the program runs, as shown in Figure 2.

Figure 2 Pie chart in change

The Tvtchart component not only can display pie charts, but also can display many kinds of three-dimensional and two-dimensional graphics, if you can make full use of it, it will add a lot to their program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.