2013-02-07 72 views
2

我需要的區域系列圖表看起來像:enter image description hereWPF圖表工具包 - 更改區域系列彩色的透明度

我成功地躲在兩軸,改變顏色,漸變畫刷。 我在改變不透明度方面仍然需要幫助,所以綠色的會在橙色的「後面」。 此外 - 如何更改圖上的小點? 如何將背景更改爲透明? 如何隱藏圖表標題?

現在它看起來是這樣的:

enter image description here

任何幫助將非常感激!

這裏是我的XAML代碼:

<LinearGradientBrush x:Key="GreenGradientBrush" StartPoint="0.5,0" EndPoint="0.5,1"> 
     <LinearGradientBrush.GradientStops> 
      <GradientStop Color="#77b31a" Offset="0.75"></GradientStop> 
      <GradientStop Color="#85d805" Offset="0.45"></GradientStop> 
     </LinearGradientBrush.GradientStops> 
    </LinearGradientBrush> 

    <LinearGradientBrush x:Key="OrangeGradientBrush" StartPoint="0.5,0" EndPoint="0.5,1"> 
     <LinearGradientBrush.GradientStops> 
     <GradientStop Color="#fff92900" Offset="0.75"></GradientStop> 
      <GradientStop Color="#ffff6115" Offset="0.45"></GradientStop> 
     </LinearGradientBrush.GradientStops> 
    </LinearGradientBrush> 

    <Style x:Key="GreenAreaSeriesStyle" TargetType="Control"> 
     <Setter Property="Background" Value="{StaticResource GreenGradientBrush}" /> 
     <Setter Property="Opacity" Value="1"></Setter> 
    </Style> 
    <Style x:Key="OrangeAreaSeriesStyle" TargetType="Control"> 
     <Setter Property="Background" Value="{StaticResource OrangeGradientBrush}" /> 
     <Setter Property="Opacity" Value="1"></Setter> 
    </Style> 

    <datavis:ResourceDictionaryCollection x:Key="MyPalette"> 
     <ResourceDictionary> 
      <Style x:Key="DataPointStyle" BasedOn="{StaticResource GreenAreaSeriesStyle}" TargetType="Control" > 
      </Style> 
     </ResourceDictionary> 
     <ResourceDictionary> 
      <Style x:Key="DataPointStyle" BasedOn="{StaticResource OrangeAreaSeriesStyle}" TargetType="Control" > 
      </Style> 
     </ResourceDictionary> 
    </datavis:ResourceDictionaryCollection> 

    <Style x:Key ="PerformanceChartMajorTickMarkStyle" TargetType="Line"> 
     <Setter Property="Visibility" Value="Collapsed" /> 
    </Style> 

</Window.Resources> 
<charting:Chart Palette="{StaticResource MyPalette}" HorizontalAlignment="Left" Margin="39,38,0,0" Name="chart1" Title="Chart Title" VerticalAlignment="Top" Width="815" Height="598" OverridesDefaultStyle="False">    
     <charting:Chart.LegendStyle> 
       <Style TargetType="datavis:Legend"> 
        <Setter Property="Width" Value="0" /> 
       </Style> 
     </charting:Chart.LegendStyle> 

     <charting:AreaSeries Name="Green" DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True" > 
      <charting:AreaSeries.IndependentAxis> 
       <charting:CategoryAxis Orientation="X" Visibility="Hidden"/> 
      </charting:AreaSeries.IndependentAxis> 
      <charting:AreaSeries.DependentRangeAxis> 
       <charting:LinearAxis Orientation="Y" Visibility="Hidden"/> 
      </charting:AreaSeries.DependentRangeAxis> 

     </charting:AreaSeries> 
     <charting:AreaSeries Name="Orange" DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True"> 
      <charting:AreaSeries.IndependentAxis> 
       <charting:CategoryAxis Orientation="X" Visibility="Hidden"/> 
      </charting:AreaSeries.IndependentAxis> 
      <charting:AreaSeries.DependentRangeAxis> 
       <charting:LinearAxis Orientation="Y" Visibility="Hidden"/> 
      </charting:AreaSeries.DependentRangeAxis> 
     </charting:AreaSeries> 
    </charting:Chart> 
+0

,如果你分享這個樣品圖片您的XAML/codebhind所以我們可以看到你已經嘗試過,並從那裏建立這將有助於。 – Maverik

+0

您是否找到解決方案?你可以請帖嗎? – Lijo

回答

2

我張貼了類似的問題,得到了以下的答案,這真的幫了我。

<ch:Chart Margin="56,21,50,72" Title="MyChart" DataContext="{Binding ElementName=Window, Mode=OneWay}" Style="{StaticResource controlStyle}" > 

       <ch:AreaSeries Name="DefaultArea" ItemsSource="{Binding Path=Key}" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}" Opacity="1" Title="111111" > 
        <ch:AreaSeries.Style> 
         <Style TargetType="ch:AreaSeries"> 
          <Setter Property="IsTabStop" Value="False"/> 
          <Setter Property="Template"> 
           <Setter.Value> 
            <ControlTemplate TargetType="ch:AreaSeries"> 
             <Canvas x:Name="PlotArea"> 
              <Path Data="{TemplateBinding Geometry}" StrokeThickness="3" Fill="Pink" Style="{TemplateBinding PathStyle}" Opacity="1" /> 
             </Canvas> 
            </ControlTemplate> 
           </Setter.Value> 
          </Setter> 
         </Style> 
        </ch:AreaSeries.Style> 
       </ch:AreaSeries> 

       <ch:AreaSeries Name="PersonnelArea" ItemsSource="{Binding Path=Key}" IndependentValueBinding="{Binding Key}" DependentValueBinding="{Binding Value}" Opacity="1" > 
        <ch:AreaSeries.Style> 
         <Style TargetType="ch:AreaSeries"> 
          <Setter Property="IsTabStop" Value="False"/> 
          <Setter Property="Template"> 
           <Setter.Value> 
            <ControlTemplate TargetType="ch:AreaSeries"> 
             <Canvas x:Name="PlotArea"> 
              <Path Data="{TemplateBinding Geometry}" StrokeThickness="3" Fill="Yellow" Style="{TemplateBinding PathStyle}" Opacity="1" /> 
             </Canvas> 
            </ControlTemplate> 
           </Setter.Value> 
          </Setter> 
         </Style> 
        </ch:AreaSeries.Style> 

       </ch:AreaSeries> 
      </ch:Chart> 

您還可以設置樣式的ressource在XAML,然後在代碼中動態地分配它後面。 這裏我的回答原來的問題: WPF AreaSeries: How to change background opacity?

相關問題