GridLines背后的OxyPlot AreaSeries

时间:2017-09-27 14:51:51

标签: c# wpf xaml charts oxyplot

我使用了AreaSeries在图表上显示彩色区域。

enter image description here

彩色区域呈现在网格线的顶部。有没有办法将网格线带到前面?

此图在WPF项目的XAML中定义。这是配置:

    <oxy:Plot Grid.Row="1"
          Margin="0"
          HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch"
          PlotType="XY"
          TitleFontSize="11"
          IsLegendVisible="False"
          Title="{Binding Channel.Name}"
          InvalidateFlag="{Binding Refresh}">
      <oxy:Plot.Axes>
        <oxy:LinearAxis Key="yAxis"
                    IsZoomEnabled="False"
                    IsPanEnabled="False"
                    Position="Left"
                    MajorGridlineStyle="Dot"
                    MajorGridlineColor="LightGray"
                    Title="Speed [m/s]"
                    Maximum="{Binding SpeedXDistance_MaxY}"/>
        <oxy:LinearAxis Key="xAxis"
                    IsZoomEnabled="False"
                    IsPanEnabled="False"
                    Position="Bottom"
                    MajorGridlineStyle="Dot"
                    MajorGridlineColor="LightGray"
                    Title="Distance [m]"
                    Maximum="{Binding SpeedXDistance_MaxX}"/>
      </oxy:Plot.Axes>
      <oxy:Plot.Series>
        <oxy:LineSeries ItemsSource="{Binding SpeedXDistancePoints}"
                        DataFieldX="X"
                        DataFieldY="Y"
                        StrokeThickness="1"
                        MarkerSize="0"
                        LineStyle="Solid"
                        Color="Blue"
                        MarkerType="None"/>
        <oxy:AreaSeries ItemsSource="{Binding SpeedXDistanceUpperLimit}"
                        Fill="AliceBlue"
                        DataFieldX="X"
                        DataFieldY="Y"
                        StrokeThickness="1"
                        MarkerSize="0"
                        LineStyle="Solid"
                        Color="DarkGray"
                        MarkerType="None"/>
      </oxy:Plot.Series>
    </oxy:Plot>

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:5)

改为创建透明色:

enter image description here

<强> XAML:

<Window x:Class="WpfApp69.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:oxy="http://oxyplot.org/wpf"
        xmlns:local="clr-namespace:WpfApp69"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <x:Array x:Key="array1" Type="{x:Type Point}">
            <Point X="0.2" Y="0" />
            <Point X="0.4" Y="15" />
            <Point X="0.6" Y="10" />
            <Point X="0.8" Y="20" />
            <Point X="1.0" Y="0" />
        </x:Array>

        <Color x:Key="MyColor" A="64" R="135" G="206" B="250"/>
    </Window.Resources>

    <Grid>
        <oxy:Plot Grid.Row="1"
          Margin="0"
          HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch"
          PlotType="XY"
          TitleFontSize="11"
          IsLegendVisible="False"
          Title="Sample Plot">
            <oxy:Plot.Axes>
                <oxy:LinearAxis Key="yAxis"
                    IsZoomEnabled="False"
                    IsPanEnabled="False"
                    Position="Left"
                    MajorGridlineStyle="Dot"
                    MajorGridlineColor="Gray"
                    Title="Speed [m/s]"
                    Maximum="20"/>
                <oxy:LinearAxis Key="xAxis"
                    IsZoomEnabled="False"
                    IsPanEnabled="False"
                    Position="Bottom"
                    MajorGridlineStyle="Dot"
                    MajorGridlineColor="Gray"
                    Title="Distance [m]"
                    Maximum="1.0"/>
            </oxy:Plot.Axes>
            <oxy:Plot.Series>
                <oxy:AreaSeries ItemsSource="{StaticResource array1}"
                        Fill="{StaticResource MyColor}"
                        DataFieldX="X"
                        DataFieldY="Y"
                        StrokeThickness="1"
                        MarkerSize="0"
                        LineStyle="Solid"
                        Color="DarkGray"
                        MarkerType="None"/>
            </oxy:Plot.Series>
        </oxy:Plot>
    </Grid>
</Window>