[This article is published by IUPRG, IUPRG @ Tom.com, www.newsoftstudio.com]
Please keep the source.
Delphi7.0 as an example
Place a dbchart on the form, or the CREATE can be programmed, but the unit must reference DBCHART.
Suppose the DBCHART name is dbchart1
[This article is published by IUPRG, IUPRG @ Tom.com, www.newsoftstudio.com]
Then press the following code (put it in a button event) to dynamically create a bar chart
MySeries: = TBarseries.create (Self); with myseries do begin
Parentchart: = dbchart1; marks.arrowLength: = 20; Marks.visible: = true; datasource: = DATAMODULE1.QRY_TOTAL; // This is a data source Dataset, pay attention: If you are wrong point to DataSource, then
// Graphics only display a record! So you must be Table or AdoQuery SeriesColor: = CLRED; xLabelssource: = 'Name'; // This is the field name that is displayed on the X-axis yvalues.datetime: = false; yvalues.name: = 'Bar'; Yvalues.Multiplier: = 1.00000000000000000000000000000000; Yvalues.order: = lonone; yvalues.valuesource: = 'score; // This is the field name to display on the Y-axis Active: = true; refreshseries; end; dbchart1 .Refreshdata;
When you put mySeries: = TBARSERIES.CREATE (Self); in form.create or show, you can add dbchart1.serieslist.clear in the button event; to ensure that each created Series is re-established according to your own code Can avoid some errors.
===================== [This article is published by IUPRG, IUPRG @ Tom.com, www.newsoftstudio.com]
Other graphs:
TareaseriestbarseriestCircledseriesteriestCustomBarseriestCustomSeriestfastLineSerieStpieseriesteriestPointSeriestSeriespoint
VCL online documentation on Teechart ---- http://www.berneda.com/teechart6docs/
[This article is published by IUPRG, IUPRG @ Tom.com, www.newsoftstudio.com]