/// <summary> /// Zooming into the chart /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textCanvas_MouseWheel(object sender, MouseWheelEventArgs e) { if (IsBubbleChart) { return; } double delta = e.Delta; Point a = Mouse.GetPosition(chartCanvas); Point max = cs.NormalizePoint(new Point(Xmax, Ymax)); Point min = cs.NormalizePoint(new Point(Xmin, Ymin)); double diffX = Math.Round((cs.Xmax - cs.Xmin) / 12, 15); double diffY = Math.Round((cs.Ymax - cs.Ymin) / 12, 15); double posRelativeX = 0; double posRelativeY = 0; try { posRelativeX = Math.Abs(max.X - a.X) / Math.Abs(min.X - a.X); posRelativeY = Math.Abs(max.Y - a.Y) / Math.Abs(min.Y - a.Y); } catch { } if (delta > 0) { Xmax -= diffX * (IsXLog ? Math.Pow(10, 1 / posRelativeX) : posRelativeX); Xmin += diffX / (IsXLog ? diffX : posRelativeX) * (IsXLog ? Xmin / 8 : 1); Ymax -= diffY * (IsYLog ? Math.Pow(10, 1 / posRelativeY) : posRelativeY); Ymin += diffY / (IsYLog ? diffY : posRelativeY) * (IsYLog ? Ymin / 8 : 1); } else { Xmax += diffX * (IsXLog ? Math.Pow(10, 1 / posRelativeX) : posRelativeX); Xmin -= diffX / (IsXLog ? diffX : posRelativeX) * (IsXLog ? Xmin / 8 : 1); Ymax += diffY * (IsYLog ? Math.Pow(10, 1 / posRelativeY) : posRelativeY); Ymin -= diffY / (IsYLog ? diffY : posRelativeY) * (IsYLog ? Ymin / 8 : 1); } drawing = ResizeChart(); }