Page 1 of 1

Making mouse drag function

Posted: Thu Nov 03, 2016 10:03 am
by copilot90
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!

Re: Making mouse drag function

Posted: Thu Nov 03, 2016 6:24 pm
by ArctionPasi
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 13421 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? :)

Re: Making mouse drag function

Posted: Fri Nov 18, 2016 7:09 am
by copilot90
Thank you for the reply

It's so kind of you to help me.

Have a nice day !