0

基本上我有一个包含多个条形系列的图表。所有系列的独立值都相同。因此,图表的 xaxes 以堆叠的相同独立值呈现。

如果我想让所有系列(第一个除外)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 值上。

那可能吗?

谢谢。

4

1 回答 1

2

DependentRangeAxis我认为你可以使用对象的属性来实现你想要的LineSeries

首先,给每个 Y 轴一个x:Name,例如TaskAxisBenefitsAxis

然后,您可以通过向 LineSeries 添加属性来告诉 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>

另一种方法是Axis在 LineSeries 内移动对象。可以在此处找到如何执行此操作的演示。

于 2012-04-06T13:57:01.943 回答