WP7-chart图表编程

WP7-chart图表编程,第1张

概述转自:http://www.cnblogs.com/linzheng/archive/2011/10/06/1980328.html sliverlight toolkit http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html Why didn't I think of that

转自:http://www.cnblogs.com/linzheng/archive/2011/10/06/1980328.html


sliverlight toolkit
http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.HTML
Why dIDn't I think of that in the first place? [windows Phone 7 Charting example updated to include reusable,platform-consistent Style and Templates]
http://blogs.msdn.com/b/delay/archive/2010/08/04/why-dIDn-t-i-think-of-that-in-the-first-place-windows-phone-7-charting-example-updated-to-include-reusable-platform-consistent-style-and-templates.aspx

利用Silverlight自带的chart组件可以很轻易地编写出各种常用的图表图形。


组件所在命名空间:
System.windows.Controls.DataVisualization.Charting

在System.windows.Controls.DataVisualization.Charting空间下可以定义下面7种图形
1、lineserIEs  线性图
2、PIESerIEs  饼图
3、ColumnSerIEs  柱形图
4、AreaSerIEs  区域图
5、barSerIEs  条状图
6、ScatterSerIEs  散点图
7、BubbleSerIEs 气泡图


 下面通过静态绑定的方法用Microsoft.Phone.Control.Panorama全景视图控件展现一下lineserIEs、PIESerIEs、ColumnSerIEs、AreaSerIEs四种图形。

页面文件  省略了重复的代码

VIEw Code
              <        phone:PhoneApplicationPage         xmlns        ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x        ="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:phone        ="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"         xmlns:shell        ="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"         xmlns:charting        ="clr-namespace:System.windows.Controls.DataVisualization.Charting;assembly=System.windows.Controls.DataVisualization.Toolkit"         xmlns:local        ="clr-namespace:DataVisualizationOnwindowsPhone"         xmlns:d        ="http://schemas.microsoft.com/Expression/blend/2008"         xmlns:mc        ="http://schemas.openxmlformats.org/markup-compatibility/2006"         xmlns:DataVisualization        ="clr-namespace:System.windows.Controls.DataVisualization;assembly=System.windows.Controls.DataVisualization.Toolkit"         xmlns:controls        ="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"         x:Class        ="DataVisualizationOnwindowsPhone.MainPage"         SupportedOrIEntations        ="PortraitOrLandscape"         OrIEntation        ="Portrait"         mc:Ignorable        ="d"         d:DesignWIDth        ="480"         d:DesignHeight        ="800"         shell:SystemTray.IsVisible        ="False"        >                 phone:PhoneApplicationPage.Resources        <!--         Data         -->                 local:ActivitIEs         x:Key        ="ActivitIEs"                 />                 </        phone:PhoneApplicationPage.FontSize        StaticResource         ResourceKey        ="PhoneFontSizenormal"        phone:PhoneApplicationPage.Foreground        ="PhoneForegroundBrush"        GrID        GrID.RowDeFinitions        RowDeFinition          Title         controls:Panorama         Title        ="图表控件"        >         ……         controls:PanoramaItem         header        ="饼图"        charting:Chart         x:name        ="pIEChart"         Style        ="        {StaticResource PhoneChartStyle}        "         Template        {StaticResource PhoneChartPortraitTemplate}         margin        ="0,-7,0"        charting:Chart.Palette        DataVisualization:ResourceDictionaryCollection        ResourceDictionary        Style         ="DataPointStyle"         targettype        ="Control"        Setter         Property        ="Background"        Setter.Value        RadialGradIEntBrush         MapPingMode        ="absolute"        GradIEntStop         color        ="Blue"         Offset        ="0.9"        ="DarkBlue"        ="1.0"        RadialGradIEntBrush        Setter        ="borderBrush"         Value        ="transparent"        Style        ="Yellow"        ="0.8"        ="Orange"        ="Red"        ="DarkRed"        ="Green"        ="DarkGreen"        ="lime"        ="limeGreen"        ="lightGray"        ="DarkGray"        charting:PIESerIEs         ="pIESerIEs"         ItemsSource        {StaticResource ActivitIEs}         DependentValuePath        ="Count"         IndependentValuePath        ="Activity"         AnimationSequence        ="FirstTolast"        charting:Chart        controls:PanoramaItem        controls:Panorama        phone:PhoneApplicationPage        >      
复制代码

 后台代码部分

          using       System.Collections.Generic;       using       System.windows;       using       System.windows.Controls;       using       Microsoft.Phone.Controls;       namespace       DataVisualizationOnwindowsPhone {       using       System.windows.Controls.DataVisualization.Charting;       using       System.windows.Media;       using       DataVisualizationOnwindowsPhone.CustomPIEChart;       public             partial             class       MainPage : PhoneApplicationPage {       public       MainPage() { InitializeComponent(); } }       //      活动信息的类                    class       ActivityInfo {       string       Activity {       get      ;       set      ; }       int       Count {       set      ; } }       活动的活动列表类 数据源      class       ActivitIEs : List      <      ActivityInfo      >       {       public       ActivitIEs() { Add(      new       ActivityInfo { Activity       =             "      上班      "      ,Count       =             100       }); Add(      吃饭      26       }); Add(      聊QQ      6       }); Add(      陪老婆      60       }); Add(      旅游      10       }); Add(      发呆      18       }); } } }    

组件常用方法: Refresh:强制该组件从它的数据源刷新数据,然后重新渲染结果序列。   组件的常用属性: ActualAxes:获取显示在该组件上的实际轴数。 Axes:获取或设置在组件中的轴的序列。 ChartAreaStyle:获取或设置ISerIEsHost的图表区域样式。 LegendItems:获取图例项的集合。 LegendStyle:获取或设置图例的样式。 LegendTitle:获取或设置图例的标题内容。 PlotAreaStyle:获取或设置该组件绘图区域的样式。 SerIEs:获取或设置显示在该组件中的数据序列集合。 StylePalette:获取或设置一个由ISerIEsHost子项所使用的样式调色板。 Title:获取或设置该组件的标题。 TitleStyle:获取或设置该组件的标题的样式。

总结

以上是内存溢出为你收集整理的WP7-chart图表编程全部内容,希望文章能够帮你解决WP7-chart图表编程所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1070503.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存