Plot line on CNiGraph3D object

Hi
I am adding some new feature into the existing code that use CNiGraph3D to display data. The data is some amplitude associated with it's location of scan (x and y). The existing code scan data from a whole area, so the graph is filled. But the new feature will scan data from just a path (eg line). So I wonder if there's a way to plot line data on CNiGraph3D object.
For example, I have this sequence of data (represented in x,y,amplitde)
(5,17,3.6)
(6,15,-9.2)
(7,14,4.9)
(6,12,-0.27)
(5,10,-2.45)
I would like to plot this data on CNiGraph3D. The graph is 10 units wide on x axis, and 20 units tall on y axis. And different value of amplitude will be plotted in difference color on Z axis.
creating a matrix of 10x20 and fill the remaing coordinates (aside from those 5 coordinates above) with some constant value (0 or something else), but it's kind of waste of memory (my real code would be so much bigger than 10x20). So I wonder if there's any alternative way to plot this kind of data on CNiGraph3D?
Thanks

The main difficulty is to calculate the X position from the click position. First, you have to find the position in the graph pane. The left position of the pane is obtained by subtracting the width of the Y scale to its left position. Then there are some basic calculations to convert the click relative position to the corresponding X value, using the scale min and max.
The second point is to create a cursor. Use the "Cursor list" attribute, which is an array of all the available cursors properties, and append a new one to the list.
Attached is a simplified version of a tool I developed some times ago with the same goal.
It answers to questions you didn't ask :
- How can I move an existing cursor without creating a new one each time I click on the graph ?
answer : the cursors are only created when you hold down the key while clicking
- How can I remove a cursor ?
answer : hold the key down while clicking close to the cursor you want to delete.
Have a look at the way the closest cursor is detected, by calculating the distance between the click position and the cursors.
Since I still have difficulties with the size of the attached documents, the vi is divided in several subs.
CC
Chilly Charly    (aka CC)
         E-List Master - Kudos glutton - Press the yellow button on the left...        
Attachments:
Graph cursors.vi.zip ‏19 KB

