1. 下载Visifire for WPF并安装,安装好以激滚简后该产品会出现在您的工具箱里2. 创建一个WPF程备亩序,并且引用WPFVisifire.Charts.dll,并且在您的代码里引用 using Visifire.Charts; using Visifire.Commons;3. 添加代码并且创建和显示图表,在该事例中图表显示在LayoutRoot里,是一个Grid容器,默认情况下Grid是空白的,必须为该Grid指定一个x:Name="LayoutRoot"4.同样地,可以通过修改Height和Width来改变图表的显示大小5.在Window1.xaml.cs里我们可以开始创建图表了,在 Window1()事件里添加一个CreateChart()函数,在CreateChart()里创建图表,具体代码如下:public Window1(){ InitializeComponent(); // Call function to create chart CreateChart();}private void CreateChart(){// Create a Chart elementChart chart = new Chart(); // Set chart width and heightchart.Width = 400;chart.Height = 300; // Create new DataSeriesDataSeries dataSeries = new DataSeries(); // Number of DataPoints to be generatedint numberOfDataPoints = 10; // To set the YValues of DataPointRandom random = new Random(); //明裤 Loop and add a few DataPointsfor (int loopIndex = 0; loopIndex < numberOfDataPoints; loopIndex++){ // Create a DataPoint DataPoint dataPoint = new DataPoint(); // Set the YValue using random number dataPoint.YValue = random.Next(1, 100); // Add DataPoint to DataSeries dataSeries.DataPoints.Add(dataPoint);} // Add DataSeries to Chartchart.Series.Add(dataSeries); // Add chart to the LayoutRoot for displayLayoutRoot.Children.Add(chart);}
相关文章
-
国际经济法案例与图表
2023-06-23 06:40 阅读(564) -
SWPF三维互动软件
2023-05-17 22:58 阅读(629) -
中文版Excel 2007图表宝典
2023-05-13 00:23 阅读(553)