c#图表控件中带有数据点(0,1)的单条条形图

c#图表控件中带有数据点(0,1)的单条条形图,c#,charts,mschart,C#,Charts,Mschart,我对VS3.5框架中的图表控件有问题。我正在试着用x轴0和y轴1绘制一个图。但结果是绘制了一张图(1,1) 我有一种情况,我需要一个(0,1)的单条 或 结果: 条形图(1,1)代替显示(0,1)点 我补充说 Chart1.ChartAreas[""].AxisX.Minimum = 0; 仍然显示相同的结果 这太令人沮丧了:当我再加一分(1,1) 例如: 结果是: 点(0,1)和(1,1)正确的条形图 出现此问题是因为添加到图表的默认系列是条形图。为了显示数据,您必须删除条形图系列并将其替换

我对VS3.5框架中的图表控件有问题。我正在试着用x轴0和y轴1绘制一个图。但结果是绘制了一张图(1,1)

我有一种情况,我需要一个(0,1)的单条

结果:

条形图(1,1)代替显示(0,1)点

我补充说

Chart1.ChartAreas[""].AxisX.Minimum = 0;
仍然显示相同的结果

这太令人沮丧了:当我再加一分(1,1)

例如:

结果是:

点(0,1)和(1,1)正确的条形图


出现此问题是因为添加到图表的默认系列是条形图。为了显示数据,您必须删除条形图系列并将其替换为点系列。请参见下面的示例代码

// clear data from the chart
chart.Series.Clear();

// add an x-y series to the chart
var xySeries = new Charting.Series() {
    LegendText = "XY Plot",
    ChartType = Charting.SeriesChartType.Point,
    Color = Color.Brown,
    MarkerStyle = Charting.MarkerStyle.Circle,
    MarkerSize = 10
};
chart.Series.Add(xySeries);

// put your point on the series
xySeries.Points.AddXY(1, 1);

// set the axis
chart.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = Charting.ChartDashStyle.Dot;
chart.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = Charting.ChartDashStyle.Dot;
这将生成以下图表

您必须使用语句添加此
,以便在可用名称空间中包含
图表

using Charting = System.Windows.Forms.DataVisualization.Charting;

要更改X轴上的标签,必须使用数据点的
AxisLabel
属性。见下面的示例:

// put your point on the series
xySeries.Points.AddXY(0, 1);
xySeries.Points[0].AxisLabel = "0"; // <--- SET AXIS LABEL HERE
//把你的观点放在这个系列上
xySeries.Points.AddXY(0,1);

xySeries.Points[0]。AxisLabel=“0”//非常感谢你的回复。但我想用条形图。条形图是我的要求。有没有办法,我们可以在条形图中绘制点(0,1)?再次感谢,是的。。我做了同样的事情,继续前进。。。但是VisualStudio中的条形图太奇怪了…为什么XYcoordinate值不能给出正确的结果。。。
// clear data from the chart
chart.Series.Clear();

// add an x-y series to the chart
var xySeries = new Charting.Series() {
    LegendText = "XY Plot",
    ChartType = Charting.SeriesChartType.Point,
    Color = Color.Brown,
    MarkerStyle = Charting.MarkerStyle.Circle,
    MarkerSize = 10
};
chart.Series.Add(xySeries);

// put your point on the series
xySeries.Points.AddXY(1, 1);

// set the axis
chart.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = Charting.ChartDashStyle.Dot;
chart.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = Charting.ChartDashStyle.Dot;
using Charting = System.Windows.Forms.DataVisualization.Charting;
// put your point on the series
xySeries.Points.AddXY(0, 1);
xySeries.Points[0].AxisLabel = "0"; // <--- SET AXIS LABEL HERE