There is MSChart, in the network I found how to make it so that the graph output area increases with the addition of data, found an example of how to show the scroll bars on the axes, so that you can scroll the graph. Now you need to make the movement of the graph with the mouse hold the mouse button on the graph output area and drag it in different directions and so that the graph itself also moves. I just can’t figure out what needs to be done for this, the control is very complicated.
1 answer
Thank you all for participating, it turned out like this, it works:
private bool isLeftButtonPressed = false; private Point mouseDown = Point.Empty; private void chart1_MouseMove(object sender, MouseEventArgs e) { if (isLeftButtonPressed) { var result = chart1.HitTest(eX, eY); if (result.ChartElementType == System.Windows.Forms.DataVisualization.Charting.ChartElementType.PlottingArea) { var oldXValue = result.ChartArea.AxisX.PixelPositionToValue(mouseDown.X); var newXValue = result.ChartArea.AxisX.PixelPositionToValue(eX); chart1.ChartAreas[0].AxisX.ScaleView.Position += oldXValue - newXValue; mouseDown.X = eX; } } } private void chart1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { isLeftButtonPressed = false; mouseDown = Point.Empty; } } private void chart1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { isLeftButtonPressed = true; mouseDown = e.Location; } }
|