如何在实时图表中显示轴部分工具提示和重新定位数据标签



1( 我希望在实时图表中显示轴部分的工具提示,但似乎无法弄清楚如何做到这一点。以下是我目前使用实时图表的代码。

<Grid Grid.Column="1" Margin="15, 15, 15, 15" MaxHeight="500">
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=Border}" />
</Grid.OpacityMask>
<Grid.Resources>
<Style TargetType="lvc:LineSeries">
<Setter Property="Stroke" Value="Black"/>
<Setter Property="LineSmoothness" Value="0"/>
<Setter Property="Fill" Value="Transparent"/>
<Setter Property="PointForeground" Value="White"/>
</Style>
<Style TargetType="lvc:Axis">
<Setter Property="ShowLabels" Value="True"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<Style TargetType="lvc:Separator">
<Setter Property="Stroke" Value="DimGray"/>
<Setter Property="StrokeDashArray" Value="2"/>
<Setter Property="IsEnabled" Value="True"/>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Border x:Name="Border" Grid.Row="0" Grid.RowSpan="3" CornerRadius="5" Background="Gray"/>
<TextBlock Grid.Row="0" TextAlignment="Center" Padding="10, 10, 0, 5" Foreground="Black" FontSize="24" FontWeight="Bold">
Process Capability
</TextBlock>
<TextBlock Grid.Row="1" TextAlignment="Center" Foreground="Black" Padding="0,0,0,20">Sample Values</TextBlock>
<lvc:CartesianChart Series="{Binding SeriesCollection}" Grid.Row="2" Margin="0, 0, 0, 0" Foreground="Black" Zoom="X">
<lvc:CartesianChart.AxisY>
<lvc:Axis Name="Y" MinValue="{Binding MinimumY}" MaxValue="{Binding MaximumY}" LabelFormatter="{Binding Formatter}">
<lvc:Axis.Sections>
<lvc:AxisSection Value="{Binding LowerSpecificationLimit}" StrokeThickness="3" Stroke="Black" DataLabel="True" ToolTip="HELLOOOO" Panel.ZIndex="99"/>
<lvc:AxisSection Value="{Binding UpperSpecificationLimit}" StrokeThickness="3" Stroke="Black" DataLabel="True" ToolTip="{Binding LowerSpecificationLimitToolTip}"/>
<lvc:AxisSection Value="{Binding NominalConstraint}" StrokeThickness="1.5" Stroke="DarkGray" DataLabel="True" StrokeDashArray="5" ToolTip="{Binding LowerSpecificationLimitToolTip}"/>
<lvc:AxisSection Value="{Binding LowerTolerance}" StrokeThickness="1.5" Stroke="DarkGray" DataLabel="True" StrokeDashArray="5" ToolTip="{Binding LowerSpecificationLimitToolTip}"/>
<lvc:AxisSection Value="{Binding UpperTolerance}" StrokeThickness="1.5" Stroke="DarkGray" DataLabel="True" StrokeDashArray="5" ToolTip="{Binding LowerSpecificationLimitToolTip}"/>
</lvc:Axis.Sections>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Grid>

2(我还希望能够更改数据标签的位置。在下图中,您可以看到轴部分数据标签与常规轴的数据标签重叠。为了防止它重叠,我想将轴部分的数据标签放置在图表的右侧而不是左侧。 图像

任何帮助,不胜感激。谢谢。

对于您的第二个问题,使用合并轴可能会有所帮助。(Axis.IsMerged属性设置为true

参考: https://lvcharts.net/App/examples/v1/wpf/Axes

相关内容

  • 没有找到相关文章