Page 1 of 1

Null data with DBChart

Posted: Fri Nov 03, 2006 4:37 am
by 9344308
I have two questions about TDBChart.

1. Does the DBChart series have and use its own memory buffer?
I have several large my own dataset of which data is in memory.
Therefore if the DBChart series has and uses its own memory buffer, two memory buffer are allocated for the same data, one is for DBChart series and one is for my own dataset. It is inefficient.

2. I have my own dataset class inherited from TDataSet. When I link my own dataset to a DBChart, it works fine. But the null data are drawn on the chart.
When I link the TClientDataset to a DBChart, the null data are not drawn.
I don't know what is wrong with my own dataset class.
My own dataset class work fine with a DBGrid.

Thanks in advance.

Seungho Jung
p.s. I am sorry for my poor english.

Re: Null data with DBChart

Posted: Fri Nov 03, 2006 4:50 pm
by 9344308
Hi,

I have solved the my question no. 2 by myself.
The TDBChart checks the data nullity by using the TField.IsNull method.
I have modified the my own DataSet class to respond correctly to the TField.IsNull method.

And about question no. 1, I think that the DBChart uses its own memory buffer for the chart data. If it is true, it is a problem, because the internal data of my own DataSet class is also memory resident.
That is, two memory buffers are allocated for one data.
So I will modify my program in order to use TChart instead of the TDBChart, and make the TChart.series class to directly access to my data.
Maybe it will take a long time to modify it.

Please share

Posted: Sun Nov 26, 2006 5:40 pm
by 9337383
Hi,
Would you please post your solution to the null here? I have been looking for something like that for a long time. I would really appreciate it.
Thanks!

Re: Please share

Posted: Mon Nov 27, 2006 1:32 pm
by 9344308
Dataset class checks if a field is null by passing a nil buffer.
Tell it is null by passing back a result of False.

Here is an example.


function TMyDataset.GetFieldData(Field: TField; Buffer: Pointer): Boolean;
var RecBuffer: PChar;
...
begin
Result := false;
if not FisOpen then exit; //Check dataset is active

RecBuffer := GetActiveRecordBuffer;
result:=(FRecordCount > 0) and (RecBuffer<>nil);

if result then begin
if < ... check if the field data is null ... > then
result := false
else if (Buffer<>nil) then begin
< ... move the field data to the Buffer ... >
result := true;
end;
end;
end;


I hope this is helpful for you.