C# 如何在Winforms中的图表控件中修剪x轴上的x值?

C# 如何在Winforms中的图表控件中修剪x轴上的x值?,c#,.net,winforms,visual-studio-2010,microsoft-chart-controls,C#,.net,Winforms,Visual Studio 2010,Microsoft Chart Controls,我有一个winforms应用程序,其中包含一个名为 comparisonChart 通过订阅mousewheel事件并执行以下操作,我在图表控件中实现了缩放功能 private void comparisonChartMouseWheel(object sender, MouseEventArgs e) { if (e.Delta < 0) { this.comparisonChart.ChartAreas[0].AxisX

我有一个winforms应用程序,其中包含一个名为

comparisonChart
通过订阅mousewheel事件并执行以下操作,我在图表控件中实现了缩放功能

private void comparisonChartMouseWheel(object sender, MouseEventArgs e)
    {
        if (e.Delta < 0)
        {
            this.comparisonChart.ChartAreas[0].AxisX.ScaleView.ZoomReset(0);
            this.comparisonChart.ChartAreas[0].AxisY.ScaleView.ZoomReset(0);
        }
        else if (e.Delta > 0)
        {
            double xMin = this.comparisonChart.ChartAreas[0].AxisX.ScaleView.ViewMinimum;
            double xMax = this.comparisonChart.ChartAreas[0].AxisX.ScaleView.ViewMaximum;
            double yMin = this.comparisonChart.ChartAreas[0].AxisY.ScaleView.ViewMinimum;
            double yMax = this.comparisonChart.ChartAreas[0].AxisY.ScaleView.ViewMaximum;
            double posXStart = this.comparisonChart.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X) - (xMax - xMin) / 4;
            double posXFinish = this.comparisonChart.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X) + (xMax - xMin) / 4;
            double posYStart = this.comparisonChart.ChartAreas[0].AxisY.PixelPositionToValue(e.Location.Y) - (yMax - yMin) / 4;
            double posYFinish = this.comparisonChart.ChartAreas[0].AxisY.PixelPositionToValue(e.Location.Y) + (yMax - yMin) / 4;
            this.comparisonChart.ChartAreas[0].AxisX.ScaleView.Zoom(posXStart, posXFinish);
            this.comparisonChart.ChartAreas[0].AxisY.ScaleView.Zoom(posXStart, posXFinish);
        }

    }
comparisonChart.Series[0].XValueType = ChartValueType.Int32;

但当我放大时,它再次显示十进制值。

这样的图表控件没有这种逻辑

检查问题的解决方案

希望这有帮助

编辑:与此同时,我在示例程序中使用缩放代码尝试了以下代码片段。现在显示的轴值不带小数

chart1.ChartAreas[0].AxisX.LabelStyle.Format = "0";
chart1.ChartAreas[0].AxisY.LabelStyle.Format = "0";

是的,这就是我要找的。Thanks@Kaushik-很乐意帮忙:)