Hi,
It seems that DrawRectangle gives wrong results. It is easiest seen by changing the angle of the chart title, which does not change the DrawRectangle at all. Another example is changing the y axis title angle from 90 to -90 where the title moves slightly, but also here the DrawRectangle remains unchanged:
Might this be a bug, or is it expected behavior?
DrawRectangle issue
Moderator: Queue Moderators
-
- Posts: 557
- Joined: Mon Mar 14, 2016 9:22 am
Re: DrawRectangle issue
Hi,
Are you talking about Title's DrawRectangle?
I don't believe there is any error, but you could try to proof that I am wrong. For better comparison, I would recommend drawing border around title, e.g. Title.Border.Style = Inner. Now you can do angle change - you should notice that box remains in the same place and only text alignment inside the box changes, which create illusion of movement. Similar with Axis range change: some labels takes more space and relative distance between Title and Axis is increased. But it is only axis drawing which move more to the right, while Title remains in the same place.
Are you talking about Title's DrawRectangle?
I don't believe there is any error, but you could try to proof that I am wrong. For better comparison, I would recommend drawing border around title, e.g. Title.Border.Style = Inner. Now you can do angle change - you should notice that box remains in the same place and only text alignment inside the box changes, which create illusion of movement. Similar with Axis range change: some labels takes more space and relative distance between Title and Axis is increased. But it is only axis drawing which move more to the right, while Title remains in the same place.
-
- Posts: 8
- Joined: Tue Jun 05, 2018 9:28 am
Re: DrawRectangle issue
Chart/ViewXY.XAxes/ViewXY.YAxes Title's DrawRectangle.
Here is a quick example using the demo app:
Chart title with angle of 0:
Chart title with angle of 90:
As you can see the only thing that changes is the DrawRectangle.Y, which seems to be measured from text center. Also take a look at default chart y axis title, which has an angle of 90, DrawRectangle.X = -23 seems wrong (X seems to be what it would have been had the title been rotated back to 0, without adjust acording to DistanceToAxis and with AutoAdjustMargins turned off):
Here is a quick example using the demo app:
Chart title with angle of 0:
Chart title with angle of 90:
As you can see the only thing that changes is the DrawRectangle.Y, which seems to be measured from text center. Also take a look at default chart y axis title, which has an angle of 90, DrawRectangle.X = -23 seems wrong (X seems to be what it would have been had the title been rotated back to 0, without adjust acording to DistanceToAxis and with AutoAdjustMargins turned off):
-
- Posts: 8
- Joined: Tue Jun 05, 2018 9:28 am
Re: DrawRectangle issue
I also see that when drawing a border around the y axis title and rotate it to -90° the text changes location, but the border stays in place and does not properly surround the text anymore:
-
- Posts: 8
- Joined: Tue Jun 05, 2018 9:28 am
Re: DrawRectangle issue
It gets even worse for right aligned y axes:
-
- Posts: 557
- Joined: Mon Mar 14, 2016 9:22 am
Re: DrawRectangle issue
Hi Roger,
Thank you for all the details. There are few separate issues here.
First about DrawRectangle. We did not clarify it before, but it is read only property of intermediate estimate. Note, that it gives accurate results only for Angle=0. Otherwise, reliable only Width, Height and central point. How are you intending to use this rectangle? LightningChart has Title.IsMouseOver() method or MouseOverOn/Off event, which will work just fine.
Second issue with Title's angle being -90 deg. This looks like text placement inside rectangle bug.
All the best.
Thank you for all the details. There are few separate issues here.
First about DrawRectangle. We did not clarify it before, but it is read only property of intermediate estimate. Note, that it gives accurate results only for Angle=0. Otherwise, reliable only Width, Height and central point. How are you intending to use this rectangle? LightningChart has Title.IsMouseOver() method or MouseOverOn/Off event, which will work just fine.
Second issue with Title's angle being -90 deg. This looks like text placement inside rectangle bug.
All the best.
-
- Posts: 8
- Joined: Tue Jun 05, 2018 9:28 am
Re: DrawRectangle issue
I wanted to expand the rectangle returned by GetActiveAxisArea() to also contain the axis title.
-
- Posts: 557
- Joined: Mon Mar 14, 2016 9:22 am
Re: DrawRectangle issue
If you have AutoMargins (_chart.ViewXY.AxisLayout.AutoAdjustMargins = true), then it will be all area from Axis till chart edge. Otherwise, you would need to calculate Title's central point and based on angle estimate the extend of the box.