1

我试图让 StripLines 显示在我放在一起的图表上,但到目前为止,我对让它们显示一点也不高兴。

    Public Sub AddExtraChartData(ByVal fromTime As DateTime, ByVal toTime As DateTime)
    ' create a background strip line for any records held within here
    Dim sl As New Charting.StripLine()

    sl.IntervalOffset = fromTime.ToOADate()
    sl.IntervalOffsetType = Charting.DateTimeIntervalType.Minutes
    Console.WriteLine("strip_interval_offset: " + sl.IntervalOffset.ToString())

    sl.BackColor = Color.Red
    sl.StripWidth = toTime.ToOADate() - fromTime.ToOADate()

    Console.WriteLine("Length of downtime: " + sl.StripWidth.ToString())
    sl.StripWidthType = Charting.DateTimeIntervalType.Minutes

    Chart1.ChartAreas(0).AxisX.StripLines.Add(sl)

    Console.WriteLine("Strip Line Count in Chart1.ChartAreas(0): ?" + Chart1.ChartAreas(0).AxisX.StripLines.Count.ToString())

    Chart1.Invalidate()
End Sub

它应该在经过的时间间隔以“块”时间(用于机器停机时间报告)显示它们,但除了图形本身之外,什么都没有显示。我的想法是否正确,如果在原始边界之外添加一条带状线,图表会重新缩放以显示它?还是会丢失?

根据我的VS调试:

strip_interval_offset: 41493.4617361111
Length of downtime: 0.0181250000023283
Strip Line Count in Chart1.ChartAreas(0): ?5

所以他们被添加了。因为我可以删除 .Add() 并以 0 结尾。但为什么它们不显示?

其他信息。我的图表是 DateTime 格式,间隔 10 分钟,并且 XValue 被索引(将不活动时间显示为间隙)

非常感谢任何帮助,谢谢。

4

0 回答 0