Making mouse drag function

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
copilot90
Posts: 13
Joined: Mon Aug 22, 2016 2:46 am

Making mouse drag function

Post by copilot90 » Thu Nov 03, 2016 10:03 am

Hello

I'm making a software base on CursorTrakingXY Chart

How can I make the dragfunction?

Look at the imagefile1

is it possible ?

also I want to set Chart x line zero

Look at the imagefile2

I wondring the chart api guide

Where I find the reference for chart develop

I think that the lightningchart have a many api

is it?

How can i get the manual like a msdn

Please help me and Have a nice day!

Thank you!
Attachments
arction_chart2.png
arction_chart2.png (22.25 KiB) Viewed 13236 times
arction_chart1.png
arction_chart1.png (38.93 KiB) Viewed 13236 times

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Making mouse drag function

Post by ArctionPasi » Thu Nov 03, 2016 6:24 pm

Hi Copilot,

Help resources

We have:
  • User's Manual in Support http://arction.com/support. The Manual explains what kind of objects LightningChart has and describes the most important features with pictures. The manual also install in the hard drive.
  • Help files (API description). You can find it in the Action program group from your start menu. It shows it in the Microsoft Help Viewer window.
    Help file and Users Manual in start menu
    Help file and Users Manual in start menu
    Help file and manual.PNG (104.02 KiB) Viewed 13231 times
  • Hundreds of examples
  • Forums which you are already found
  • Support by e-mail, please don't hesitate to contact us :D
Formatting X axis labels
To format X axis labels, you can disable automatic formatting by:
_chart.ViewXY.XAxes[0].AutoFormatLabels = false;

Then set
_chart.ViewXY.XAxes[0].LabelsTimeFormat property, based on your preference. Standard .NET formatting applies there, see Double.ToString and DateTime.ToString formatting commands.

Or alternatively set FormatValueLabel event handler for the axis, and convert each value to string there.


Defining bands with mouse

Use mouse event handlers, to create a Band, and update it's ValueBegin and ValueEnd.

Code: Select all

//Disable zooming 
            _chart.ViewXY.ZoomPanOptions.LeftMouseButtonAction = MouseButtonAction.None; 

            //Subscribe to mouse event handlers 
            _chart.PreviewMouseDown += _chart_PreviewMouseDown;
            _chart.PreviewMouseMove += _chart_PreviewMouseMove;
            _chart.PreviewMouseUp += _chart_PreviewMouseUp;

Code: Select all

 private double _bandStart = 0;
        private Band _bandUnderPainting = null; 

       
        void _chart_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //Start band painting

            _chart.BeginUpdate(); 
         
            AxisX xAxis = _chart.ViewXY.XAxes[0]; 
            Point mousePos = e.GetPosition(_chart);

            xAxis.CoordToValue((int)mousePos.X, out _bandStart, false, true); 

            Band b = new Band(_chart.ViewXY, xAxis, _chart.ViewXY.YAxes[0]);
            b.Binding = AxisBinding.XAxis;
            b.ValueBegin = _bandStart;
            b.ValueEnd = _bandStart; 
            b.MouseInteraction = false; 

            _chart.ViewXY.Bands.Add(b);

            _bandUnderPainting = b;

            _chart.EndUpdate(); 
            
        }


        void _chart_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //Update band end value 


            if (_bandUnderPainting == null)
                return;

            _chart.BeginUpdate();

            AxisX xAxis = _chart.ViewXY.XAxes[0];
            Point mousePos = e.GetPosition(_chart);
            double bandStop;

            //Convert mouse position into X axis Value. 

            xAxis.CoordToValue((int)mousePos.X, out bandStop, false, true);
            _bandUnderPainting.ValueEnd = bandStop;

            _chart.EndUpdate();
        }

        void _chart_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //Stop painting 

            if (_bandUnderPainting == null)
                return;

            _bandUnderPainting.MouseInteraction = true;
            
            _bandUnderPainting = null;
        }

Like this, a Band appears in the chart when you press mouse down, band updates while you are dragging the mouse, and stops defining the Band when you release the mouse button. Is this a working solution for you? :)
LightningChart Support Team, PT

copilot90
Posts: 13
Joined: Mon Aug 22, 2016 2:46 am

Re: Making mouse drag function

Post by copilot90 » Fri Nov 18, 2016 7:09 am

Thank you for the reply

It's so kind of you to help me.

Have a nice day !

Post Reply