Jump to content
Software FX Community

Dragging markers on a date-time axis


crowther
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...