チャートの軸をカスタマイズする

Silverlight Toolkit のチャートは軸(横軸や縦軸)のカスタマイズが可能です。
Silverlight でチャートを作成する』で作ったカラムチャートのサンプルを元に試してみました。

<UserControl x:Class="ChartSample.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls"
    xmlns:Charting="clr-namespace:Microsoft.Windows.Controls.DataVisualization.Charting;assembly=Microsoft.Windows.Controls.DataVisualization"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <Charting:Chart Title="ノート PC" x:Name="_chart">
            <Charting:Chart.Series>

                <!--カラムチャートを指定-->
                <Charting:ColumnSeries
                    Title="売上"
                    ItemsSource="{Binding}"
                    IndependentValueBinding="{Binding Name}"
                    DependentValueBinding="{Binding Sales}"/>

            </Charting:Chart.Series>

            <Charting:Chart.Axes>
                <!--
                    横軸をカスタマイズ。
                    前景色を赤&フォントをイタリックに。
                -->
                <Charting:Axis AxisType="Category"
                               Title="ノート PC"
                               Orientation="Horizontal"
                               Foreground="Red"
                               FontStyle="Italic"/>

                <!--
                    縦軸をカスタマイズ。
                    前景色を緑&フォントをイタリックに。
                -->
                <Charting:Axis AxisType="Linear"
                               Title="売上額"
                               Orientation="Vertical"
                               ShowGridLines="True"
                               Minimum="0"
                               Interval="500000"
                               Foreground="Green"
                               FontStyle="Italic"/>
            </Charting:Chart.Axes>
        </Charting:Chart>
    </Grid>
</UserControl>

Axis タグを追加しています。今回は横軸と縦軸の色やフォントスタイルを変更。

修正した Silverlight アプリケーションの実行画面が下図です。
f:id:griefworker:20081210121748p:image
うん、ちゃんと反映されている。今回はこれだけ(;^_^A