Null data with DBChart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Seungho Jung
Newbie
Newbie
Posts: 8
Joined: Fri Nov 25, 2005 12:00 am

Null data with DBChart

Post by Seungho Jung » Fri Nov 03, 2006 4:37 am

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.

Seungho Jung
Newbie
Newbie
Posts: 8
Joined: Fri Nov 25, 2005 12:00 am

Re: Null data with DBChart

Post by Seungho Jung » Fri Nov 03, 2006 4:50 pm

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.

kai
Newbie
Newbie
Posts: 21
Joined: Mon May 10, 2004 4:00 am

Please share

Post by kai » Sun Nov 26, 2006 5:40 pm

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!

Seungho Jung
Newbie
Newbie
Posts: 8
Joined: Fri Nov 25, 2005 12:00 am

Re: Please share

Post by Seungho Jung » Mon Nov 27, 2006 1:32 pm

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.

Post Reply