在 Office Web Components 图表中对日期值进行分组
我怎样才能格式化&类别轴中的组日期?
我尝试用这段代码来做到这一点:
With ChartSpace.Charts(0).Axes(chAxisPositionCategory)
.NumberFormat = "mmm yyyy"
.GroupingType = chAxisGroupingManual
End With
但我得到的只是“无效参数”。
如果我写这个:
debug.print ChartSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat
我得到“常规”
,然后如果我写:
ChartSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat = "General"
它是“无效参数”!!!
这是使用 OWC11 的 MS Access 中的 VBA 代码。我已将数据绑定到包含 3 列的 SQL 表:
Field1 varchar(200),
Date1 datetime, --can't use Date type or the chart won't recognise as date!!
Value1 int
我一直在寻求帮助,其他人也有这个问题,但没有人有答案 - 除了不能解决问题的替代方案。我有一个在 html 中工作但使用硬编码数据的 MS 示例。我需要使用所有基于时间的 X 轴分组函数,但无法超越简单的数字格式。
添加评论:发现这现在可以工作:
.Charts(0).Axes(chAxisPositionCategory).CategoryLabels.PivotAxis.Fields(0).NumberFormat = "mmm yyyy"
但仍然无法进行分组。
How can I format & group dates in the category axes?
I try to do it with this code:
With ChartSpace.Charts(0).Axes(chAxisPositionCategory)
.NumberFormat = "mmm yyyy"
.GroupingType = chAxisGroupingManual
End With
but all that I get is "invalid parameter".
If I write this:
debug.print ChartSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat
I get "General"
and then if I write:
ChartSpace.Charts(0).Axes(chAxisPositionCategory).NumberFormat = "General"
it's "invalid parameter"!!!
This is VBA code in MS Access using OWC11. I've bound the data to an SQL Table with 3 columns:
Field1 varchar(200),
Date1 datetime, --can't use Date type or the chart won't recognise as date!!
Value1 int
I've been searching for help and others have this problem but no one has had an answer - except alternatives that don't fix the problem. I enve have a MS example that works in html but uses hardcoded data. I need to use all the time based X axis grouping functions but can't get past a simple number format.
add comment: discovered that this will now work:
.Charts(0).Axes(chAxisPositionCategory).CategoryLabels.PivotAxis.Fields(0).NumberFormat = "mmm yyyy"
still can't do the grouping though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到这已经很旧了,但因为它仍然没有答案并且可搜索:
您可以通过使用 x 轴上的时间刻度选项在 OWC11 中按日期进行分组:
默认行为是对日期进行分组,请使用 GroupingNone 枚举将其关闭。
@David-W-Fenton:OWC11 已弃用,但延长支持期至 2014 年,并且仍然可以下载。从来没有一款 MS 能够替代它们并具有所有功能。 .NET 3.5 的图表控件不允许最终用户以相同的方式操作图表。由于安全问题,我不会在网站中使用 OWC,但我在内部 WinForms 应用程序中使用它们。我不知道还有哪个免费图表控件可以实现与 OWC 相同级别的运行时图表操作。 (很抱歉在答案中添加评论,但我还没有评论的权限)。
I realize this is old but since it is still unanswered and searchable:
You can group by dates in OWC11 by using the timescale option on the x axis:
The default behavior is to group the dates, use the GroupingNone enum to turn that off.
@David-W-Fenton: OWC11 is depreceated but is in extended support until 2014 and still downloadable. There has never been a MS replacement for them that has all the functionality. The chart controls for .NET 3.5 don't allow the end user to manipulate the chart in the same way. I would not use OWC in a website due to security issues, but I use them in internal WinForms apps. I don't know of another free chart control that allows the same level of runtime chart manipulation as OWC. (Sorry for adding a comment to an answer but I don't have the priviledge to comment yet).