Hi
I have a dinamic Array of TQuery
Each index of the array contain a TQuery that is used to supply data to a
TLineSeries.
My problem is... no data is getting extracted and the Chart display an empty
graph.
If i use a standars TQuery or one that i create manually but not WITHIN an
array the data is being transfert.
Am i doing something wrong here or is it just the TDbChart that cant support
this..
Here part of the code if it can help someone:
----------------------
Procedure AddNewSerie(Sender: TComponent; var Chart: TDBChart; var Dataset:
TQuery; XValues, YValues, SerieTitle: String);
Var
NewSerie: TChartSeries;
Begin
// Cration d'un nouveau set de courbe. TLineSeries est le choix par
dfaut pour l'instant
NewSerie := TLineSeries.Create(Sender);
// ParentChart indique quelle Chart la courbe est associ
NewSerie.ParentChart := Chart;
// Le Datasource indique o l'information est rcuprer
NewSerie.DataSource := Dataset;
// Indique quelle champ est utilis pour fournir l'informatin des X
NewSerie.XLabelsSource := XValues;
// Indique quelle champ est utilis pour fournir l'informatin des X
NewSerie.YValues.ValueSource := YValues;
// Quelle nom portera la courbe (i.e. dans la lgende)
NewSerie.Title := SerieTitle;
End;
----------------------
ArraySize := 0;
// Maintenant que toutes les structures sont prtes, on peut
commencer
// reconstruire
// On se positionne au dbut de la table tblSensorDef qui contient
les
// sensors afficher.
tblSensorsdef.First;
// On boucle tant qu'il y des enregistrements disponibles
While Not tblSensorsdef.Eof Do
Begin
// On doit crer une nouvelle instance de TQuery pour cette
courbe
// On incrmente l'indice
Inc(ArraySize);
// On Agrandi le vecteur
ReAllocMem(SqlArray, SizeOf(TQuery) * ArraySize);
// On crer un TQuery dans l'espace nouvellement crer
SqlArray[ArraySize - 1] := TQuery.Create(Self);
// Maintenant que le TQuery est prt, on insre le code SQL
PrepareSQL(SqlArray[ArraySize - 1], TableDatabaseName,
tblSensorsdefVirtualAddr.AsInteger);
// Courbe Minimum
If tblSensorsdefMinimum.AsBoolean Then
Begin
AddNewSerie(frmMain, frmMain.GraphChart,
SqlArray[ArraySize - 1], 'Heures', 'MinimumValue', 'Capteur ' +
tblSensorsdefVirtualAddr.AsString + ', Min.');
AddInLCB(frmMain.lcbActiveCurves, 'Capteur ' +
tblSensorsdefVirtualAddr.AsString + ', Min.');
SqlArray[ArraySize - 1].Open;
End;
// Courbe Moyenne
If tblSensorsdefMoyenne.AsBoolean Then
Begin
AddNewSerie(frmMain, frmMain.GraphChart,
SqlArray[ArraySize - 1], 'Heures', 'AverageValue', 'Capteur ' +
tblSensorsdefVirtualAddr.AsString + ', Moy.');
AddInLCB(frmMain.lcbActiveCurves, 'Capteur ' +
tblSensorsdefVirtualAddr.AsString + ', Moy.');
SqlArray[ArraySize - 1].Open;
End;
// Courbe Maximum
If tblSensorsdefMaximum.AsBoolean Then
Begin
AddNewSerie(frmMain, frmMain.GraphChart,
SqlArray[ArraySize - 1], 'Heures', 'MaximumValue', 'Capteur ' +
tblSensorsdefVirtualAddr.AsString + ', Max.');
AddInLCB(frmMain.lcbActiveCurves, 'Capteur ' +
tblSensorsdefVirtualAddr.AsString + ', Max.');
SqlArray[ArraySize - 1].Open;
End;
tblSensorsdef.Next; // Enregistrement suivant
End;
// On Transfert les option du ChartBuilder au Graphique
frmMain.edGraphTitle.Text := edChartTitle.Text; // Titre du
graphique
frmMain.edXTitle.Text := edXTitle.Text; // Titre de
l'axe des X
frmMain.edYTitle.Text := edYTitle.Text; // Titre de
l'axe des Y
frmMain.cbStartDate.Checked := cbStartDate.Checked;
frmMain.dtStartDate.Date := dtStartDate.Date;
frmMain.dtStartTime.Time := dtStartTime.Time;
frmMain.cbStopDate.Checked := cbStopDate.Checked;
frmMain.dtStopDate.Date := dtStopDate.Date;
frmMain.dtStopTime.Time := dtStopTime.Time;
ApplyRange;
Close; // On ferme le ChartBuilder;
End;
hope someone can help
Mike
--
Nature limits what we can DO
Science limits what we can UNDERSTAND
Theorie what we can THINK
and Religion what we can HOPE