Draw a line connecting two points in the WPF chart

I'm trying to understand the best way to draw a line between two existing points on my graph in WPF.  At first, I thought I had it works fine; I just added another parcel to my graph then given exactly two points for rendering.  But I quickly noticed that the app has become surprisingly slow and CPU was quite high (adding other plots does not affect the use of the CPU as long as they have a complete set of points (?)).  He wants me if I looked at using the DataToScreen method on the chart but I can't know what the parameters are.  The second parameter is simply an IList that tells me a lot.  This seems to be the method I want to use for the coordinates of a point on the graph screen.

No one knows what the second parameter is supposed to be for the DataToScreen method?  Everything I tried throws an Exception of Argument.

Thank you
Dan

DataToScreenwill return a screen coordinate in the plot area of a chart of the value of the raw data horizontal and vertical in the given list. The parameter value is a IList for compatibility with other methods of graphical query such as FindNearestValue , return IList values containing raw data.

A concrete example, say you had a graphical configuration with a wide horizontal axis ranging from 0 to 100 and a vertical axis double precision ranging from 10 to 20:


        
            
            
        
    

To get the screen coordinates of the value at the center of the two axes, you can call:

graph.DataToScreen(plot, new object[] { 50, 15.0 })

Note that the raw data values corresponding to the type of axes (horizontal AxisInt32 returns the integer 50 and vertical AxisDouble Gets the value 15.0 ).

You also mentioned a performance issue where "adding other plots does not affect the CPU so that they have a complete set of points". I did a simple test app that adds an array of two points of a chart on each key (for example graph.Data.Add(new[] { new Point(x1, y1), new Point(x2, y2) }); ), but could not reproduce the problem you saw. Could you share the code, you use to draw the connection line?

Tags: NI Software

