Stacked bars with neg values still rendered faulty in 3D
-
- Newbie
- Posts: 32
- Joined: Tue Jul 21, 2009 12:00 am
- Location: Nijmegen, Netherlands
Stacked bars with neg values still rendered faulty in 3D
Hi
Recently I updated from Tee7Pro to Tee8Pro. There is still a bug (was already there in Tee5! ) and I have a patch for it, as I have to display bar charts with pos and neg values all the time.
It involves some patches in series.pas and TeEngine.pas.
I can post them here if you want me to. I have been applying these patches from tee5 upto Tee8 and they seem to have no negative impact on the other TChart series. (tested for several years!)
Regards - Hans
Recently I updated from Tee7Pro to Tee8Pro. There is still a bug (was already there in Tee5! ) and I have a patch for it, as I have to display bar charts with pos and neg values all the time.
It involves some patches in series.pas and TeEngine.pas.
I can post them here if you want me to. I have been applying these patches from tee5 upto Tee8 and they seem to have no negative impact on the other TChart series. (tested for several years!)
Regards - Hans
- Attachments
-
- TeeStackedBar.zip
- Contains 2 BMP's and the TXT file generated by the native export
- (17.42 KiB) Downloaded 254 times
Re: Stacked bars with neg values still rendered faulty in 3D
Hi Hans,
Yes it would be very kind if you would provide your changes to us. We'll be pleased to see if we can include them asap.
Yes it would be very kind if you would provide your changes to us. We'll be pleased to see if we can include them asap.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 32
- Joined: Tue Jul 21, 2009 12:00 am
- Location: Nijmegen, Netherlands
Re: Stacked bars with neg values still rendered faulty in 3D
Here are the patches
Code: Select all
Function TBarSeries.DrawSeriesForward(ValueIndex:Integer):Boolean;
begin
Case FMultiBar of
mbNone,
mbSide,
mbSideAll: result:=inherited DrawSeriesForward(ValueIndex);
mbStacked,
mbSelfStack:
begin
{$IFDEF HH_PATCH_TC_STACKED}
result:=not GetVertAxis.Inverted;
{$else}
result:=YValues.Value[ValueIndex]>=YOrigin; { 5.01 }
if GetVertAxis.Inverted then result:=not result;
{$endif}
end;
else
result:=(not GetVertAxis.Inverted);
end;
end;
////////////////////////////////////////////////////////////////
Procedure DrawAllSeriesValue(ValueIndex:Integer);
{$IFDEF HH_PATCH_TC_STACKED}
// These two functions respectively only draw all the positive values and all the negative values
// this allows the Roofs of the barseries to be placed correctly instead of creating M.G.Escher like charts
Procedure TryDrawPosSeries(ASeries:TChartSeries);
begin
With ASeries do
if FActive and (ZOrder=TheSeries.ZOrder) and (ValueIndex<Count) and (MandatoryValueList[ValueIndex]>=0.0) then
DrawValue(ValueIndex)
end;
Procedure TryDrawNegSeries(ASeries:TChartSeries);
begin
With ASeries do
if FActive and (ZOrder=TheSeries.ZOrder) and (ValueIndex<Count) and (MandatoryValueList[ValueIndex]<0.0) then
DrawValue(ValueIndex)
end;
{$ENDIF}
{ If the ASeries parameter has the same "Z" order than the current
series, draw the point }
Procedure TryDrawSeries(ASeries:TChartSeries);
begin
With ASeries do
if FActive and (ZOrder=TheSeries.ZOrder) and (ValueIndex<Count) then
DrawValue(ValueIndex)
end;
var t : Integer;
tmp1 : Integer;
tmp2 : Integer;
Begin
tmp1:=SeriesList.IndexOf(TheSeries);
tmp2:=SeriesCount-1;
{$IFDEF HH_PATCH_TC_STACKED}
// This splits up drawing of series in a negative and a positive phase
// the negative phase is drawn first so the roof tops of negative Bars will
// be overwritten by the bottoms of the positive bars. Also fixes the same
// problem for the area charts
if ValueIndex<TheSeries.Count then
begin
if TheSeries.DrawSeriesForward(ValueIndex) then
begin
for t:=tmp2 downto tmp1 do TryDrawNegSeries(Series[t]);
for t:=tmp1 to tmp2 do TryDrawPosSeries(Series[t]);
end
else
begin
for t:=tmp2 downto tmp1 do TryDrawPosSeries(Series[t]);
for t:=tmp1 to tmp2 do TryDrawNegSeries(Series[t]);
end
end
else
begin
for t:=tmp1 to tmp2 do TryDrawNegSeries(Series[t]);
for t:=tmp1 to tmp2 do TryDrawPosSeries(Series[t]);
end;
{$ELSE}
if ValueIndex<TheSeries.Count then
begin
if TheSeries.DrawSeriesForward(ValueIndex) then
for t:=tmp1 to tmp2 do TryDrawSeries(Series[t])
else
for t:=tmp2 downto tmp1 do TryDrawSeries(Series[t])
end
else for t:=tmp1 to tmp2 do TryDrawSeries(Series[t])
{$endif}
end;
- Attachments
-
- TestTChart.zip
- Small app to display positive and negative stacked bars problem
- (6.08 KiB) Downloaded 300 times
Re: Stacked bars with neg values still rendered faulty in 3D
Hi Hans,
First of all I'd like to thank you very much for your fix suggestions.
I've seen that your code improves the result of the stacked bars but, if I'm right, still not for all the situations. I mean, in your sample application, one could still see some bars not drawn correctly if you don't disable BarSeries1. Am I missing something?
Images explain better than words...
Before any change (I've only added checkboxes to the legend, clicked btTestYears and zoomed a little bit):
We can see many errors.
Note that disabling the first series the result is improved:
Then, after applying your code, the result is better in the first case:
And perfect when disabling the first series:
If I'm not wrong, there still remains something. So, I'll add the issue to the wish list to be revised asap to implement a fix that would solve all situations, if possible.
Of course, you code will help our developers to find the best solution.
First of all I'd like to thank you very much for your fix suggestions.
I've seen that your code improves the result of the stacked bars but, if I'm right, still not for all the situations. I mean, in your sample application, one could still see some bars not drawn correctly if you don't disable BarSeries1. Am I missing something?
Images explain better than words...
Before any change (I've only added checkboxes to the legend, clicked btTestYears and zoomed a little bit):
We can see many errors.
Note that disabling the first series the result is improved:
Then, after applying your code, the result is better in the first case:
And perfect when disabling the first series:
If I'm not wrong, there still remains something. So, I'll add the issue to the wish list to be revised asap to implement a fix that would solve all situations, if possible.
Of course, you code will help our developers to find the best solution.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 32
- Joined: Tue Jul 21, 2009 12:00 am
- Location: Nijmegen, Netherlands
Re: Stacked bars with neg values still rendered faulty in 3D
Yes, it would be very nice if it got fixed. I have been hammering on this since tee4 or tee5 if I remember correctly. For now, as an intermediate patch I suggest you implement my patch "as is". It won't break any code for your customers, and fixes about 100% of my stacked bars trouble .
Regards - Hans
Regards - Hans
-
- Newbie
- Posts: 32
- Joined: Tue Jul 21, 2009 12:00 am
- Location: Nijmegen, Netherlands
Re: Stacked bars with neg values still rendered faulty in 3D
I seem to be unable to reproduce your screenshots. Did you apply both patches?
1 patch in Series.pas:
TBarSeries.DrawSeriesForward
2 patches in TeEngine.pas,
introducing TryDrawPosSeries and TryDrawNegSeries
And the code for calling them from within TryDrawSeries
Regards - Hans
1 patch in Series.pas:
TBarSeries.DrawSeriesForward
2 patches in TeEngine.pas,
introducing TryDrawPosSeries and TryDrawNegSeries
And the code for calling them from within TryDrawSeries
Regards - Hans
Re: Stacked bars with neg values still rendered faulty in 3D
Hi Hans,
Following your suggestions I have:
At Series.pas:
At TeEngine.pas:
And the following code added to your application still shows a bad result:
Following your suggestions I have:
At Series.pas:
Code: Select all
Function TBarSeries.DrawSeriesForward(ValueIndex:Integer):Boolean;
begin
Case FMultiBar of
mbNone,
mbSide,
mbSideAll: result:=inherited DrawSeriesForward(ValueIndex);
else
result:=(not GetVertAxis.Inverted);
end;
end;
Code: Select all
{ Draw one single point (ValueIndex) for all Series }
Procedure DrawAllSeriesValue(ValueIndex:Integer);
{ If the ASeries parameter has the same "Z" order than the current
series, draw the point }
Procedure TryDrawPosSeries(ASeries:TChartSeries);
begin
With ASeries do
if FActive and (ZOrder=TheSeries.ZOrder) and (ValueIndex<Count) and (MandatoryValueList[ValueIndex]>=0.0) then
DrawValue(ValueIndex)
end;
Procedure TryDrawNegSeries(ASeries:TChartSeries);
begin
With ASeries do
if FActive and (ZOrder=TheSeries.ZOrder) and (ValueIndex<Count) and (MandatoryValueList[ValueIndex]<0.0) then
DrawValue(ValueIndex)
end;
var t : Integer;
tmp1 : Integer;
tmp2 : Integer;
Begin
tmp1:=SeriesList.IndexOf(TheSeries);
tmp2:=SeriesCount-1;
// This splits up drawing of series in a negative and a positive phase
// the negative phase is drawn first so the roof tops of negative Bars will
// be overwritten by the bottoms of the positive bars. Also fixes the same
// problem for the area charts
if ValueIndex<TheSeries.Count then
begin
if TheSeries.DrawSeriesForward(ValueIndex) then
begin
for t:=tmp2 downto tmp1 do TryDrawNegSeries(Series[t]);
for t:=tmp1 to tmp2 do TryDrawPosSeries(Series[t]);
end
else
begin
for t:=tmp2 downto tmp1 do TryDrawPosSeries(Series[t]);
for t:=tmp1 to tmp2 do TryDrawNegSeries(Series[t]);
end
end
else
begin
for t:=tmp1 to tmp2 do TryDrawNegSeries(Series[t]);
for t:=tmp1 to tmp2 do TryDrawPosSeries(Series[t]);
end;
end;
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
BarSeries1.Clear;
BarSeries2.Clear;
BarSeries3.Clear;
BarSeries2.Add(-5);
BarSeries3.Add(-5);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 32
- Joined: Tue Jul 21, 2009 12:00 am
- Location: Nijmegen, Netherlands
Re: Stacked bars with neg values still rendered faulty in 3D
Hi
Changing the line
into
in routine DrawAllSeriesValue(ValueIndex:Integer); seems to fix this particular problem, but I am unsure whether this breaks any other code. Down here it looks great, also for your sample.
Regards - Hans
Changing the line
Code: Select all
<snip>
if ValueIndex<TheSeries.Count then
begin
if TheSeries.DrawSeriesForward(ValueIndex) then
begin
for t:=tmp2 downto tmp1 do
TryDrawNegSeries(Series[t]);
<snip>
Code: Select all
<snip>
if True then
begin
if TheSeries.DrawSeriesForward(ValueIndex) then
begin
for t:=tmp2 downto tmp1 do
TryDrawNegSeries(Series[t]);
<snip>
Regards - Hans
Re: Stacked bars with neg values still rendered faulty in 3D
Hi Hans,
Thank you again for our interest on the bug tracking and fixing.
Your code seems to work fine for stacked bars but it brakes the result for mbSide and mbStacked100 with negative values.
I've incremented the issue tracking ticket to be fixed asap (TV52014308). It seems that the appropriate solution should be really near.
Thank you again for our interest on the bug tracking and fixing.
Your code seems to work fine for stacked bars but it brakes the result for mbSide and mbStacked100 with negative values.
I've incremented the issue tracking ticket to be fixed asap (TV52014308). It seems that the appropriate solution should be really near.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |