vb.net 并非所有 Xaxis 标签都显示在来自绑定数据集的图表控件上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21360845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Not All Xaxis Labels Showing On Chart Control From Bound Dataset
提问by Riples
I have a problem with a couple of various chart controls that I am trying to bind to different datasets. Basically, when I run the following query, my chart control will only show every 2nd Label on the X Axis no matter what size I make the chart.
我在尝试绑定到不同数据集的几个各种图表控件时遇到问题。基本上,当我运行以下查询时,无论我制作的图表大小如何,我的图表控件都只会显示 X 轴上的每个第二个标签。
SELECT MID(MONTHNAME(created_at),1,3) as Month, COUNT(created_at) AS TotalCreatedCalls, COUNT(closed_at) AS TotalClosedCalls FROM call_detail WHERE DATE(created_at) BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 MONTH) AND CURDATE() GROUP BY MONTH(created_at)
However, if I remove the MONTHNAME statement and just return the MONTH, all 12 months appear fine on the X Axis Label as numbers.
但是,如果我删除 MONTHNAME 语句并只返回 MONTH,则所有 12 个月在 X 轴标签上都显示为数字。
SELECT MONTH(created_at) as Month, COUNT(created_at) AS TotalCreatedCalls, COUNT(closed_at) AS TotalClosedCalls FROM call_detail WHERE DATE(created_at) BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 MONTH) AND CURDATE() GROUP BY MONTH(created_at)
I have the same exact issue with another chart control where I am trying to show peoples names along the X Axis, but I only get every 5th name. However, I also have another chart control with pulls 7 days and shows the week name on the X Axis and that seems to work fine.
我在另一个图表控件上有同样的问题,我试图在 X 轴上显示人们的名字,但我只得到每第 5 个名字。但是,我还有另一个图表控件,可以拉 7 天并在 X 轴上显示周名称,这似乎工作正常。




回答by Manojbabu
Add this code it will help you
添加此代码它将帮助您
chart1.ChartAreas(0).AxisX.Interval = 1
chart1.ChartAreas(0).AxisX.Interval = 1

