【问题标题】:Remove endpoints of x-axis in MS Chart删除 MS 图表中 x 轴的端点
【发布时间】:2013-01-15 13:29:30
【问题描述】:

我有一个图表(见附图),我想删除端点“2060”和“2020”。我希望间距保持不变。但我想隐藏标签 2060 和 2020。有没有办法可以使用 MS Chart 以编程方式实现这一点?

创建轴的代码:

            var area = new ChartArea();

        chart.ChartAreas.Add(area);
        chart.ChartAreas[0].Position.X = 5;
        chart.ChartAreas[0].Position.Y = 10;
        chart.ChartAreas[0].Position.Height = 80;
        chart.ChartAreas[0].Position.Width = 80;
        chart.ChartAreas[0].AxisX.LabelStyle.Font = font10Point;
        chart.ChartAreas[0].AxisY.LabelStyle.Font = font10Point;
        chart.ChartAreas[0].AxisX.Title = "Target Date Fund";
        chart.ChartAreas[0].AxisY.Title = "% Up Capture";

        chart.ChartAreas[0].AxisX.TitleFont = font10Point;
        chart.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Transparent;
        chart.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Black;
        chart.ChartAreas[0].BorderColor = Color.Black;
        chart.ChartAreas[0].Position = new ElementPosition(0, 10, 75, 85);

        chart.Series[0].YAxisType = AxisType.Secondary;
        chart.ChartAreas[0].AxisY.LabelStyle.Enabled = false;
        chart.ChartAreas[0].AxisX.Crossing = 2060; 
        chart.ChartAreas[0].AxisX.IsReversed = true;
        area.AxisX.Minimum = 2020; 
        area.AxisX.Maximum = 2060; 
        area.AxisX.Interval = 10;
        area.AxisX.LineWidth = int.Parse("5");
        area.AxisX.MajorTickMark.LineWidth = int.Parse("5");
        area.AxisY.MajorTickMark.LineWidth = int.Parse("5");

        area.AxisY.Minimum = area.AxisY2.Minimum = 0;
        area.AxisY.Maximum = area.AxisY2.Maximum = 120;
        area.AxisY.Interval = area.AxisY2.Interval = 20;
        area.AxisY.LineWidth = int.Parse("5");

【问题讨论】:

  • 你有代码吗?请阅读faqHow to Ask
  • @Soner Gönül 对!忘记添加:)

标签: c# graph mschart


【解决方案1】:

你可以使用LabelStyle.IsEndLabelVisible属性:

area.AxisX.LabelStyle.IsEndLabelVisible = false;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多