Plotting on xy graph based on mouse coordinates

I am looking into plotting Mouse coordinates on XY Graph continuously based on where i move. My computer's resolution is 1200x800 and i would like it to plot based on where i move.,
Attached is my progress so far.
Attachments:
progress.png ‏74 KB

The XY Graph has a method which converts coordinates to XY values. You can call it by right clicking the graph and selecting Create>>Invoke Node>>Map Coordinates to XY.
However, if you look at the help for it, you will see that the coordinates it expects are those of the pane the graph is in, and the coordinates you have are of the screen. You can convert your global coords to pane coords by getting the VI's Front Panel Window. Panel Bounds property, building two matching XY clusters from the data and subtracting them (assuming the VI only has one pane) or you can use another loop with an event structure and a Mouse Move event (which returns local data) on the graph and then transfer the position data to your loop (you could also use a single loop, but that might be more complicated because the event structure will process every move of the mouse as a new event).
You will also need to keep the data to place in the graph somewhere. If you open the context help window and hover over the graph's BD terminal, you will see the data types it expects and you will need to build one of those yourself. A shift register is something you might want to look into. There are also some examples showing working with graphs in the example finder (Help>>Find Examples).
Try to take over the world!

Similar Messages

  • Plot number of graph display using mouse

    Dear all,
    I have attach a VI. How can i display the plot number (small label) when i move my mouse on any of the points on the plot? I have tried annotations label before however when i zoom in on the plot, my annotations are clearly out of view. Making annotations for every datapoints are also inefficient.
    There are many plots to be displayed also and the use of colour to identify is quite limited. I have also tried to make the plots visible and invisble however it is also very troublesome if there are many plots.
    I am wondering if there are any ways to distinguish which plots belong to which number when i hover my mouse on the datapoints on any of the plots or any other workround i can do apart from the methods i described above.
    Can anyone help me out on this? Thanks you!
    Attachments:
    Waveform Graph Coords.vi ‏13 KB

    Dear all,
    I have come up with some modifications as attach. Right now i am able to update my annotations as i scroll the mouse along the plot. However i face one problem, when i use the zoom  function on the graph to zoom in onto some window and i try to scroll the mouse again, it always return the plot back to the original view plot (un zoom plot).
    Is there any ways i can modify the plots so that the annotations will remain in the zoomed view without it going back to the original view plot?
    Thank you and hope someone can help me on this.
    Attachments:
    Untitled 1.vi ‏17 KB
    Untitled 1.vi ‏17 KB

  • Moving xy graph cursor with mouse and programmab​ly controllin​g snap to point

    Hi,
    I have run into a bit of a problem. I am trying to create a program which allows a user to select a location on an XY graph by simply clicking in the vacinity of the plot. Most of it is working, however I find that I can't programmably control the snap to point function reliably.
    I hope this is a clear outline of the problem:
    - The cursor starts in a Free state, so that when the
    user clicks in the plot area, I can set the cursor
    position to the nearest point by setting the
    CursorPosition using the graph's property node.
    - Maybe the user didn't like the chosen location and
    wants to drag the cursor over a bit. Ok, user drags
    the cursor to a new position.
    - Now th
    e cursor position is probably not exactly on
    the plot trace. If, at this point, I set the cursor
    to Snap To Point, the cursor does not snap to the
    nearest point on the graph (relative to its current
    position), but instead to the last place a _mouse_
    action placed it.
    - Immediately after the new location has been set,
    the cursor state has to be reset to free in case I
    need to programmably move the cursor again (I
    can't seem to programmably control the mouse in
    any state but Free)
    How do I go about getting the cursor to snap to the closest point at it's new location? I'm at a loss.
    Any insight you might have would be greatly appreciated.
    Thanks much!
    Tere

    So what is the question about... I have to use XY graph in my program. It is used in Loop while cycle. It shows the statistic of a variable. I am using cursors in this graph to check the actual value of a variable in different period of time. But there are 7 variables and it is extremely hard for user to check each value independently. So I tried to make them moving on the X axis (TIME) together using the property node (cursors reading the position (only X axis, Y axis status lock to plot) of the major cursor and follow it... Everything looks great? But it did not work when I am trying to move the major cursor manually on graph... It works only when I am using the cursor movement buttons... But they work very slowly when there is a lot of data in graph.
    I want to find out is it possible to make seven coursers mouthing together By the X axe and be Locked each at its plot by Y axe manually (Using mouse moving on a graph). Is it possible? If it is than how to do it?

  • Looking up the values in a waveform graph with a mouse click

    Hi,
    Does anyone know how to look up the values in a waveform graph with a mouse
    click but... without the cursor legend on, if i press in the waveform graph
    nothing happens, i must search my cursors and only then i can see the values
    of my signal data?! Isn't there any other way?
    Best regards,
    Thijs Boerée

    Dear Chad,
    I know of the function "bring cursor to center". I also figured out that
    when i use a property node of the cursor array of clusters, that i can see
    that some values change when i move the cursor (i can see the X and Y scale
    value change of the graph and also the values of the mouse pointer (in
    points due to screen resolution)) But in this cluster i can't set the mouse
    position. I allready made a VI where i can see the bounds of my
    waveformgraph and I have the Xscale (min and max) and the Yscale (min and
    max), with a linear fit i can translate my mouse position to X an Y scale
    values and when i click on my waveform graph the cursor go's to that
    position (property node of the cursor position), only disadvantage is that i
    only have the bounds of my plot area and not the position, i do have the
    position of my waveform graph but the plot area isn't allways in the center,
    if i could extract the position of the plot area i may find a solution to
    solve this problem.
    And to file a product question:
    I would like to see the function that with a mouse click a little menu
    appears and that there are options to for example set a marker on that data
    and when you right click on it, that there are options to remove it or to
    add comment, a 2D array could make a list of the different channels with
    it's markers (time stamps and comments).
    Best regards,
    And thank you for your help.
    Thijs Boer�e
    "Chad AE" schreef in bericht
    news:[email protected]...
    > Dear Thijs,
    >
    > Thank you for contacting National Instruments.
    >
    > To address your question, there is no direct VI, command, or property
    > node that will allow the cursor snap-to-mouse functionality.
    >
    > I notice a problem you may be occuring is trying to find where the
    > cursor is on the graph. If this is an issue, you can select Bring to
    > Center from the Formatting Ring on the Cursor Legend to move the
    > cursor to the center of the graph.
    >
    > Let me know if you have any further questions or if this does not
    > resolve your issue, as I would be happy to file a product suggestion
    > so that LabVIEW is improved in future versions.
    >
    > Thanks again and have a great day!
    >
    > Chad AE
    > Applications Engineer - National Instruments

  • Creating a graph based on a quadratic equation.

    Hello, I just got my first Mac and iWork 09.
    I'm trying to create a graph in Numbers 09 based on a quadratic equation however I cannot find any way of doing this.
    I just need to some simple graphs based on equations such as y = x^2 + 3x + 5
    How do I make this into a graph in Numbers 09?
    Oh and another question... If I have a graph with points based on X and Y data, can I turn the trend line into an equation?
    Thanks
    Message was edited by: conielo

    To create a scatter chart, you need two columns (or rows) of data, one being X and the other being Y. So, in Column B put the X values you would like plotted. In Column C put your equation to calculate Y for each of those points.
    B2 =1
    B3 =2
    etc
    C2 =B2^23*B25
    then fill down to fill in the rest of the rows in the column.
    I'd recommend a look at the Numbers user's manual if the above doesn't make sense.
    If you have plotted some X-Y data and want the trendline equation, you can turn on a trendline and have it display the equation. You can't use the coefficients from the equation unless you read them off the chart and type them into your table manually. However, you can calculate the trendline yourself in your table. That was covered in some depth in a thread from a little while back. Here's the link to that thread:
    http://discussions.apple.com/thread.jspa?messageID=9015541&#9015541

  • How to let the user define the colors for each plots in the graph (I use LabVIEW 7)?

    How to let the user define the colors for each plots in the graph (I
    use LabVIEW 7)?

    Hi,
    Take a look at this example, it uses property nodes to select tha
    active plot and then changes the color of that plot.
    If you want to make the number of plots dynamic you could use a for
    loop and an array of color boxes.
    I hope this helps.
    Regards,
    Juan Carlos
    N.I.
    Attachments:
    Changing_plot_color.vi ‏38 KB

  • Flash player in firefox is not giving the exact mouse coordinates while running a flex application in firefox. Actually it was working fine in the previous versions. I mean in the ver 5.5. In the latest version its not working fine

    Hi Friends,
    I face some mouse issues with the later versions of the Firefox (6 and above). When a flex application is executed in a Firefox, It runs on the flash player in the browser. While getting the mouse coordinates, flash player is returning some bad coordinates. Please respond to this as soon as possible

    A good place to ask advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.<br />
    See http://forums.mozillazine.org/viewforum.php?f=25

  • Order Graph Based on a different field

    I'm creating a bar graph to track our design work for a specific season.   I want the bar grapsh to have a sort order based on the taskID but display the Ttask Description on the chart.   Here is an example of the data.  RIght now the chart is based on the Task Description so the tasks are sorted in alphabetical order.   The result is the graph shows the tasks in the wrong sequence.
    I appreciate your help solving this issue.
    TaskID  Task Description
    10 Turn over item from Design
    20 Quote product item cost
    30 Order Design Sample
    40 Season Management Review

    Sorry for the delay in responding to your reply.  Let me give a little more background.  We design gift items for specific seasons.  A season may have 50 - 100 designs.  All designs have 7 tasks that management wants to track.  They want a bar chart that shows the description of the tasks on the x axis.   The bar chart shows how many jobs per task are not started, in progress or completed.  This is working as designed.  The only problem is the descriptions of the tasks are in alphabetical order, not the actual sequence in which they occur.    To get the proper sequence there is another field called TaskID.  When I use this field, then the number of the task is dsplayed on the graph, not the description.  
    So, the question is how can I show the bars of the graph based on the TaskID but display the desctription?  THanks for your help.

  • Creating Graph based on runtime conditions

    Hi,
    Right now i am able to create Graphs based on Views. But my requirement is that, if i click on certain component, i should be able to crate another graph at runtime which will display information based on the Clicked Component of original graph.
    Any help will be appreciated.
    Thanks

    Hi,
    I think the options are
    - create a second graph and hide it at runtime
    - create the graph on the fly in a managed bean, wich is quite a bit of code to write, that is justified if the "generated" graph is different (e.g. different model data) for each master selection.
    The first approach should be doable by detecting the selected information on the master graph and the query the detail iterator accordingly + displaying it.
    The second approach is a deep dive into the graph model APIs because you will have to code this all manually. Note that we don't have documentation for this approach yet
    Frank

  • Labeling Variable Number of Plots on a Graph?

    I'm loading up an unknown number of files and graphing them. Since it can get a bit confusing, I'd like to be able to take a portion of the file name and label each plot on my graph. Since there is a variable number of graphs, I can't seem to work around how to wire the property node. There are several other things I'd like to do with the graph, but dont know if its possible or not such as having a label pop up if your cursor is over a plot.

    You are going to have to embed the reference node for the graph into a for-loop like the attached example. File names or portions thereof are built as strings and then added into the property node Plot>>Plot Name.
    I'm not sure about how to get a label to pop up if you are over the plot. You might be able to do it with some cursors and associated code.
    Attachments:
    Graph-Names.vi ‏20 KB

  • Setting the series color of a bi beans graph based on the data values

    How do I conditionally set the series color of a bi beans graph based on the data values?
    I am using the following code to get the data values and set the series color:
    Graph gr=(Graph)CmdrDashboardP1_pres1.getView();
    DataAccess da=gr.getGraphModel().getDataAccess();
    DataDirector dd=gr.getDataDirector();
    DataMap dm=dd.getDataMap();
    int re=dd.ROW_EDGE;
    int ce=dd.COLUMN_EDGE;
    Object val=da.getValue(re,ce,dm.DATA_TYPE);
    int seriesCount=da.getEdgeCurrentSlice(DataDirector.ROW_EDGE);
    if (val <=45.0)
    gr.getSeries().setColor(new Color(255,0,0),seriesCount);
    I get a NullPointerException from the line of code "Object val=da.getValue(re,ce,dm.DATA_TYPE)." I have tried the code with DATA_UNFORMATTED as well, but get the same exception. When I print the DataMap value of dm the results are [dataUnformatted, dataViewFormat, value, dataIsTotal, dataType].
    Also, I get the error "method <= (java.lang.Object,double) not found in class _CmdrDashboardP1" from the "if (val <=45.0)" code.
    Thanks for any assistance

    How do I conditionally set the series color of a bi beans graph based on the data values?
    I am using the following code to get the data values and set the series color:
    Graph gr=(Graph)CmdrDashboardP1_pres1.getView();
    DataAccess da=gr.getGraphModel().getDataAccess();
    DataDirector dd=gr.getDataDirector();
    DataMap dm=dd.getDataMap();
    int re=dd.ROW_EDGE;
    int ce=dd.COLUMN_EDGE;
    Object val=da.getValue(re,ce,dm.DATA_TYPE);
    int seriesCount=da.getEdgeCurrentSlice(DataDirector.ROW_EDGE);
    if (val <=45.0)
    gr.getSeries().setColor(new Color(255,0,0),seriesCount);
    I get a NullPointerException from the line of code "Object val=da.getValue(re,ce,dm.DATA_TYPE)." I have tried the code with DATA_UNFORMATTED as well, but get the same exception. When I print the DataMap value of dm the results are [dataUnformatted, dataViewFormat, value, dataIsTotal, dataType].
    Also, I get the error "method <= (java.lang.Object,double) not found in class _CmdrDashboardP1" from the "if (val <=45.0)" code.
    Thanks for any assistance

  • About get mouse coordinates on screen?

    how to get mouse coordinates in java, i don't look for a appropriate method.

    The MouseEvent which is given to the MouseMotionListener or the MouseListener has one getX() and one getY() method. That are the coordinates in your applicetion window starting with (0,0) in the upper left corner.
    Hope this helps
    Markus

  • Mouse Coordinate issues caused by Scaling Components in a JScrollPane

    Hi All,
    I've been attempting to write a program that includes a simple modeler. However, I've been having some trouble with being able to select components when attempting to implement zoom functionality - when I "zoom" (which is done via scroll wheel) using the scale Graphics2D method, while it zooms correctly, the mouse location of components do not seem scale.
    I've tried one of the solutions found on the forums here (create a custom event queue that adjusts the mouse coordinates) and while it seemed to work initially, if I zoom in and adjust the current view position using the scrollbars, certain components contained in the JPane will become un-selectable and I haven't been able to work out why.
    I've attached a SSCCE that reproduces the problem below - it implements a JScrollPane with a JPane with a few selectable shapes set as the Viewport. The zoom is done using the mouse scroll wheel (with wheel up being zoom in and wheel down being zoom out)
    Any help in order to fix the selection/de-selection issues on zoom would be greatly appreciated! I've spent some time reading through the forums here but have unfortunately not been able to find a workable solution around it.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Tester extends JScrollPane
        public Tester() {
            this.setViewportView(new Model());
        public static void main (String[] args) {
            JFrame main = new JFrame();
            main.add(new Tester());
            main.setSize(500,300);
            main.setResizable(false);
            main.setVisible(true);
    class Model extends JPanel implements MouseListener, MouseWheelListener
        private GfxClass selection = null;
        private static double zoomLevel = 1;
        // zoom methods
        public void setZoom(double zoom) {
            if( zoom < 0 && zoomLevel > 1.0)
                zoomLevel += zoom;
            if( zoom > 0 && zoomLevel < 5.0)
                zoomLevel += zoom;
        public static double getZoom() { return zoomLevel; }
        public void resetZoom() { zoomLevel = 1; }
        public Model() {
            super(null);
            addMouseListener(this);
            addMouseWheelListener(this);
            MyEventQueue meq = new MyEventQueue();
            Toolkit.getDefaultToolkit().getSystemEventQueue().push(meq);
            for(int i = 0; i <7; i++) {
                double angle = Math.toRadians(i * 360 / 7);
                GfxClass oc_tmp = new GfxClass((int)(200 + 150 * Math.cos(angle)), (int)(125 + 100 * Math.sin(angle)), "Element"+i);
                add(oc_tmp);
            repaint();
        public void paint (Graphics g) {
            Graphics2D g2 = (Graphics2D) g.create();
            AffineTransform oldTr=g2.getTransform();
            g2.scale(getZoom(),getZoom());
            super.paint(g2);
            g2.setTransform(oldTr);
            setBackground (Color.white);
            super.paintBorder(g2);
        private static class MyEventQueue extends EventQueue  {
            protected void dispatchEvent(AWTEvent event) {
                AWTEvent event2=event;
                if ( !(event instanceof MouseWheelEvent) && (event instanceof MouseEvent) ) {
                    if ( event.getSource() instanceof Component && event instanceof MouseEvent) {
                        MouseEvent me=(MouseEvent)event2;
                        Component c=(Component)event.getSource();
                        Component cursorComponent=SwingUtilities.getDeepestComponentAt(c, me.getX(), me.getY());
                        JPanel zContainer= getZoomedPanel(cursorComponent);
                        if (zContainer!=null) {
                            int x=me.getX();
                            Point p=SwingUtilities.convertPoint(zContainer,0,0,(Component)event.getSource());
                            int cX=me.getX()-p.x;
                            x=x-cX+(int)(cX/getZoom());
                            int y=me.getY();
                            int cY=me.getY()-p.y;
                            y=y-cY+(int)(cY/getZoom());
                            MouseEvent ze = new MouseEvent(me.getComponent(), me.getID(), me.getWhen(), me.getModifiers(), x, y, me.getClickCount(), me.isPopupTrigger());
                            event2=ze;
                super.dispatchEvent(event2);
        public static JPanel getZoomedPanel(Component c) {
            if (c == null)
                return null;
            else if (c instanceof Model)
                return (Model)c;
            else
                return getZoomedPanel(c.getParent());
        private void deselectAll() {
            if(selection != null)
                selection.setSelected(false);
            selection = null;
        public void mouseClicked(MouseEvent arg0)  {    }
        public void mouseEntered(MouseEvent arg0)  {    }
        public void mouseExited(MouseEvent arg0)   {    }
        public void mouseReleased(MouseEvent arg0) {    }   
        public void mousePressed(MouseEvent me) {
            Component c1 = findComponentAt(me.getX(),me.getY());
            if(c1 instanceof GfxClass)
                if(selection != null)
                    selection.setSelected(false);
                selection = (GfxClass)c1;
                selection.setSelected(true);
            else
                deselectAll();
            repaint();
            return;
        public void mouseWheelMoved(MouseWheelEvent e) { // controls zoom
                int notches = e.getWheelRotation();
                if (notches < 0)
                    setZoom(0.1);
                else
                    setZoom(-0.1);
                this.setSize(new Dimension((int)(500*getZoom()),(int)(300*getZoom())));           
                this.setPreferredSize(new Dimension((int)(500*getZoom()),(int)(300*getZoom())));     
                repaint();
    class GfxClass extends Component { // simple graphical component
        private boolean isSelected = false;
        private String name;
        public GfxClass(int xPos, int yPos, String name) {
            this.name = name;
            this.setLocation(xPos,yPos);
            this.setSize(100,35);
        public void setSelected(boolean b) {
            if( b == isSelected )
                return;
            isSelected = b;
            repaint();
        public boolean isSelected() {
            return isSelected;
        public void paint(Graphics g2) {
            Graphics2D g = (Graphics2D)g2;
            if( isSelected )
                g.setColor(Color.RED);
            else
                g.setColor(Color.BLUE);
            g.fill(new Ellipse2D.Double(0,0,100,35));
            g.setColor(Color.BLACK);
            g.drawString(name, getSize().width/2 - 25, getSize().height/2);
    }Edited by: Kys99 on Feb 22, 2010 9:09 AM
    Edited by: Kys99 on Feb 22, 2010 9:10 AM

    Delete your EventQueue class. Change one line of code in your mouse pressed method.
    public void mousePressed(MouseEvent me) {
        Component c1 = findComponentAt((int) (me.getX()/getZoom()),
                                       (int) (me.getY()/getZoom()));
    }

  • Read from spreadshee​t and plot multiple XY graph

    I'm trying to read a text file using the "Read from Spreadsheet" function. Next I want to plot the data in it on a single XY Graph.
    The text file contains 4 coloums and the first coloumn is X axis and rest are for Y axis. I'm not able to get the multiple plots. 
    However, I could get it to plot when only a single graph is to be plotted(only 2 coloumn in file). I've attached my VI and a picture here.
    I need help in plotting multiple XY graph from the text file with the 4 coloumns.
    Solved!
    Go to Solution.
    Attachments:
    Test_1.vi ‏13 KB

    Here's a more scalable solution, useful if you have one x and many y columns.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    MultiXY.png ‏5 KB
    MultiXY.vi ‏10 KB

  • Problem Plotting a Line Graph

    I am trying to plot some line graphs on Numbers and am a new user.
    I can't seem to work out an issue. I want the numbers on the X axis to ascend from 0 onwards from left to right but at the moment they are descending from 10 to 0 left to right.
    How can I change this so the graph is plotted logically?
    Thanks in advance

    There are two basic types of X-Y charts.  All but one are "category" charts where the X axis is evenly spaced and the "numbers" are actually text. The data will be presented in the order listed in your table.  The other is a scatter chart. The icon for this chart looks like a shotgun blast.
    If your X axis numbers are evenly spaced (0,1,2,3...) you can use either type of chart.  Sort your table in ascending order and it will chart as you want it to.
    If your X axis numbers are not evenly spaced (such as 1,2,4,5,10) and you want the chart to be a true X-Y plot of the data, you have to use the scatter chart.  In contrast to the category charts where the X axis values must be in a header column/row, a scatter chart requires the X and Y data to be in data cells. You may have to move your data over a column so the X data is not in a header column.

Maybe you are looking for