WPF Tookit Chart

 

如何使用Chart

实例:

Binding数据源中是一个KeyValuePair对象。可以是Dictionary.

<charting:Chart x:Name="chtSummary" Width="770" Height="400" Title="My Chart Title">
    <charting:Chart.TitleStyle>
        <Style TargetType="datavis:Title">
            <Setter Property="FontSize" Value="28" />
            <Setter Property="FontFamily" Value="Arial" />
            <Setter Property="Margin" Value="5, 10, 5, 15" />
        </Style>
    </charting:Chart.TitleStyle>
    <charting:Chart.LegendStyle>
        <Style TargetType="datavis:Legend">
            <Setter Property="Width" Value="0" />
        </Style>
    </charting:Chart.LegendStyle>
    <charting:Chart.Series>
        <charting:BarSeries ItemsSource="{Binding}" DependentValuePath="Value" IndependentValuePath="Key" IsSelectionEnabled="True" >
            <charting:BarSeries.IndependentAxis>
                <charting:CategoryAxis Orientation="Y" AxisLabelStyle="{StaticResource SummaryChartAxisStyle}" />
            </charting:BarSeries.IndependentAxis>
        </charting:BarSeries>   
    </charting:Chart.Series>    
</charting:Chart>

 

 

如何添加第二个Y坐标

secondary y axis on WPF toolkit chart

 

实例:

On the first serie (ColumnSerie on my example), add this

<DVC:ColumnSeries.DependentRangeAxis >
    <DVC:LinearAxis Location="Left" Orientation="Y" />
</DVC:ColumnSeries.DependentRangeAxis>

On the second serie (LineSeries), add this

<DVC:LineSeries.DependentRangeAxis >
    <DVC:LinearAxis Location="Right" Orientation="Y" />
</DVC:LineSeries.DependentRangeAxis>

 

如何修改图列的名称

实例:

LineSeries Title=" Monthly Count" is responsible for display the legend text

<wpft:Chart Canvas.Top="80" Canvas.Left="10" Name="mcChart"
       Width="400" Height="250"
       Background="LightSteelBlue">
    <wpft:Chart.Series>
     <wpft:LineSeries Title=" Monthly Count"
        IndependentValueBinding="{Binding Path=Key}"
        DependentValueBinding="{Binding Path=Value}">
</wpft:LineSeries>
</wpft:Chart.Series>           
</wpft:Chart>

 

改变DataPointStyle

实例:

<chartingToolkit:Chart Margin="0,12,12,12" Name="chart1">
   <chartingToolkit:Chart.Series>
    <chartingToolkit:ColumnSeries DependentValuePath="value">
     <chartingToolkit:ColumnSeries.DataPointStyle>
      <Style TargetType="chartingToolkit:ColumnDataPoint">
       <Setter Property="DependentValueStringFormat" Value="{}{0:C0}"/>
      </Style>
     </chartingToolkit:ColumnSeries.DataPointStyle>
    </chartingToolkit:ColumnSeries>
    
   </chartingToolkit:Chart.Series>
   <chartingToolkit:Chart.Axes>
    <chartingToolkit:LinearAxis Orientation="Y" ShowGridLines="False" HorizontalAlignment="Left">
     <chartingToolkit:LinearAxis.AxisLabelStyle>
      <Style TargetType="chartingToolkit:AxisLabel">
       <Setter Property="StringFormat" Value="{}{0:C0}"/>
      </Style>
     </chartingToolkit:LinearAxis.AxisLabelStyle>
    </chartingToolkit:LinearAxis>
   </chartingToolkit:Chart.Axes>
  </chartingToolkit:Chart>
posted @ 2015-04-14 10:37  霍旭东  阅读(1395)  评论(0编辑  收藏  举报