我一直在使用http://d3future.codeplex.com/中提供的D3版本
它在股票图表上运行良好,但在AddLineGraph上给出了一个错误。下面的代码来自其他网站的帖子。
一些可用的DynamicDataDisplay.dll版本(v2/v3/v4)似乎可以与该语句一起工作/编译。
任何帮助都将不胜感激。
public partial class MainWindow : Window
{
public ObservableDataSource<Point> source1 = null;
public MainWindow()
{
InitializeComponent();
//this.Loaded += MainWindow_Loaded;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
source1 = new ObservableDataSource<Point>();
//Set identity mapping of point
source1.SetXYMapping(p => p);
plotter3.AddLineGraph(source1, 4, "Data Row");
//Fits the chart within ViewPort
plotter3.Viewport.FitToView();
// Start computation in 2nd thread
Thread simThread = new Thread(new ThreadStart(Computation));
simThread.IsBackground = true;
simThread.Start();
}
}发布于 2016-03-10 07:38:55
试试AddLineChart。我不知道它为什么会改变:
var x = Enumerable.Range(0, 9).Select(i => i * 100.0);
var y = new double[] { 10, 9, 7, 8, 5, 6, 4, 3, 2, 1 };
var source = DataSource.Create(x,y);
var line = plotter.AddLineChart(source)
.WithStroke(Brushes.Red)
.WithStrokeThickness(2)
.WithDescription("x vs y");发布于 2016-03-10 21:19:04
这可能会对你有所帮助,注意这里Point是你Collection中的元素类型,Collection是你的enumerable数据点的集合。
var ds = new EnumerableDataSource<Point>(Collection);
LineGraph line;
ds.SetXMapping(x => x.X);
ds.SetYMapping(y => y.Y);
line = new LineGraph(ds);
line.LinePen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Red, 2);
//line.Description = new PenDescription("description");
Graph.Children.Add(line);
Graph.FitToView();发布于 2016-03-13 01:32:15
感谢你们所有的有用的回复。
经过多次修改(是的,我是一个初学者),我发现在项目中添加5个cs文件并使用D3Future源代码站点上提供的DynamicDataDisplay.dll(56kb)可以使代码像最初发布的那样运行。这五个文件是::1 Plotter2D 2 Plotter2DExtensions 3 Description 4 StandardDescription 5 PenDescription
现在我不需要Legends和Description,所以我注释掉了对它们的引用,只是为了让代码用AddLineGraph方法编译和运行。
我使用的是Windows 10/Visual Studio Community Edition 2015。
谢谢。
https://stackoverflow.com/questions/35904310
复制相似问题