Similar Messages

  • Help needed in plotting Line Graph!!!!!!!!!Pls help!!

    Hi, i need help in plotting a simple line graph showing the x&y axis and has to plot 3 different lines in the same graph.I have written a program and i need to implement this graph in it.Is there any tutorial for plotting line graphs,i mean steps included.
    Please help!

    You describe your need, but not where it originates from.
    Is it a programming assignment? If so, I hope this is not your chosen major, as you will fail because you are a non-resourceful plagarist.
    Do you need to simply graph some data? Use an existing package. There are free ones somewhere.
    What do you mean "i have written a program and i need to implement this graph in it"? If you wrote the program, wouldn't you be done?
    Enjoy programming

  • How do I fix the format of plot lines for an arbitrary number of sets of data plotted on the same x-y graph?

    I have written a VI to control an LCR meter and perform sweep functions. I have two x-y graphs on my front panel (one for each of 2 measured parameters). The VI is designed with a button to take a measurement, plot the data, and then wait for another event (like write data, clear plot, or measure again). The user can take simultaneous measurements and these are plotted on top of the data already there in the same x-y graphs (using an array of clusters with shift registers). There is no limit on how many sets of data can be on the x-y graph. 
    Now, my issue is in formatting the plot lines (color, thickness, marker type). I can fix the first plot line by adjusting the parameters of the x-y graph. However, I also want to control the format of all consecutive plot lines. How can I do this for an arbitrary number of lines? The main thing I want to do is to have all of them show the square marker type (the default is no marker type, just a line). 
    Thanks!

    Hi maximum23,
    You can use properties of plot to format the plot lines. You just have to select Active plot using property and then select color and line width etc..
    You can define color and width etc parameter by asking user or you can just make them default.
    Gaurav k
    CLD Certified !!!!!
    Do not forget to Mark solution and to give Kudo if problem is solved.

  • Scatter plot line width

    First off, I'm using the trial version of iWork '09. So I want to eventually put a chart into keynote to present to my colleagues, however, putting the chart up on a projector requires me to have a thicker plot line. So if I use a scatter plot, my axis' turn out great, but I cannot adjust the line's width. I don't want symbols, I just want a line connecting the points. If I use the line chart instead of the scatter, the x-axis displays "Untitled 1, Untitled 2" as the labels. I can't change them to the corresponding numbers which is annoying. I can change everything else fine: axis line width, font size, etc. Its just eh connecting line I'm having trouble with

    Actually, found a roundabout way to do this. Have to use line chart and in the x-axis label, you have to insert your formula for what cells you want such as Table 1 :: B212:B912 and just set the category counter to only include one label every so many counts. Kind of a pain, but works. However, can't have only the few tickmarks (should be 5 labels and corresponding 5 tickmarks in my case, but I have 5 labels and 700 tickmarks), all are shown instead. It tacks all of the labels individually, but you can choose which ones are shown, but cannot remove tickmarks... Any ideas?
    Message was edited by: chemgoof

  • Disappearing plot line when zoomed

    I am having a problem with my CNiGraph plot line disappearing when the axes min and max are explicitly defined and they are substantially smaller than they would be if the graph were autoscaled.  I am using measurement studio 8.6.1.465 and NiDaqmx 9.0.2 on windows XP.  I am controlling axis scale either by SetAutoScale() or SetMinMax().  My code is rather large, so I am including snippets of what I am doing below.    
    I noticed a thread with a similar problem at:
    http://forums.ni.com/ni/board/message?board.id=232&message.id=3769&query.id=1275984#M3769 
    Please help!  I have tried window invalidation, turning on/off immediate updates to the graph, setting axes visible/invisible, etc.
    -drew 
    Setup code:
            CNiPlot plot = m_pGraph->GetPlots().Add();
            CNiCursor cursor = m_pGraph->GetCursors().Add();
            //cursor.SetSnapMode(CNiCursor:napPointsOnPlot);
            cursor.SetSnapMode(CNiCursor:napNearestPoint);
            cursor.SetVisible(true);
            cursor.SetPointStyle(CNiCursor:ointCross);
            cursor.SetCrosshairStyle(CNiCursor::CrosshairNone);
            cursor.SetColor(CNiColor(255,255,255));
            cursor.SetPlot(plot);
            CNiAxes axes = m_pGraph->GetAxes();
            CNiAxis xAxis, yAxis;
            xAxis = axes.Item(1);
            yAxis = axes.Item(2);
            yAxis.FormatString = ".##e";
            xAxis.FormatString = "hh:nn:ss";
            CNiColor lineColor(m_plotArray[i]->m_lineColor);
            plot.LineColor = lineColor;
            plot.XAxis.GetTicks().SetMajorGrid(true);
            plot.YAxis.GetTicks().SetMajorGrid(true);
            plot.XAxis.GetTicks().SetMajorGridColor(CNiColor(60,60,60));
            plot.YAxis.GetTicks().SetMajorGridColor(CNiColor(60,60,60));
        m_pGraph->ChartLength = m_graphLength;
        m_pGraph->ChartStyle = CNiGraph::ChartStrip;
        m_pGraph->SetImmediateUpdates(true);
    Graphing:
    CNiReal64Matrix newData;
    m_pGraph->GetPlots().Item(i+1).ChartXY(newData);
    m_pGraph->GetCursors().Item(i+1).SetPosition(newData(0,maxCol),
                                                                        newData(1,maxCol));
    Solved!
    Go to Solution.

    I managed to fix this problem, noticing that panning the graph caused the line to redraw properly.  I added a very small amount of 'jitter' to the X axis each time after ChartXY is called. Since autoscale mode seems to refresh just fine, i only introduce jitter if the axis min/max is set explicitly:
    if (!m_pGraph->Axes.Item("XAxis").GetAutoScale()){
            static double plusMinus = 1.0;
            m_pGraph->Axes.Item("XAxis").SetMinMax(m_pGraph->Axes.Item("XAxis").GetMinimum()+(plusMinus*0.000000001),
                                                    m_pGraph->Axes.Item("XAxis").GetMaximum()+(plusMinus*0.000000001));
            plusMinus *= -1.0;
    It seems this is a bug in the graph control since there is no problem with the cursor drawing properly and I should not need to write code like this to keep my plot lines from disappearing?
    -drew

  • When I render and Export there are these little lines around moving objects

    When I render and Export there are these little lines around moving objects, what are they and how do I fix it?

    The lines are caused by the video being interlaced.
    If you export to DVD they should no longer appear. However, if they don't disappear you can use the Deinterlace filter on the footage whilst in FCE.
    How are you exporting ..... QT Movie or QT Conversion ....... and what are you exporting to - the internet or DVD?

  • Plot line, bar and pie chart

    Anyone can let me know where can i learn or tutorial on how to plot line, bar and pie chart by using java2D... (no third-party software)....
    thanks in advance.

    Here's a pie chart app I made for an earlier question:
    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PieChart {
      public static void main(String[] args) {
        int[] data = {
          18, 95, 102, 87
        PieCharter pie = new PieCharter();
        pie.enterData(data);
        JFrame f = new JFrame("Pie Chart");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(pie);
        f.setSize(400,300);
        f.setLocation(300,300);
        f.setVisible(true);
    class PieCharter extends JPanel {
      int[] data, percents;
      int dataTotal;
      final int
        PAD = 25,
        R_PAD = 5;
      public PieCharter() {
        setBackground(Color.white);
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        Font font = new Font("lucida sans unicode", Font.PLAIN, 16);
        g2.setFont(font);
        FontRenderContext frc = g2.getFontRenderContext();
        int width = getWidth();
        int height = getHeight();
        int cx = width/2;
        int cy = height/2;
        int dia = (int)Math.min(width, height) - 2*PAD;
        g2.draw(new Ellipse2D.Double((width - dia)/2, (height - dia)/2, dia, dia));
        // draw zero datum
        double radians = 0;
        int x = cx + (int)((dia/2) * Math.cos(radians));
        int y = cy - (int)((dia/2) * Math.sin(radians));
        g2.draw(new Line2D.Double(cx, cy, x, y));
        String s;
        int dataWidth, dataHeight, deltaR, rXInc, rYInc;
        for(int i = 0; i < data.length; i++) {
          radians += 2*Math.PI * data/dataTotal;
    x = cx + (int)((dia/2) * Math.cos(radians));
    y = cy - (int)((dia/2) * Math.sin(radians));
    g2.draw(new Line2D.Double(cx, cy, x, y));
    s = String.valueOf(percents[i]) + "%";
    dataWidth = (int)font.getStringBounds(s, frc).getWidth();
    dataHeight = (int)font.getLineMetrics(s, frc).getAscent();
    deltaR = (int)Math.sqrt(dataWidth*dataWidth + dataHeight*dataHeight)/2 + R_PAD;
    rXInc = (int)(deltaR * Math.cos(radians));
    rYInc = (int)(deltaR * Math.sin(radians));
    x += rXInc;
    y -= rYInc;
    x -= dataWidth/2;
    y += dataHeight/2;
    g2.drawString(s, x, y);
    s = String.valueOf(data[i]);
    dataWidth = (int)font.getStringBounds(s, frc).getWidth();
    dataHeight = (int)font.getLineMetrics(s, frc).getAscent();
    x = cx + (int)((dia/4) * Math.cos(radians - 2*Math.PI * data[i]/(2*dataTotal)));
    y = cy - (int)((dia/4) * Math.sin(radians - 2*Math.PI * data[i]/(2*dataTotal)));
    x -= dataWidth/2;
    y += dataHeight/2;
    g2.drawString(s, x, y);
    private void prepareData() {
    for(int i = 0; i < data.length; i++)
    dataTotal += data[i];
    percents = new int[data.length];
    int dataPlus = 0;
    for(int i = 0; i < data.length; i++) {
    dataPlus += data[i];
    percents[i] = Math.round(100 * dataPlus/dataTotal);
    public void enterData(int[] data) {
    this.data = data;
    prepareData();
    repaint();

  • Can a plot line width be larger than level 5

    When I programming in Labview 6.1, in the property of plot, I found the line width only have 5 level. In my case, I need a much thicker plot line than level 5. Is there anyway to realize increasing the line width beyond the 5 options provided in Labview?
    Really thank you if you can help me.

    You can programmatically thicken lines by creating a duplicate data plot that is offset from the original.  Then use the Plot.FillTo property node and fill between the original and the duplicate.
    I back saved the example from LV7 to 6.1, but I have no way to test it on 6.1
    2006 Ultimate LabVIEW G-eek.
    Attachments:
    THICK.vi ‏18 KB

  • How to add the actual figure alone the plotted line

    Hi,
    Please advise on how to show the database figure alone a plotted line as per attached
    Thanks

    Then Change the diagram type to "Line with Markers":
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Is there a function to output the crossing point of two plotted lines

    I got some data plotted on a graph, I need to find the crossing point  of the plotted lines on the graph (The plotted data curves are not linear lines) and detect it by an indicator. I could compare the to data arrays plotted and output the two closest data numbers, but the really crossing pionts is sertainly an intercept of two Interpolated values made by the graph, wich are not in my data buffers. any suggestions will be full Stared   
    Zamzam
    HFZ

    I only did a cursory look and didn't find any built-in function that jumped up screaming "I'm it! I'm it!", but that doesn't mean something doesn't exist given the large number of functions available with LabVIEW. An alternate solution is to use linear interpolation between successive points. If the points are close together then you can assume a straight line between the points and break this down to the simple case of finding the intersection of two lines, which is trivial. Not sure how computationally intensive of an algorithm this would be, and there would clearly be some error involved, and you will need to determine if the error is tolerable for you.

  • Microsoft JScript Runtime Error, Line: 0, Error: Object Expected?

    Hi,
    I just got a new computer and I have Java 2 Runtime Environment SE v 1.4.2. I keep having problems with it. It says, "Microsoft JScript Runtime Error, Line:0, Error: Object Expected. I have no idea what to do or what is actually causing this. It shows up randomly when I have been using "Dell Jukebox by musicmatch" or even when I'm surfing. Can someone please help me fix the problem?
    "Jay"

    Hi,
    I just got a new computer and I have Java 2 Runtime
    Environment SE v 1.4.2. I keep having problems with
    it. It says, "Microsoft JScript Runtime Error, Line:0,
    Error: Object Expected. I have no idea what to do or
    what is actually causing this. This is not a java err. It is a scripting error.
    It shows up randomly
    when I have been using "Dell Jukebox by musicmatch" or
    even when I'm surfing. Can someone please help me fix
    the problem?
    "Jay" Someone can certainly help you - contact the website's webmaster & send them the err. They wrote it; they have to fix it.

  • How to plot line and bar chart in one graph

    i have one graph, but in this graph i want to plot line or bar chart using radio button selection.
    can i do that...

    You must have 2 data arrays or plots to get this. Make sure your plot legend is visible. Drag the plot legend vertical borders to view both plots. Select one of the plot to be bar plot (See the attachment)
    Attachments:
    BarPlots.PNG ‏14 KB

  • A Runtime Error Has Occured Do you wish to Debug? Line 90 Error: Object Expected

    A Runtime Error Has Occured Do you wish to Debug? Line 90
    Error: Object Expected
    This error is recieved when trying to open "The Fan" video
    news Page from Comcast, This error appears and when you select yes
    or no, the page comes up to install Adobe Flash Player, however
    even after installing it, the error still appears when attempting
    again, even after restart, this does not occur on Firefox, only
    IE

    Also I am on Windows Vista

  • PDF - Text on multiple lines become seperate objects - is there a way to prevent this?

    I'm exporting to PDF from inDesign with the idea that the text would be editable with Acrobat Pro.
    However, when opening the PDF in Acrobat Pro, each line is a seperate instance / object.
    Is there a way around this?
    I imagine I can recreate the text in Acrobat Pro - but it would be good if there was a way round from inDesign - as i imagine it would be better for SEO and screen readers. Also, i've uploaded PDFs to sites before like Slideshare, yudu, issuu which create a text only version - only the text only version is scr*wed up due to the above problemo.
    Help much appreciated or even to know if its not possible. Thanks.

    Not really sure what SEO has to do with it? But I think  you're talking about "Accessibility"
    When a PDF is created that's what happens. You can't export it and have paragraphs of text editable. PDFs are meant to be FINAL files.
    For accessiblity follow these tips -
    http://www.adobe.com/accessibility/products/acrobat/
    http://tv.adobe.com/watch/accessibility-adobe/preparing-indesign-files-for-accessibility/
    http://tv.adobe.com/watch/accessibility-adobe/acrobat-tagging-pdf-content-as-a-table/
    http://indesignsecrets.com/creating-accessible-pdf-documents.php

  • Help needed in plotting line graph!

    Hi i need help in plotting a line graph complete with both axes shown,plus the legend on the side shown.
    Pls help!!!!
    rgds

    Here's a simple line graph applet I did some time backimport java.awt.*;
    public class LineGraff extends java.applet.Applet{
       double []toGraff = {6.0, -14.0, -164.0, -210.0, 108.0, 770.0,
                                1354.0, 896.0, -572.0, -1348.0, -780.0, -108.0};
       double []numsFromFile = {6.0, -14.0, -164.0, -210.0, 108.0, 770.0,
                                1354.0, 896.0, -572.0, -1348.0, -780.0, -108.0};
       int max, min, size, Hscale;
       double Vscale;
       public void init(){
          size = numsFromFile.length-1;
          java.util.Arrays.sort(numsFromFile);
          max = (int) numsFromFile[size];
          min = (int) numsFromFile[0];
          Vscale = max-min;
          Vscale = 200/Vscale;
         Hscale = Math.round(300/size);
       public void paint(Graphics g) {
          g.setFont(new Font("Arial",0,14));
          g.drawString("Example app: drawing a graph from a double array",25,18);
          g.setFont(new Font("Arial",0,10));
          g.setColor(Color.blue);
          g.fillRect(10,20,365,230);
          g.setColor(Color.cyan);
          g.drawLine(25,25,25,225);
          g.drawLine(25,140,330,140);
          g.setColor(Color.white);
          int intA = 30, intB = 0, intC = 0;
          int intD = (int) (Math.round(140 - (Vscale * toGraff[0])));
             for(int i=1; i <= size; i++) {
               intC = intA + Hscale;
               intB = intD;
               intD = (int) (Math.round(140 - (Vscale * toGraff[ i ])));
               g.drawLine(intA, intB, intC, intD);
                  if(toGraff[ i ] > 0)
                     g.drawString(Double.toString(toGraff[ i-1 ]), intA+6, intB-3);
                  else
                     g.drawString(Double.toString(toGraff[ i-1 ]), intA+6, intB+8);
               intA += Hscale;
          g.drawString(Double.toString(toGraff[size]), intA+6, intD-3);    
    }

Maybe you are looking for

  • Attribute change run problem - infoobject is not listed in the list

    Hi folks, When I load master data for 0customer, the infoobject 0customer doesnt come in the infoobject list for attribute change run. Also, when I try to activate master data manually it says 'Master Data already active'. and the reality is M versio

  • Screen flickers off - Edge13 intel, ubuntu

    I have an edge 13 w/ intel chip running dual boot of windows 7 and ubuntu [just upgraded to 10.10, but was having this problem for a few weeks while still using 10.04].  I rarely use windows, and the problem I'm having happens in Ubuntu. The problem

  • ClassCastException in KodoHelper

    Hi Folks I received a ClassCastException when invoking KodoHelper.getPersistenceManagerFactory(File). The exception implies to me that Kodo is casting its PersistenceManagerFactoryImpl class to some incompatible type. Here is the contents of kodo.pro

  • When I upgraded Adobe, I lost access to be able to convert files.

    I purchased a subscription to Adobe last month to convert PDF's into word/excel documents. Last week I upgraded Adobe and lost my access to this subscription. How do I inplement the subscription again so I can continuing converting my files?

  • Hello It is possible to downgrade the iphone 5 to 6.1.4

    Hello It is possible to downgrade the iphone 5 to 6.1.4