Topic: Refresh a chart
Hello Dmitry
I'm using chart on a form in a project. All works fine !
In this project I've added a fonction import (from csv)
I also can exporte to csv, txt and html
I'm wondering how to refresh this chart along the data contained in a new file.
(i.e on opening application, the grid displays eight rows and the chart shows eigth points on the graph).
Then i import a new file (csv) with five rows and the chart displays always eight points.
To refresh, I use this code
procedure Form1_Button6_OnClick (Sender: string; var Cancel: boolean); // Bouton Rafraîchir
var Results : TDataSet;
DateValue : Double;
TauxValue : String;
begin
ChartLine.Series[0].Clear;
SQLQuery('SELECT Date_Prise, Taux FROM diabete ORDER BY Date_Prise DESC', Results);
while not Results.Eof do
begin
DateValue := SQLDateTimeToDateTime( Results.FieldByName('Date_Prise').asString );
TauxValue := Results.FieldByName('taux').asString;
if ValidFloat(TauxValue) then ChartLine.Series[0].AddXY(DateValue, StrToFloat(TauxValue));
Results.Next;
end;
end;
Does this procedure allows to refresh datas of the new file imported (csv) ?
For those using Chartline, you can deactivate 3D view with this instruction :
If not Form1.CheckBox1.Checked then
ChartLine.View3D := False (or False)
You also can deactivate display of legends with this instruction :
If not Form1.CheckBox2.Checked then
ChartLine.Legend.Visible := True (of False);
Thanks Dmitry for your answer.
JB