perry3819 Posted May 9, 2007 Report Share Posted May 9, 2007 After reading the docs and searching this forum, it doesn't look like one can select a range of X values. Is this true? As an example, say that I have an X axis with values ranging from 0 to 10 on a line chart. I would like to: Click '2' and drag the mouse to '7'. I would like some visual feedback that '2' through ''7' are selected. I would like to register an event listener that is called with the selected range.. If this is not possible, as a workaround my customer may be OK with zooming in on the values as a way of selecting them. For instance, just '2' through '7' would be displayed on the chart. However, I do not see a way to find out what X values are currently being displayed. How is this done? Thanks, Perry Link to comment Share on other sites More sharing options...
Frank Posted May 10, 2007 Report Share Posted May 10, 2007 1) The UI you describe is not built-in into Chart FX, however you can implement it capturing the appropriate mouse events. All the API to translate from pixels to logical value (Axis.PixelToValue) and from logical value to pixel (Axis.ValueToPixel) exists. 2) The UserZooming event is fired when a zoom is about to occur. You receive the x,y coordinates for the start andend of the dragging rectangle. You can chose to handle this event yourself (set e.Handled = true) or let Chart FX do it. 3) You can, at any time after the chart is drawn, ask for the current range by calling Axis.GetScrollView Link to comment Share on other sites More sharing options...
perry3819 Posted May 10, 2007 Author Report Share Posted May 10, 2007 Thanks for the reply Frank! One further question: is there a way to provide visual feedback that a range is selected? Something like highlighting the X coordinates? Link to comment Share on other sites More sharing options...
Frank Posted May 11, 2007 Report Share Posted May 11, 2007 As the mouse is moved you can trap this event and change any attributes of the chart you want, for instance, you can create an axis section that changes the color of the labels and has a background color to indicate the range. For example: private AxisSection m_draggingSection; On Mouse Down: if (m_wantToSelect) { double x = chart1.AxisX.PixelToValue(e.X); m_draggingSection = new AxisSection(x,x,Color.Red); m_draggingSection.FontStyle = FontStyle.Bold; chart1.AxisX.Sections.Add(m_draggingSection);} On MouseMove: if (m_draggingSection != null) { double x = chart1.AxisX.PixelToValue(e.X); x = Math.Max(x,m_draggingSection.From); m_draggingSection.To = x; } On MouseUp: if (m_draggingSection != null) { chart1.AxisX.Sections.Remove(m_draggingSection); m_draggingSection = null; } Link to comment Share on other sites More sharing options...
perry3819 Posted May 12, 2007 Author Report Share Posted May 12, 2007 Frank: You are providing first class support. Keep up the great work! Thanks, Perry Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.