Devin Rader's Blog
I write the code...

Using the Mouse Wheel to zoom in and out of the UltraChart

Tuesday, February 07, 2006 8:01 AM

Heres a small code snippet that demonstrates how to use the MouseWheel event to change the scale of the UltraChart.  As the user scrolls forward or backward, the chart zooms in or out.  Also notice that in order for the chart control to capture the MouseWheel event it has to have Focus, so you can just use the MouseEnter event to give the chart control focus as soon as the mouse enters the control.

private void ultraChart1_MouseWheel(object sender, MouseEventArgs e)
{
    System.Diagnostics.Debug.WriteLine(e.Delta)
;
    if 
(e.Delta<0)
    {
        
if (this.ultraChart1.Axis.X.ScrollScale.Scale<1)
        {
            
this.ultraChart1.Axis.X.ScrollScale.Scale+=.02;
            this
.ultraChart1.Axis.Y.ScrollScale.Scale+=.02;
        
}
        
return;
    
}
    
    
if(e.Delta>0)
    {
        
if (this.ultraChart1.Axis.X.ScrollScale.Scale>0)
        {
            
this.ultraChart1.Axis.X.ScrollScale.Scale-=.02;
            this
.ultraChart1.Axis.Y.ScrollScale.Scale-=.02;
        
}

        
return;
    
}
    
}

private void ultraChart1_MouseEnter(object sender, System.EventArgs e)
{
    
this.ultraChart1.Focus();
}


  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

Hello,
I recommend testing bth properties for being between 0 and one, otherwise youll get an <ClassName id="ref-11">System.ArgumentOutOfRangeException</ClassName>
<Message id="ref-12">The value of this property must be between 0,00 and 1,00.</Message>
if the user zooms in manually in one of the axis.
Have a nice weekend,
Caroline 2/10/2006 8:04 AM | Caroline

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

Excellent point...yes, you definitly should test both Scales. 2/10/2006 8:06 AM | Devin

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

Still another comment:
- if you test for the properties to be >= 0.02 and <= 0.98 you avoid also crashes if the user zoomed manually and differently on the axes.

- in composite charts, you have to set these properties to the Axis elements, like this for example: if(this.ultraChart1.Axis.X.ScrollScale.Visible == true)
{
if (e.Delta<0)
{
if (this.ultraChart1.Axis.X.ScrollScale.Scale <= 0.98)
{ this.ultraChart1.Axis.X.ScrollScale.Scale += .02;
}
this.ultraChart1.InvalidateLayers();
this.ultraChart1.Refresh();
return;
}
The Invalidate() and Refresh() are needed because otherwise the zooming will occur only if you leave the control right after to mouse-wheeling.
Greetings, have fun,
Caroline 2/13/2006 4:52 AM | Caroline

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

Hi Devin ,

Am using Infrgistics NetAdvantage_NET_20073_CLR20 version(Trail Version)
Am unable to find MouseWheel event
1.Do i need at refer for any other dll
2.Do i need to update with latest version

how to generate MouseWheel event please help me out from issue

Thanks in Advance 4/2/2009 5:31 PM | Ravi Kumar

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

Hey Ravi,

Try attaching to the event through code.
I couldn't see the event in the designtime editor myself but it should be available if you try in your code. 4/6/2009 1:50 AM | Kristof

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

Thanks a lot works great! 2/17/2010 4:18 PM | js

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

As a famous designer shoes, Super Cheap Christian Louboutin Shoes no doubt, Louboutin Christianity is the highest exposure.Christian Louboutin Shoes boots As a famous designer shoes .
5/13/2010 4:25 AM | Christian Louboutin 2010

# cheap timberland boots

All things in their being are good for timberland boots sale something.Difficult circumstances serve as a textbook of timberland boots life for people.Failure is the mother of success. -- Thomas Paine.For man is man and master of his timberland 6 inch boots fate.The unexamined life is not worth living. None is of freedom or of mens 6 inch timberland boots life deserving unless he daily conquers it anew. -- Erasmus.Our destiny offers not the cheap timberland boots cup of despair, but the chalice of timberland boots uk opportunity. So let us seize it, not in fear, but in gladness. -- R.M. Nixon.Living without an discount timberland boots aim is like sailing without a timberland womens roll top compass. -- John Ruskin.What makes life dreary is the want of motive. -- George Eliot.Towering genius timberland shoes disdains a beaten path. It seeks regions hitherto unexplored. There is no such timberland womens premium boots thing as a great talent without great will - power.The good seaman is known in bad weather.Gods determine what you're going to womens timberland premium boots be. An aim in life is the only fortune worth finding. -- Robert Louis Stevenson.While there is timberland winter boots life there is hope.Try not to become a man of success but rather try to become a man of value. -- A. Einstein.You have to believe in womens timberland boot yourself. That's the secret of success. -- Charles Chaplin.Pursue your object, be it what it will, steadily and indefatigably.We must accept finite timberland shoes store disappointment, but we must never lose infinite hope. -- Mattin Luther King.Energy and persistence conquer all things. -- Benjamin Franklin.Nothing seek timberland hiking boots , nothing find.Cease to struggle and you cease to live. -- Thomas Carlyle. http://www.timberland4you.co.uk/ YQ7 1/6/2011 9:07 PM | timberland shoes

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

namespace "MouseEventArgs" could not found ,are you missing assembly or reference? 5/19/2011 11:47 PM | latesh

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

what is ultraChart1? please explore it ...
6/25/2011 2:38 AM | tarun

# re: Using the Mouse Wheel to zoom in and out of the UltraChart

Is there a specific namespace that needs to be declared to allow for the MNouseWheel event? I currently have the MouseEnter event but not the MouseWheel event. I am using the following Infragistics namespaces: Infragistics.UltraChart.Shared.Styles, Infragistics.UltraChart.Resources.Appearance, Infragistics.UltraChart.Core.Layers, & Infragistics.Win.UltraWinGrid


6/28/2011 1:38 PM | Ruben

Post a comment