0

图表是由代码创建的。但我不能禁用图表中的垂直线。这是创建图表的代码:

        public void CreateChart() {
        CleanChart();

        visiChart = new Chart()
        {
            ToolTipEnabled = true,
            Width = 400,
            Height = 200,
            Padding = new Thickness(0),
            Margin = new Thickness(0, 6, 0, -12),
            Background = new SolidColorBrush(Colors.White),
        };

        ChartGrid grid = new ChartGrid()
        {
            Enabled = false
        };
        DataSeries dataSeries = new DataSeries();
        DataPoint dataPoint;
        Axis yAx = new Axis()
        {
            AxisLabels = new AxisLabels() { Enabled = false },
            Grids = new ChartGridCollection() {grid}
        };

        int i = 0;
        var deps = App.CurrentAgreement.Deposits.Deposit.Where(x => x.DepositIliv + x.DepositLink > 0).ToList();

        foreach (var dep in deps) {
            dataPoint = new DataPoint();
            dataPoint.YValue = dep.DepositIliv + dep.DepositLink + dep.UValue + dep.WarrantyValue;
            dataPoint.XValue = i;
            i++;
            dataPoint.LabelText = dataPoint.YValue.Out();
            dataPoint.AxisXLabel = DateTime.Parse(dep.DepositDate).ToString("MMM yyyy");
            dataPoint.MouseLeftButtonUp += dataPoint_MouseLeftButtonUp;
            dataSeries.DataPoints.Add(dataPoint);
        }
        dataSeries.LabelEnabled = true;
        dataSeries.RenderAs = RenderAs.Column;
        dataSeries.Color = new SolidColorBrush(Colors.Green);
        visiChart.Series.Add(dataSeries);
        visiChart.AxesY.Add(yAx);

        ChartPlaceHolder.Children.Add(visiChart);
    }

但我不需要可见的垂直线。这是一个图表屏幕。

图表

我怎样才能禁用线路?请帮帮我。

4

1 回答 1

0

您还必须从 AxisX 禁用网格线。

例子:

ChartGrid grid = new ChartGrid()
{
    Enabled = false
};

Axis xAx = new Axis();
xAx.Grids.Add(grid);
visiChart.AxesX.Add(xAx);
于 2013-04-15T04:57:24.337 回答