Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 698

Summary: axis increment strange when really smaller than the axis range
Product: VCL TeeChart Reporter: yeray alonso <yeray>
Component: AxisAssignee: yeray alonso <yeray>
Status: RESOLVED FIXED    
Severity: enhancement CC: wayneenterprise
Priority: ---    
Version: 140220   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
URL: http://www.teechart.net/support/viewtopic.php?f=3&t=14832
Chart Series: --- Delphi / C++ Builder RAD IDE Version:
Attachments: axis increments

Description yeray alonso 2014-04-04 09:34:44 EDT
Created attachment 150 [details]
axis increments

Axis increment strange when really smaller than the axis range.

Look at the application attached.
With the actual sources, in a Large Data Range, if you set:
- 0.1 increment for the bottom axis, you get 0.8 increments (labels at 0, 0.8, 1.6,...)
- 0.01 increment for the bottom axis, you get 0.64 increments (labels at 0, 0.64, 1.28,...)
- 0.001 increment for the bottom axis, you get 1.024 increments (labels at 0, 1.1024, 2.048,...)

Is that the expected result? It looks strange.

In v2013.08, the same application shows 0.5 increments (labels at 0, 0.5, 1,...) in the bottom axis when you set either 0.1, 0.01 or 0.001 increments.
Comment 1 Bruce 2022-12-19 04:33:22 EST
Still an actual bug.
Comment 2 Bruce 2022-12-19 04:40:15 EST
Tried to set an axis increment to avoid duplicate labels when zooming too much, but this setting doesn't work properly, just added another problem.
Comment 3 yeray alonso 2023-01-10 03:45:21 EST
The `TChartAxis.CalcLabelsIncrement` function calculates the final increment considering the `Increment` property, the axis range, etc. It was doing multiple attempts in a *2 basis which wasn't accurate enough for some situations. We've changed it for a *0.2 basis.

Also note you can use `OnBeforeDrawAxes` event to manually set the axis `Increment` considering the actual axis range. Ie:

```
procedure TForm1.Chart1BeforeDrawAxes(Sender: TObject);
begin
  if (Chart1.Axes.Bottom.Maximum - Chart1.Axes.Bottom.Minimum) < 0.02 then
    Chart1.Axes.Bottom.Increment := 0.001
  else if (Chart1.Axes.Bottom.Maximum - Chart1.Axes.Bottom.Minimum) < 0.2 then
    Chart1.Axes.Bottom.Increment := 0.01
  else if (Chart1.Axes.Bottom.Maximum - Chart1.Axes.Bottom.Minimum) < 2 then
    Chart1.Axes.Bottom.Increment := 0.1;
end;
```
Comment 4 Bruce 2023-01-10 10:40:15 EST
The proposed workaround solves the problem of duplicates, but it also breaks the increment in the way you described it above in 2014. In my project I get axis increments 0, 8.192, 16.384, 24.576, ... instead of 0, 10, 20, ... when I don't use suggested code snippet.
Comment 5 yeray alonso 2023-01-11 04:44:26 EST
Indeed it doesn't work as it did in v2013.08, but I think it's more coherent now.
If you set an increment of 0.001, it makes sense that 0.477 is tested before testing 0.5.
Comment 6 Bruce 2023-01-11 09:28:48 EST
(In reply to yeray alonso from comment #5)
> Indeed it doesn't work as it did in v2013.08, but I think it's more coherent
> now.
> If you set an increment of 0.001, it makes sense that 0.477 is tested before
> testing 0.5.

So how do you set the increments to always get "nice" labels while avoiding duplicates, as it used to be?