THistogramSeries % Bar Width
THistogramSeries % Bar Width
Hi,
What does this property do? Setting it to 100% produces bars that overlap. The value I need to obtain non-overlapping bars is much less than this, but varies according to the zoom. What does 100% mean? There seems not to be any help for this class. I'm using in TeeChart Pro v2014.12.140923 32-bit VCL in XE7.
Regards
Toreba
What does this property do? Setting it to 100% produces bars that overlap. The value I need to obtain non-overlapping bars is much less than this, but varies according to the zoom. What does 100% mean? There seems not to be any help for this class. I'm using in TeeChart Pro v2014.12.140923 32-bit VCL in XE7.
Regards
Toreba
Re: THistogramSeries % Bar Width
Hello Toreba,
Could you please arrange a simple example project showing us what are you exactly doing?
Thanks in advance.
Could you please arrange a simple example project showing us what are you exactly doing?
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: THistogramSeries % Bar Width
Yeray,
I'm sorry, I was wrong (again). THistogramSeries works fine, and doesn't offer a % bar width property. It is In fact TBarSeries for which the property makes no sense. Do you agree with that?
Regards
Toreba
I'm sorry, I was wrong (again). THistogramSeries works fine, and doesn't offer a % bar width property. It is In fact TBarSeries for which the property makes no sense. Do you agree with that?
Regards
Toreba
Re: THistogramSeries % Bar Width
Hello Toreba,
There are 3 properties with similar names that could be confusing you. From the online docs:
There are 3 properties with similar names that could be confusing you. From the online docs:
TCustomBarSeries.BarWidthPercent wrote:TCustomBarSeries.BarWidthPercent
TCustomBarSeries
property BarWidthPercent: Integer;
Unit
Series
Description
Default Value: 70
The BarWidthPercent property determines the percent of total Bar width used. Setting BarWidthPercent := 100 makes joined Bars. You can control how many Bars appear at same time by using TChart.MaxPointsPerPage property. The BarWidth and BarHeight properties indicate Bar dimensions in pixels.
TBarSeries.BarWidth wrote:TBarSeries.BarWidth
TBarSeries
property BarWidth: Integer;
Unit
Series
Description
Run time and read only. The BarWidth property returns the width of vertical Bars in pixels. Bar widths change at run-time when resizing or zooming the Chart. BarWidth is a read-only property. You can use the CustomBarWidth property to set a fixed pixels Bar width.
Which one doesn't behave as you'd expect?TBarSeries.CustomBarWidth wrote:TBarSeries.CustomBarWidth
TBarSeries
property CustomBarWidth: Integer;
Unit
Series
Description
Default: 0
The CustomBarWidth property determines the fixed Bar width in pixels. You can use the BarWidth property to get the current Bar width in pixels.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: THistogramSeries % Bar Width
Yeray,
I think it's the first of these properties that doesn't work, at least using v2014.12.140923 32-bit in XE7. It's easy to show with a simple demo. Do you need me to provide one?
Regards
Toreba
I think it's the first of these properties that doesn't work, at least using v2014.12.140923 32-bit in XE7. It's easy to show with a simple demo. Do you need me to provide one?
Regards
Toreba
Re: THistogramSeries % Bar Width
Hi toreba,
This is what I get with v2012.14 and the code below:
This is what I get with v2012.14 and the code below:
Code: Select all
uses Series, TeeConst;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Title.Text.Text:=TeeMsg_Version;
Chart1.View3D:=false;
with Chart1.AddSeries(TBarSeries) as TBarSeries do
begin
FillSampleValues();
BarWidthPercent:=100;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: THistogramSeries % Bar Width
Yeray,
Yes, I get the same, but see what happens when you zoom in. The bar width in pixels seems to remain unchanged, so then fills less than 100% of the gap between the adjacent bars either side. When you have a lot of points and zoom in a long way to the detail, the effect is at its worst. That's what I need to correct. Is there a combination of properties that would do that? Or is it a bug?
Regards
Toreba.
Yes, I get the same, but see what happens when you zoom in. The bar width in pixels seems to remain unchanged, so then fills less than 100% of the gap between the adjacent bars either side. When you have a lot of points and zoom in a long way to the detail, the effect is at its worst. That's what I need to correct. Is there a combination of properties that would do that? Or is it a bug?
Regards
Toreba.
Re: THistogramSeries % Bar Width
Hello Toreba,
Adding this, the BarWidthPercent property works better when zooming also:
Adding this, the BarWidthPercent property works better when zooming also:
Code: Select all
AutoBarSize:=true;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: THistogramSeries % Bar Width
We experience a similar problem for TBarSeries where the bar widths are not aligned according to the preset BarWidthPercent when the x-axis is not set to automatic, i.e. does not show all existing values in the series. See the image below.
The settings are:
We achieved this by adding some code to TBarSeries.DoBeforeDrawChart (I omitted some local procedures to make it easier readable):
We would appreciate if this or a similar functionality could be integrated into the standard code to make it available for other users.
Kind regards,
Linus
PS: I also attached a simple demo project containing the example above:
The settings are:
- BarWidthPercent set to 70%
- Bottom Axis with manual Minimum/Maximum, i.e. non-automatic mode. The intention is to display the values with respect to the current time (illustrated by the vertical ColorLineTool), i.e. it is a "moving window" where the axis bounds are frequently updated to focus the current time.
We achieved this by adding some code to TBarSeries.DoBeforeDrawChart (I omitted some local procedures to make it easier readable):
Code: Select all
Procedure TCustomBarSeries.DoBeforeDrawChart;
var t : Integer;
Stop : Boolean;
tmp : Integer;
tmpNonMandatoryAxisRange : Double;
tmpValueStepPerBar: Double;
const cstAutoCalcBarPointsByBarSteps = True;
begin
inherited;
IBarSize:=0;
IOrderPos:=1;
IPreviousCount:=0;
INumBars:=0;
IMaxBarPoints:=TeeAllValues;
Groups:=nil;
Stop:=False;
With ParentChart do
for t:=0 to SeriesCount-1 do
if Series[t].Active then
begin
if SameClass(Series[t]) and SameMandatoryAxis(Series[t]) then
begin
Stop:=Stop or (Series[t]=Self);
tmp:=Series[t].Count;
// ARC ///////////////////////////////////////////////////////////////////
// Calculate "visible" Bar Points based on their "step width" between two bars compared to visible axis range
if cstAutoCalcBarPointsByBarSteps and (NotMandatoryAxis.Automatic=False) then
begin
tmpNonMandatoryAxisRange:=NotMandatoryAxis.Maximum-NotMandatoryAxis.Minimum;
if (tmp>1) and (tmpNonMandatoryAxisRange>0) then
begin
tmpValueStepPerBar:=Series[t].NotMandatoryValueList.Range/(tmp-1); // -1 since we want the step BETWEEN two bars
tmp:=Round(tmpNonMandatoryAxisRange/tmpValueStepPerBar)+1; // +1 since the last bar also requires space
end;
end;
//////////////////////////////////////////////////////////////////////////
if (IMaxBarPoints=TeeAllValues) or (tmp>IMaxBarPoints) then
begin
IMaxBarPoints:=tmp;
if FSideMargins and (tmp>0) then
Inc(IMaxBarPoints);
end;
Case FMultiBar of
mbNone: INumBars:=1;
mbSide,
mbSideAll,
mbSelfStack:
begin
Inc(INumBars);
if not Stop then Inc(IOrderPos);
end;
mbStacked,
mbStacked100: if NewGroup(TCustomBarSeries(Series[t]).FStackGroup) then
begin
Inc(INumBars);
if not Stop then Inc(IOrderPos);
end;
end;
if not Stop then
Inc(IPreviousCount,tmp);
end;
end;
for t:=0 to Length(Groups)-1 do
if Groups[t]=FStackGroup then
begin
IOrderPos:=t+1;
break;
end;
Groups:=nil;
if INumBars=0 then
INumBars:=1;
{ this should be after calculating INumBars }
if FMultiBar=mbSelfStack then
if ParentChart.MaxPointsPerPage=0 then
IMaxBarPoints:=INumBars
else
IMaxBarPoints:=ParentChart.MaxPointsPerPage
else
if ParentChart.MaxPointsPerPage>0 then
IMaxBarPoints:=ParentChart.MaxPointsPerPage;
if (ParentChart.MaxPointsPerPage>0) and FSideMargins and (IMaxBarPoints>0) then
Inc(IMaxBarPoints);
end;
Kind regards,
Linus
PS: I also attached a simple demo project containing the example above:
Re: THistogramSeries % Bar Width
Hello Linus,
That looks useful, thank you for the contribution. We'll run a few checks and include it in the product code.
Thanks again.
Regards,
Marc Meumann
That looks useful, thank you for the contribution. We'll run a few checks and include it in the product code.
Thanks again.
Regards,
Marc Meumann
Steema Support
Re: THistogramSeries % Bar Width
Hello Marc,
thanks for the prompt and positive feedback. Happy to contribute - and after all, we're of course very interested to use the standard code base without having to merge any customisations of ours when installing a TeeChart update ...
Have a nice weekend,
Linus
thanks for the prompt and positive feedback. Happy to contribute - and after all, we're of course very interested to use the standard code base without having to merge any customisations of ours when installing a TeeChart update ...
Have a nice weekend,
Linus