I am writting a simple application what read a csv file, shows the data into an stringgrid, and plot the values in a chart.
Since the numbers of columns is unknown, i add the series in runtime by counting the humber of columns in the stringgrid. Everything works fine except when the cells are empty.
I know there is an example in TAChart component about to assign "NaN" to that component, and after explore the example and this forum, i still can´t figure out how could i use this information to my case.
This is the procedure i create to read the stringgrid and create lineseries in the Chart:
procedure TMain.PlotData (Table: TstringGrid; Chart: TChart);
var
colnumber: Integer;
rownumber: integer;
ls: Tlineseries;
x: TDateTime;
y: double;
begin
Chart.ClearSeries;
colnumber := Table.ColCount;
rownumber := Table.RowCount;
for i := 0 to colnumber-2 do
begin
ls := Tlineseries.Create(Chart);
chart.addSeries(ls);
ls.Legend.Format := Table.Cells[i+2, 1];
for n := 2 to Rownumber-1 do
begin
x := StrToDateTime(Table.Cells[1, n]);
y := StrToFloat(Table.Cells[i + 2, n]);
ls.AddXY(x, y);
end;
end;
end;
How could i solve this issue? Thanks!