Roadmap Tutorial API's: XYGraph Axes etc Series Stats

TxyGraph Tutorial

  1. Getting Started
  2. Using Series
  3. Getting Data Automatically
  4. Analysing Data
  5. Changing the graph Appearance
  6. Other things you can do with the graph

Getting Data Automatically

Introduction

Series can be set to retrieve data automatically. The series can be set to retrieve information automatically from an internal TDataSource, or from a text file, table, query or a TxyHolder. You can control when this is done and the way the rows are read into the graph. I have restrained from making the series "dataaware" in the normal delphi sense because filling a graph can utilise considerable resources and take some time. Also the methods offered present far more power to the programmer.

In general the same approach is used whatever the source of the data. The first is to choose datasource that becomes the table. If the source is a text file some properties that influence the interpretation of the table need to be set. Then you can choose which rows to read, and then columns and column formats are chosen. Finally, call

    xygraph1[1].refresh

to load the data.

Choosing a data source

This table shows the data sources supported by TxyGraph along with the meaning if the SrcInfo string for each type:

DataSrc SrcInfo
ds_Manual Ignored - data cannot be loaded automatically
ds_TextFile Name of the file
ds_DataSet The name of the tDataSource Component
ds_BDETable Alias:tablename (i.e. DBDemos:Biolife.db)
ds_BDEQuery Alias:SQL (i.e. DBDemos:select * from Biolife)
ds_xyHolder the ID of the TxyHolder Component
ds_ODBC DSN:SQL query

ODBC support requires ODBCExpress. With ds_BDETable and ds_BDEQuery a TTable and a TQuery will be created internally when required.

Text Files

TextFileByWidth - set to false for delimited text files (default) or true for text files with fixed width columns

ColWidth - if TextFileByWidth this is the width of the columns (all columns have to be the same width)

TextSeparators - the characters that delimit the file (note that space is treated specially because multiple spaces are treated as a single delimitor - if you include it in the string) default - comma and tab character

TextMarkers - default ' and " - these wrap string cells

Most files are OK with the defaults

Row Choice

HeaderCount - the number of rows in the table considered to represent header rows. this defaults to 0 for non-text files and 1 for text files

RowHitFreq - Row selection - 1 rows are skipped for every row read (1 = read every row)

RowChoice Action
rc_all all rows will be read
rc_starttoall any rows where RowStart <= xvalue will be read
rc_alltoend any rows where xvalue <= RowFinish will be read
rc_starttoend any rows where RowStart <= xvalue <= RowFinish will be read
rc_firstXNum The first RowStart rows will be read
rc_lastXNum The last RowFinish rows will be read
   

Note that the selective row choice assumes that the table is sorted on the x column. Data can still be read if the x column is not sorted but these screening approaches will not work.

Some of these row choice selections are not possible with some non-live SQL result sets.

Columns

Columns are named by either fieldname or the name in the first row of the table for text files. If no name is found then '(Col X)' will be used instead. You can use '(Col X)' even if a column name is available

XDataCol, YDataCol name of the column

XFormat, YFormat:TTxtFieldtype If the datasource is a text type and either column consists of dates you need to set this here so that the values will be read correctly.