Bar Series


Q: I want to plot all Bars in a Bar Series, no matter if they are outside the Chart. How ?


Set the Bar Series "CalcVisiblePoints" property to False.

When this property is False, the Series will not calculate which bars are inside the Chart and which not.

DELPHI CODE : 

 Series1.CalcVisiblePoints:=False;

CBUILDER CODE : 

 Series1->CalcVisiblePoints=false;

Q: Setting Bar border properties for individual Bar points.

I wanna draw a border in just one point of a Series. If I set the property BarPen to draw a border, all points in the Serie get modifications. For example, I want that all Values major than 1000 get a red border. How can I do this.


You can use the code below, using the OnGetBarStyle event of Bar Series components.

DELPHI CODE : 

procedure TForm1.Series1GetBarStyle(Sender: TCustomBarSeries;
  ValueIndex: Integer; var TheBarStyle: TBarStyle);
begin
  if Sender.YValues[ValueIndex]<1000 then Chart1.Canvas.Pen.Style:=psClear 
  else Chart1.Canvas.Pen.Style:=Sender.BarPen.Style; 
end; 

CBUILDER CODE : 

void __fastcall TForm1::Series1GetBarStyle(TCustomBarSeries *Sender,
      int ValueIndex, TBarStyle &TheBarStyle)
{
  if (Sender->YValues->Value[ValueIndex]<1000)
   Chart1->Canvas->Pen->Style=psClear;
  else
   Chart1->Canvas->Pen->Style=Sender->BarPen->Style;

}

Q: Stacked Bars with negative values do not display correctly


This bug has been fixed in TeeChart Pro 4.0


Q: How do I sort Series in an ascending/descending order?

If you already added points to series and just want to sort them in descending order, add

DELPHI CODE : 

 Series1.Yvalues.Order:=loDescending;

CBUILDER CODE : 

 Series1->YValues->Order=loDescending; 

You can also specify points will be ordered before adding them to series with:

DELPHI CODE : 

 Series1.Yvalues.Sort;

CBUILDER CODE : 

 Series1->YValues->Sort(); 

Q: How can I use Bar series for a histogram?

"I'm using a Bar Series to display a histogram. Bars are centered in the X values and they are at 100% width. How can I change it so it will start at last point and end at next one?"

One way to customize bar "points" is using the AddXY method instead of AddBar. Then you can calculate the desired "X" coordinates where each bar is centered.

 


Q: How can I control the border around the bar ? 

That's quite easy. You can control the border via the BarPen :

Delphi code:

Series1.BarPen.Visible:=true;
Series1.BarPen.Width:=2;


CBuilder code:

Series1->BarPen->Visible=true;
Series1->BarPen->Width:=2;