Page 1 of 1

Incorrect bar width with TChartScrollBar

Posted: Tue Nov 29, 2016 2:36 pm
by 16478065
Hello
I have set up the following code.

Code: Select all

	TChart * Chart1 = new TChart(this);
	TChartScrollBar *scrollBar = NULL;
	Chart1->Parent = this;
	Chart1->Align = alClient;

	Chart1->AddSeries(new THorizBarSeries(Chart1))->FillSampleValues(20);
	Chart1->LeftAxis->Minimum = 0;
	Chart1->LeftAxis->Maximum = 5;
	Chart1->LeftAxis->Automatic = false;

	scrollBar = new TChartScrollBar(this);
	scrollBar->Parent = this;
	scrollBar->Align = alRight;
	scrollBar->Kind = sbVertical;
	scrollBar->Width = 17;
	scrollBar->Min = 0;
	scrollBar->Max = 100;
	scrollBar->Chart = Chart1;
	scrollBar->RecalcPosition();
When my series is composed of 5 values (FillSampleValues (5)), I get this...
5_items.png
5_items.png (25.94 KiB) Viewed 6315 times
When my series is composed of 100 values (FillSampleValues (100)), I get this...
100_items.png
100_items.png (34.95 KiB) Viewed 6312 times
Since Chart1-> LeftAxis-> Maximum is always 5, I would like that in both cases, my bars have the same width.

In my example, with 100 values, the bars are very small whereas there is ample room to display them. He pretends to put all the bars on a single page.

What should be done ?

Re: Incorrect bar width with TChartScrollBar

Posted: Wed Nov 30, 2016 9:56 am
by yeray
Hello,

Try setting your bar series AutoBarSize property to true:

Code: Select all

  THorizBarSeries *horizBar1 = new THorizBarSeries(Chart1);
  Chart1->AddSeries(horizBar1);
  horizBar1->FillSampleValues(20);
  horizBar1->AutoBarSize=true;

Re: Incorrect bar width with TChartScrollBar

Posted: Wed Nov 30, 2016 2:51 pm
by 16478065
Thanks, this solution works