Silverlight工具包图表:隐藏x轴标签



基本上我有一个带有多个条形序列的图表。所有系列的独立值都是相同的。因此,图表的xax是用相同的独立值堆叠呈现的。

如果我想让所有系列(除了第一个)的xax标签都不可见,我如何在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值打印。

这可能吗?

谢谢。

我认为可以使用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对象。可以在这里找到如何做到这一点的演示。

最新更新