彩票走势图

LightningChart Ultimate使用教程:在WPF中绘制点线数据

原创|使用教程|编辑:郝浩|2013-10-30 09:30:47.000|阅读 1502 次

概述:本教程讲述如何使用图表工具LightningChartUltimate PointLineSeries系列描绘变量区间点线数据。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

本教程讲述如何使用图表工具LightningChartUltimate PointLineSeries系列描绘变量区间点线数据。

学习该教程,你需要具备:

  • 基本C#和Visual Studio 2010知识
  • 安装LightningChartUltimate v5.1 (.NET4)
  • Visual Studio 2010或更高环境

1、添加LightningChartUltimate控件

建立一个WPF应用程序。在e Visual Studio工具栏中拖放组件"LightningChartUltimate"到表格窗口编辑器。

LightningChart Ultimate组件

窗口编辑器如下图:

LightningChart Ultimate窗口编辑器

代码如下:

<Window x:Class="Arction_tutorial1.MainWindow"
xmlns="//schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="//schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:lcu="//www.arction.com/schemas/">
<Grid UseLayoutRounding="True">
<lcu:LightningChartUltimate HorizontalAlignment="Stretch"
Name="lightningChartUltimate1" VerticalAlignment="Stretch" Margin="0" />
</Grid>
</Window>

2、初始化LightningChart组件

编辑MainWindow.xaml.cs源代码,用自定义外观设置和随机数据初始化。代码如下:

/* Tutorial:
* Simple LightningChart WPF application
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


using Arction.WPF.LightningChartUltimate;
using Arction.WPF.LightningChartUltimate.Views.ViewXY;
using Arction.WPF.LightningChartUltimate.SeriesXY;
using Arction.WPF.LightningChartUltimate.Axes;

//Make sure to use namespace similar to project name
namespace Arction_tutorial1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

public MainWindow()
{
InitializeComponent();
InitializeChart();
}

private void InitializeChart()
{
//Initialize chart
lightningChartUltimate1.BeginUpdate();

//Get XY view
ViewXY chartView = lightningChartUltimate1.ViewXY;

//Get default x-axis and set the range and ValueType
AxisX axisX = chartView.XAxes[0];
axisX.SetRange(0, 20);
axisX.ValueType = AxisValueType.Number;

//Get default y-axis and set the range.
AxisY axisY = chartView.YAxes[0];
axisY.SetRange(0, 100);

//Add point line series
PointLineSeries pls = new PointLineSeries(chartView, axisX, axisY);
pls.PointsVisible = true;

//Generate random data
Random rand = new Random();
const double dInterval = 1;
int iPointCount = (int)((axisX.Maximum - axisX.Minimum) / dInterval) + 1;
SeriesPoint[] aPoints = new SeriesPoint[iPointCount];
for (int iPoint = 0; iPoint < iPointCount; iPoint++)
{
aPoints[iPoint].X = (double)iPoint;
aPoints[iPoint].Y = 100.0 * rand.NextDouble();
}
//Assign the data for the point line series
pls.Points = aPoints;

//Add series to the PointLineSeries container in the view
chartView.PointLineSeries.Add(pls);

//Apply chart property changes, which causes chart to be painted
lightningChartUltimate1.EndUpdate();
}
}
}

编译并运行这个程序,结果如下图所示:

LightningChart Ultimate主窗口

下载地址:LightningChartUltimate


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP