Hi,
I want to change Axis range by Right-Drag on the Axis.
I used ViewXY.
I already used Left-Drag on the Axis to Scrolling (AxisXYBase.MouseScrolling) and RectangleZoom on innerArea (ZoomPanOptions).
But, I want to zoom-in (-out) only one Axis without MouseWheel.
Is it possible?
or, Could you add it in future updating?
Best Regard,
AxisZooming by Right-Drag
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: AxisZooming by Right-Drag
Hi Fukasawa,
by pressing Ctrl + Alt it zooms all the Y axis in the segment when clicking the left or right mouse button. But that's over the graph area, not over the axis. Maybe it helps you, I don't know.
We'll keep your suggestion on mind for future development. Thanks
by pressing Ctrl + Alt it zooms all the Y axis in the segment when clicking the left or right mouse button. But that's over the graph area, not over the axis. Maybe it helps you, I don't know.
We'll keep your suggestion on mind for future development. Thanks
LightningChart Support Team, PT
Re: AxisZooming by Right-Drag
Hi Pasi,
Thank you for your reply.
But, I want to do it without keyboard.
So then I tried it with MouseDown and MouseMove.
At constructor
field
method
I have 2 question.
Is there anything problem or improvement?
Why doesn't AxisXYBase have ValueToCoord()?
Best Regard,
Thank you for your reply.
But, I want to do it without keyboard.
So then I tried it with MouseDown and MouseMove.
At constructor
Code: Select all
YAxes.ForEach(yAx =>
yAx.MouseDown += (s, e) => Ax_MouseDown(e, yAx));
XAxes.ForEach(xAx =>
xAx.MouseDown += (s, e) => Ax_MouseDown(e, xAx));
Code: Select all
private AxisXYBase axDragged;
private Point previousMouseLocation;
Code: Select all
private void Ax_MouseDown(MouseEventArgs e, AxisXYBase ax)
{
if (e.Button != MouseButtons.Right)
return;
axDragged = ax;
previousMouseLocation = e.Location;
lChart.MouseMove += Ax_Dragging;
}
private void Ax_Dragging(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Right)
{
lChart.MouseMove -= Ax_Dragging;
return;
}
double maxValue = axDragged.Maximum;
double minValue = axDragged.Minimum;
double langeAxValue = maxValue - minValue;
int distanceMouseMove = 0;
//double langeAxCoord = axDragged.ValueToCoord(minValue) - axDragged.ValueToCoord(maxValue);
double langeAxCoord = 0d;
if (axDragged.GetType() == typeof(AxisY))
{
distanceMouseMove = previousMouseLocation.Y - e.Y;
langeAxCoord = ((AxisY)axDragged).ValueToCoord(minValue) - ((AxisY)axDragged).ValueToCoord(maxValue);
}
else
{
distanceMouseMove = previousMouseLocation.X - e.X;
langeAxCoord = ((AxisX)axDragged).ValueToCoord(minValue) - ((AxisX)axDragged).ValueToCoord(maxValue);
}
double distanceAxValue = distanceMouseMove / langeAxCoord * langeAxValue;
maxValue += distanceAxValue;
minValue -= distanceAxValue;
axDragged.SetRange(minValue, maxValue);
previousMouseLocation = e.Location;
}
Is there anything problem or improvement?
Why doesn't AxisXYBase have ValueToCoord()?
Best Regard,
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: AxisZooming by Right-Drag
That seems to work very well
CoordToValue and ValueToCoord methods are not implemented in the AxisXYBase class because X axis has additional parameter for CoordToValue. There's many differences in the axes, but mostly the properties and methods are identical.
CoordToValue and ValueToCoord methods are not implemented in the AxisXYBase class because X axis has additional parameter for CoordToValue. There's many differences in the axes, but mostly the properties and methods are identical.
LightningChart Support Team, PT