Support Oracle ftNumber type

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Liang
Newbie
Newbie
Posts: 22
Joined: Wed Jul 28, 2010 12:00 am

Support Oracle ftNumber type

Post by Liang » Wed Aug 25, 2010 3:00 pm

Hello

Is it possible for TDBChart to support a DataSet who hold fields in type of ftNumber returned by Oracle?

Currently all these fields are treated as text, so it is not possible to draw series unless I need to manually cast hundreds of ftNumber fields into ftFloat or ftLargeInt.

is there any simple or trick I can play to automatically treat ftNumber type as ftFloat or ftLargeInt?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Support Oracle ftNumber type

Post by Narcís » Fri Aug 27, 2010 1:52 pm

Hi Liang,
Is it possible for TDBChart to support a DataSet who hold fields in type of ftNumber returned by Oracle?

Currently all these fields are treated as text, so it is not possible to draw series unless I need to manually cast hundreds of ftNumber fields into ftFloat or ftLargeInt.
I have added your request to the wish-list to be considered for inclusion in future releases.
is there any simple or trick I can play to automatically treat ftNumber type as ftFloat or ftLargeInt?
The only solution I can think of is manually readying your dataset and populating TeeChart series using existing methods: Add, AddXY, AddArray, etc. Obviously, at some stage you'll have to convert a text type to a numeric type.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Liang
Newbie
Newbie
Posts: 22
Joined: Wed Jul 28, 2010 12:00 am

Re: Support Oracle ftNumber type

Post by Liang » Sun Sep 19, 2010 6:18 am

Hello

I have modified the source code for supporting Oracle NUMBER type as following:

In Chart.pas

Code: Select all

Function TeeFieldType(AType:TFieldType):TTeeFieldType;
begin
  Case AType of
    {$IFDEF CLR}TFieldType.{$ENDIF}ftAutoInc,
    // etc. etc 
  else
    begin
      if Integer(AType)=107 then // this is Oracle Number type, cast to integer. During the implementation, 
      // the Oracle-supporing dataset component will use its own ->AsFloat to convert it to a float type for charting
      begin
        Result:=tftNumber;
      end
      else
        result:=tftNone;
    end
  end;
end;
It works fine. Please kindly check it. I would like to contribute them to you.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Support Oracle ftNumber type

Post by Narcís » Wed Sep 22, 2010 10:00 am

Hello Liang,

As you can see here, TFieldType's maximum value is 51 so it doesn't make much sense to use casting AType to 107. Where did you got that from? Is there any Oracle test database or a trial version we can use to test this here?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Liang
Newbie
Newbie
Posts: 22
Joined: Wed Jul 28, 2010 12:00 am

Re: Support Oracle ftNumber type

Post by Liang » Sat Sep 25, 2010 2:01 am

Hello

I am using Devart's ODAC for Oracle database access.

And they have especially uses 107 to represent OracleNumber type.

So I guess that there may be of some standard on using 107 as Integer number to represent OracleNumber for data inter-changing?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Support Oracle ftNumber type

Post by Narcís » Mon Sep 27, 2010 11:34 am

Hi Liang,

Thanks for the info.

People at Devart already admitted they are doing it the wrong way :)

http://www.devart.com/forums/viewtopic. ... tfieldtype

We don't think we should modify our source for such specific circumstances moreover considering that Deavart may fix this issue.

We have added an internal procedure, as a public variable in DBChart, which you can use to define your own codes, for example:

Code: Select all

procedure MyFieldType(const AType:TFieldType; var TeeType:TTeeFieldType);
begin
  if Ord(AType)=107 then TeeType:=tftNumber;
end;

...
TeeOnGetFieldType:=MyFieldType;
...
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Liang
Newbie
Newbie
Posts: 22
Joined: Wed Jul 28, 2010 12:00 am

Re: Support Oracle ftNumber type

Post by Liang » Tue Sep 28, 2010 7:17 am

Hello

If I understand it correctly, your mentioned "variable" is an event procedure, which will be fired on Checking the fieldType?

If so, would you please kindly directly declare it as an event:

OnGetFieldType=procedure(const ASource:TComponent; const AType:TFieldType;var TeeType:TTeeFieldType) of object;

So user can just click the event and put his own code in for overridding the result?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Support Oracle ftNumber type

Post by Narcís » Tue Sep 28, 2010 9:04 am

Hello Liang,

What you request is only used in the editors and is global for all TDBChart and TDBTree successors. We think it's too specific for being an event, we think an event should be used for notifying rather than for "collect" variables. Moreover, this is only necessary to be able to deal with Devart's implementation which omitted standard TFieldType.

You could create your own chart class inheriting from TDBChart and implementing it as you wish. Object oriented programming essence is overriding objects!
So user can just click the event and put his own code in for overridding the result?
Does this mean you are exposing TeeChart API to your end-users? If so please contact our Sales Dept. at sales at steema dot com explaining your applications nature.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Liang
Newbie
Newbie
Posts: 22
Joined: Wed Jul 28, 2010 12:00 am

Re: Support Oracle ftNumber type

Post by Liang » Wed Sep 29, 2010 2:00 am

Hello

I do not suggest Oracle support only in the editors but a general support.

Considering the fact that 107 is DevArt's specific, maybe other Oracle component has other value, so for a wider range support, regardless what actual Oracle component user is using, I think expose this event out is more user friendly for easier handling as following

1. User clicked the event
2. And override the result based on his specific Oracle-supported components as

Code: Select all

void __fastcall TFrorm1::DBChart1OnGetFieldType(TObject *Sender,TComponent *ASource, TFieldType *AType, TTeeFieldType &TeeType)
{
   if ((Integer)AType==[107 or other value, which is whatsoever component's specific to represents its Oracle Number type])
  {
    TeeType=tftNumber; //<--- user override result here
  };
}
So, I am not request to expose TeeChart API out to end-user, but would rather have this event expose to software developers.

Your suggest to use a global variable of course also works, but coding is a little more complicated for a C++ user.
Attachments
pic1.jpg
a new event fired for datatype for user to override
pic1.jpg (35.9 KiB) Viewed 6624 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Support Oracle ftNumber type

Post by Narcís » Wed Sep 29, 2010 9:01 am

Hello Liang,

We think this is just necessary because of a sub-par implementation of one specific component ignoring the standards of the environment it is designed for. If we find that it is necessary in other circumstances we might consider implementing the event. However, probably this is the first similar case we found during the 15 years of life of TeeChart VCL. Moreover Devart team stated they are looking for a solution to the issue so that feature wouldn't be necessary either.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply