[Bug]TDBCrossTabSource manipulates for 0 instead of NULL

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
easyblue
Newbie
Newbie
Posts: 10
Joined: Wed Jan 04, 2012 12:00 am

[Bug]TDBCrossTabSource manipulates for 0 instead of NULL

Post by easyblue » Wed Mar 14, 2012 6:11 am

Hello

Image a following table be manipulated by TDBCrossTabSource:

//---- Table Data----------
Year |Region |Sales
2000 |East | 1000
2000 |West |1500
2001 |East |1200
2002 |East |1700
2002 |West |2300


//------ TDBCrossTabSource settings---------
Group on "Region" to sum the "sales" with Label on "Year"

The for the series for region "West", it will have a 0 value on year 2001 instead of a NULL value, which is wrong. Since region "west" has no data on "year" 2001, it should skip it, or adding a NULL value instead of a 0 value.

Please kindly review and correct it.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: [Bug]TDBCrossTabSource manipulates for 0 instead of NULL

Post by Yeray » Wed Mar 14, 2012 12:30 pm

Hi,

This was addressed here in the past:
http://www.teechart.net/support/viewtop ... ll*#p42614
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

easyblue
Newbie
Newbie
Posts: 10
Joined: Wed Jan 04, 2012 12:00 am

Re: [Bug]TDBCrossTabSource manipulates for 0 instead of NULL

Post by easyblue » Thu Mar 15, 2012 1:00 am

Hi

It is a different case.

In my case, there is no record at all for region west in year 2001 in dataset, not a 0, or a NULL value. But when use DBCrossTabSource, a 0 value is assigned, which make the display wrong.

So in my case, more accurately, when DBCrossTabSource manipulates value for series "west", it should skip year 2001, or calling AddNULL for year 2001, not like currently adding a 0 value for year 2001.

Actually after two days try, I managed to achieve it by modify TeeDBCrossTab.pas, starting line 305

Code: Select all

            if tmpPoint=-1 then
            begin
              tmpSeries.Add(tmpValue,tmpLabel,clTeeColor);

              with Series.ParentChart do
              for t:=0 to SeriesCount-1 do
              if tmpSeries<>Series[t] then
                 if tmpSeries.Count>Series[t].Count then
                    for tt:=1 to (tmpSeries.Count-Series[t].Count) do
                    begin
                       Series[t].Add(0,tmpLabel);
                    end;
            end
            else
            begin
              With tmpSeries.MandatoryValueList do
              case Formula of
                gfCount,
                gfSum: Value[tmpPoint]:=Value[tmpPoint]+tmpValue;
                end;
              end;
            end;

into

Code: Select all

            if tmpPoint=-1 then
            begin
              tmpSeries.Add(tmpValue,tmpLabel,clTeeColor);

              with Series.ParentChart do
              for t:=0 to SeriesCount-1 do
              if tmpSeries<>Series[t] then
                 if tmpSeries.Count>Series[t].Count then
                    for tt:=1 to (tmpSeries.Count-Series[t].Count) do
                    begin
                       Series[t].AddNull(TmpLabel); // Occupy it with a NULL value
                    end;
            end
            else
            begin
              With tmpSeries.MandatoryValueList do
              case Formula of
                gfCount,
                gfSum:begin
                  Value[tmpPoint]:=Value[tmpPoint]+tmpValue;
                  tmpSeries.ValueColor[tmpPoint]:=clTeeColor;//now this should be a valid value 
                end;
              end;
            end;

easyblue
Newbie
Newbie
Posts: 10
Joined: Wed Jan 04, 2012 12:00 am

Re: [Bug]TDBCrossTabSource manipulates for 0 instead of NULL

Post by easyblue » Fri Mar 16, 2012 2:03 pm

Hello

line 284 should also be change as following in case the series "west" is the master series

Code: Select all

                  for t:=0 to Series.Count-1 do
                      tmpSeries.AddNULL(Series.Labels[t]);

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: [Bug]TDBCrossTabSource manipulates for 0 instead of NULL

Post by Yeray » Fri Mar 16, 2012 3:02 pm

Hi,

Thanks for sharing the proposal. I've added it to the wish list to be investigated for inclusion asap (TV52016090).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply