我对WPF图表库有一个奇怪的问题,即
System.Windows.Controls.DataVisualization.Charting
对于某些数据,该图表似乎正确显示,但对于总和数据,x轴行交替出现在上下位置。下面是X轴样式。和制图区域样式。下面是图表代码以及x轴的标签。
但是有时正确。当呈现不同的数据时。 我没有对XAML进行任何更改。
<charting:Chart x:Name="mcChart" Width="660" HorizontalAlignment="Stretch" Padding="0"
Background="White" FontFamily="Lato" BorderBrush="White" BorderThickness="0">
<charting:Chart.LegendStyle>
<Style TargetType="{x:Type datavis:Legend}">
<Setter Property="Width" Value="0" />
</Style>
</charting:Chart.LegendStyle>
<charting:Chart.PlotAreaStyle>
<Style TargetType="Grid">
<Setter Property="Background" Value="White" />
</Style>
</charting:Chart.PlotAreaStyle>
<charting:Chart.Style>
<Style TargetType="charting:Chart">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:Chart">
<Border Background="{TemplateBinding Background}" BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--<datavis:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}" />-->
<!-- Use a nested Grid to avoid possible clipping behavior resulting from ColumnSpan+Width=Auto -->
<Grid Grid.Row="1" Margin="0,15,0,15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<datavis:Legend x:Name="Legend" Style="{TemplateBinding LegendStyle}" Grid.Column="1" />
<chartingprimitives:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}">
<Grid Canvas.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" />
<Border Canvas.ZIndex="10" BorderBrush="White" BorderThickness="0" />
</chartingprimitives:EdgePanel>
</Grid>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</charting:Chart.Style>
<charting:LineSeries Title="" IsSelectionEnabled="True"
IndependentValueBinding="{Binding Key}"
DependentValueBinding="{Binding Value}" Background="White"
PolylineStyle="{StaticResource GooglePolylineStyle}"
DataPointStyle="{StaticResource GoogleLineDataPointStyle}" Margin="0,0,0,10">
<charting:LineSeries.DependentRangeAxis>
<charting:LinearAxis
x:Name="systolic_chart_yaxis"
Orientation="Y" MajorTickMarkStyle="{StaticResource ChartMajorTickMarkStyle}"
ShowGridLines="True"/>
</charting:LineSeries.DependentRangeAxis>
<!--<charting:LineSeries.IndependentAxis>
<charting:DateTimeAxis
Orientation="X" MajorTickMarkStyle="{StaticResource ChartMajorTickMarkStyle}"
Name="mainchart_timeaxis"
ShowGridLines="False"
>
</charting:DateTimeAxis>
</charting:LineSeries.IndependentAxis>-->
<!-- Shared horizontal axis -->
</charting:LineSeries>
<charting:Chart.Axes>
<charting:DateTimeAxis Orientation="X" Location="Bottom" Margin="0 10 0 0"
ShowGridLines="False"
MajorTickMarkStyle="{StaticResource ChartMajorTickMarkStyle}"
AxisLabelStyle="{StaticResource DateTimeAxisLabelStyle1}"/>
</charting:Chart.Axes>
</charting:Chart>
<style x:Key="DateTimeAxisLabelStyle1" TargetType="charting:DateTimeAxisLabel">
<Setter Property="YearsIntervalStringFormat"
Value="{}{0:MM/yy}"/>
<Setter Property="MonthsIntervalStringFormat"
Value="{}{0:MM/yy}"/>
<Setter Property="DaysIntervalStringFormat"
Value="{}{0:MM/dd}"/>
<Setter Property="HoursIntervalStringFormat"
Value="{}{0:hh:mm}"/>
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="270"></RotateTransform>
</Setter.Value>
</Setter>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter>
<Setter Property="Width" Value="40"/>
</Style>