Overlapping bars

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Numinor
Newbie
Newbie
Posts: 4
Joined: Thu Mar 06, 2014 12:00 am

Overlapping bars

Post by Numinor » Tue Mar 25, 2014 4:04 pm

I have 3 bars per date and the bars overlap. It seems to be by creation order so the older ones are behind the newer ones. How do I eliminate this overlapping behavior?

Thanks

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

Re: Overlapping bars

Post by Yeray » Thu Mar 27, 2014 2:16 pm

Hello,

Please make sure the three bars have the same XValue.
Here it is a simple example doing something similar to what I understood you are doing, and I see no overlapping bars:

Code: Select all

uses Series, DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
    tmpDate: TDateTime;
begin
  Chart1.Axes.Bottom.LabelStyle:=talPointValue;

  for i:=0 to 2 do
    with Chart1.AddSeries(TBarSeries) as TBarSeries do
    begin
      XValues.DateTime:=true;

      for j:=0 to 3 do
      begin
        tmpDate:=IncDay(Today, j);
        AddXY(tmpDate, 25+random*75);
      end;
    end;
end;
If you still find problems with it, please arrange a simple example project we can run as-is to reproduce the problem here.
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

Numinor
Newbie
Newbie
Posts: 4
Joined: Thu Mar 06, 2014 12:00 am

Re: Overlapping bars

Post by Numinor » Thu Mar 27, 2014 3:17 pm

Here's the full code-

Code: Select all

procedure TfrmPsrGraph.SetupGraph(const v1,v2,v3:shortstring);
var
  xBar1,xBar2,xBar3:TBarSeries;
  xLine1,xLine2,xLine3:TLineSeries;
  xTrend:TTrendFunction;
  i:integer;
  m, b: Double;
begin
  xTrend:=TTrendFunction.Create(self);

  for i := chtPSR.SeriesCount -1 downto 0 do
     chtPSR.Series[i].Free;

  CalcScrapPercent;

//  chtPSR.Axes.Bottom.LabelStyle:=talPointValue;  //only show dates with data

  xBar3:=TBarSeries.Create(chtPSR);
  xBar3.ParentChart:=chtPSR;
  xBar3.DataSource:=fPSRTable;
  xBar3.YValues.ValueSource:=v3;
  xBar3.XValues.ValueSource:='psrdate';
  xBar3.XValues.DateTime:=true;
  xBar3.ShowInLegend:=false;
  xBar3.Marks.Visible:=false;
  xBar3.color:=clAqua;
  xBar3.RefreshSeries;
  xBar3.Title:='s3 ';
  xBar3.ShowInLegend:=true;

  xBar1:=TBarSeries.Create(chtPSR);
  xBar1.ParentChart:=chtPSR;
  xBar1.DataSource:=fPSRTable;
  xBar1.YValues.ValueSource:=v1;
  xBar1.XValues.ValueSource:='psrdate';
  xBar1.XValues.DateTime:=true;
  xBar1.ShowInLegend:=false;
  xBar1.Marks.Visible:=false;
  xBar1.color:=clRed;
  xBar1.RefreshSeries;
  xBar1.Title:='s1 ';
  xBar1.ShowInLegend:=true;

  xBar2:=TBarSeries.Create(chtPSR);
  xBar2.ParentChart:=chtPSR;
  xBar2.DataSource:=fPSRTable;
  xBar2.YValues.ValueSource:=v2;
  xBar2.XValues.ValueSource:='psrdate';
  xBar2.XValues.DateTime:=true;
  xBar2.ShowInLegend:=false;
  xBar2.Marks.Visible:=false;
  xBar2.color:=clGreen;
  xBar2.RefreshSeries;
  xBar2.Title:='s2 ';
  xBar2.ShowInLegend:=true;

  if pos('scrap',v1)>0 then begin
    MakeTitle('SCRAP: ');
    xBar3.Title:='s3 '+formatfloat('0.00%',fScrap.s3);
    xBar1.Title:='s1 '+formatfloat('0.00%',fScrap.s1);
    xBar2.Title:='s2 '+formatfloat('0.00%',fScrap.s2);
  end
  else MakeTitle('PRODUCTION: ');


  if cb3rd.Checked then AddTrend(xBar3,xLine3);
  if cb1st.Checked then AddTrend(xBar1,xLine1);
  if cb2nd.Checked then AddTrend(xBar2,xLine2);

  chtPSR.BottomAxis.ExactDateTime:=true;
  chtPSR.BottomAxis.DateTimeFormat:='m/d';
  chtPSR.BottomAxis.Increment:= DateTimeStep[dtOneDay];

end;
I will email you a screen shot of the overlapping bars if you want. I dont see how to upload images here.

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

Re: Overlapping bars

Post by Yeray » Fri Mar 28, 2014 4:00 pm

Hello,
Numinor wrote:Here's the full code-
This is not the full code. There is a table I don't know (fPSRTable), some unknown variables (v1, v2, v3, fScrap) and some unknown methods (CalcScrapPercent, AddTrend).
Please arrange a simple example project we can run as-is to reproduce the problem here.
See the instructions in my signature.
Numinor wrote:I will email you a screen shot of the overlapping bars if you want. I dont see how to upload images here.
Here you have the instructions to attach a file in phpbb forums. It's quite straightforward. While you are writting a reply or a new message, if you scroll down you'll find the "Upload attachment" tab. You click on the "Browse..." button, you select your file and you click the "Add the file" button.
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