2011-11-22 94 views
3

有什么方法在图表上标注轴?Chart Toolkit上的标签WPF

<charting:Chart Name="EventAlertsChart" BorderThickness="0" Margin="0,10,0,0"> 

     <charting:Chart.Axes> 
      <charting:LinearAxis Orientation="Y" Minimum="0" Title="Number of Alerts" Margin="0,0,10,0" /> 
     </charting:Chart.Axes> 


     <charting:Chart.LegendStyle> 
      <Style TargetType="Control"> 
       <Setter Property="Width" Value="0" /> 
       <Setter Property="Height" Value="0" /> 
      </Style> 
     </charting:Chart.LegendStyle> 

     <charting:Chart.Series> 
      <charting:ColumnSeries Name="LineSeriesBWSrc" ItemsSource="{Binding AlertPoints,UpdateSourceTrigger=PropertyChanged}" 
        IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}" Title="Alerts" Background="Maroon" > 
       <charting:ColumnSeries.DataPointStyle> 
        <Style TargetType="charting:ColumnDataPoint"> 
         <Setter Property="Background" Value="Crimson" /> 
        </Style> 
       </charting:ColumnSeries.DataPointStyle> 
      </charting:ColumnSeries> 
     </charting:Chart.Series> 
    </charting:Chart> 

我已经成功使用

<charting:Chart.Axes> 
      <charting:LinearAxis Orientation="Y" Minimum="0" Title="Number of Alerts" Margin="0,0,10,0" /> 
    </charting:Chart.Axes> 

但是如果我想轴它出现在图表的顶部标注的X标记Y轴。我只是想能够在“时间”和“事件”这样的轴上输入一些传说,但我找不到一个正确的方法来做到这一点。

如果我在X轴上做同样的事情,那么图例和值将会出现在图表的顶部。 enter image description here

当引入了X轴的代码为:

<charting:Chart.Axes> 
      <charting:LinearAxis Orientation="Y" Minimum="0" Title="Number of Alerts" 

enter image description here

回答

4

不知道我有问题的权利,但如果你想显示的地方自定义内容轴可以通过以下方式完成:

<!-- TODO: Define own custom templates for 
    YAxisTitleContentTemplate and XAxisTitleContentTemplate 
--> 
<charting:Chart.Axes> 
    <charting:LinearAxis Orientation="Y"> 
    <charting:LinearAxis.Title> 
      <ContentControl 
       ContentTemplate="{StaticResource YAxisTitleContentTemplate}"/> 
    </charting:LinearAxis.Title> 
    </charting:LinearAxis> 
    <charting:CategoryAxis Orientation="X"> 
     <charting:CategoryAxis.Title> 
      <ContentControl 
        ContentTemplate="{StaticResource XAxisTitleContentTemplate}"/> 
     </charting:CategoryAxis.Title> 
    </charting:CategoryAxis> 
</charting:Chart.Axes> 

编辑:标题为X轴只

<charting:Chart.Axes> 
     <charting:CategoryAxis Orientation="X" Title="The X Axis Title" /> 
</charting:Chart.Axes> 
+0

我已经编辑我的问题,或许现在更清楚。 – Manolete

+0

仍然不清楚,所以你能够显示文字,但不能......? – sll

+0

我能够正确显示数据。但我想显示该轴的标签。 X轴是“时间”,“Y”轴是“警报数量”。 – Manolete