本文整理汇总了C#中EnumerableDataSource.AddMapping方法的典型用法代码示例。如果您正苦于以下问题:C# EnumerableDataSource.AddMapping方法的具体用法?C# EnumerableDataSource.AddMapping怎么用?C# EnumerableDataSource.AddMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnumerableDataSource
的用法示例。
在下文中一共展示了EnumerableDataSource.AddMapping方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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"));
}
示例2: 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);
Matrix m = Matrix.Identity;
m.RotateAt(45, 10, 10);
line = new LineGraph
{
Stroke = Brushes.Green,
StrokeThickness = 2,
DataTransform =
//new MatrixDataTransform(m)
new RotateDataTransform(45.0.DegreesToRadians())
};
line.DataSource = compositeDataSource;
line.AddToPlotter(plotter);
plotter.Viewport.Constraints.Add(new PhysicalProportionsConstraint { ProportionRatio = 1 });
// adding graph to plotter
plotter.AddLineGraph(compositeDataSource,
new Pen(Brushes.Goldenrod, 3),
new SampleMarker(),
new PenDescription("Cosine"));
//plotter.Viewport.FitToViewRestrictions.Add(new FollowDataWidthRestriction { Width = 1 });
plotter.PreviewKeyDown += plotter_KeyDown;
}
示例3: LineGraphData
public LineGraphData(int size, string description)
{
// Array for data
data = new RingArray<DataPoint>(size);
// Convert to an enumerable data source for line graph
ds = new EnumerableDataSource<DataPoint>(data);
// and set mappings
ds.SetXMapping(x => x.X);
ds.SetYMapping(y => y.Y);
ds.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, p => string.Format("{0}, {1}, " + description, p.X, p.Y));
}
示例4: CreateDataSource
private EnumerableDataSource<DataPoint> CreateDataSource(IEnumerable<DataPoint> data)
{
EnumerableDataSource<DataPoint> ds = new EnumerableDataSource<DataPoint>(data);
MercatorTransform transform = new MercatorTransform();
ds.SetXMapping(p => p.X);
ds.SetYMapping(p => transform.DataToViewport(new Point(0, p.Y)).Y);
ds.AddMapping(CirclePointMarker.FillProperty, dp =>
{
double alpha = (dp.Data - currentRange.Min) / (currentRange.Max - currentRange.Min);
Debug.Assert(0 <= alpha && alpha <= 1);
const double hueWidth = 100;
double hue = hueWidth * (alpha - 0.5) + hueSlider.Value;
if (hue > 360) hue -= 360;
else if (hue < 0) hue += 360;
Debug.Assert(0 <= hue && hue <= 360);
Color mainColor = new HsbColor(hue, 1, 0 + 1 * alpha, 0.3 + 0.7 * alpha).ToArgbColor();
const int colorCount = 5;
GradientStopCollection colors = new GradientStopCollection(colorCount);
double step = 1.0 / (colorCount - 1);
for (int i = 0; i < colorCount; i++)
{
Color color = mainColor;
double x = attSlider.Value * step * i;
color.A = (byte)(255 * Math.Exp(-x * x));
colors.Add(new GradientStop(color, step * i));
}
return new RadialGradientBrush(colors);
});
return ds;
}
示例5: TooltipSample
public TooltipSample()
{
InitializeComponent();
// Prepare data in arrays
for (int i = 0; i < N; i++)
{
x[i] = i * 0.2;
y[i] = Math.Cos(x[i]);
}
// Add data sources:
yDataSource = new EnumerableDataSource<double>(y);
yDataSource.SetYMapping(Y => Y);
yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty,
Y => String.Format("Value is {0}", Y));
xDataSource = new EnumerableDataSource<double>(x);
xDataSource.SetXMapping(X => X);
ds = new CompositeDataSource(xDataSource, yDataSource);
// adding graph to plotter
// todo
//chart = plotter.AddLineGraph(ds,
// new Pen(Brushes.LimeGreen, 3),
// new CircleElementPointMarker
// {
// Size = 10,
// Brush = Brushes.Red,
// Fill = Brushes.Orange
// },
// new PenDescription("Cosine"));
plotter.Children.Add(new CursorCoordinateGraph());
// Force evertyhing plotted to be visible
plotter.FitToView();
}
示例6: PlotNormalDistribution
private void PlotNormalDistribution(double[] data, Histogram histogram, string distributionName, Color color)
{
if (data == null || histogram == null)
return;
var points = 50;
var normalDistribution = new NormalDistribution(data.Average(), Math.Variance(data), points, histogram.LowerBound, histogram.UpperBound);
//var normalDistribution = new NormalDistribution(histogram.Mean(), histogram.Variance(), points, histogram.LowerBound, histogram.UpperBound);
var densityCurve = normalDistribution.DensityCurve;
var xValues = new double[points];
var yValues = new double[points];
for (var index = 0; index < points; index++)
{
xValues[index] = densityCurve[index, 0];
yValues[index] = densityCurve[index, 1];
}
// Add data sources.
var yDataSource = new EnumerableDataSource<double>(yValues);
yDataSource.SetYMapping(Y => Y);
yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Normal Value \n\n{0}", Y));
var xDataSource = new EnumerableDataSource<double>(xValues);
xDataSource.SetXMapping(X => X);
var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);
// MatchValuePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 500000 });
var graph = ChartPlotter.AddLineGraph(compositeDataSource, color, 0.5, distributionName);
// Cache for later usage (e.g. change visibility).
if (graph != null)
_histogramGraphs.Add(graph);
}
示例7: PlotNonlinearity
private void PlotNonlinearity(Nonlinearity nonlinearity, string distributionName, Color color, double lineThickness)
{
if (nonlinearity == null)
return;
var curve = nonlinearity.FiringRateCurve;
// Prepare data in arrays.
var x = new double[curve.GetLength(0)];
var y = new double[curve.GetLength(0)];
for (var index = 0; index < curve.GetLength(0); index++)
{
x[index] = curve[index, 0];
y[index] = curve[index, 1];
}
// Add data sources.
var yDataSource = new EnumerableDataSource<double>(y);
yDataSource.SetYMapping(Y => Y);
yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Normal Value \n\n{0}", Y));
var xDataSource = new EnumerableDataSource<double>(x);
xDataSource.SetXMapping(X => X);
var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);
// MatchValuePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 500000 });
var graph = ChartPlotter.AddLineGraph(compositeDataSource, color, lineThickness, distributionName);
// Cache for later usage (e.g. change visibility).
if (graph != null)
_histogramGraphs.Add(graph);
}
示例8: PlotHistogram
private void PlotHistogram(Histogram histogram, string histogramName, Color color)
{
if (histogram == null)
return;
// Prepare data in arrays.
var pointIndex = 0;
var dataPointCount = 4 * histogram.BucketCount;
var x = new double[dataPointCount];
var y = new double[dataPointCount];
foreach (var bucket in histogram.Buckets())
{
//var yValue = bucket.Count;
var yValue = bucket.RelativeCount(histogram);
// lower left point of the histogram bar
x[pointIndex] = bucket.LowerBound;
y[pointIndex] = 0;
// upper left point of the histogram bar
x[pointIndex + 1] = bucket.LowerBound;
y[pointIndex + 1] = yValue;
// upper right point of the histogram bar
x[pointIndex + 2] = bucket.UpperBound;
y[pointIndex + 2] = yValue;
// lower right point of the histogram bar
x[pointIndex + 3] = bucket.UpperBound;
y[pointIndex + 3] = 0;
pointIndex += 4;
}
// Add data sources.
var yDataSource = new EnumerableDataSource<double>(y);
yDataSource.SetYMapping(Y => Y);
yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Match Value \n\n{0}", Y));
var xDataSource = new EnumerableDataSource<double>(x);
xDataSource.SetXMapping(X => X);
var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);
// MatchValuePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 500000 });
var graph = ChartPlotter.AddLineGraph(compositeDataSource, color, 1, histogramName);
// Cache for later usage (e.g. change visibility).
if (graph != null)
_histogramGraphs.Add(graph);
}
示例9: PlotEigenvalues
private LineAndMarker<ElementMarkerPointsGraph> PlotEigenvalues(int cell, Brush brush)
{
double[] eigenValues;
double[][] eigenVectors;
var stc = SpikeTriggeredAnalysis.CalculateSTC(_stimuli, new double[][][] { _spikes[cell - 1] }, RoundStrategy.Round);
SpikeTriggeredAnalysis.CalculateEigenValues(stc, out eigenValues, out eigenVectors);
// Prepare data in arrays
var N = eigenValues.Length;
var x = new double[N];
var y = new double[N];
for (var index = 0; index < N; index++)
{
x[index] = index;
y[index] = eigenValues[index];
}
// Add data sources:
var yDataSource = new EnumerableDataSource<double>(y);
yDataSource.SetYMapping(Y => Y);
yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Cell {0} - Eigenvalue \n\n{1}", cell, Y));
var xDataSource = new EnumerableDataSource<double>(x);
xDataSource.SetXMapping(X => X);
var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);
EigenvaluePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 30 });
var graph = EigenvaluePlotter.AddLineGraph(compositeDataSource, new Pen(brush, 1), new SampleMarker() { Brush = brush }, new PenDescription(string.Format("Eigenvalues of Cell {0}", cell)));
return graph;
}
示例10: LogYWindow_Loaded
void LogYWindow_Loaded(object sender, RoutedEventArgs e)
{
//ChartPlotter plotter = new ChartPlotter();
//plotter.Children.Add(new CursorCoordinateGraph());
//plotter.DataTransform = new Log10YTransform();
//VerticalAxis axis = new VerticalAxis
//{
// TicksProvider = new LogarithmNumericTicksProvider(10),
// LabelProvider = new UnroundingLabelProvider()
//};
//plotter.MainVerticalAxis = axis;
//plotter.AxisGrid.DrawVerticalMinorTicks = true;
//const int count = 500;
//double[] xs = Enumerable.Range(1, count).Select(x => x * 0.01).ToArray();
//EnumerableDataSource<double> xDS = xs.AsXDataSource();
//var pows = xs.Select(x => Math.Pow(10, x));
//var linear = xs.Select(x => x);
//var logXs = Enumerable.Range(101, count).Select(x => x * 0.01);
//var logarithmic = logXs.Select(x => Math.Log10(x));
//plotter.AddLineGraph(pows.AsYDataSource().Join(xDS), "f(x) = 10^x");
//plotter.AddLineGraph(linear.AsYDataSource().Join(xDS), "f(x) = x");
//plotter.AddLineGraph(logarithmic.AsYDataSource().Join(logXs.AsXDataSource()), "f(x) = log(x)");
//Content = plotter;
ChartPlotter plotter = new ChartPlotter();
plotter.DataTransform = new Log10YTransform();
VerticalAxis yAxis = new VerticalAxis
{
TicksProvider = new LogarithmNumericTicksProvider(10),
LabelProvider = new UnroundingLabelProvider()
};
plotter.MainVerticalAxis = yAxis;
plotter.AxisGrid.DrawVerticalMinorTicks = true;
HorizontalDateTimeAxis xAxis = new HorizontalDateTimeAxis();
plotter.MainHorizontalAxis = xAxis;
EnumerableDataSource<TPoint> edsPow = new EnumerableDataSource<TPoint>(
Enumerable.Range(1, 2000).Select(s =>
new TPoint
{
X = DateTime.Now.AddYears(-20).AddDays(s),
Y = Math.Pow(10, s / 5000.0)
}
).ToList());
//edsPow.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
edsPow.SetXMapping(s => xAxis.ConvertToDouble(s.X));
edsPow.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
edsPow.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));
EnumerableDataSource<TPoint> edsLinear = new EnumerableDataSource<TPoint>(
Enumerable.Range(1, 2000).Select(s =>
new TPoint
{
X = DateTime.Now.AddYears(-20).AddDays(s),
Y = s / 2000.0
}
).ToList());
//edsLinear.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
edsLinear.SetXMapping(s => xAxis.ConvertToDouble(s.X));
edsLinear.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
edsLinear.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));
edsLog10 = new EnumerableDataSource<TPoint>(
Enumerable.Range(1, 2000).Select(s =>
new TPoint
{
X = DateTime.Now.AddYears(-20).AddDays(s),
Y = Math.Log10(s)
}
).Where(s => s.Y > 0).ToList());
//edsLog10.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
edsLog10.SetXMapping(s => xAxis.ConvertToDouble(s.X));
edsLog10.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
edsLog10.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => String.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));
SolidColorBrush brushPow = new SolidColorBrush(Colors.Green);
Pen linePenPow = new Pen(brushPow, 2.0);
CircleElementPointMarker markerPow = new CircleElementPointMarker
{
Size = 4,
Brush = brushPow,
Fill = brushPow
};
PenDescription descPow = new PenDescription("f(x) = 10 ^ x");
//var chartPow = plotter.AddLineGraph(edsPow, linePenPow, (ShapeElementPointMarker)null/*markerPow*/, descPow);
SolidColorBrush brushLinear = new SolidColorBrush(Colors.Blue);
Pen linePenLinear = new Pen(brushLinear, 2.0);
CircleElementPointMarker markerLinear = new CircleElementPointMarker
{
Size = 4,
Brush = brushLinear,
//.........这里部分代码省略.........
示例11: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
List<Point> list = new List<Point>();
Random rnd = new Random();
for (int i = 0; i < 300; i++)
{
list.Add(new Point(i, rnd.Next(50)));
}
EnumerableDataSource<Point> edc;
edc = new EnumerableDataSource<Point>(list);
edc.SetXMapping(x => x.X);
edc.SetYMapping(y => Convert.ToDouble(y.Y));
edc.AddMapping(CircleElementPointMarker.ToolTipTextProperty, s => String.Format("Y-Data : {0}\nX-Data : {1}", s.Y, s.X));
LineGraph line =new LineGraph(edc);
plotter.Children.Add(line);
//,
line.LinePen = new Pen(Brushes.Transparent, 3);
//line. new CircleElementPointMarker
//{
// Size = 15,
// Brush = border,
// Fill = c2
//};
// null
// ));
}
示例12: plot_template
public void plot_template()
{
double[] x_1 = new double[pattern.length];
double[] y_1 = new double[pattern.length]; ;
for (int i = 0; i < pattern.length; i++)
{
x_1[i] = (double)pattern.template_x[i];
y_1[i] = (double)pattern.template_y[i];
}
var yDataSource = new EnumerableDataSource<double>(y_1);
yDataSource.SetYMapping(Y => Y);
yDataSource.AddMapping(Microsoft.Research.DynamicDataDisplay.PointMarkers.ShapeElementPointMarker.ToolTipTextProperty,
Y => string.Format("Value is {0}", Y));
var xDataSource = new EnumerableDataSource<double>(x_1);
xDataSource.SetXMapping(X => X);
CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);
chart_plotter_template = plotter.AddLineGraph(compositeDataSource, Color.FromRgb(12, 0, 4), 2, "Шаблон");
}