怎样在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; //定义在页面
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询