我试图抵消我的majorGrids和LabelStyle。当我设置一个间隔时,它工作正常,但当我试图抵消该间隔时,我无法使其工作。
绘制的数据沿x轴具有固定点。它们总是相同且对数(不确定是否相关)。
无论IntervalOffset的价值如何,我都尝试过它总是一样的。我也尝试过设置IntervalOffsetType和Interval类型(我在代码中尝试过不同的东西)。我想要的是标签和majorGridLines从63开始并重复每三个点。
以下是一些代码:
包含图表的表单中的代码
private void setupChart()
{
// Setup Chart
chartPathData.Legends[0].Docking = Docking.Bottom;
chartPathData.ChartAreas[0].AxisX.LabelStyle.IntervalOffset = 1;
chartPathData.ChartAreas[0].AxisX.LabelStyle.Interval = 3;
chartPathData.ChartAreas[0].AxisX.LabelStyle.IntervalType = 0;
chartPathData.ChartAreas[0].AxisX.LabelStyle.IntervalOffsetType = 0;
chartPathData.ChartAreas[0].AxisX.MajorGrid.IntervalOffset = 1;
chartPathData.ChartAreas[0].AxisX.MajorGrid.Interval = 3;
chartPathData.ChartAreas[0].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Number;
chartPathData.ChartAreas[0].AxisX.MajorGrid.IntervalOffsetType = DateTimeIntervalType.Number;
chartPathData.ChartAreas[0].AxisY.Minimum = 0;
chartPathData.ChartAreas[0].AxisY.Maximum = 100;
}
private void GraphPath(Pathdata pathData, string pathName, Color color)
{
var seriesPath = new Series
{
Name = pathName,
IsVisibleInLegend = true,
IsXValueIndexed = true,
Color = color,
ChartType = SeriesChartType.FastLine
};
chartPathData.Series.Add(seriesPath);
// GraphPath just creates a graphable version
// of pathData assigning X values at the corresponding
// properties (creating x,y points)
GraphPath graphPath = new GraphPath(pathData);
foreach (GraphPoint point in graphPath.GraphPoints)
{
seriesPath.Points.AddXY(point.x, point.y);
}
}
DataPath类
public class DataPath
{
public ThirdOctaveValue A50 { get; set; }
public ThirdOctaveValue A63 { get; set; }
public ThirdOctaveValue A80 { get; set; }
public ThirdOctaveValue A100 { get; set; }
public ThirdOctaveValue A125 { get; set; }
public ThirdOctaveValue A160 { get; set; }
public ThirdOctaveValue A200 { get; set; }
public ThirdOctaveValue A250 { get; set; }
public ThirdOctaveValue A315 { get; set; }
public ThirdOctaveValue A400 { get; set; }
public ThirdOctaveValue A500 { get; set; }
public ThirdOctaveValue A630 { get; set; }
public ThirdOctaveValue A800 { get; set; }
public ThirdOctaveValue A1000 { get; set; }
public ThirdOctaveValue A1250 { get; set; }
public ThirdOctaveValue A1600 { get; set; }
public ThirdOctaveValue A2000 { get; set; }
public ThirdOctaveValue A2500 { get; set; }
public ThirdOctaveValue A3150 { get; set; }
public ThirdOctaveValue A4000 { get; set; }
public ThirdOctaveValue A5000 { get; set; }
}
以下是结果