/// <summary> /// 检查是否可以调整。确保可以调整。 /// </summary> /// <param name="ScaleView"></param> private static void CheckZoomable(AxisScaleView ScaleView) { if (!ScaleView.IsZoomed) { ScaleView.Zoom(ScaleView.ViewMinimum, ScaleView.ViewMaximum * 0.999999999); } }
private void TChart_MouseWheel(object sender, MouseEventArgs e) { if (this.Series.Count == 0 || this.Series[0].Points.Count < 3) { return; } AxisScaleView view1 = this.ChartAreas[0].AxisX.ScaleView; double total = Math.Abs(e.Delta); double interval = 1; for (int i = 0; i < total; i += 120) { if (e.Delta > 0) { interval *= 0.8; } else { interval *= 1.2; } } if (interval > 1 && (view1.ViewMaximum - view1.ViewMinimum) > (this.ChartAreas[0].AxisX.Maximum - this.ChartAreas[0].AxisX.Minimum) * 0.8) { view1.ZoomReset(); this.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; UpdateLine(); return; } this.ChartAreas[0].CursorX.IsUserSelectionEnabled = false; if (this.ChartAreas[0].AxisX.CustomLabels.Count == 0) { return; } string v1 = this.ChartAreas[0].AxisX.CustomLabels[0].Text; double value; if (this.Series[0].XValueType == ChartValueType.Time) { var v2 = v1.Split(' ')[0].Split(':'); value = v2[0].ToInt() * 60 + v2[1].ToInt(); } else { value = v1.ToDouble(); } double min2 = value - (value - view1.ViewMinimum) * interval; min2 = Math.Floor(min2); double max2 = value + (view1.ViewMaximum - value) * interval; max2 = Math.Ceiling(max2); if (interval < 1 && max2 - min2 < minInterval * 3) { return; } view1.Zoom(min2, max2); UpdateShow(); UpdateLine(); }
private void Zoom(AxisScaleView asv, double coeff) { double shift = coeff * (asv.ViewMaximum - asv.ViewMinimum); asv.Zoom(asv.ViewMinimum + shift, asv.ViewMaximum - shift); }