Silverlight调用Visfire开源图表组件的源代码:
using System; using System.Collections.Generic; using System.linq; using System.Net; using System.windows; using System.windows.Controls; using System.windows.documents; using System.windows.input; using System.windows.Media; using System.windows.Media.Animation; using System.windows.Shapes; using Visifire.Charts; namespace SL { public partial class VisifireTest : UserControl { public Visifiretest() { InitializeComponent(); List<DateTime> updateTime = new List<DateTime>() { new DateTime(2010,2,01,7,11,03),new DateTime(2010,3,12,4,13,5,14,6,15,16,8,17,9,18,03) }; List< string> value = new List< string>() { " 20"," 25"," 40"," 55"," 67"," 74"," 88"," 94" }; List< string> value1 = new List< string>() { " 33"," 44"," 48"," 15"," 70"," 56"," 77"," 5" }; List< string> value2 = new List< string>() { " 10"," 81"," 66"," 60"," 12"," 100" }; List< object> valueList = new List< object> { value,value1,value2 }; CreateChart(" 内存使用率",updateTime,valueList," %",1,IntervalTypes.Minutes); } public voID CreateChart( string tablename,List<DateTime> updateTime,List< object> valueList,string rihgtStr,int chartInterval,IntervalTypes intervaltype) { Chart chart = new Chart(); //创建一个图表 /* 设置图表属性 */ chart.WIDth = 500; chart.Height = 400; chart.ToolbarEnabled = true; chart.ScrollingEnabled = false; chart.VIEw3D = true; Title Title = new Title() { Text = tablename,padding = new Thickness(0,10,0) }; //图表标题 chart.Titles.Add(Title); //添加标题 Axis xAxis = new Axis(); //创建X轴 xAxis.IntervalType = intervaltype; //X轴分类类型,小时*分*秒 xAxis.Interval = chartInterval; //X轴坐标间隔距离 xAxis.ValueFormatString = " hh:mm:ss"; //X轴时间显示格式 chart.AxesX.Add(xAxis); //为图表添加X轴 Axis yAxis = new Axis(); //创建Y轴 yAxis.Suffix = rihgtStr; //Y轴后缀% yAxis.AxisMinimum = 0; //Y轴最小值为0 chart.AxesY.Add(yAxis); //为图表添加Y轴 for ( int i = 0; i < valueList.Count; i++) { DataSerIEs dataSerIEs = new DataSerIEs(); //创建数据线 dataSerIEs.RenderAs = RenderAs.line; // 数据线显示类型为线型 dataSerIEs.XValueType = ChartValueTypes.DateTime; //设置X轴的类型为日期类型 List< string> value = (List< string>)valueList[i]; for ( int j = 0; j < updateTime.Count; j++) { DataPoint dataPoint = new DataPoint(); //创建数据点 dataPoint.XValue = updateTime[j]; //设置数据点X轴的值; dataPoint.YValue = double.Parse( value[j]); //设置Y轴值 dataPoint.MarkerSize = 8; //设置数据点的大小 dataPoint.MouseleftbuttonDown += new MousebuttonEventHandler(dataPoint_MouseleftbuttonDown); //数据点的鼠标单击事件 dataSerIEs.DataPoints.Add(dataPoint); //为数据线添加数据点 } chart.SerIEs.Add(dataSerIEs); //为图表添加数据线 } LayoutRoot.Children.Add(chart); } voID dataPoint_MouseleftbuttonDown( object sender,MousebuttonEventArgs e) { } } }
希望对大家有用~
总结以上是内存溢出为你收集整理的Silverlight调用Visfire开源图表组件的源代码全部内容,希望文章能够帮你解决Silverlight调用Visfire开源图表组件的源代码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)