图表工具包WPF上的标签 [英] Labels on Chart Toolkit WPF
问题描述
有没有办法在图表上标记轴?
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>
我已管理使用
<charting:Chart.Axes>
<charting:LinearAxis Orientation="Y" Minimum="0" Title="Number of Alerts" Margin="0,0,10,0" />
</charting:Chart.Axes>
然而,如果我想标记X轴,它会出现在图表的顶部。我只是想在轴上输入一些图例,如时间和事件,但我找不到一个正确的方法来做。
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.
如果我做在X轴上相同,则图例和值将转到图表的顶部。
If I do the same on the X axis, then the legend and the values go to the top of the chart.
当X轴的代码被引入为:
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:仅限X轴的标题
$ b
Title for the X Axis only
<charting:Chart.Axes>
<charting:CategoryAxis Orientation="X" Title="The X Axis Title" />
</charting:Chart.Axes>
这篇关于图表工具包WPF上的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!