Axis labels for rotated series
Original Reporter info from Mantis: wp @wpam
-
Reporter name:
Original Reporter info from Mantis: wp @wpam
- Reporter name:
Description:
In TAChart, series get their data points from so-called chart sources and via TChartDataItem records which contain the x,y values of data points as well as some text for data point labels. When the chart source is assigned to the Marks.Source property of an axis then the axis can be labeled with these data point labels as well.
This works fine for the basic configuration of a horizontal axis. By interchanging the series properties AxisIndexX and AxisIndexY, however, the presentation can be rotated, i.e. x values are plotted along the vertical, y values along the horizontal axis.
In this case the assignment of the data point labels to the axis often does not work any more. The reason is that the axis not knowing anything about the series plotted along it uses the y value of the data point to position the label, but the series has exchanged x and y and plots the data point with its x value on the y axis.
An adapter chart source is required to adjust the chart source with the data to the axis. This can be achieved by a TUserDefinedChartSource which reads the data point source and passes the x/y values in reverse order (as y/x) to the series.
In total this procedure is rather complicated and should be simplified.
Steps to reproduce:
Run attched demo; it shows as stacked bar series with x values 1, 2, 3, ...; the associated y values can be changed by the radiobuttons accordingly. The bars are labeled via their data point records as "A", "B", ... along the horizontal axis.
Click on the checkbox "Rotated" - the bars are rotated by 90°, i.e. x runs vertically, y horizontally. The axis labels are correct in the case "y = 1,2,3...", i.e. when x = y. When switching to y = '2, 4, 6..." or "y = 10, 20, 30...", however, some or all labels are missing - this is because scaling of the y axis is determined by the data plotted along it. Since in the rotated case the original x values are drawn on the y axis, the y axis range is 1..4; but the labels are drawn according to the y value in the data point record, i.e. at y=2, 4, 6 or 10, 20, 30, respectively - this does not match.
When "use adapter source" is checked the labels are not connected directly to the axis but via a userdefined chart source which exchanges x and y. In this case the rotated axes are always labeled correctly.
Mantis conversion info:
- Mantis ID: 35535
- Fixed in revision: r63677 (#bf2c904f)
- Target version: 2.2