1

階層的にグループ化されたデータシリーズがあります。この構造を反映するチャートの凡例が必要です (スクリーンショットを参照)

[編集: 潜在的なクライアント IP の問題を防ぐために画像を削除しました]

グループをオフにすると、そのすべての子軸が自然にオフになります。組み込みの軸凡例でこれを行うことは可能ですか? もしそうなら、どのようにいくつかの指針を提供できますか?(現在、私は最もかすかなアイデアを持っていないため)そうでない場合、最善の回避策は何ですか?凡例を無効にし、カスタム コントロールを実装してから、SeriesSource のバインドされたプロパティを動的に変更しますか?

4

1 に答える 1

0

SciChartLegendコントロールは、 LegendModifier.LegendDataプロパティを介して SeriesInfo の ObservableCollection にバインドすることによってデータを表示する単純なItemsControlです。

英語で言うと、ItemsControl で階層グループを表示する方法がわかれば、SciChart Legend コントロールでも同じことができるということです。

行う必要があるのは、ItemsControl から継承する独自のクラスを作成して LegendModifier.LegendData にバインドし、必要に応じて項目をグループ化することです。または、添付されたビヘイビアーまたはコンバーターを使用してアイテムをグループ化します。

次に、 LegendModifier Documentationのテクニックを使用して、独自のクラスまたは ItemsControl (SciChartLegend の代わりに) を使用できます。

別の方法 – LegendModifier.LegendData を SciChartLegend にバインドする

または、LegendModifier.LegendData を SciChartLegend にバインドして、アプリケーションの任意の場所に配置することもできます。LegendModifier.LegendData を ItemsControl.ItemsSource にバインドし、必要に応じてテンプレート化することもできます。

<!-- Somewhere else in your application, you can declare n ItemsControl -->
<!-- and bind to LegendModifier.LegendData -->
<ItemsControl
   Margin="23,23"
   ScrollViewer.HorizontalScrollBarVisibility="Auto"
   ScrollViewer.VerticalScrollBarVisibility="Auto"
   <!-- Here you may need a converter or attached behaviour to group the SeriesInfo as you wish -->
   ItemsSource="{Binding LegendData.SeriesInfo, ElementName=legendModifier, Mode=OneWay}">
    <ItemsControl.ItemTemplate>
        <!-- Here you may need a Hierachical Data Template to display hierachical data -->
        <DataTemplate x:Key="SciChartLegendItemTemplate" DataType="chartData:SeriesInfo">
            <StackPanel Orientation="Horizontal">
                <CheckBox Margin="5,0,0,0"
                          HorizontalAlignment="Left"
                          VerticalAlignment="Center"
                          IsChecked="{Binding RenderableSeries.IsVisible, Mode=TwoWay}"
                          Visibility="Visible" />

                <r:PointMarker Width="40"
                               Height="10"
                               Margin="5,0,0,0"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               HorizontalContentAlignment="Stretch"
                               VerticalContentAlignment="Stretch"
                               DataContext="{Binding RenderableSeries}"
                               DeferredContent="{Binding LegendMarkerTemplate}"
                               Visibility="{Binding ShowSeriesMarkers, RelativeSource={RelativeSource AncestorType=visuals:SciChartLegend}, Converter={StaticResource BooleanToVisibilityConverter}}" />

                <TextBlock Margin="5,0,5,0"
                           HorizontalAlignment="Left"
                           Text="{Binding SeriesName}" />
            </StackPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

このようなものは完全な解決策ではありませんが、SciChart Legend API を使用して ItemsControl とテンプレートの凡例項目を置き換える方法を示しています。そこから、アイテムをグループ化し、データを階層的に表示できるようになることを願っています。

于 2016-05-11T16:18:36.560 に答える