![](/img/trans.png)
[英]How to reuse a Style with ContentControl to make code more compact?
[英]How to make points more compact using fastpoint chart in
您可以通过设置每个Axis
的Minimum
和Maximum
来控制每个Axis
的数据值范围。
语法是:
someChart.ChartAreas[CAIndexOrName].AxisX.Minimum = someDoubleValue;
让我们准备一个图表来显示一天:
Axis ax = chart.ChartAreas[0].AxisX; // a short reference
ax.IntervalType = DateTimeIntervalType.Hours;
ax.Interval = 1;
要将属性设置为某些DateTime
值,您需要将它们转换为双精度值; 对于此转换,有两个内置函数: DateTime.ToOADate
和,以反转DateTime.FromOADate
这使得x轴显示24小时:
DateTime dt = DateTime.Today;
ax.Minimum = dt.ToOADate();
ax.Maximum = (dt.AddHours(24)).ToOADate();
ax.LabelStyle.Format = "H:mm"; // optional
您还可能希望控制系列值的数据类型:
Series s = chart.Series[0];
s.XValueType = ChartValueType.DateTime; // or some other type, maybe Time
请注意,您还可以控制每个轴上的Labels
Interval
和TickMarks
和Gridlines
,但也可以设置Offset
以稍早或稍后启动它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.