NationalInstruments(二)深圳市裕量科技有限公司
深圳市裕量科技有限公司 http://www.szmgt.com.cn/
Graph折线曲线样式以及赋值
DataSource 数值赋值
Plots 线类型集合

ChartCollection<double, double>[] data = new ChartCollection<double, double>[3];
Random rand = new Random();
NationalInstruments.Controls.Primitives.PlotCollection plots = new NationalInstruments.Controls.Primitives.PlotCollection();
Plot plot = new Plot();
for (int index = 0; index < 3; index++)
{
data[index] = new ChartCollection<double, double>(100);
for (int i = 0; i < 100; i++)
{
double er = rand.NextDouble();
data[index].Append(i, er);
}
plot = new Plot();
if (index == 0)
{
plot.Label = "Line";
plot.Name = "Line";
plot.Renderer = new NationalInstruments.Controls.Rendering.LinePlotRenderer() { Stroke = new SolidColorBrush(Color.FromRgb(255, 0, 0)), StrokeThickness = 1 };
}
else if (index == 1)
{
plot.Label = "Point";
plot.Name = "Point";
plot.Renderer = new NationalInstruments.Controls.Rendering.PointPlotRenderer() { Stroke = System.Windows.Media.Brushes.Black, Fill = System.Windows.Media.Brushes.Orange, Shape = PointShape.Ellipse, Size = new System.Windows.Size(10, 10) };
}
else if (index == 2)
{
plot.Label = "Point";
plot.Name = "Point";
plot.Renderer = new NationalInstruments.Controls.Rendering.BarPlotRenderer() { Stroke = System.Windows.Media.Brushes.Black, Fill = System.Windows.Media.Brushes.Blue };
}
plots.Add(plot);
}
graph.Plots.AddRange(plots);
graph.DataSource = data;
最终效果图


浙公网安备 33010602011771号