crowther Posted June 3, 2009 Report Share Posted June 3, 2009 Hi, I have a chart with datetimes on the X axis and decimal values on the Y. The X axis is configured as follows: chartA.DataSourceSettings.Style = chartA.DataSourceSettings.Style | DataSourceStyles.DatesAsLabels;chartA.AxisX.DataFormat.Format = AxisFormat.DateTime; chartA.AxisX.LabelsFormat.Format = AxisFormat.DateTime;I want the user to be able to change the values on the graph by dragging the markers. I have set the AllowDrag property to true and the markers can now be moved but they can be moved horizontally as well as vertically (i.e. both the datetime and value can be changed!). Is there anyway of restricting the change to the Y-axis only? Chris. Quote Link to comment Share on other sites More sharing options...
AndreG Posted June 3, 2009 Report Share Posted June 3, 2009 You could change your axis to be categorical instead of numerica. But then every point will be plotted with the same distance between them. So unless your data comes on a fixed period anyways, i can see how that would not work. The other way would be to implement the dragging yourself. You can use the mouse events, then when the click happens in one point you could use the PointToPixel and PixelToPoint methods. That way, using the pixel information you get on the mouse move event you can calculate the point information to pass the marker. Let me know if it makes sense. Quote Link to comment Share on other sites More sharing options...
Frank Posted June 3, 2009 Report Share Posted June 3, 2009 Capturing the ChangedByUser event will allow you to select which changes are allowed and which are not. When dragging a point in an X/Y chart the event will be fired twice, one for the X and one for the Y. You can stop to X-Value change by setting the Handled property to true during this event. Quote Link to comment Share on other sites More sharing options...
crowther Posted June 4, 2009 Author Report Share Posted June 4, 2009 Thanks Frank. That works perfectly. private void chartA_DataChangedByUser(object sender, PointLabelEventArgs e) { if (e.Axis == chartA.AxisX) e.Handled = true; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.