Kelver Merlotti
Kelver Merlotti

Reputation: 33

Delphi TChart Bar Width

I'm trying to figure it out how to set a fixed size to the bars' width in TChart.

I've tried to search a lot for a similar "problem", but I may be using the wrong terms, because I found no related topics in the internet.

My chart has Horizontal Scrolling enabled, so I would like to have bars with the same width regardless how many bars are in the chart.

Here's a sample where I added 10 sample values and, for my purpose, this bar width is acceptable:

10 bars

But when I add 40 sample values, for example, the bars became so thin, even when showing only 10 values and letting all the others visible only after scroll the bars to the left:

more bars

Here's the code I'm using to add the sample values (just for you to see there's nothing special):

procedure TForm5.Button1Click(Sender: TObject);
var
    i: Integer;
begin
    for i := 0 to ChartFatGrupoPerc.SeriesCount-1 do
        ChartFatGrupoPerc.Series[i].FillSampleValues(StrToInt(eItems.Text));
    ChartFatGrupoPerc.BottomAxis.Maximum := StrToInt(eMax.Text);
    ChartFatGrupoPerc.BottomAxis.Minimum := StrToInt(eMin.Text);
end;

So, the question is: Is there an way I can define the bars' width regardless the amount of values?

Thanks in advance,
Kelver Merlotti [KM]

Upvotes: 3

Views: 2010

Answers (1)

LU RD
LU RD

Reputation: 34889

Is there an way I can define the bars' width regardless the amount of values?

Yes, setting these properties would do the trick:

AutoBarSize := false; 
CustomBarWidth := aSuitableNumber;

Upvotes: 4

Related Questions