This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Jason, Is there a way to control the number of labels displayed? I have a chart with lots of points and displaying each label is not feasible. What I want to do is as the use zooms in when it is feasible I would like to turn on the labels. As they zoom out I want to be able to turn off the labels. Second question is: I allow the users to click on a custom axis and drag it up and down. As they are dragging the axis I adjust the max and min values so the axis labels adjust accordingly. However, I am not sure how to calculate the offset for for increasing/decreasing of the max/min values so that the operation appears smooth. |
|
|
Hello Peter For your first question, there currently isn't an option to control the number of labels displayed. I have added a RangeChanged event to the ChartAxis class which will be available in the next nightly build. You can listen to the RangeChanged event of the X axis, check its ActualMinimum and ActualMaximum properties to check the range, then change the ShowDataLabels property on the series as appropriate. For your second question, you can use something like the following in your custom axis:
First listen to mouse down and store the physical mouse position on the axis and also capture the mouse. When the mouse moves, first check that the mouse button is pressed. Next, get the current physical position of the mouse on this axis which can be compared to the previous mouse position. Then there are some calculations that convert the physical mouse movement to the logical axis movement. I then use the built in Pan method which is the best way to update the min/max values. Then update the previous mouse position field ready for the next time the mouse moves. Finally, release the mouse capture when the mouse is released. Let us know how it goes. -Jason |
|
|
Hi Jason, Thanks for the reply. I did something similar yesterday and it works. I will try the new build shortly for the first question. Now I have one more question. The other thing I do with the axis when the user hovers over the custom axis I let them use the mouse wheel to zoom vertically(y axis). How do you I translate the mouse wheel into zoom parameters? Thanks for all the help. Peter |
|
|
Hello Peter For mouse wheel zooming on the axis, you can use something like the following in your custom axis:
Here I get the mouse position and use it to find the ratio of the Y position from the top of the axis. Next I use a hard coded zoom ratio based on which way the mouse wheel is being rotated. By multiplying this zoom ratio with the current axis range, you will get the new range of the axis. Next I increment and decrment the min and max values based on the difference between the old and new axis range. The zooming is centered around the position of the mouse by using the topRatio value. This should get the effect you're after. -Jason |
|
|
Hi Jason, Thanks for the reply. This would not quite work for me. I need to do my calculations from the center of the axis and not from the mouse y position. Is there an easy way to find out the physical location of the center of the axis on the screen? Thanks, Peter |
|
|
Hello Peter To do this, you could use something like the following instead of my previous code example:
Here, rather than calculating the ratio of the mouse position, I am simple incrementing/decrementing the min/max values by half the difference between the old an new range. This zooms vertically from the center of the axis no matter where the mouse is. If you need the physical center of the axis, you can just use ActualHeight / 2.0. Let us know how it goes. -Jason |
|