Similar Questions

  • Connecting two points on the compound path

    Hi guys,.

    First time posting and had a little research but could not know what I needed - forgive me if the answer is and I am looking with the wrong keywords!

    I'm trying to change a font, that I turned into an object. I don't want the tail down to cross during the rest of the letter and I want also to shorten the tail, so I want to join paths, so I can modify it all as one. If you look at the pictures, I'm hoping to join them at the pink line; the second image shows the current paths.

    He is currently a compound path, if that makes a difference.

    Is it possible to get this happening, or is my best bet to trace it?

    Thank you!

    Illustrator.PNG

    illustrator2.PNG

    tashacarolina,

    IF I (put) understand it, if you initially return a compound path, then:

    (1) with the line Segment tool ClickDrag between Anchor Points where you would like the tail to be cut, then object > path > divide objects below, then a compound path output if necessary (unlikely);

    Now you have a simple path;

    (2) cut the ponytail where you want and remove the line to the main part.

    (3) you can adjust the shape of the tip where you cut in 1), if you want to curve.

  • draw a line of nested MC to the other

    I use the drawing API to draw a line from one MC nested within two levels of MCs relative to another similarly nested MC. Can someone tell me how to get the X, Y coordinates of the two points?

    It's too much typing. If gp = grandparent, p = parent, c = child, use:

  • How to draw a line between two buttons?

    Hello.

    I want to do two mobile buttons attached to a line. When changing the position of any button you change in the appearance of the line of course.  I know how to draw a line, but after MOUSE_DOWN and I don't know how to remove an old monotube and how this line to appear all the time?

    My code

    btn2.addEventListener (MouseEvent.MOUSE_DOWN,
    mouseDownHandler3);
    btn2.addEventListener (MouseEvent.MOUSE_UP, mouseUpHandler3);
    btn3.addEventListener (MouseEvent.MOUSE_DOWN, mouseDownHandler3);
    btn3.addEventListener (MouseEvent.MOUSE_UP, mouseUpHandler3);

    Set a mouse down Manager (the user is dragging)
    function mouseDownHandler3(evt:MouseEvent):void {}
    var object = evt.target;
    We have to limit them by dragging to the area inside the canvas
    object.startDrag ();
    }
    function mouseUpHandler3(evt:MouseEvent):void {}
    var obj = evt.target;
    obj.stopDrag ();
    spisujemy x, y
    var x2Pos:Number = btn2.x;
    var y2Pos:Number = btn2.y;
    var x3Pos:Number = btn3.x;
    var y3Pos:Number = btn3.y;
    trace (x3Pos);
    trace (y3Pos);
    var roundObject:Shape = new Shape();
    roundObject.graphics.lineStyle (2, 0 x 990000,. 75);
    roundObject.graphics.moveTo (x2Pos, y2Pos);
    roundObject.graphics.lineTo (x3Pos, y3Pos);
    this.addChild (roundObject);
    this.removeChild (this.getChildAt (this.numChildren-1));
    }

    Source. FLA: http://www.mediafire.com/?y2tyzz4zxun

    Here is a solution that you can adapt for two or more buttons...

    var btns:Array = [btn2, btn3]; instances in concert

    handlers all btn
    function setBtns (): void {}
    for (var i = 0; i)
    inclinometer [i] .buttonMode = true;
    inclinometer [i] .addEventListener (MouseEvent.MOUSE_DOWN, grab);
    inclinometer [i] .addEventListener (MouseEvent.MOUSE_UP, drop);
    }
    }

    setBtns();

    inspired by ECCAS btns lines all while occurs wildfire
    function drawLines(e:Event=null):void {}
    Graphics.Clear;
    graphics.lineStyle (2, 0xFF0000);
    ((graphics.moveTo(btns[0].x+(btns[0].width/2), btns[0].y+(btns[0].height/2));

    for (var j = btns.length - 1; j > = 1; j-) {}
    ((graphics.lineTo(btns[j].x+(btns[j].width/2), btns[j].y+(btns[j].height/2));
    }
    }

    managers
    function grab(event:MouseEvent):void {}
    event.target.startDrag ();
    addEventListener (Event.ENTER_FRAME, drawLines);

    }

    function drop(event:MouseEvent):void {}
    event.target.stopDrag ();
    removeEventListener (Event.ENTER_FRAME, drawLines);

    }

    drawLines();

  • Secondary axis on the WPF chart

    Hello

    I'm tracing a secondary value axis on my WPF chart. I have a graphic linked to a table of AnalogWaveform of objects that I change during execution. This table can be different sizes depending on the user's selection, however assume that there are two types of data to the chart.

    I would like to match a data type of my main axis and the other guy to my axis is secondary. For example, I have four AnalogWaveform opposes the plot, two of whom are in Hz (primary) and the other two in Volts (secondary).

    According to the documentation, I need an additional of element under my definition of . What I have is:

             

























    This adds a second value axis to the left of my main axis. What I need is for this axis which will be located to the right of my chart and somehow to draw each AnalogWaveform on the right y-axis.

    I build my locations in the code as follows:


    _graph. Plots.Clear ();

    RawData is my AnalogWaveform[], built in advance based on a response from the server
    foreach (AnalogWaveform waveform in RawData)
    {
    If (waveform! = null)
    {
    field = new plot (waveform. ChannelName);
    parcel of land. DataContext = waveform;

    plots. Add (Plot); plots is a simple list
    }
    }

    _graph. Plots.AddRange (studs); Add locations to graph

    _legend. ItemsSource = plots. Add locations to the legend

    Any help would be appreciated on how to do it.

    Thanks in advance.

    To position your second Y axis across the graph, set the Location property on the axis of Far .

    To associate a plot to a default axis, set the VerticalScale property on the ground in the axis value is appropriate.

  • How to draw two points in the xy graph?

    Hi, I need help to use the 2 different points to 2 different coordinates. Can someone help me with this? If possible, please give me a vi that also calculate the distance and the angle between the 2 points. Thank you

    it they are

  • How to draw a line connected?

    Just trying to create a traditional slide with boxes that are joined by lines.    I do not use a sensitive project.   But it doesn't seem to be seeking a way to create an organization chart nice with connectors (lines) that connect to the forms and move when you move the shape.  Do I have to draw this kind of thing outside 8 Captivate?

    Thank you

    Captivate has no connector, sorry.

  • Connect two VMs via the connection to the local network using VMWare Player

    So this topic can be posted already, but I'm at the end of the roll, trying to find a solution. I have VMWare player installed 3.1.4 on an enterprise_x64 of Windows 7 system. I configured two virtual machines: OS1 comments: Red Hat Enterprise Linux Server 5.5_x64 and OS2 comments: WIndows 7 Ultimate_x64. I need the Linux server to act as a database server in the system environment, that I am creating. The Windows 7 VM will be the client PC. The Linux server is configured to be it's own DHCP server, so ideally the client PC connects to the field of tht and also follow the Linux server IP address.

    I tried all the options of networkign for each virtual computer, but no sem to create this type of connectivity. How to configure the network settings in VMWare Player to make two virtual computers can communicate with each other via a virtual network? (Communication with the host pc is not necessary)

    The short answer is to manually install the lack vmnetcfg.exe, Editor of virtual networkand configure VMnet2 without DHCP and host vNIC and then configure manually each virtual machine network adapter to use Custom VMnet2.

    The longer answer has already been given so many times that you should be able to find detailed directions, however...

    To install the lack vmnetcfg.exe, virtual network editor, run VMware-player-* .exe-e c:\vmptmp go to a command line and then in the c:\vmptmp folder, locate the file c:\vmptmp\network.cab and extract (double-click on the .cab file) vmnetcfg.exe (virtual network editor) file in the working directory of VMware Player usually ' C:\Program Files\VMware/VMware Player ' you can create a shortcut to it and place it with the shortcut of VMware Player if you want to access more easily to her.  This utility is not installed by default is however necessary to turn off the automatic bypass on VMnet0 if the system is multihomed and two or more physical host from the NETWORK adapter is active or you want change VMnet1 and VMnet8 subnet addresses or additional VMnets.

    The you must manually change the configuration of each virtual machine's .vmx file in Notepad, change an existing parameter and add another.

    Change:

    ethernet0.connectionType = "nat"
    

    TO:

    ethernet0.connectionType = "custom"
    

    Add:

    ethernet0.vnet = "VMnet2"
    

    Note: Regardless of connectionType ethernet (n) shows it should be changed to "custom".

    Be sure also to Machine virtual are stop, not suspended and VMware Player is closed when you edit the .vmx config files.

    Here are some pictures to show.

    Here in the VMnet2 virtual network Editor is selected and is how it should be if you what to use your own DHCP server and the host does not have a vNIC.  You can change the IP address as a result of your needs.

    Here's the value VM card network NAT settings.

    This is what network settings Virtual Machine map will look like after you change the configuration of the Virtual Machine's .vmx file to use Custom VMnet2.

    BTW if you replace the Machine network card virtual settings through the user interface customized by something else then you will need to manually edit the .vmx config file to retrieve.   With VMware Workstation, you do not need to manually install the virtual network editor and should not manually edit the .vmx config file as the custom list box is still present and shows all VMnets to select from.

  • Draw a line between two entities

    Hello. I am on the Data Modeler and I use the Visual tool. I want to connect 2 entities with just a line that I can add comments or notes. I can create a relationship of foreign key between 2 entities now, but a primary key is required to do this. Some of my tables do not have primary keys, but I need to put a line between them, with comments or notes saying what relations there are. I know that the software is by default to foreign key relationships via primary keys, but I need to draw my own in there. Any ideas? Thank you!

    Yes, this is a frequent question on the forum. Once you draw the line, he opens a straight dialogue/property box? On the left, you will see a node called related columns. Click on that. You will see the map with the column name that is generated in the child column field. Click on that column and you'll see that it really is a drop-down selection list, which will show you all the FK "candidate" columns already in the table. One of them will be hopefully the FK column that you want to attach. Pick it up. When you click on apply or OK, the tool will ask you if you want to remove the generated column. Select "Yes".

    Note: the drop-down list won't give you the possibility to select the columns having the same exact data type and column PK of the source size. If the column that you want to attach to the is not an exact match, the tool will not let you join her. I had a situation where my PK was a surrogate Number key (9), but the target FK column was Number (6). I had to change the definition of column target in order to define the FK in the model. (So I added a note on the column of this change and why I did it). Unfortunately the model is now synchronized with the Pb of the production. Finally, we must convince the DBA to make the change (unless it's a third-party to which application cases you will have to live with it).

  • Draw a line from any Point to any Point B dynamically using AS3

    I'm doing an animation where there are several places (for example A, B, C, D,...) on a map. If a person clicks a location A and then B elsewhere, I wanted to draw a dotted line from point A (from the destination of the aircraft) to point B (to destination of the flat) using AS3. Please help me...

    Here's a quick timeline and dirty code it does (class is below):

    var line:Shape;
    var lineGraphics:Graphics;
    var clickSwitch:int = 0;
    var mousePositions:Array = [];
    var conversion:Number = 180 / Math.PI;
    
    init();
    function init():void {
         drawBackground();
         line = new Shape();
         addChild(line);
         lineGraphics = line.graphics;
         stage.addEventListener(MouseEvent.CLICK, onClick);
    }
    
    function onClick(e:MouseEvent):void
    {
         clickSwitch = 1 - clickSwitch;
         mousePositions[clickSwitch] = new Point(mouseX, mouseY);
         if (clickSwitch == 0) {
              drawLine();
         }
         else {
              removeLine();
         }
    }
    
    function removeLine():void
    {
         lineGraphics.clear();
         line.rotation = 0;
    }
    
    function drawLine():void
    {
         lineGraphics.lineStyle(1, 0xff0000);
         lineGraphics.moveTo(0, 0);
         var dotDistance:Number = 2;
         var nextX:Number = dotDistance;
         while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
              lineGraphics.lineTo(nextX, 0);
              nextX += dotDistance;
              lineGraphics.moveTo(nextX, 0);
              nextX += dotDistance;
         }
         line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
         line.x = mousePositions[1].x;
         line.y = mousePositions[1].y;
    }
    
    function drawBackground():void
    {
         var s:Shape = new Shape();
         var g:Graphics = s.graphics;
         g.beginFill(0xC0C0C0);
         g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
         g.endFill();
         addChild(s);
    }
    

    Class:

    package
    {
         import flash.display.Graphics;
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.events.MouseEvent;
         import flash.geom.Point;
    
         public class DottedLine extends Sprite
         {
              private var line:Shape;
              private var lineGraphics:Graphics;
              private var clickSwitch:int = 0;
              private var mousePositions:Array = [];
              private var conversion:Number = 180 / Math.PI;
    
              public function DottedLine()
              {
                   init();
              }
    
              private function init():void {
                   drawBackground();
                   line = new Shape();
                   addChild(line);
                   lineGraphics = line.graphics;
                   stage.addEventListener(MouseEvent.CLICK, onClick);
              }
    
              private function onClick(e:MouseEvent):void
              {
                   clickSwitch = 1 - clickSwitch;
                   mousePositions[clickSwitch] = new Point(mouseX, mouseY);
                   if (clickSwitch == 0) drawLine();
                   else removeLine();
              }
    
              private function removeLine():void
              {
                   lineGraphics.clear();
                   line.rotation = 0;
              }
    
              private function drawLine():void
              {
                   lineGraphics.lineStyle(1, 0xff0000);
                   lineGraphics.moveTo(0, 0);
                   var dotDistance:Number = 2;
                   var nextX:Number = dotDistance;
                   while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
                        lineGraphics.lineTo(nextX, 0);
                        nextX += dotDistance;
                        lineGraphics.moveTo(nextX, 0);
                        nextX += dotDistance;
                   }
                   line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
                   line.x = mousePositions[1].x;
                   line.y = mousePositions[1].y;
              }
    
              private function drawBackground():void
              {
                   var s:Shape = new Shape();
                   var g:Graphics = s.graphics;
                   g.beginFill(0xC0C0C0);
                   g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                   g.endFill();
                   addChild(s);
              }
    
         }
    
    }
    
  • How to connect two parameters to the program contributing to run

    Hey, I'm a bit new to oracle applications

    I have 2 settings, say P_office_id and P_emp_id. What I want is a LOVs of P_office_id and P_emp_id (this one I did with) and my problem is when I chose a value for P_office_id, the corresponding P_emp_ids must be filled in LOV of P_emp_id.

    Someone help out me. I need

    Hello

    You can define a set of dependent values called P_emp_id depends on the P_office_id using the +: $FLEX$. P_office_id + as well as the SQL which flows in the office_id into this profilw in the State for all of emp_id values.

    Knockaert

  • Earning two points on the graph

    Hello

    Hi Florent.

    Here is an example.

  • Point to the bar chart data label

    Hello

    I need to display the value (which appears as a ToolTip to move the mouse) on the top of each chart, so that users can display numbers without the mouse hovering over each bar. I can't find the option. Do any one help please?

    Thank you

    Open the properties of the graph-> title and labels - >-> Display Options for the data markers-> Show-> Show data labels always

    Mark nicely so useful/full

    Thank you

    AJ

  • Hide the first and the last Division in the WPF chart axis

    I want to hide the default marker of the first and the last major division in an axis of a chart of WPF. I tried to extend RangeDivisionsMode and define my own class object to the MajorDivisions.Mode property on the axis. But even when I returns a list empty in RangeDivisionsMode.GetDivisions(...), the first and the last marker is drawn.

    Thanks in advance, Jonas

    The minimum and maximum labels are transmitted separately when displaying a scale (even if technical RangeDivisionsMode custom can be used for the minor divisions).

    There is no direct configuration option to hide extreme labels, but you can achieve this effect by initializing the LabelPresenter property on MajorDivisions by a custom implementation:

    class CustomFormatter : GeneralValueFormatter {

            protected override UIElement VisualizeCore( TData value, ValuePresenterArgs args, UIElement existingVisual ) {

                UIElement element = base.VisualizeCore( value, args, existingVisual );

    var axis = (Axis)args.Context;

                Range range = axis.Range;

                var comparer = range.Comparer;

                bool isExtreme =

                       comparer.Compare( range.Minimum, value ) == 0

                    || comparer.Compare( range.Maximum, value ) == 0;

                element.Opacity = isExtreme ? 0.0 : 1.0;

    return element;

            }

        }

  • Problem by drawing a line dynamically

    Hello. I want to draw a line between two points in a dynamic way, it's average, by clicking on a canvas the first time will give the origin of the line and clicking will give once again, the end of the line (segment/stroke). I'll appreciate any help with this issue. Thanks in advance.

    Hello

    pls find the solution of your problem with the code below and let me know if you have any problem.

    Main.MXML

    http://www.Adobe.com/2006/mxml '.

    "Layout ="vertical"verticalAlign ="middle"xmlns:local =" * ">

    DrawingCanvas

    http://www.Adobe.com/2006/mxml"backgroundColor ="0xFFffff ".

    Width = "400" height = "300".

    creationComplete = "onCreationComplete () '"

    "xmlns:local =" * ">

    private function onCreationComplete():void

    {

    this.addEventListener (MouseEvent.MOUSE_DOWN, onMouseDown);

    this.addEventListener (MouseEvent.MOUSE_MOVE, onMouseMove);

    this.addEventListener (MouseEvent.MOUSE_UP, onMouseUp);

    }

    private var isMouseDown: Boolean;

    private var counter: number = 0;

    private var myShape: Shape = new Shape();

    private var : Point of origin;

    private var : destination Point;

    private function onMouseDown(event: MouseEvent):void

    {

    isMouseDown = true;

    origin = new Point (event.localX, event.localY);

    }

    private function onMouseMove(event: MouseEvent):void

    {

    if (isMouseDown is true)

    {

    destination = new Point (event.localX, event.localY);

    var lineThickness:Number = 2;

    var lineColor:Number = 0 x 000000;

    var lineAlpha:Number = 1;

    myShape.graphics.clear ();

    myShape.graphics.lineStyle (lineThickness, lineColor, lineAlpha);

    myShape.graphics.moveTo (origin.x, origin.y);

    myShape.graphics.lineTo (destination.x, destination.y);

    }

    }

    private function onMouseUp(event: MouseEvent):void

    {

    this.rawChildren.addChild (myShape);

    isMouseDown = false;

    }

    ]]>

    with respect,

    Mayeul Singh Bartwal

Maybe you are looking for