2020. 2. 17. 11:07ㆍWPF/코드
<<oxyplot.pdf>>
koverflow.com/questions/32697963/wpf-plotting-a-cosine-function-when-radiobutton-is-clicked
- <<WpfApp1.zip>>
- WPF 프로젝트 만들기
- 프로젝트 -> NuGet 패키지 관리
- 찾아보기 클릭 -> oxyplot 검색
- 검색 항목중 OxyPlot.Wpf 선택 -> 설치
- 설치가 완료 - 참조 항목 확인
File Name : "MainWindow.xmal"
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:oxy="http://oxyplot.org/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="410.333" Width="525">
<Window.DataContext>
<local:MainPlotView/>
</Window.DataContext>
<Grid>
<Grid Background="#FFE5E5E5">
<oxy:PlotView x:Name="MyPlot" Model="{Binding MyModel}" IsEnabled="False"/>
</Grid>
</Grid>
</Window>
File Name : "MainPlotView.cs"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OxyPlot;
using OxyPlot.Series;
using OxyPlot.Annotations;
using OxyPlot.WindowsForms;
using OxyPlot.Wpf;
using OxyPlot.Axes;
using System.Windows.Threading;
namespace WpfApp1
{
public class MainPlotView
{
public DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(10) };
public static double[] Plot_Y_Data = new double[160];
public MainPlotView()
{
//PlotView_Bar();
Plot_Init();
Plot_Update();
}
private void Plot_Init ()
{
this.MyModel = new PlotModel()
{
Title = "DSP",
};
}
private void Plot_Update( )
{
Random rnd = new Random();
var data = new DataPoint[160];
MainWindow mw = new MainWindow();
timer.Tick += (sender, args) =>
{
//var buf = mw.Plot_Y_Data;
MyModel.Series.Clear();
for (int i = 0; i < 160; i++)
{
data[i] = new DataPoint(i, Plot_Y_Data[i]);
}
var stemseries = new StemSeries();
stemseries.Points.AddRange(data);
MyModel.Series.Add(stemseries);
MyModel.InvalidatePlot(true);
};
timer.Start();
}
private void PlotView_Bar()
{
Random rnd = new Random();
BarPoints = new List<DataPoint>();
DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
this.Title = "DSP";
timer.Tick += (sender, args) =>
{
BarPoints.Clear();
for (int i = 0; i < 160; i++)
{
BarPoints.Add(new DataPoint(i, rnd.Next()));
}
};
timer.Start();
}
public PlotModel MyModel { get; private set; }
public string Title { get; private set; }
public IList<DataPoint> Points { get; private set; }
public IList<DataPoint> BarPoints { get; private set; }
}
}
'WPF > 코드' 카테고리의 다른 글
WPF___백그라운드 프로세서 종료 (0) | 2020.02.17 |
---|---|
WPF___Enum 반복 ( 나열 된 수 만큼 반복 ) (0) | 2020.02.17 |
TextBox___Cursor 끝으로 보내기 (0) | 2020.02.17 |
WPF___TextBox 현재 커서 라인 구하기 (0) | 2020.02.17 |
Paste___DataObjectPastingEventArgs (0) | 2020.02.17 |