2012-04-06 86 views
0

基本上我有一個帶有多個小節系列的圖表。所有系列的獨立價值都是一樣的。所以圖表的xaxes是用相同的獨立值堆疊來呈現的。Silverlight ToolKit Chart:隱藏xaxis標籤

如果我想讓所有系列(第一個除外)xaxes的標籤不可見,我怎麼能在xaml聲明中做到這一點?

任何人都可以請給我這方面的援助嗎?

更新:

我所遇到例如用下面的代碼:

<toolkit:Chart x:Name="myChart" Width="600" Height="400"> 
<toolkit:LineSeries     
Title="Tasks" 
ItemsSource="{Binding}" 
IndependentValueBinding="{Binding Month}" 
DependentValueBinding="{Binding Task}">      
</toolkit:LineSeries> 

<toolkit:LineSeries     
Title="Benefits" 
ItemsSource="{Binding}" 
IndependentValueBinding="{Binding Month}" 
DependentValueBinding="{Binding Benefits}">    
</toolkit:LineSeries> 

<toolkit:Chart.Axes> 
<toolkit:LinearAxis Orientation="Y" Location="Left" Title="First" /> 
<toolkit:LinearAxis Orientation="Y" Location="Right" Title="Second" /> 
</toolkit:Chart.Axes>    
</toolkit:Chart> 

如果打印上面的代碼,你會看到,這兩個系列將左邊一個立足Y值。我們如何改變它,以便第一個系列將繪製左邊的Y值和第二個系列中的Y值,並與右邊的Y值進行比較。

是可能的嗎?

謝謝。

+0

是否可以共享圖表的所有XAML?我寫了一個簡單的測試應用程序,但我無法重現您的問題。 – 2012-04-06 07:31:52

+0

添加示例,希望您能展示一些方向。謝謝 – developer 2012-04-06 12:48:34

回答

2

我認爲你可以使用LineSeries對象的DependentRangeAxis屬性實現你想要的。

首先給每個Y軸一個x:Name,例如TaskAxisBenefitsAxis

然後,你可以告訴一個供LineSeries加給它的財產

DependentRangeAxis="{Binding ElementName=TaskAxis}" 

DependentRangeAxis="{Binding ElementName=BenefitsAxis}" 

酌情使用的軸。

圖表的完全XAML然後變成

<toolkit:Chart x:Name="myChart" Width="600" Height="400"> 
     <toolkit:LineSeries     
       Title="Tasks" 
       ItemsSource="{Binding Path=Data1}" 
       IndependentValueBinding="{Binding Month}" 
       DependentValueBinding="{Binding Task}" 
       DependentRangeAxis="{Binding ElementName=TaskAxis}"> 
     </toolkit:LineSeries> 
     <toolkit:LineSeries     
       Title="Benefits" 
       ItemsSource="{Binding Path=Data1}" 
       IndependentValueBinding="{Binding Month}" 
       DependentValueBinding="{Binding Benefits}" 
       DependentRangeAxis="{Binding ElementName=BenefitsAxis}"> 
     </toolkit:LineSeries> 
     <toolkit:Chart.Axes> 
      <toolkit:LinearAxis Orientation="Y" Location="Left" Title="First" x:Name="TaskAxis" /> 
      <toolkit:LinearAxis Orientation="Y" Location="Right" Title="Second" x:Name="BenefitsAxis" /> 
     </toolkit:Chart.Axes> 
    </toolkit:Chart> 

另一種方法是移動檢測LineSeries內的Axis對象。演示如何做到這一點可以找到here

+0

謝謝。這解決了我的第一個問題。但是我仍然無法將其更改爲我想要的最終版本。如果你有時間,請看看這篇文章。 http://stackoverflow.com/questions/10050691/silverlight-toolkit-chart-multiple-series-with-bar-and-line – developer 2012-04-07 00:32:27