怎样在SilverLight的Chart的数据点上显示详细信息
1个回答
展开全部
默认方式下产生的Chart在鼠标在数据点上悬停时,只显示数值,如果要显示更锋侍运详细信息,必须改变DataPoint的Style,下面的代码是以AreaChart为例,设置的内容。
<!-- Page AreaDataPoint Style1 -->
<Style x:Key="AreaToolTipStyle1" TargetType="chartingToolkit:AreaDataPoint">
<Setter Property="Background" Value="Green" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Width" Value="4" />
<Setter Property="Height" Value="4" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:AreaDataPoint">
<Grid x:Name="Root" Opacity="1">
<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<TextBlock Text="数量"></TextBlock>
<ContentControl Content="{TemplateBinding FormattedDependentValue}" />
<TextBlock Text="日期"></TextBlock>
<ContentControl Content="{TemplateBinding IndependentValue}" />
</StackPanel>
</ToolTipService.ToolTip>
<Ellipse StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}"谈物/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
并在动态生成图表时,加入如下语句:
areaSeries1.DataPointStyle = Application.Current.Resources["AreaToolTipStyle1"] as Style; //定义在Style文件
areaSeries1.DataPointStyle = this.Resources["AreaToolTipStyle1"] as Style; //定银梁义在页面
<!-- Page AreaDataPoint Style1 -->
<Style x:Key="AreaToolTipStyle1" TargetType="chartingToolkit:AreaDataPoint">
<Setter Property="Background" Value="Green" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Width" Value="4" />
<Setter Property="Height" Value="4" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:AreaDataPoint">
<Grid x:Name="Root" Opacity="1">
<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<TextBlock Text="数量"></TextBlock>
<ContentControl Content="{TemplateBinding FormattedDependentValue}" />
<TextBlock Text="日期"></TextBlock>
<ContentControl Content="{TemplateBinding IndependentValue}" />
</StackPanel>
</ToolTipService.ToolTip>
<Ellipse StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}"谈物/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
并在动态生成图表时,加入如下语句:
areaSeries1.DataPointStyle = Application.Current.Resources["AreaToolTipStyle1"] as Style; //定义在Style文件
areaSeries1.DataPointStyle = this.Resources["AreaToolTipStyle1"] as Style; //定银梁义在页面
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询