C#.NetのWPFで実際に1つのGUIを開発しています。実際には埋め込みデバイスとのシリアル通信アプリケーションです。頻繁に受信したデータを折れ線グラフで表示します。それらのチャートを保存し、それを印刷するオプションを与えるオプションを提供しています。無料のライブラリやソフトウェアのサポートを使って動的にこれを描くことはできますか?C#WPFアプリケーションの動的折れ線グラフ
6
A
答えて
9
私はすべてのWPFチャート作成のニーズにDynamic Data Displayを使用します。これは、グラフの保存をサポートし、非常に迅速で、シームレスなズームとパンを提供します。 名前空間:のxmlns:D3 = "http://research.microsoft.com/DynamicDataDisplay/1.0"
XAML:
<d3:ChartPlotter Name="plotter" Background="White">
<d3:ChartPlotter.Resources>
<conv:Date2AxisConverter x:Key="Date2AxisConverter"/>
</d3:ChartPlotter.Resources>
<d3:ChartPlotter.HorizontalAxis>
<d3:HorizontalDateTimeAxis Name="dateAxis"/>
</d3:ChartPlotter.HorizontalAxis>
<d3:Header Content="{Binding PlotHeader}"/>
<d3:VerticalAxisTitle Content="Value"/>
<d3:HorizontalAxisTitle Content="Date"/>
</d3:ChartPlotter>
C#コード:コンバータ
public class Date2AxisConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is DateTime && targetType == typeof(double))
{
return ((DateTime)value).Ticks/10000000000.0;
// See constructor of class Microsoft.Research.DynamicDataDisplay.Charts.DateTimeAxis
// File: DynamicDataDisplay.Charts.Axes.DateTime.DateTimeAxis.cs
// alternatively, see the internal class Microsoft.Research.DynamicDataDisplay.Charts.DateTimeToDoubleConversion
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
// try Microsoft.Research.DynamicDataDisplay.Charts.DateTimeAxis.DoubleToDate
throw new NotSupportedException();
}
#endregion
}
C#コードを使用します。グラフのクリアと折れ線グラフの作成ここで、私のStockasticProcessPointは、 "DateTime t"フィールドと "Double value"フィールドを持つ構造体です。
using Microsoft.Research.DynamicDataDisplay;
using System.Collections.ObjectModel;
using Microsoft.Research.DynamicDataDisplay.DataSources;
public void ClearLines()
{
var lgc = new Collection<IPlotterElement>();
foreach (var x in plotter.Children)
{
if (x is LineGraph || x is ElementMarkerPointsGraph)
lgc.Add(x);
}
foreach (var x in lgc)
{
plotter.Children.Remove(x);
}
}
internal void SendToGraph() {
IPointDataSource _eds = null;
LineGraph line;
ClearLines();
EnumerableDataSource<StochasticProcessPoint> _edsSPP;
_edsSPP = new EnumerableDataSource<StochasticProcessPoint>(myListOfStochasticProcessPoints);
_edsSPP.SetXMapping(p => dateAxis.ConvertToDouble(p.t));
_edsSPP.SetYMapping(p => p.value);
_eds = _edsSPP;
line = new LineGraph(_eds);
line.LinePen = new Pen(Brushes.Black, 2);
line.Description = new PenDescription(Description);
plotter.Children.Add(line);
plotter.FitToView();
}
これで、WPFでグラフをプロットできるはずです。シリアルポートから戻ってきたときにデータを追加することは問題ありません。また、DynamicDataDisplayのバインディングの例を見ることもできます。
関連する問題
- 1. 折れ線グラフは
- 2. 折れ線グラフnvd3
- 3. MPAndroidChart折れ線グラフのスクロールオーバーラップ
- 4. 折れ線グラフの問題
- 5. matplotlibの折れ線グラフ
- 6. SSRS折れ線グラフのカスタムカラー
- 7. 複数の折れ線グラフ
- 8. dc.jsのマルチシリーズ折れ線グラフ
- 9. Bokeh折れ線グラフのループ
- 10. D3の折れ線グラフCSV
- 11. jqueryに動的な折れ線グラフはありますか?
- 12. gnuplotの折れ線グラフと棒グラフ
- 13. 折れ線グラフの参照線
- 14. 私のwpfプログラムに折れ線グラフを追加
- 15. 折れ線グラフCanvasJS/ChartJS
- 16. D3折れ線グラフ - レンダリングキュー
- 17. 折れ線グラフ(グーグルチャート)カスタムは
- 18. 折れ線グラフ用Google Script。
- 19. ggplot:オーバーレイバーと折れ線グラフ
- 20. タイコスクリプト折れ線グラフd3
- 21. 折れ線グラフとエラーバー
- 22. Android棒グラフと折れ線グラフMPAndroidChart
- 23. ggplotly棒グラフと折れ線グラフ
- 24. d3折れ線グラフ、線図なし
- 25. 勝利のチャート - 折れ線グラフのツールチップ
- 26. 空白 - ChartJSの折れ線グラフのポイントストローク
- 27. Googleの折れ線グラフのオーバーラップツールチップ
- 28. 多くのポイント(〜500,000)を使用したJavaScriptの動的折れ線グラフ
- 29. Rプロットされた折れ線グラフ
- 30. D3.jsは、折れ線グラフの下
ライブラリファイルをプロジェクトに追加するにはどうすればいいですか。すべての.dllファイルを追加する必要があるかどうかにかかわらずダウンロードしました。 – Mukthi
Visual Studioのプロジェクトの参照フォルダ - >参照の追加を行います。 DynamicDataDisplay.dllをプロジェクトに追加します。他の外部参照と同じです。 – NetSquirrel
ソースコードとナゲットのインストールについては、https://github.com/apoydence/DynamicDataDisplayとhttps://www.nuget.org/packages/DynamicDataDisplay/をご覧ください。 – Andrew