AutoScale graphical wpf

How can I autoscale graphical WPF on request? When you work with graphics WF, I used something like this (activate autoscale, then disable it):

(Graph (AxisDouble). Axes [0]). Setting device = RangeAdjuster.FitLoosely;
(Graph (AxisDouble). Axes [1]). Setting device = RangeAdjuster.FitLoosely;

(Graph (AxisDouble). Axes [0]). Setting device = RangeAdjuster.None;
(Graph (AxisDouble). Axes [1]). Setting device = RangeAdjuster.None;

but chart WPF has no effect

Immediately all the WPF Chart redraws the data when the Adjuster on a change in the axis. To do this manually, you can call the Refresh method on the chart. In your example:

((AxisDouble)graph.Axes[0]).Adjuster = RangeAdjuster.FitLoosely;

    ((AxisDouble)graph.Axes[1]).Adjuster = RangeAdjuster.FitLoosely;

    graph.Refresh();

    ((AxisDouble)graph.Axes[0]).Adjuster = RangeAdjuster.None;

    ((AxisDouble)graph.Axes[1]).Adjuster = RangeAdjuster.None;

Tags: NI Software

Similar Questions

  • Graphical WPF children order

    I have a canvas added to the children of a WPF XAML graphic in the development of the various blocks of text and lines. Later in the code, I add RangeCursors. The RangeCursors of paint on top of the canvas, but I like the canvas on top. Is there a way to control this? I tried both adding the RangeCursors at the end of the children's collection and insertion in the 0 position, but the result is the same (RangeCursors on top).

    Set the ZIndex to the canvas with a value greater than the default value of zero:


            Panel.ZIndex="1" ... />
            
        

  • graphical WPF detect the mouse on the axis

    How can the interaction of the mouse with the axes of the events? With graphics WF, I used following code:

    switch (graph. HitTest (provable, e.Y))
    {
    case XYGraphHitTestInfo.XAxis:

    etc...

    You can use the GetScaleAt method to detect a ladder to a given mouse position ( GetChildrenAtPoint should return scales as well, but this does not work in the current version).

    Here is an example of using GetScaleAt in the MouseLeftButtonDown event on a graph (note that the graph should have a background of testable success as Transparent , instead of the value default null , or only clicks exactly on the visuals in the balance works):

    private void OnGraphMouseLeftButtonDown( object sender, MouseButtonEventArgs e ) {

            Point screenPosition = e.GetPosition( graph );

            var scale = graph.GetScaleAt( screenPosition );

            Console.WriteLine( "Scale at {0}? {1}", screenPosition, scale == null ? "no" : "yes" );

        }

  • Graphical WPF dot line type does not

    When I set type of line point-to-point, point dash, dash-dot-dot, I don't see the points, dashes only. The graph is in vector mode. The solid lines are working too of course.

    I was not able to reproduce the problem. Here's the test code I used:

    XAML
        
            
                
                
                
                
                
            
        

    Code
            graph.DataSource = Enumerable.Range( 0, 5 ).Select( plot =>
                Enumerable.Range( 0, 201 )
                    .Select( i => plot + Math.Sin( i * Math.PI / 200 ) )
                    .ToArray( )
            ).ToArray( );

    When I run it, it looks like this:

  • Graphical WPF reset the Axes of origin

    Hello

    Is there a way to reset a horizontal axis (0) originally?

    I already used ResetZoomPan(), but this only the definition panoramic and zoom to its original state.

    I would like to reset the chart as it appears from the first load.

    Thanks for all the help.

    Assuming that your chart is configured as in the example below:


          
            
          
          ...
        

    You can set the range using the element named axis:

    xAxis.Range = new Range(0.0, 10.0)

    Or by casting the first element of the Axes collection, if it is without name:

    ((Axis)graph.Axes[0]).Range = new Range(0.0, 10.0)

  • Rotate the Wpf graphics in a 3d viewport

    Gentlemen.

    Someone at - it an example of how to roate a graphical wpf with the viewport3d?

    Thank you

    George

    You can host a WPF control with the help of the Viewport2DVisual3D class (in the example in the article, simply replace with and change the RotateTransform3D according to needs).

  • LogarithmBase10 does not properly

    I have replace or WIN graphic graphical WPF.

    I'm using LogarithmBase10 in some graphics (you can see in the sample project).

    When the range from 0, that's OK, but if I change the beach to another number (70
    for example) the divisions do not display correctly [divisions are overcrowded].

    You can change the range and sometimes it is overcrowded and sometimes it's OK (depending on the number of departure).

    I have to say: chart WIN, it is not the case.

    First of all, just to clarify: by "WIN", you mean "Windows Forms?

    I was able to reproduce the problem using your example. This seems to be a problem with how we generate divisions auto for logarithmic scales. To work around the problem, you can set the Mode on the MinorDivisions to the below custom implementation:

    public class CustomLogarithmicRangeDivisionsMode : RangeDivisionsMode {

            protected override IList GetDivisionsCore( IRangeDataMapper dataMapper, int divisionsEstimate ) {

                return Auto.GetDivisions( dataMapper, divisionsEstimate );

            }

    protected override IList GetSubdivisionsCore( IRangeDataMapper dataMapper, IList dependentDivisions ) {

                // (Note: this example assumes you supply the graph with "double" values)

                const int LogarithmBase = 10;

                double firstDivision = (double)(object)dependentDivisions[0];

                double lastDivision = (double)(object)dependentDivisions[dependentDivisions.Count - 1];

                double previousPower = Math.Pow( LogarithmBase, Math.Floor( Math.Log( firstDivision, LogarithmBase ) ) );

    var subdivisions = new List();

                double division = previousPower;

                while( division < lastdivision="" )="">

                    for( int i = 1; i < logarithmbase;="" ++i="" )="">

                        double subdivision = i * division;

                        subdivisions.Add( (TData)(object)subdivision );

                    }

    division *= LogarithmBase;

                }

    return subdivisions;

            }

        }

  • The point value of graphic display WPF overview

    Hello

    Y at - it an easy way to display the value of a point (with formatting similar to a slider) flying over when the mouse point? I use the chart control WPF (MStudio 2013) with several plots represented graphic on an AxisDouble. (y-axis) and AxisPrecisionDateTime (x axis). Let me know if you need more information and thanks in advance.

    When a Cursor is set to align the data, it uses the FindNearestValue method to find the value of land near. When it is not set to align the data, he reports the value of the current screen with the ScreenToData method. The following code example shows how to use both to display the current value of the mouse on a chart using a ToolTip:

    private static readonly GraphQueryArgs query = new GraphQueryArgs(

            PlotsToSearch.Any, SearchDimensions.HorizontalAndVertical,

            SearchDirections.ForwardAndReverse, isInclusive: true );

    public MainWindow( ) {

            InitializeComponent( );

    graph.PlotAreaMouseMove += this.OnPlotAreaMouseMove;

            graph.PlotAreaMouseLeave += delegate { graph.ToolTip = null; };

            ToolTipService.SetInitialShowDelay( graph, 0 );

            ToolTipService.SetShowDuration( graph, int.MaxValue );

        }

    private void OnPlotAreaMouseMove( object sender, MouseEventArgs e ) {

            IPlot plot = graph.AllPlots[0];

            Point screenPosition = graph.GetPlotAreaPosition( e );

            IList pixelValue = graph.ScreenToData( plot, screenPosition );

            string tip = string.Format(

                "Absolute value at point {0} is {1}.",

                screenPosition, FormatValue( pixelValue ) );

            Point relativePosition = graph.ScreenToRelative( screenPosition );

    PlotValue nearestValue = graph.FindNearestValue( plot, relativePosition, query );

            if( nearestValue != null )

                tip += Environment.NewLine + string.Format(

                    "Nearest value on {0} is {1}.",

                    nearestValue.PlotObserver.Label,

                    FormatValue( nearestValue.Value ) );

    graph.ToolTip = tip;

        }

    private static string FormatValue( IList values ) {

            return string.Join( ", ", values.Cast( ) );

        }

  • WPF graphical zoom

    Hello

    I am trying to use the zoom on a graph of WPF, but I don't know how. Can you please give me an example how can I Zoom in/dΘplacer in a graph of Wpf?

    I want the same function as in the example of WPF-Feature Tour

    http://www.NI.com/example/29739/en/

    See screenshot

    Also the Start/Stop function and Zoom/Pan functions.

    Thank you very much

    Manual

    The page 'Picture' in the Tower of WPF functionality uses a GraphInteractionPalette to expose all of the built-in interactions available for the chart. To use it in your own code, simply link to the graph:

    Graph="{Binding ElementName=graph}" />

    When one of the buttons is activated, the palette will set the corresponding GraphInteraction the instance as the DefaultInteraction on the chart.

    The "Start/Stop" button simply controls the timer for a source of simulation data used to illustrate the graphics (similar to the way that the sample of "Trace" Project installed with Measurement Studio is implemented). The button is not bound to any member of the graph.

  • WPF graphics getChildrenAtPoint

    I have a wpf that I add Point Annotations and Annotation driven program, when the user clicks the buttons 'Take Point Annotation' and 'take the Annoation range '. I would choose an annotation when the user clicks top brand him able to change or remove. I used the method getChildrenAtPoint of the graph, but the collection that this method returns is always empty...

    My definition of graph is:



















    and the addAnnotation method is:

    ' Private Sub TakeRangeAnnotation_Executed (ByVal sender As Object, ExecutedRoutedEventArgs e)
    {
    Dialogue WindowAnnotation = new WindowAnnotation();
    If (dialog box. ShowDialog() is true)
    {
    Ann NationalInstruments.Controls.RangeAnnotation = new NationalInstruments.Controls.RangeAnnotation ();
    Ann. HorizontalRange = rangeCursor.ActualHorizontalRange;
    Ann. VerticalRange = rangeCursor.ActualVerticalRange;
    Ann. Label = dialogue. Annotation in question;
    Ann. HorizontalAxis = xAxis;
    Ann. VerticalAxis = yAxis;
    Graph Children.Add (ann);
    }
    }

    I call the method getChlidrenAtPoint on the PlotAreaMouseLeftButtonUp event:

    ' private void graph_PlotAreaMouseLeftButtonUp (object sender, MouseButtonEventArgs e)
    {
    Point mousePos = e.GetPosition (graph);
    ScreenPos graphic = point. GetPlotAreaPosition (e);
    IEnumerable = graphic children1. GetChildrenAtPoint (mousePos);
    IEnumerable = graphic views2. GetChildrenAtPoint (screenPos);

    I tried the two position of the mouse and PlotAreaPosition, but the two collections are always empty, also if I click on an Annotation of the range

    I was able to reproduce the problem you saw and confirmed there is a bug in our code that prevents the annotations to appear in the results of the hit test. We have created a work item for this problem.

    To work around this, here's an example of how you can test for manual to achieve a RangeAnnotation in a graph is configured with double horizontal and vertical axes:

    double[] dataValue = graph.ScreenToData(plot, screenPos).Cast().ToArray();

    foreach( var rangeAnnotation in graph.Children.OfType() ) {

            var horizontalRange = (Range)rangeAnnotation.HorizontalRange;

            var verticalRange = (Range)rangeAnnotation.VerticalRange;

    if( horizontalRange.Contains(dataValue[0])

                 && verticalRange.Contains(dataValue[1]) ) {

                // matching range annotation found

            }

        }

  • App "Unresponsive" with WPF graphics, GraphInteraction.Zoom and sliders

    I can't chart WPF (MS2013) to work with the sliders AND the GraphInteraction of Zoom (zoom with the mouse). The zoom rectangle redraws so slowly that the app is unusable, sometimes even suspended for long enough to get the "(ne répond pas) title" Windows. " WPF is supposed to redraw at 60 fps, but I'm< 1="" fps="" when="" i="" use="" more="" than="" a="" couple="" cursors.="" how="" can="" i="" use="" both="" mouse-zoom="" and="" ~100="" cursors="" at="" the="" same="">

    The attached csproj is based on the example of Charting. I pre-load 4 locations with 900 data points each and add 90 sliders and set the graphics DefaultInteraction on Zoom. When you try to mouse-zoom on a region, the zoom rectangle does not appear immediately and all holding left mouse to the bottom of the rectangle redraws slowly)< 1="" fps),="" not="">

    I tried to go to Raster and marking the sliders as ReadOnly, but it does not help. I considered to implement my mouse zoom (app has an example of resizing control just to test the performance of a simple), but it feels stupid disable the native just to implement zoom even. I do have performance problems similar with the mouse zoom rectangle (~ 5 fps refresh) without sliders, but this behavior is easier to reproduce. In our application, we often represent 4 channel with 500 K points and 100 data sets + read-only cursors.

    Advice / Solutions / advice would be really appreciated!

    -David

    The problem is due to the large number of cursors, each of which is generating its own visuals and recalculate its position on each update to the chart. The Visual zoom being in the same layer that cursors, layout is also done on the sliders each time the Visual zoom resizes.

    Instead of using the individual sliders a hundred to annotate every point, I would recommend using a custom object to render the annotations for all points. Joined a fast model (which still reduces the number of visuals generated using a custom point form which includes the vertical line of the reticle). Add an instance of the AnnotatingCursor to the Children collection of the graph will mark each 10th point with a diamond.

  • Link z scale graphical data without autoscale marker of intensity

    When directly change us the value of marker without autoscale, no change can take place on the route of the graph of the intensity of. So, how can we link the values of the scale marker z for the data displayed on the ground?

    To be more precise, because many people may prefer that they have the graph of the intensity for different sets of data with the same z scale so that they can very easily compare visually the value z-scale to compare the color. But for the different sets of data, they can get different and AutoScale will result in trouble for the same z scale.

    However, when deactivate us autoscale and just do the scale marker z the same, in fact the graph will be is more really connected with the plot and making it impossible to compare the values of z of the plot.

    I tried to change the beach instead of the brand, but it does not work for scale z that when we get a negative value for the location of marker z scale, the graph only get something very weird as only black and white.

    So, how can we define two graph of intensity at the same z scale and z scale and at the same time markers have the graph link to the data we have?

    Hi weirpenguin,

    Please see the new example. I changed it to LabVIEW 2009 and U8.

    If the graphic is U8, it means that data cannot be outside the range of 0-255 anyway, right?  U8 is only 0-255. Then why grow you to be larger than 0-255 range?

    Kind regards

  • WPF graphics export to image problem

    My problem is that I created a new custom personalized using the chart wpf OR as a base. The control includes mainly the chart, its axis and legends on a grid. To allow the legend be moved, I put it in a grid of the child. My problem is that he was trying to export as an image control, I use the code below (similar to wpf graphical image export):

    Rect bounds = LayoutInformation.GetLayoutSlot(MainGrid);
    var bitmap = new RenderTargetBitmap((int)bounds.Width + 1, (int)bounds.Height + 1, 96, 96, PixelFormats.Default);
    bitmap.Render(MainGrid);
    

    My problem is the axes and the edges of the image exported to the Clipboard is dark as shown below. Is saved in the image, the edges are quite transparent but better (not visible in the photos app but visible in the paint). My question is why is this behavior and how can it be avoided?

    Thank you.

    The problem is the default color of the grid or niGraph in WPF is transparent. I simply changed color or image now saved correctly.

  • graphic multithreaded WPF error

    When I create 2 wires that respectively show 2 graphics, an error occurs.

    When I commented "_controlDispatcher1.BeginInvoke (aps1 [f], simulatedData)", no error occurs.

    code in MainWindow.xaml.cs line: 320

    complete code to testmultithread.zip

    I was able to reproduce the problem with your test project and create a task to solve this problem for the next version.

    The underlying problem is with the cache that allows us to record textures point when rendering with bitmaps. From your application, the simple workaround solutions as "using vector rendering" and "do not use item renderers" do not seem to appropriate. However, using pre-initialized converters shared, you can avoid the cache access exception and always use the point rendering. Here are the changes I have made to your project to get this working:

    (1) PointGraphicsReal.xaml

    Remove the section, where the point local renderers are created.

    (2) PointGraphicsReal.xaml.cs

    Declare a static collection of converters point to share between all the graphs and use them as the default value for the PointGraphicsReal graph:

    private static readonly SolidColorBrush[] _pointFills = new[]{
            Brushes.Red,
            Brushes.Lime,
            Brushes.Blue,
            Brushes.Yellow,
            Brushes.Magenta,
            Brushes.Cyan,
            Brushes.Red,
            Brushes.Lime,
            Brushes.White,
            Brushes.Lime,
            Brushes.Red,
            Brushes.Yellow,
            Brushes.Blue,
            Brushes.Cyan,
            Brushes.Magenta,
            Brushes.Lime,
            Brushes.Red,
            Brushes.White,
        };

    public static readonly PlotRendererCollection PointRenderers = new PlotRendererCollection(
            _pointFills.Select( fill => {
                var pointRenderer = new PointPlotRenderer { Shape = PointShape.Ellipse, Fill = fill, Stroke = null };
                // Freeze the renderer so that it can be used on any thread.
                pointRenderer.Freeze( );
                return pointRenderer;
            } )
        );

    public PointGraphicsReal( ) {
            InitializeComponent( );

    graph.DefaultPlotRenderers.AddRange( PointRenderers );

    // ...
        }

    (3) MainWindow.xaml.cs

    Initialize the converters point shared on the main UI thread, before they are used on all other threads, but their use in a hidden graph.

    public MainWindow( ) {
            new NationalInstruments.Controls.Primitives.Tables.RenderTargetBitmapWrapper( 1.0, 1.0 );
            InitializeComponent( );

    // Use all of the the shared renderers on one thread, to pre-cache the render settings for safe use on all threads.
            var graph = new Graph( );
            graph.Visibility = Visibility.Hidden;
            graph.RenderMode = RenderMode.Hardware;
            graph.DefaultPlotRenderers.AddRange( PointGraphicsReal.PointRenderers );
            graph.Data.AddRange( Enumerable.Repeat( (object)default( Point ), graph.DefaultPlotRenderers.Count ) );
            var panel = (Panel)this.Content;
            panel.Children.Add( graph );
        }

  • WPF graphics, display plot marker (with contact information tooltip) on the mouse event

    Hello

    I need display the coordinates of the point of the field when the mouse pointer is positioned top/close to him.

    I already display a ToolTip with coordinates using the code in this LINK (works equally well for graph).

    However, it is not easy to see where the field is selected, especially when you have more than one land close to eachother.  Is there a way to display some sort of a 'marker '?  A bit of as Signal Analyzer?

    Thank you.

    If you want to display a target and the label next to the value as a user moves the mouse over a graphic, a possibility would be to use SetRelativePosition on a slider.

    If you want to just use a marker in the chart and keep the label in the ToolTip, you can set the relative position of a Visual in the Children collection:

    XAML

        

            

                

                ni:Cursor x:Name="cursor" />

                

                Ellipse x:Name="marker" Width="10" Height="10"

                         Stroke="Black" StrokeThickness="2"

                         niPrimitives:RelativePanel.RelativeHorizontalAlignment="Center"

                         niPrimitives:RelativePanel.RelativeVerticalAlignment="Center"

                         />

            

        

    Code

        private void OnPlotAreaMouseMove( object sender, MouseEventArgs e ) {

            IPlot plot = graph.AllPlots[0];

            Point screenPosition = graph.GetPlotAreaPosition( e );

            Point relativePosition = graph.ScreenToRelative( screenPosition );

    // Option 1

            cursor.SetRelativePosition( relativePosition );

    // Option 2

            PlotValue nearestValue = graph.FindNearestValue( plot, relativePosition, query );

            if( nearestValue != null ) {

                graph.ToolTip = string.Format(

                    "Nearest value is at ({0},{1}).",

                    nearestValue.Value.Cast( ).ToArray( ) );

    Point nearestValuePosition = nearestValue.GetRelativePosition( );

                RelativePanel.SetRelativeHorizontalPosition( marker, nearestValuePosition.X );

                RelativePanel.SetRelativeVerticalPosition( marker, nearestValuePosition.Y );

            }

        }

Maybe you are looking for