//Constructor generates the values for all the values in the class, including the equation public StraightFit(ObservableCollection <CoordPoint> coordinates, ChartBounds CurrentBounds, Canvas currentCanvas) { this.currentCanvas = currentCanvas; this.maxBoundsX = CurrentBounds.MaxBoundsX; this.minBoundsX = CurrentBounds.MinBoundsX; this.maxBoundsY = CurrentBounds.MaxBoundsY; this.minBoundsY = CurrentBounds.MinBoundsY; this.coordinates = coordinates; for (int i = 0; i < coordinates.Count; i++) { XValues.Add(coordinates[i].X); } for (int i = 0; i < coordinates.Count; i++) { YValues.Add(coordinates[i].Y); } xBar = Mean(XValues); yBar = Mean(YValues); Sxy = Variance(XValues, YValues); Sxx = Variance(XValues, XValues); Gradient = Sxy / Sxx; YIntercept = yBar - (Gradient * xBar); }
public ExponentialIncreaseFit(ObservableCollection <CoordPoint> coordinates, Canvas currentCanvas, ChartBounds CurrentBounds, double C) { this.currentCanvas = currentCanvas; this.maxBoundsX = CurrentBounds.MaxBoundsX; this.minBoundsX = CurrentBounds.MinBoundsX; this.maxBoundsY = CurrentBounds.MaxBoundsY; this.minBoundsY = CurrentBounds.MinBoundsY; this.coordinates = coordinates; this.C = C; // Puts the X and Y values into their on list so they can be calculated on for (int i = 0; i < coordinates.Count; i++) { XValues.Add(coordinates[i].X); } for (int i = 0; i < coordinates.Count; i++) { YValues.Add((((coordinates[i].Y / C) - 1) * -1)); } // Sets the curve values A = GetA(); B = GetB(); }
/// <summary> /// Handles the CollectionChanged event of the PointsSource control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param> void PointsSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { double xValue = GetReflectionValue(XPath, PointsSource, XValues.Count + 1); double yValue = GetReflectionValue(YPath, PointsSource, YValues.Count + 1); XValues.Add(xValue); YValues.Add(xValue); Points.Add(new ChartPoint() { XValue = xValue, YValue = yValue }); } else if (e.Action == NotifyCollectionChangedAction.Remove) { IList oldItems = e.OldItems; double oldXValue = GetReflectionValueFromItem(XPath, oldItems[0]); int index = XValues.IndexOf(oldXValue); XValues.RemoveAt(index); YValues.RemoveAt(index); Points.RemoveAt(index); } else if (e.Action == NotifyCollectionChangedAction.Reset) { Points.Clear(); GeneratePointsFromSource(); } }
private void RegisterObject(int _kind, Guid _xObjectUid) { ServerXList list; IServerXValue value; if (!XValues.TryGetValue(_kind, out value)) { list = new ServerXList(); XValues.Add(_kind, list); } else { list = (ServerXList)value; } list.AddChildUid(_xObjectUid); }
public void addData(double x, double y, double z) { lock (_lockObj) { XValues.Add(new DataPoint(XValues.Count, x)); YValues.Add(new DataPoint(YValues.Count, y)); ZValues.Add(new DataPoint(ZValues.Count, z)); if (MaxCount == ZValues.Count) { XValues.RemoveAt(0); reNumbering(XValues); YValues.RemoveAt(0); reNumbering(YValues); ZValues.RemoveAt(0); reNumbering(ZValues); } parseData(); } }
/// <inheritdoc /> /// <summary> /// Main Parse Function for the Lwpolyline Class /// </summary> /// <param name="list"></param> /// <param name="index"></param> /// <returns>True or false if the parse was successful</returns> public override bool Parse(TaggedDataList list, int index) { for (var currentIndex = index + 1; currentIndex < list.Length; ++currentIndex) { var currentData = list.GetPair(currentIndex); if (currentData.GroupCode == GroupCodesBase.EntityType) { break; } if (base.Parse(list, currentIndex)) { continue; } switch (currentData.GroupCode) { // Number of Vertices case LwPolylineCodes.NumberOfVertices: NumberOfVertices = int.Parse(currentData.Value); continue; // Lwpolyline Flag case LwPolylineCodes.PolylineFlag: PolyLineFlag = currentData.Value.Contains("1"); continue; // Constant Width case LwPolylineCodes.ConstantWidth: ConstantWidth = double.Parse(currentData.Value); continue; // Elevation case LwPolylineCodes.Elevation: Elevation = double.Parse(currentData.Value); continue; // Thickness case LwPolylineCodes.Thickness: Thickness = double.Parse(currentData.Value); continue; // X values case GroupCodesBase.XPoint: BulgeList.Add(Bulge.BulgeNull); XValues.Add(double.Parse(currentData.Value)); continue; // Y values case GroupCodesBase.YPoint: YValues.Add(double.Parse(currentData.Value)); continue; // Bulge Values case LwPolylineCodes.Bulge: BulgeList.RemoveAt(BulgeList.Count - 1); BulgeList.Add(double.Parse(currentData.Value)); continue; default: continue; } } return(true); }
private void UpdateSample(TimeSpan sampleTime, TimeSpan sampleBackFor) { var sampleLimit = DateTimeOffset.Now - sampleBackFor; XMinimum = sampleLimit.ToUnixTimeMilliseconds(); var values = _history.SelectTimeSampleBackwards( x => x.Date, x => x.Balance, sampleTime, sampleLimit, DateTime.Now); XValues.Clear(); YValues.Clear(); foreach (var(timestamp, balance) in values.Reverse()) { YValues.Add((double)balance.ToDecimal(MoneyUnit.BTC)); XValues.Add(timestamp.ToUnixTimeMilliseconds()); } if (YValues.Any()) { var maxY = YValues.Max(); YLabels = new List <string> { "0", (maxY / 2).ToString("F2"), maxY.ToString("F2") }; } else { YLabels = null; } if (XValues.Any()) { var minX = XValues.Min(); var maxX = XValues.Max(); var halfX = minX + ((maxX - minX) / 2); var range = DateTimeOffset.FromUnixTimeMilliseconds((long)maxX) - DateTimeOffset.FromUnixTimeMilliseconds((long)minX); if (range <= TimeSpan.FromDays(1)) { XLabels = new List <string> { DateTimeOffset.FromUnixTimeMilliseconds((long)minX).DateTime.ToString("t"), DateTimeOffset.FromUnixTimeMilliseconds((long)halfX).DateTime.ToString("t"), DateTimeOffset.FromUnixTimeMilliseconds((long)maxX).DateTime.ToString("t"), }; } else if (range <= TimeSpan.FromDays(7)) { XLabels = new List <string> { DateTimeOffset.FromUnixTimeMilliseconds((long)minX).DateTime.ToString("ddd MMM-d"), DateTimeOffset.FromUnixTimeMilliseconds((long)halfX).DateTime.ToString("ddd MMM-d"), DateTimeOffset.FromUnixTimeMilliseconds((long)maxX).DateTime.ToString("ddd MMM-d"), }; } else { XLabels = new List <string> { DateTimeOffset.FromUnixTimeMilliseconds((long)minX).DateTime.ToString("MMM-d"), DateTimeOffset.FromUnixTimeMilliseconds((long)halfX).DateTime.ToString("MMM-d"), DateTimeOffset.FromUnixTimeMilliseconds((long)maxX).DateTime.ToString("MMM-d"), }; } } else { XLabels = null; } }