本文整理汇总了C#中EnumerableDataSource类的典型用法代码示例。如果您正苦于以下问题:C# EnumerableDataSource类的具体用法?C# EnumerableDataSource怎么用?C# EnumerableDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumerableDataSource类属于命名空间,在下文中一共展示了EnumerableDataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Window1
public Window1()
{
InitializeComponent();
Content = plot;
plot.MainHorizontalAxis = axis;
const int N = 10;
double[] x = new double[N];
double[] y = new double[N];
DateTime[] date = new DateTime[N];
for (int i = 0; i < N; i++)
{
x[i] = i * 0.1;
y[i] = Math.Sin(x[i]);
date[i] = DateTime.Now.AddMinutes(-N + i);
}
EnumerableDataSource<double> xs = new EnumerableDataSource<double>(x);
xs.SetYMapping(_x => _x);
EnumerableDataSource<DateTime> ys = new EnumerableDataSource<DateTime>(date);
ys.SetXMapping(axis.ConvertToDouble);
CompositeDataSource ds = new CompositeDataSource(xs, ys);
plot.AddLineGraph(ds);
}
示例2: showprogress
private void showprogress()
{
DBProgressConnect DBProgressConnect_Inst = new DBProgressConnect();
DataTable ProgressData = new DataTable();
ProgressData = DBProgressConnect_Inst.Read(globaldata.current_user);
datagrid1.ItemsSource = ProgressData.DefaultView;
int data_count = DBProgressConnect_Inst.Count(globaldata.current_user);
DateTime[] dates = new DateTime[data_count];
double[] scores = new double[data_count];
for (int i = 0; i < data_count; i++)
{
dates[i] = Convert.ToDateTime(ProgressData.Rows[i][1]);
scores[i] = Convert.ToDouble(ProgressData.Rows[i][2]);
}
var datesDataSource = new EnumerableDataSource<DateTime>(dates);
datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));
var scoreDataSource = new EnumerableDataSource<double>(scores);
scoreDataSource.SetYMapping(y => y);
CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, scoreDataSource);
Plotter.AddLineGraph(compositeDataSource1, new Pen(Brushes.Blue, 2), new CirclePointMarker { Size = 10.0, Fill = Brushes.Red }, new PenDescription("Time vs. Score for "+globaldata.current_user+""));
Plotter.Viewport.FitToView();
}
示例3: CreateHistograms
private void CreateHistograms()
{
EnumerableDataSource<int> x = new EnumerableDataSource<int>(Enumerable.Range(0, 256).ToArray());
x.SetXMapping(_x => _x);
Func<int, double> mapping;
if (check.IsChecked.GetValueOrDefault())
mapping = logMapping;
else
mapping = linearMapping;
red = new EnumerableDataSource<int>(reds);
red.SetYMapping(mapping);
green = new EnumerableDataSource<int>(greens);
green.SetYMapping(mapping);
blue = new EnumerableDataSource<int>(blues);
blue.SetYMapping(mapping);
CompositeDataSource rDS = new CompositeDataSource(x, red);
CompositeDataSource gDS = new CompositeDataSource(x, green);
CompositeDataSource bDS = new CompositeDataSource(x, blue);
plotter.RemoveAllGraphs();
plotter.AddLineGraph(rDS, Colors.Red, 1, "Red").FilteringEnabled = false;
plotter.AddLineGraph(gDS, Colors.Green, 1, "Green").FilteringEnabled = false;
plotter.AddLineGraph(bDS, Colors.Blue, 1, "Blue").FilteringEnabled = false;
}
示例4: DrawChart
private void DrawChart()
{
var xpoints = new int[_visitedPoints.Count];
var ypoints = new int[_visitedPoints.Count];
var times = new int[_visitedPoints.Count];
for (int i = 0; i < times.Length; i++)
{
times[i] = i;
xpoints[i] = (int) _visitedPoints[i].Position.X;
ypoints[i] = (int) _visitedPoints[i].Position.Y;
}
var timesDataSource = new EnumerableDataSource<int>(times);
timesDataSource.SetXMapping(x => timeAxis.ConvertToDouble(x));
var xPointsDataSource = new EnumerableDataSource<int>(xpoints);
xPointsDataSource.SetYMapping(y => Convert.ToInt32(y));
var yPointsDataSource = new EnumerableDataSource<int>(ypoints);
yPointsDataSource.SetYMapping(y => Convert.ToInt32(y));
var compositeDataSource1 = new CompositeDataSource(xPointsDataSource, timesDataSource);
var compositeDataSource2 = new CompositeDataSource(yPointsDataSource, timesDataSource);
plotter.AddLineGraph(compositeDataSource1,
new Pen(Brushes.GreenYellow, 2),
new CirclePointMarker {Size = 10.0, Fill = Brushes.Red},
new PenDescription("x/t"));
plotter.AddLineGraph(compositeDataSource2,
new Pen(Brushes.Gold, 2),
new CirclePointMarker {Size = 10.0, Fill = Brushes.DodgerBlue},
new PenDescription("y/t"));
plotter.Viewport.FitToView();
}
示例5: PlantView_DataContextChanged
void PlantView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
foreach (var g in _extGraphs)
ExtGraph.Children.Remove(g);
_extGraphs.Clear();
foreach (var g in _wells)
ExtGraph.Children.Remove(g);
_wells.Clear();
PlantViewModel P = e.NewValue as PlantViewModel;
if (P != null)
{
EnumerableDataSource<Time.Core.TimestampValue> ds = new EnumerableDataSource<TimestampValue>(P.plant.Extractions.AsTimeStamps);
ds.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
ds.SetYMapping(var => var.Value);
_extGraphs.Add(ExtGraph.AddLineGraph(ds, new Pen(Brushes.Black, 3), new PenDescription("Groundwater")));
if (P.plant.SurfaceWaterExtrations.Items.Count > 0)
{
EnumerableDataSource<Time.Core.TimestampValue> ds2 = new EnumerableDataSource<TimestampValue>(P.plant.SurfaceWaterExtrations.AsTimeStamps);
ds2.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
ds2.SetYMapping(var => var.Value);
_extGraphs.Add(ExtGraph.AddLineGraph(ds2, new Pen(Brushes.Red, 3), new PenDescription("Surface water")));
}
}
ZoomToTimeScale();
}
示例6: CreateCurrencyDataSource
private EnumerableDataSource<CurrencyInfo> CreateCurrencyDataSource(List<CurrencyInfo> rates)
{
EnumerableDataSource<CurrencyInfo> ds = new EnumerableDataSource<CurrencyInfo>(rates);
ds.SetXMapping(ci => dateAxis.ConvertToDouble(ci.Date));
ds.SetYMapping(ci => ci.Rate);
return ds;
}
示例7: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
for (int i = 0; i < animatedX.Length; i++)
{
animatedX[i] = 2 * Math.PI * i / animatedX.Length;
animatedY[i] = Math.Sin(animatedX[i]);
}
EnumerableDataSource<double> xSrc = new EnumerableDataSource<double>(animatedX);
xSrc.SetXMapping(x => x);
animatedDataSource = new EnumerableDataSource<double>(animatedY);
animatedDataSource.SetYMapping(y => y);
// Adding graph to plotter
//todo
//plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource),
// new Pen(Brushes.Magenta, 3),
// new PenDescription("Sin(x + phase)"));
timer.Interval = TimeSpan.FromMilliseconds(10);
timer.Tick += AnimatedPlot_Timer;
timer.IsEnabled = true;
// Force evertyhing plotted to be visible
plotter.FitToView();
}
示例8: MainWindow
//Instance of object which contains configuration for sending data.
//ULoader_JSON config;
//Instacje of object which sends data.
//USender uSender;
public MainWindow()
{
InitializeComponent();
attentionValuesCollection = new DataCollection();
var attentionDataSource = new EnumerableDataSource<Data>(attentionValuesCollection);
attentionDataSource.SetXMapping(x => dateAttention.ConvertToDouble(x.Date));
attentionDataSource.SetYMapping(y => y.Value);
plotterAttention.AddLineGraph(attentionDataSource, Colors.Red, 2, "Attetion");
connector = new Connector();
connector.DeviceConnected += new EventHandler(OnDeviceConnected);
connector.DeviceConnectFail += new EventHandler(OnDeviceFail);
connector.DeviceValidating += new EventHandler(OnDeviceValidating);
connector.ConnectScan("COM3");
//Stworzenie obiektu typu Random do wyboru losowego słowa ze słownika.
randomWordNumber = new Random();
wordNumber = 0;
attentionComingCounter = 0;
attentionValueSum = 0;
puzzlesSolved = 0;
wordStatList = new List<WordStat>();
currentWord = "";
//config = new ULoader_JSON(@"..\..\config.json");
//uSender = config.GetSender("output1");
}
示例9: MainWindow_Loaded
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
// Prepare data in arrays
const int N = 100;
double[] x = new double[N];
double[] y = new double[N];
for (int i = 0; i < N; i++)
{
x[i] = i * 0.1;
y[i] = Math.Cos(x[i]);
}
// Add data sources:
var yDataSource = new EnumerableDataSource<double>(y);
yDataSource.SetYMapping(Y => Y);
yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty,
Y => string.Format("Value is {0}", Y));
var xDataSource = new EnumerableDataSource<double>(x);
xDataSource.SetXMapping(X => X);
CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);
plotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 1 });
// adding graph to plotter
plotter.AddLineGraph(compositeDataSource,
new Pen(Brushes.Goldenrod, 3),
new SampleMarker(),
new PenDescription("Cosine"));
}
示例10: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// Prepare data in arrays
const int N = 100;
double[] x = new double[N];
double[] cs = new double[N];
double[] sn = new double[N];
for (int i = 0; i < N; i++)
{
x[i] = i * 0.1;
cs[i] = Math.Sin(x[i]);
sn[i] = Math.Cos(x[i]);
}
// Add data sources:
// 3 partial data sources, containing each of arrays
var snDataSource = new EnumerableDataSource<double>(sn);
snDataSource.SetYMapping(y => y);
var xDataSource = new EnumerableDataSource<double>(x);
xDataSource.SetXMapping(lx => lx);
var csDataSource = new EnumerableDataSource<double>(cs);
csDataSource.SetYMapping(y => y);
var csqDataSource = new EnumerableDataSource<double>(cs);
csqDataSource.SetYMapping(y => y * y);
// 2 composite data sources and 2 charts respectively:
// creating composite data source
CompositeDataSource compositeDataSource1 = new CompositeDataSource(xDataSource, snDataSource);
// adding graph to plotter
plotter.AddLineGraph(compositeDataSource1,
new Pen(Brushes.DarkGoldenrod, 3),
new CirclePointMarker { Size = 10, Fill = Brushes.Red },
new PenDescription("Sin"));
// creating composite data source for cs values
CompositeDataSource compositeDataSource2 = new CompositeDataSource(xDataSource, csDataSource);
// Adding second graph to plotter
plotter.AddLineGraph(compositeDataSource2,
new Pen(Brushes.Blue, 3),
new TrianglePointMarker { Size = 20, Fill = Brushes.Blue },
new PenDescription("Cos"));
// creating composite data source for cs^2 values
CompositeDataSource compositeDataSource3 = new CompositeDataSource(xDataSource, csqDataSource);
// Adding thirs graph to plotter
Pen dashed = new Pen(Brushes.Magenta, 3);
dashed.DashStyle = DashStyles.Dot;
plotter.AddLineGraph(compositeDataSource3,
dashed,
new PenDescription("Cos^2"));
// Force evertyhing plotted to be visible
plotter.FitToView();
}
示例11: ExperimentalIV_DataSource
public ExperimentalIV_DataSource(List<PointD> data)
{
_ExperimentalData = data;
_ExperimentalDataSource = new EnumerableDataSource<PointD>(_ExperimentalData);
_ExperimentalDataSource.SetXMapping(x => x.X);
_ExperimentalDataSource.SetYMapping(y => y.Y);
dispatcher = Dispatcher.CurrentDispatcher;
}
示例12: CreatePerformanceGraph
private void CreatePerformanceGraph(string instanceName, string counterName)
{
var perfData = new PerformanceData(new PerformanceCounter("Process", counterName, instanceName));
var filteredData = new FilteringDataSource<PerformanceInfo>(perfData, new MaxSizeFilter());
var dataSource = new EnumerableDataSource<PerformanceInfo>(filteredData);
dataSource.SetXMapping(pi => (pi.Time.TimeOfDay.TotalSeconds - (_currentTotal == 0 ? _currentTotal = pi.Time.TimeOfDay.TotalSeconds : _currentTotal)));
dataSource.SetYMapping(pi => Proc.GetCpuValue(pi.Value));
Plotter.AddLineGraph(dataSource, 0.8, string.Format("{0} - {1}", counterName, instanceName));
}
示例13: Handle
/// <summary>
/// Updates the graph of the histogram with the newly calculated data of the frame
/// once it is rendered.
/// </summary>
public override void Handle(Pipeline.TickRenderedMessage message)
{
Data = new EnumerableDataSource<KeyValuePair<int, double>>(
NodeModel.Data.Select((datum, idx) => new KeyValuePair<int, double>(idx, datum))
);
Data.SetXMapping(k => k.Key);
Data.SetYMapping(k => k.Value);
NotifyOfPropertyChange(() => Data);
}
示例14: AddLineGraph
private void AddLineGraph(Point startPoint, Point endPoint)
{
var ds = new EnumerableDataSource<Point>(new List<Point> {
new Point { X = startPoint.X, Y = startPoint.Y },
new Point { X = endPoint.X, Y = endPoint.Y }
});
ds.SetXYMapping(pt => pt);
plotter.AddLineGraph(ds);
}
示例15: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// Prepare table. We use standart data table
DataTable table = new DataTable();
table.Columns.Add("Sine", typeof(double));
table.Columns.Add("Time", typeof(DateTime));
table.Columns.Add("Index", typeof(int));
table.Columns.Add("Sqrt", typeof(double));
for (int i = 0; i < 100; i++)
{
table.Rows.Add(
Math.Sin(i / 10.0),
DateTime.Now + new TimeSpan(0, 0, i),
i,
Math.Sqrt(i));
}
// Prepare data source with mapping
TableDataSource data = new TableDataSource(table);
// X is time in seconds
data.SetXMapping(row => ((DateTime)row["Time"] - (DateTime)table.Rows[0][1]).TotalSeconds);
// Y is value of "Sine" column
data.SetYMapping(row => 10 * (double)row["Sine"]);
// Map HSB color computes from "Index" column to dependency property Brush of marker
data.AddMapping(ShapePointMarker.FillProperty,
row => new SolidColorBrush(new HsbColor(3 * (int)row["Index"], 1, 1).ToArgbColor()));
// Map "Sqrt" based values to marker size
data.AddMapping(ShapePointMarker.SizeProperty,
row => 4 + (double)row["Sqrt"]);
// Plot first graph
plotter.AddLineGraph(data,
new Pen(Brushes.Blue, 2),
new CirclePointMarker(),
new PenDescription("First series (Sine)"));
// Prepare data source for second graph. table.Rows is enumerable,
// so we can plot its contents as IEnumerable with items of TableRow type
EnumerableDataSource<DataRow> data2 = new EnumerableDataSource<DataRow>(table.Rows);
// X is time in seconds again
data2.SetXMapping(row => ((DateTime)row["Time"] - (DateTime)table.Rows[0][1]).TotalSeconds);
// Y is value of "Sqrt" column
data2.SetYMapping(row => (double)row["Sqrt"]);
// Plot second graph without markers
plotter.AddLineGraph(data2,
Colors.Red, 3.0,
"Second series (Sqrt)");
// Force evertyhing plotted to be visible
plotter.Viewport.FitToView();
}