SmartLabels
SmartLabels provides intelligent label management for axis values, automatically adjusting label visibility, rotation, and spacing to prevent overlapping and improve chart readability.
Properties
| Property name | Description |
|---|---|
| Enabled | When set to True, enables smart label management. The chart will automatically manage label visibility and positioning based on available space. Default: False. |
| AutoRotate | When set to True, labels may be automatically rotated to fit within the available space when there isn't enough room to display them horizontally. Default: True. |
| MinLabelSpacing | The minimum spacing (in pixels) required between adjacent labels. Labels that would appear closer than this distance may be hidden. Default: 5. |
| MinLabels | The minimum number of labels that should always be displayed, even if spacing constraints would normally hide them. Default: 2. |
| MaxLabels | The maximum number of labels to display. When set to 0, there is no maximum limit. Default: 0. |
Usage
SmartLabels is particularly useful when: - Displaying charts with many data points where labels would normally overlap - Creating responsive charts that need to adapt to different container sizes - Presenting date/time data where labels may vary in length
Example
var
s: TTMSFNCChartSerie;
begin
TMSFNCChart1.BeginUpdate;
TMSFNCChart1.Clear;
s := TMSFNCChart1.Series.Add;
s.Mode := smStatistical;
// Enable SmartLabels for x-axis
s.XValues.SmartLabels.Enabled := True;
s.XValues.SmartLabels.MinLabelSpacing := 10;
s.XValues.SmartLabels.AutoRotate := True;
// Enable SmartLabels for y-axis
s.YValues.SmartLabels.Enabled := True;
s.YValues.SmartLabels.MinLabels := 3;
s.YValues.SmartLabels.MaxLabels := 10;
TMSFNCChart1.EndUpdate;
end;
Notes
- SmartLabels works independently for the x-axis and y-axis, allowing different configurations for each
- When
EnabledisFalse, all labels are displayed using standard positioning - The
AutoRotatefeature only affects labels when there isn't sufficient horizontal space