Hello Pasi
Thank you for your fast answer. Your idea is good, but I've a problem with the reset from the zoom. I've the following methods for each axis:
Code: Select all
/// <summary>
/// Update the min and the max value if they are larger than the current one.
/// </summary>
/// <param name="min">
/// The min value from the new points.
/// </param>
/// <param name="max">
/// The max value from the new points.
/// </param>
public void UpdateMinMax(double min, double max)
{
bool updateMax = false;
bool updateMin = false;
if (max > _max)
{
_max = max;
_lightningChartAxisXYBase.RangeRevertMaximum = _max;
updateMax = _autoScale && !_zoomed && !_panned;
}
if (min < _min || (!_includeZero && _min == 0))
{
_min = min;
_lightningChartAxisXYBase.RangeRevertMinimum = _min;
updateMin = _autoScale && !_zoomed && !_panned;
}
if (updateMin && updateMax)
{
_lightningChartAxisXYBase.SetRange(_min, _max);
}
else if (updateMax)
{
_lightningChartAxisXYBase.Maximum = _max;
}
else if (updateMin)
{
_lightningChartAxisXYBase.Minimum = _min;
}
}
private void LightningChartAxisBaseOnRangeChanged(double newMin, double newMax, Arction.WPF.LightningChartUltimate.Axes.AxisBase axis, ref bool cancelRendering)
{
_zoomed = false;
_panned = false;
if ((newMax - newMin) != (_max - _min))
{
_zoomed = true;
}
else if (newMin != _min)
{
_panned = true;
}
}
When I reset the zoom (rectangle with the mouse), I've the following values (y-axis):
(this._lightningChartAxisXYBase).RangeRevertMaximum 1.014568843
(this._lightningChartAxisXYBase).RangeRevertMinimum 0.900584273
_max 1.014568843
_min 0.900584273
newMax 1.0173329030115472
newMin 0.8980834567990762
newMax-_max 0.0027640600115472758
_min-newMin 0.0025008162009237944
There is a margin or something else. With a delta, it works, but that's not the correct solution.
Code: Select all
private void LightningChartAxisBaseOnRangeChanged(double newMin, double newMax, Arction.WPF.LightningChartUltimate.Axes.AxisBase axis, ref bool cancelRendering)
{
_zoomed = false;
_panned = false;
if (Math.Abs((newMax - newMin) - (_max - _min)) > 0.008)
{
_zoomed = true;
}
else if (Math.Abs(newMin - _min) > 0.008)
{
_panned = true;
}
}
I've disabled the AutoYFit and MarginPixels, but nothing works.
Code: Select all
_lightningChart.ViewXY.ZoomPanOptions.AutoYFit.Enabled = false;
_lightningChart.ViewXY.ZoomPanOptions.AutoYFit.MarginPercents = 0;
_lightningChart.ViewXY.ZoomPanOptions.ViewFitYMarginPixels = 0;
Do you have an idea for my problem?