本文整理汇总了C#中DataPoint类的典型用法代码示例。如果您正苦于以下问题:C# DataPoint类的具体用法?C# DataPoint怎么用?C# DataPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataPoint类属于命名空间,在下文中一共展示了DataPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetData
// Retrieve end of day price data from yahoo finance
public void GetData(string symbol, int period, int observations)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://ichart.yahoo.com/table.csv?s=" + symbol);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
DataPointCollection logReturns = new DataPointCollection();
int i = 0;
string line = sr.ReadLine();// skip first line (header)
string[] m = sr.ReadLine().Split(',');
// The # of items we need to retrieve (make sure right amount)
int j = period*4 + 1;
if (j <= observations*4+1)
{
j = ((observations * 4) + 1);
}
while (i < j)
{
string[] n = sr.ReadLine().Split(',');
double l = Convert.ToDouble(m[4]);
double k = Convert.ToDouble(n[4]);
DataPoint t = new DataPoint(Math.Log(l / k), Convert.ToDateTime(m[0]));
logReturns.Add(t);
m = n;
i++;
}
// Calculate volatilities
double annualFactor = Math.Sqrt(252);
for (i = 0; i < j / 2; ++i)
{
double vol = StandardDeviation(logReturns.GetRange(i, period)) * annualFactor;
DataPoint t = new DataPoint(vol, logReturns[i].Date);
_vols.Add(t);
}
// Calculate std-dev of all volatilities
for(i = 0; i < observations; ++i)
{
double stdDev = StandardDeviation(_vols.GetRange(i, period));
DataPoint t = new DataPoint(stdDev, _vols[i].Date);
_volStdDev.Add(t);
}
// Take subset so we can plot on graph
_vols = _vols.GetRange(0, observations);
}
开发者ID:kev946,项目名称:Hist-Vol-Std-Dev-Graph,代码行数:51,代码来源:Program.cs
示例2: PointsTest
public void PointsTest(int i, double x, double y)
{
var s = GetSpectrum();
var expected = new DataPoint(i, x, y);
var actual = s.Points.ToArray()[i];
Assert.AreEqual(expected, actual);
}
开发者ID:terasato,项目名称:Xbrt,代码行数:7,代码来源:SpectrumTest.cs
示例3: CreateChart
public static void CreateChart(string imagePath,string name, IEnumerable<BenchResult> results, Func<BenchResult,double> selector)
{
Chart chart = new Chart();
chart.Width = 500;
chart.Height = 400;
chart.Titles.Add(name);
var area = new ChartArea("Default");
chart.ChartAreas.Add(area);
var series = new Series("Default");
chart.Series.Add(series);
area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep90;
area.AxisX.LabelStyle.TruncatedLabels = false;
area.AxisX.Interval = 1;
series.ChartType = SeriesChartType.Column;
series.IsValueShownAsLabel = true;
series.XValueType = ChartValueType.String;
series.YValueType = ChartValueType.Int32;
foreach(var r in results.OrderBy( r => selector(r)))
{
DataPoint point = new DataPoint();
point.SetValueXY(r.Serializer.Replace("Adapter",""),(int)Math.Round(selector(r)));
point.AxisLabel = r.Serializer.Replace("Adapter", "");
series.Points.Add(point);
}
chart.SaveImage(imagePath, ChartImageFormat.Png);
}
开发者ID:etishor,项目名称:SerializationTests,代码行数:29,代码来源:ChartHelper.cs
示例4: uxGamesRepeater_ItemDataBound
protected void uxGamesRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
UserMeanGameScore mgs = (UserMeanGameScore)e.Item.DataItem;
//e.Item.FindControl("uxIndividualCharge");
if (Session["SessionId"] != null)
{
Guid sessionId = new Guid(Session["SessionId"].ToString());
GamesScoreWS.GameScoreService gsClient = new GamesScoreWS.GameScoreService();
IndividualGameResults igResults = gsClient.FetchIndividualGames(sessionId, mgs.GameId);
if (igResults.Success)
{
Chart createChart = (Chart)e.Item.FindControl("uxIndividualCharge");
createChart.Titles.Add(mgs.Game);
Series resultsSeries = createChart.Series["GameScores"];
foreach (t_GameResults gr in igResults.GameResultList)
{
DataPoint dp = new DataPoint();
decimal indexical = ((decimal)gr.Score / (decimal)gr.Total) * 100;
dp.SetValueXY(gr.Created.ToShortDateString(), indexical);
dp.ToolTip = string.Format("{0} out of {1} in {2} seconds", gr.Score, gr.Total, gr.TestDuration);
resultsSeries.Points.Add(dp);
}
}
}
}
开发者ID:kbinghamibs,项目名称:UMKC5551_Project,代码行数:26,代码来源:Default.aspx.cs
示例5: Add
protected override void Add(DataPoint<decimal> dataPoint)
{
//TimeSeriesLock.EnterWriteLock();
try
{
TimeSeries.Add(dataPoint);
}
finally
{
// TimeSeriesLock.ExitWriteLock();
}
OnNewDataPoint(dataPoint);
bool haveToProcess = false;
//TimeSeriesLock.EnterReadLock();
try
{
haveToProcess = TimeSeries.Count >= _period;
}
finally
{
//TimeSeriesLock.ExitReadLock();
}
// not ideal, value can still change, but it is acceptable for the stats
if (haveToProcess)
ProcessNewValue();
}
开发者ID:msxor,项目名称:TradingAtomics,代码行数:28,代码来源:DataPointCountIndicator.cs
示例6: GetPaletteEntryIndex
private int GetPaletteEntryIndex(DataPoint dp)
{
var series = (ChartSeries)dp.Presenter;
var cartesianChart = series.Chart as RadCartesianChart;
var pieChart = series.Chart as RadPieChart;
int index;
if (cartesianChart != null)
{
BarSeries barSeries = series as BarSeries;
BubbleSeries bubbleSeries = series as BubbleSeries;
if ((barSeries != null && barSeries.PaletteMode == SeriesPaletteMode.DataPoint) ||
(bubbleSeries != null && bubbleSeries.PaletteMode == SeriesPaletteMode.DataPoint))
{
index = dp.Index;
}
else
{
index = cartesianChart.Series.IndexOf((CartesianSeries)series);
}
}
else if (pieChart != null)
{
index = pieChart.Series.IndexOf((PieSeries)series);
}
else
{
index = ((RadPolarChart)series.Chart).Series.IndexOf((PolarSeries)series);
}
return index;
}
开发者ID:Rufix,项目名称:xaml-sdk,代码行数:32,代码来源:PaletteBrushConverter.cs
示例7: Slope
public static double Slope(DataPoint[] points)
{
double xAvg = 0, yAvg = 0;
for (int i = 0; i < points.Length; i++)
{
xAvg += points[i].temperature;
yAvg += points[i].position;
}
xAvg = xAvg / points.Length;
yAvg = yAvg / points.Length;
double v1 = 0;
double v2 = 0;
for (int i = 0; i < points.Length; i++)
{
v1 += (points[i].temperature - xAvg) * (points[i].position - yAvg);
v2 += Math.Pow(points[i].temperature - xAvg, 2);
}
double a = v1 / v2;
return a;
}
开发者ID:ejholmes,项目名称:openfocus,代码行数:26,代码来源:FocusMax.cs
示例8: RestClient_posts_metrics
public async void RestClient_posts_metrics()
{
var metricName = GetUniqueMetricName();
var dataPoint = new DataPoint(DateTime.UtcNow.MillisecondsSinceEpoch(), 5L);
var metric = new Metric(metricName)
.AddTag("route_id", "1")
.AddDataPoint(dataPoint);
await _client.AddMetricsAsync(new[] {metric});
var query = new QueryBuilder()
.SetStart(TimeSpan.FromSeconds(5))
.AddQueryMetric(new QueryMetric(metricName));
Thread.Sleep(TimeSpan.FromSeconds(2));
var response = await _client.QueryMetricsAsync(query);
response.Queries.Should().HaveCount(1);
response.Queries[0].SampleSize.Should().Be(1);
response.Queries[0].Results.Should().HaveCount(1);
response.Queries[0].Results[0].DataPoints.Single().ShouldBeEquivalentTo(dataPoint);
}
开发者ID:syncromatics,项目名称:KairosDbClientDotNet,代码行数:25,代码来源:RestClientTests.cs
示例9: QueryMetricsAsync_uses_sum_aggregator
public async void QueryMetricsAsync_uses_sum_aggregator()
{
var metricName = GetUniqueMetricName();
var time = DateTime.UtcNow.MillisecondsSinceEpoch();
var dataPoint = new DataPoint(time, 10L);
var dataPoint2 = new DataPoint(time + 1, 30L);
var metric = new Metric(metricName)
.AddTag("route_id", "1")
.AddDataPoint(dataPoint2)
.AddDataPoint(dataPoint);
await _client.AddMetricsAsync(new[] { metric });
var queryMetric = new QueryMetric(metricName)
.AddAggregator(new SumAggregator(1, TimeUnit.Minutes));
var query = new QueryBuilder()
.SetStart(TimeSpan.FromSeconds(10))
.AddQueryMetric(queryMetric);
Thread.Sleep(TimeSpan.FromSeconds(2));
var response = await _client.QueryMetricsAsync(query);
response.Queries.Should().HaveCount(1);
response.Queries[0].Results.Should().HaveCount(1);
response.Queries[0].Results[0].DataPoints.Single().Value.Should().Be(40L);
}
开发者ID:syncromatics,项目名称:KairosDbClientDotNet,代码行数:31,代码来源:RestClientTests.cs
示例10: AddChartSeries
// Override the AddChartSeries method to provide the chart data
protected override void AddChartSeries()
{
ChartSeriesData = new List<Series>();
var series = new Series()
{
ChartType = SeriesChartType.Pie,
BorderWidth = 1
};
var shares = chartData.ShareData;
foreach (var share in shares)
{
var point = new DataPoint();
point.IsValueShownAsLabel = true;
point.AxisLabel = share.Name;
point.ToolTip = share.Name + " " +
share.Share.ToString("#0.##%");
if (share.Url != null)
{
point.MapAreaAttributes = "href=\"" +
share.Url + "\"";
}
point.YValues = new double[] { share.Share };
point.LabelFormat = "P1";
series.Points.Add(point);
}
ChartSeriesData.Add(series);
}
开发者ID:chung1991,项目名称:webenterprise,代码行数:30,代码来源:BrowserShareChart.cs
示例11: ValidMessage_ProducesValidJson
public void ValidMessage_ProducesValidJson()
{
var name = "foo";
var value = 1923;
var instance = "i-349da92";
var collectedAt = new DateTime(2012, 1, 2);
var collectedAtEpochSeconds = (long) collectedAt.Subtract(CustomMetricsMessage.EpochTime).TotalSeconds;
var dp = new DataPoint(name, value, collectedAt, instance);
var now = DateTime.UtcNow;
var msg = new CustomMetricsMessage(dp);
var json = msg.ToJson();
Assert.NotNull(json);
var deserialized = (JObject)JsonConvert.DeserializeObject(json);
Assert.Equal(CustomMetricsMessage.ProtocolVersion, deserialized["proto_version"].Value<int>());
Assert.True(deserialized["timestamp"].Value<long>() >= CustomMetricsMessage.EpochTime.Subtract(now).TotalSeconds);
var pointsArray = deserialized["data"].Value<JArray>();
Assert.NotNull(pointsArray);
Assert.Equal(1, pointsArray.Count);
var data0 = (JObject)pointsArray[0];
Assert.Equal(name, data0["name"].Value<string>());
Assert.Equal(value, data0["value"].Value<int>());
Assert.Equal(instance, data0["instance"].Value<string>());
Assert.Equal(collectedAtEpochSeconds, data0["collected_at"].Value<long>());
}
开发者ID:hudl,项目名称:stackdriver.net,代码行数:29,代码来源:CustomMetricsMessageTests.cs
示例12: BindProductSalesChart
public void BindProductSalesChart(int year)
{
using (CartDataClassesDataContext context = new CartDataClassesDataContext())
{
var productSales = from o in context.Orders
where o.DatePlaced.Value.Year == year
group o by o.DatePlaced.Value.Month into g
orderby g.Key
select new
{
Month = g,
TopProducts = (from op in context.OrderProducts
where op.OrderDate.Value.Year == year && op.OrderDate.Value.Month == g.Key
group op by op.ProductID into opg
orderby opg.Count() descending
select new { ProductName = context.Products.Where(p => p.ProductID == opg.Key).Single().ProductName, ProductCount = opg.Count() }).Take(5)
};
foreach (var sale in productSales)
{
Series series = new Series(Enum.Parse(typeof(Month), sale.Month.FirstOrDefault().DatePlaced.Value.Month.ToString()).ToString()) { ChartType = SeriesChartType.Bubble};
foreach (var topProduct in sale.TopProducts){
DataPoint point = new DataPoint() { XValue = sale.Month.Key, YValues = new double[] { (double)topProduct.ProductCount }, Label = topProduct.ProductName };
series.Points.Add(point);
}
ProductSalesChart.Series.Add(series);
}
}
}
开发者ID:BritishBuddha87,项目名称:shopAlott,代码行数:30,代码来源:Default.aspx.cs
示例13: DataPoint
public static DataPoint operator +(DataPoint d1, DataPoint d2)
{
DataPoint temp = new DataPoint();
temp.Commits = d1.Commits + d2.Commits;
temp.AddedLines = d1.AddedLines + d2.AddedLines;
temp.DeletedLines = d1.DeletedLines + d2.DeletedLines;
return temp;
}
开发者ID:HuChundong,项目名称:gitextensions,代码行数:8,代码来源:ImpactLoader.cs
示例14: addPoint
public void addPoint(DataPoint point)
{
lock (this.theLock)
{
points.Add(point);
dataPoints.Add(point.AsDataObject());
}
}
开发者ID:somenobody0,项目名称:Anomaly-Detection-Project,代码行数:8,代码来源:DataContainer.cs
示例15: DataVector
public DataVector(DataPoint pt1, DataPoint pt2)
{
xDiff = pt2.X - pt1.X;
yDiff = pt2.Y - pt1.Y;
if (xDiff != 0 || yDiff != 0)
{
isZero = false;
}
}
开发者ID:buaaqlyj,项目名称:CurvePane,代码行数:9,代码来源:DataVector.cs
示例16: GetLabelLayoutSlot
public override RadRect GetLabelLayoutSlot(DataPoint point, FrameworkElement visual, int labelIndex)
{
visual.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
double x = point.LayoutSlot.X + ((point.LayoutSlot.Width - visual.ActualWidth) / 2);
double y = point.LayoutSlot.Y + ((point.LayoutSlot.Height - visual.ActualHeight) / 2);
return new RadRect(x, y, visual.ActualWidth, visual.ActualHeight);
}
开发者ID:msincenselee,项目名称:win8-xaml-sdk,代码行数:9,代码来源:CenterInsideLabelStrategy.cs
示例17: MetricTelemetry
/// <summary>
/// Initializes a new instance of the <see cref="MetricTelemetry"/> class with empty
/// properties.
/// </summary>
public MetricTelemetry()
{
this.Data = new MetricData();
this.Metric = new DataPoint();
this.context = new TelemetryContext(this.Data.properties, new Dictionary<string, string>());
// We always have a single 'metric'.
this.Data.metrics.Add(this.Metric);
}
开发者ID:bitstadium,项目名称:HockeySDK-Windows,代码行数:13,代码来源:MetricTelemetry.cs
示例18: GetLabelLayoutSlot
public override RadRect GetLabelLayoutSlot(DataPoint point, FrameworkElement visual, int labelIndex)
{
var size = new Size(visual.ActualWidth + visual.Margin.Left + visual.Margin.Right, visual.ActualHeight + visual.Margin.Top + visual.Margin.Bottom);
var series = (ChartSeries)point.Presenter;
double top = point.LayoutSlot.Center.Y - (size.Height / 2);
double left = series.Chart.PlotAreaClip.Right - size.Width + Offset;
return new RadRect(left, top, size.Width, size.Height);
}
开发者ID:unicloud,项目名称:FRP,代码行数:10,代码来源:RightAlignedLabelStrategy.cs
示例19: addDataPoint
public void addDataPoint(DataContainer container, DataPoint point)
{
//Add data point to container
container.addPoint(point);
//If the container is full, push to the server
if (container.count() >= MAX_DATA_POINTS)
{
pushData(container);
}
}
开发者ID:somenobody0,项目名称:Anomaly-Detection-Project,代码行数:11,代码来源:DataController.cs
示例20: ReceivedData
public virtual void ReceivedData(DataPoint data)
{
GetComponent<Pulse>().ScaleSecond();
if(imSpecial) {
imSpecial.OnReceivedData(data);
}
else {
nodeState = NodeState.active;
data.FindNewTarget(this);
timeToLoneliness = 2.3f;
}
}
开发者ID:Kahrzdn,项目名称:GameJam14,代码行数:12,代码来源:Node.cs
注:本文中的DataPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论