使用SciChart v5.1.0.11299,我试图以TimeSpanAxis作为X轴显示VerticalLineAnnotations。我可以使用NumericAxis显示垂直线,但不能使用TimeSpanAxis显示垂直线。
<s:SciChartSurface ChartTitle="Values vs Time">
<s:SciChartSurface.XAxis>
<s:TimeSpanAxis AxisTitle="Time">
<s:TimeSpanAxis.VisibleRange>
<s:TimeSpanRange Min="00" Max="00:10:00"/>
</s:TimeSpanAxis.VisibleRange>
</s:TimeSpanAxis>
</s:SciChartSurface.XAxis>
<s:SciChartSurface.YAxis>
<s:NumericAxis AxisTitle="Values"/>
</s:SciChartSurface.YAxis>
<s:SciChartSurface.Annotations>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="00:00:10"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="00:00:20"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="00:01:00"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="00:02:00"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="00:05:00"/>
</s:SciChartSurface.Annotations>
</s:SciChartSurface>
但是,作为NumericAxis的相应版本会渲染VerticalLineAnnotations:
<s:SciChartSurface ChartTitle="Values vs Not Time">
<s:SciChartSurface.XAxis>
<s:NumericAxis AxisTitle="Not Time">
<s:NumericAxis.VisibleRange>
<s:DoubleRange Min="00" Max="1000"/>
</s:NumericAxis.VisibleRange>
</s:NumericAxis>
</s:SciChartSurface.XAxis>
<s:SciChartSurface.YAxis>
<s:NumericAxis AxisTitle="Values"/>
</s:SciChartSurface.YAxis>
<s:SciChartSurface.Annotations>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="0010"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="0020"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="0100"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="0200"/>
<s:VerticalLineAnnotation Stroke="Orange" StrokeThickness="1" X1="0500"/>
</s:SciChartSurface.Annotations>
</s:SciChartSurface>
这一定是可能的,但我找不到与NumericAxis有关的必要差异的例子?
提前致谢。
答案 0 :(得分:0)
我认为这里的问题是你无法在Xaml中轻松设置TimeSpan。
VerticalLineAnnotation.X1的属性是IComparable,因此Xaml编译器将其作为字符串选取。
尝试在代码中设置X1为TimeSpan,附加行为或绑定到ViewModel