【问题标题】:Silverlight ToolKit Chart: Hide xaxis labelsSilverlight ToolKit 图表:隐藏 xaxis 标签
【发布时间】:2012-04-06 04:15:47
【问题描述】:

基本上我有一个包含多个条形系列的图表。所有系列的独立值都相同。因此,图表的 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 值绘制。

这可能吗?

谢谢。

【问题讨论】:

  • 是否可以共享图表的所有 XAML?我写了一个简单的测试应用程序,但我无法重现您的问题。
  • 示例添加,希望你能指出一些方向。谢谢

标签: silverlight charts


【解决方案1】:

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

首先,给每个 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>

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多