Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual Studio、图表、x轴点名称_C#_Sql_Charts - Fatal编程技术网

C# Visual Studio、图表、x轴点名称

C# Visual Studio、图表、x轴点名称,c#,sql,charts,C#,Sql,Charts,我正在创建一个小程序,通过图表显示每个月的销售总额,我需要通过我的SQL响应名称(2012'7、2012'8、2012'9)调用X轴点(1、2、3、4、5),但找不到如何执行此操作 代码: 如果我没弄错,你可以用这个: Chart1.ChartAreas(0).AxisX.CustomLabels.Add(0.5, 1.5, "1"); Chart1.ChartAreas(0).AxisX.CustomLabels.Add(1.5, 2.5, "2");

我正在创建一个小程序,通过图表显示每个月的销售总额,我需要通过我的SQL响应名称(2012'7、2012'8、2012'9)调用X轴点(1、2、3、4、5),但找不到如何执行此操作

代码:


如果我没弄错,你可以用这个:

Chart1.ChartAreas(0).AxisX.CustomLabels.Add(0.5, 1.5, "1");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(1.5, 2.5, "2");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(2.5, 3.5, "3");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(3.5, 4.5, "4");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(4.5, 5.5, "5");

前两个数字决定这些标签将传播多远。第三个是标签本身。

我可能也能帮上忙,但我不明白“我需要用我的SQL响应名称(2012'7、2012'8、2012'9)来调用X轴点(1、2、3、4、5)”谢谢,抱歉有点难以理解的解释!)chart1.ChartAreas[“ChartArea1”].AxisX.CustomLabels.Add(i+0.5,i+1.5,sqlReader[“年]).ToString()+'\''+sqlReader[“月”].ToString();作品;)非常感谢。
Chart1.ChartAreas(0).AxisX.CustomLabels.Add(0.5, 1.5, "1");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(1.5, 2.5, "2");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(2.5, 3.5, "3");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(3.5, 4.5, "4");
            Chart1.ChartAreas(0).AxisX.CustomLabels.Add(4.5, 5.5, "5");