上图WPF工具包标签 [英] Labels on Chart Toolkit WPF

查看:193
本文介绍了上图WPF工具包标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法标记在海图轴

 <图表:图表名=EventAlertsChart了borderThickness = 0利润=0,10,0,0> 

<图表:Chart.Axes>
<图表:LinearAxis在方向=Y最小=0标题=通知数保证金=0,0,10,0/>
< /图表:Chart.Axes>


<图表:Chart.LegendStyle>
<风格的TargetType =控制>
< setter属性=宽度值=0/>
< setter属性=高度值=0/>
< /样式和GT;
< /图表:Chart.LegendStyle>

<图表:Chart.Series>
<图表:的ColumnSeries NAME =LineSeriesBWSrc的ItemsSource ={结合AlertPoints,UpdateSourceTrigger =的PropertyChanged}
IndependentValueBinding ={绑定路径=关键}DependentValueBinding ={绑定路径=值}标题=警报背景=栗色>
<图表:ColumnSeries.DataPointStyle>
<风格的TargetType =图表:ColumnDataPoint>
< setter属性=背景值=深红/>
< /样式和GT;
< /图表:ColumnSeries.DataPointStyle>
< /图表:&的ColumnSeries GT;
< /图表:Chart.Series>
< /图表:图表>



我已经成功使用标示Y轴

 <图表:Chart.Axes> 
<图表:LinearAxis在方向=Y最小=0标题=通知数保证金=0,0,10,0/>
< /图表:Chart.Axes>



不过如果我想轴它出现在图表的顶部标签的X.我只是想能够像时间和事件的轴键入一些传说,但我不能找到一个妥善的办法做到这一点。



如果我这样做在X轴上是相同的,那么说明和值去图表的顶部。



当X轴的代码被引入:

 <图表:Chart.Axes> 
<图表:LinearAxis在方向=Y最小=0标题=号警报





解决方案

不知道我有问题的权利,但如果你想显示的地方坐标轴,你可以自定义内容这样做以下列方式:



<预类=郎咸平的XML prettyprint-覆盖> < - TODO:定义自己的自定义模板
YAxisTitleContentTemplate和XAxisTitleContentTemplate
- >
<图表:Chart.Axes>
<图表:LinearAxis在方向=Y>
<图表:LinearAxis.Title>
< ContentControl中
的ContentTemplate ={StaticResource的YAxisTitleContentTemplate}/>
< /图表:LinearAxis.Title>
< /图表:LinearAxis在>
<图表:类别时方向=X>
<图表:CategoryAxis.Title>
< ContentControl中
的ContentTemplate ={StaticResource的XAxisTitleContentTemplate}/>
< /图表:CategoryAxis.Title>
< /图表:类别时>
< /图表:Chart.Axes>



编辑:标题为X轴仅



 <图表:Chart.Axes> 
<图表:类别时方向=X标题=X轴标题/>
< /图表:Chart.Axes>


Is there any way to label the axis on charts?

<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>

I've managed to label the Y axis using

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

however if I want to label the X axis it appears on the top of the chart. I just want to be able to type some legends on the axis like "Time" and "Events" but I cannot find a proper way to do it.

If I do the same on the X axis, then the legend and the values go to the top of the chart.

When the code for X axis is introduced as:

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

解决方案

Not sure I got question right but if you want to show custom content in place of the Axes you can do it in the following way:

<!-- 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>

EDIT: Title for the X Axis only

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

这篇关于上图WPF工具包标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