[英]label the X axis in a System.Windows.Forms.DataVisualization.Charting chart with weekdays
The x dimension of my graph is composed of double values which contain the number of minutes.我的图表的 x 维度由包含分钟数的双精度值组成。 They cover a range of 1 week.
它们涵盖了 1 周的范围。 While I have no problem with correctly displaying those values on the graph, I would like the X-axis labels to be week-days (the hour:minute precision is not important on the labels, but is present on the graph, because monday at 15:00 is a point between monday and tuesday, but placed before the points monday at 16:00, for example).
虽然我在图表上正确显示这些值没有问题,但我希望 X 轴标签是工作日(小时:分钟精度在标签上并不重要,但出现在图表上,因为星期一在15:00 是星期一和星期二之间的一个点,但例如放置在星期一 16:00 点之前)。 Any idea how I can achieve this?
知道我如何实现这一目标吗?
PS: the mentioned values in minutes are obtained from: #(day of week)*24*60 + hours*60 + minutes, where #(day of week) = 0 for monday, 1 for tuesday, ... PS:提到的分钟值来自:#(星期几)*24*60 + 小时*60 + 分钟,其中#(星期几) = 0 表示星期一,1 表示星期二,...
I have been analyzing the Microsoft code samples here: Samples Environments for Microsoft Chart Controls .我一直在这里分析 Microsoft 代码示例: Microsoft Chart Controls 的示例环境。 The behavior you wish may be accomplished by either option below:
您希望的行为可以通过以下任一选项来完成:
You can set the corresponding Axis IntervalType of the ChartArea to Days - assuming it is ok for you to have to transform minutes to days.您可以将 ChartArea 的相应 Axis IntervalType 设置为 Days - 假设您可以将分钟转换为天。 You state the core idea here is to have a "time" based graph, no matter whether its minutes or days simply divide minutes by /(60[minutes]*24[hours])
你在这里陈述的核心思想是有一个基于“时间”的图表,无论是分钟还是天,只需将分钟除以 /(60[minutes]*24[hours])
Your desire for bigger time spans can be accomplished by calculating minutes related to a fixed start time/date.您可以通过计算与固定开始时间/日期相关的分钟数来实现您对更大时间跨度的渴望。
var chartArea = new System.Windows.Forms.DataVisualization.Charting.ChartArea
{
Name = "ChartArea1",
AxisX = new System.Windows.Forms.DataVisualization.Charting.Axis
{
IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Days
}
};
//...//
chart.ChartAreas.Add(chartArea);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.