Hi, I'm using the zoom feature of xamDataChart and trying to customize it, please advise:
I would like the zoom to be only on x axis , I've set only horizontal and it is works fine
1. While dragging on the chart to zoom in, I get a dashed-rectangle based on the position I've started the drag until the end position, but I would like to see only X axis being selected and not Y axis. that is, upper and lower lines of the rectangle should always be on top and bottom of the chart - as there is no meaning to selecting part of the y axis in this case.
2. I want to change the label appearance once I zoom. that is, when the zoomed in range is hour, show time by minute, if range is minute, show seconds, etc. I have the event but I could not find how to calculate the viable range for this matter.
Thanks.
Hello eligazit,
Regarding the label appearance when zooming, there are a couple of forum threads that exist currently that address a way that you can dynamically format the XamDataChart axis labels based on the zoom level. I would recommend that you take a look at the following forum threads for more information on this issue:
Thread 1: http://es.infragistics.com/community/forums/t/71107.aspx.
Thread 2: http://es.infragistics.com/community/forums/p/52624/274026.aspx#274026.
Regarding the drag-zoom functionality, the current functionality of the XamDataChart is that the preview rectangle is drawn based on the user's click and drag operation, and it does not take into account the horizontal or vertical zoom-able properties of the chart. You may notice that parts of the chart are shaded when you are dragging, and this is the piece of the chart that takes the orientation of the zoom into account on this matter.
It is possible however, to implement your own preview rectangle zooming functionality to the XamDataChart. To do this, I would recommend handling the PreviewMouseDown, PreviewMouseMove, and PreviewMouseUp events of the chart. You will also need to set the DefaultInteraction property of the XamDataChart to "None" to prevent the default preview rectangle zooming operation in the chart.
In the PreviewMouseDown event, you can draw your rectangle on the RootCanvas of one of your axes based on the mouse position relative to that canvas. Note, that since you are only zooming in the horizontal direction, you only need to worry about the SetLeft of the Canvas for this, as the top will be 0. You can then set the rectangle's Height property to the ActualHeight of that canvas to have this custom preview rectangle show up on the top and bottom of the chart.
In the PreviewMouseMove event, you can check that the rectangle exists in the canvas and that the mouse is down, and modify the dimensions of the rectangle accordingly. Then, in the PreviewMouseUp event, you can determine the dimensions of the rectangle to use for the new WindowRect property of the XamDataChart. For horizontal zooming, this WindowRect's dimensions would look something like the following, where "left" and "right" are the Canvas.GetLeft and the Canvas.GetLeft + rect.Width of the rectangle, respectively:
double leftScale = xAxis.UnscaleValue(left) / (xAxis.ItemsCount - 1);double rightScale = xAxis.UnscaleValue(right) / (xAxis.ItemsCount - 1);
double rectX = leftScale;double rectWidth = (rightScale - leftScale);
chart.WindowRect = new Rect(rectX, 0, rectWidth, 1);
I have attached a sample project that demonstrates the custom zooming functionality. I hope this helps you.
If you would like to see this type of operation formally supported in a future version of the XamDataChart, I would recommend suggesting a new product idea for it at http://ideas.infragistics.com. This product ideas site will place you in direct communication with our product development teams who plan and prioritize upcoming features and products based on community and user feedback.
Please let me know if you have any other questions or concerns on this matter.Sincerely,AndrewAssociate Developer
Hi,
Thanks for the highly detailed answer.
It seems to be rather complicated to implement my own selection rectangle, while loosing the nice shadows on the sides, I would suggest this be a feature built-in, I will create a feature request.
as for the label changes during zoom - the 2nd thread seems to cover what I need - thanks!
Thank you for your update.
I am glad that the second thread covers your needs on this matter.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer