Page 1 of 1

How do I know Datasource of a series

Posted: Thu Jan 01, 2004 12:19 pm
by 8440512
How can I get the Datasource of a seies?
I don't want DatasetName.
I think XLabelsSource will get the columnname or FieldName .
but there is no YLabelsSource function.
I want to get X-axis and Y-axis datasource for a series
from the Series Name.
How is this possible?

Posted: Fri Jan 02, 2004 11:16 am
by Marjan
Hi.
How can I get the Datasource of a seies?
By accessing TChartSeries.DataSource property. It can point to other series, table, query, ...
I want to get X-axis and Y-axis datasource for a series from the Series Name.
Not from series name, but rather from XValues.ValueSource and YValues.Valuesource properties. Example

Code: Select all

var XFieldName, YFieldName: String;
XFieldName := Series1.XValues.ValueSource;
YFieldName := Series1.YValues.ValueSource;

How to get dataset X,y axis firld names.

Posted: Sat Jan 03, 2004 11:31 am
by 8440512
But
Series1.XValues.ValueSource;
and
Series1.YValues.ValueSource;

returns the fieldname only when DAtasource is assigned to Dataset in the design time.

If the Datasource is set to random values in the desing time and datasource is assigned as dataset in the runtime, the above functions are not giving the results.
What is the solution.

Posted: Sat Jan 03, 2004 12:14 pm
by Marjan
If the Datasource is set to random values in the desing time and datasource is assigned as dataset in the runtime, the above functions are not giving the results.
Correct. You also have to connect series XValues and Yvalues ValueSource to appropriate dataset fields. This cannot be done automaticaly. Of course, the same goes for design time - you still have to define fields for YValues, XValues and optionally, XLabels. So, when you connect series to dataset at runtime, you must use the following code:

Code: Select all

Series1.XValues.ValueSource := XFieldName;
Series1.YValues.ValueSource := YFieldName;
Series1.DataSource := Table1;
Series1.CheckDataSource;
Naturally, setting only DataSource property will not change ValueSource property - you have to use the code above to connect series Xvalues, YValues, XLabels to appropriate datasource fields.