/// <summary> /// Gets the data table for this series. /// </summary> private IEnumerable GetData(GraphValues graphValues) { if (graphValues != null && graphValues.TableName == null && graphValues.FieldName != null) { // Use reflection to access a property. return(graphValues.GetData(this.graph)); } else if (graphValues != null && graphValues.TableName != null && graphValues.FieldName != null) { // Create the data if we haven't already if (this.data == null && this.dataStore.TableExists(graphValues.TableName)) { this.data = this.dataStore.GetFilteredData(graphValues.TableName, filter); } // If the field exists in our data table then return it. if (this.data != null && graphValues.FieldName != null && this.data.Columns[graphValues.FieldName] != null) { if (this.data.Columns[graphValues.FieldName].DataType == typeof(DateTime)) { return(DataTableUtilities.GetColumnAsDates(this.data, graphValues.FieldName)); } else if (this.data.Columns[graphValues.FieldName].DataType == typeof(string)) { return(DataTableUtilities.GetColumnAsStrings(this.data, graphValues.FieldName)); } else { return(DataTableUtilities.GetColumnAsDoubles(this.data, graphValues.FieldName)); } } } return(null); }
public void OnPost(List <string> accounts, string start = "", string end = "") { DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); DateTime.TryParse(start, out startDate); DateTime endDate = startDate.AddMonths(4); DateTime.TryParse(end, out endDate); ViewData["Title"] = $"Explore > Cash Flow"; Forecast forecast = null; var accessToken = HttpContext.GetTokenAsync("access_token").Result; var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; _cache.TryGetValue(userId, out forecast); if (forecast == null) { forecast = Cache.GetForecast(accessToken, userId); _cache.Set(userId, forecast); } foreach (var account in forecast.Accounts.Where(a => accounts.Contains(a.AccountId))) { Accounts.Add(new Tuple <string, string>(account.AccountId, account.Name)); } var accountBalances = forecast.Accounts.Where(a => accounts.Contains(a.AccountId)).ToDictionary(k => k.AccountId, v => 0L); var transactionsByDay = forecast.Transactions.Where(t => accounts.Contains(t.AccountId)).GroupBy(g => g.Date.Date).ToDictionary(k => k.Key, v => v.ToList()); var day = forecast.Transactions.Min(t => t.Date.Date); while (day < forecast.ForecastUntil) { if (day >= endDate) { break; } if (transactionsByDay.ContainsKey(day)) { var accountActivity = transactionsByDay[day].GroupBy(g => g.AccountId).ToDictionary(k => k.Key, v => v.Sum(t => t.Amount)); foreach (var accountId in accountActivity.Keys) { accountBalances[accountId] += accountActivity[accountId]; } } foreach (var accountId in accountBalances.Keys) { GraphValues.Add(new Tuple <string, string, long>(day.ToShortDateString(), accountId, accountBalances[accountId])); } day = day.AddDays(1); } GraphValues = GraphValues.Where(t => DateTime.Parse(t.Item1) >= startDate).ToList(); ViewData["LastUpdated"] = forecast.LastModifiedOn; }
public override void Update(GameTime gameTime) { GraphValues.Add(this._statistics.MemoryUsed); if (GraphValues.Count > ValuesToGraph + 1) { GraphValues.RemoveAt(0); } // we must have at least 2 values to start rendering if (GraphValues.Count <= 2) { return; } MaxValue = (int)GraphValues.Max(); AverageValue = (int)GraphValues.Average(); MinimumValue = (int)GraphValues.Min(); CurrentValue = (int)this._statistics.MemoryUsed; if (!AdaptiveLimits) { return; } AdaptiveMaximum = MaxValue; AdaptiveMinimum = 0; }
/// <summary> /// Y2 has been changed by the user. /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void OnY2Changed(object sender, EventArgs e) { GraphValues graphValues = new GraphValues(); graphValues.TableName = this.seriesView.SeriesEditor.DataSource; graphValues.FieldName = this.seriesView.SeriesEditor.Y2; this.SetModelProperty("Y2", graphValues); }
public unsafe static GraphValues ToModel(this DataPacket packet, GraphModel graph, int freq) { GraphValues valueGraph = new GraphValues(packet.Index); foreach (var key in graph.Keys) { valueGraph.AddDetector(key); } ProcessCycle(packet.Cycles.First(), graph, valueGraph, freq); return(valueGraph); }
public Interval <string[]> Match(Word word, int index, Interval scope = null) { var match = Query.Match(word, index, scope); if (match == null) { return(null); } bool matchGraph = word.GraphicalForms.Any(g => g.Intervals.IntersectWith(match) .Where(i => GraphValues.Contains(i.Value)) .Count() > 0); bool isMatch = matchGraph == !Negated; return(isMatch ? match : null); }
public void SelectCell(TableCell cell) { if (cell.IsSelected) { var position = GraphValues.Count; GraphValues.Add(new GraphCell(position, cell)); GraphDataPropertyChanged?.Invoke(new GraphPointCoordinatesUpdated()); } else { GraphValues.Remove(GraphValues.Where(x => x.GraphTableCell.Equals(cell)).Single()); for (int i = 0; i < GraphValues.Count(); i++) { var currentGraphCell = GraphValues.ElementAt(i); currentGraphCell.PositionX = i; } GraphDataPropertyChanged?.Invoke(new GraphPointCoordinatesUpdated()); } }
public static void ProcessCycle(CycleData cycle, GraphModel graph, GraphValues values, int freq) { foreach (var detector in graph.Keys) { var detectorData = cycle.Values .Where(x => x.Detector == detector) .ToArray(); graph.TryGetValue(detector, out var sources); foreach (var source in sources) { try { var row = (source - 1) % cycle.Mode; var measurement = detectorData[row]; var i = ((source * 2) / cycle.Mode) + (freq % 2); if (i >= measurement.Imag.Length) { continue; } var imag = measurement.Imag[i]; var real = measurement.Real[i]; var ac = Math.Sqrt(Math.Pow(imag, 2) + Math.Pow(real, 2)); var phase = Math.Atan2(imag, real); values.SetSourceValue(detector, source, new NodeValue() { AC = ac, Phase = phase }); } catch { } } } }
private void showStatistics() { GraphValues.Clear(); double tempDouble, maxValue = 0; for (int i = 0; i < StatisticalRelocations.Count; i++) { foreach (Report report in ShownReports) { if (report.ClusterIdNumber == i) { tempDouble = report.GetCoordinate().GetDistanceTo(StatisticalRelocation[i]); if (tempDouble > maxValue) { maxValue = tempDouble / 1000; } } } GraphValues.Add(maxValue); } }
private void fetchReport(int reportId) { //showKMeansResult(); foreach (Report rep in ShownReports) { if (rep.ReportID == reportId) { SelectedReport.Address = rep.Address; SelectedReport.FallingTime = rep.FallingTime; SelectedReport.LatLongLocation = rep.LatLongLocation; SelectedReport.NumberOfBooms = rep.NumberOfBooms; SelectedReport.ReporterID = rep.ReporterID; SelectedReport.ReportID = rep.ReportID; SelectedReport.Updated = rep.Updated; Reporter tempRep = FactoryDal.GetDal().GetReporter(SelectedReport.ReporterID); Reporter.LatLongReporterLocation = tempRep.LatLongReporterLocation; Reporter.ReporterAddress = tempRep.ReporterAddress; Reporter.ReporterID = tempRep.ReporterID; Reporter.ReporterName = tempRep.ReporterName; Reporter.ReporterProfilePicture = tempRep.ReporterProfilePicture; GraphValues.Clear(); double distance = 0; for (int i = 0; i < StatisticalRelocations.Count; i++) { if (rep.ClusterIdNumber == i) { try { Idal dal = FactoryDal.GetDal(); UpdatedReport upReport = dal.GetUpdatedReport(rep.ReportID); double lon = getLong(upReport.NewCoordinates); double lat = getLat(upReport.NewCoordinates); GeoCoordinate g = new GeoCoordinate(lat, lon); distance = g.GetDistanceTo(StatisticalRelocation[i]) / 1000; string[] latLong = upReport.NewCoordinates.ToString().Split(','); Details1 = ReverseGeoCoding(latLong[0], latLong[1]); string[] latLong2 = StatisticalRelocations[i].ToString().Split(','); Details2 = ReverseGeoCoding(latLong2[0], latLong2[1]); SelectedReport.Details1 = details1; SelectedReport.Details2 = details2; } catch (Exception) { MessageBox.Show("The report hasn't been updated, \n please update the report first!"); //throw new Exception("The report not updated \n please update the report first"); } } } GraphValues.Add(distance); GraphValues.Add(distance); } } }
public AreaGraphData(SrmDocument document, DocNode docNode, DisplayTypeChrom displayType, GraphValues.ReplicateGroupOp replicateGroupOp, int ratioIndex, AreaNormalizeToData normalize, AreaExpectedValue expectedVisible, PaneKey paneKey) : base(document, docNode, displayType, replicateGroupOp, paneKey) { _docNode = docNode; _ratioIndex = ratioIndex; _normalize = normalize; _expectedVisible = expectedVisible; }
private void UpdateAxes(bool resetAxes, GraphValues.AggregateOp aggregateOp, AreaNormalizeToData normalizeData, AreaNormalizeToView areaView, IsotopeLabelType standardType) { if (resetAxes) { XAxis.Scale.MaxAuto = XAxis.Scale.MinAuto = true; YAxis.Scale.MaxAuto = true; } if (BarSettings.Type == BarType.PercentStack) { YAxis.Scale.Max = 100; YAxis.Scale.MaxAuto = false; YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Percentage); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } else { if (normalizeData == AreaNormalizeToData.optimization) { // If currently log scale or normalized to max, reset the y-axis max if (YAxis.Type == AxisType.Log || YAxis.Scale.Max == 1) YAxis.Scale.MaxAuto = true; YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Percent_of_Regression_Peak_Area); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } else if (areaView == AreaNormalizeToView.area_maximum_view) { YAxis.Scale.Max = 1; if (IsDotProductVisible) // Make YAxis Scale Max a little higher to accommodate for the dot products YAxis.Scale.Max = 1.1; YAxis.Scale.MaxAuto = false; YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Normalized); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } else if (Settings.Default.AreaLogScale) { // If currently not log scale, reset the y-axis max if (YAxis.Type != AxisType.Log) YAxis.Scale.MaxAuto = true; if (Settings.Default.PeakAreaMaxArea != 0) { YAxis.Scale.MaxAuto = false; YAxis.Scale.Max = Settings.Default.PeakAreaMaxArea; } YAxis.Type = AxisType.Log; YAxis.Title.Text = GraphValues.AnnotateLogAxisTitle(aggregateOp.AnnotateTitle( Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area)); YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 1; } else { // If currently log scale, reset the y-axis max if (YAxis.Type == AxisType.Log) YAxis.Scale.MaxAuto = true; if (Settings.Default.PeakAreaMaxArea != 0) { YAxis.Scale.MaxAuto = false; YAxis.Scale.Max = Settings.Default.PeakAreaMaxArea; } else if (!YAxis.Scale.MaxAuto) { YAxis.Scale.MaxAuto = true; } string yTitle = Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area; switch (areaView) { case AreaNormalizeToView.area_ratio_view: yTitle = string.Format(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Ratio_To__0_, standardType.Title); break; case AreaNormalizeToView.area_global_standard_view: yTitle = Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Ratio_To_Global_Standards; break; } YAxis.Title.Text = aggregateOp.AnnotateTitle(yTitle); YAxis.Type = AxisType.Linear; YAxis.Scale.MinAuto = false; FixedYMin = YAxis.Scale.Min = 0; } // Handle a switch from percent stack if (!YAxis.Scale.MaxAuto && YAxis.Scale.Max == 100) YAxis.Scale.MaxAuto = true; } Legend.IsVisible = Settings.Default.ShowPeakAreaLegend; AxisChange(); // Reformat Y-Axis for labels and whiskers var maxY = GraphHelper.GetMaxY(CurveList,this); if (IsDotProductVisible) { var extraSpace = _lableHeight*(maxY/(Chart.Rect.Height - _lableHeight*2))*2; maxY += extraSpace; } GraphHelper.ReformatYAxis(this, maxY); }
public RTGraphData(SrmDocument document, TransitionGroupDocNode selectedGroup, PeptideGroupDocNode selectedProtein, int? result, DisplayTypeChrom displayType, GraphValues.IRetentionTimeTransformOp retentionTimeTransformOp ) : base(document, selectedGroup, selectedProtein, result, displayType, retentionTimeTransformOp, PaneKey.DEFAULT) { }
protected GraphData(SrmDocument document, TransitionGroupDocNode selectedGroup, PeptideGroupDocNode selectedProtein, int? iResult, DisplayTypeChrom displayType, GraphValues.IRetentionTimeTransformOp retentionTimeTransformOp, PaneKey paneKey) { RetentionTimeTransformOp = retentionTimeTransformOp; // Determine the shortest possible unique ID for each peptide or molecule var sequences = new List<Tuple<string, bool>>(); foreach (var nodePep in document.Molecules) sequences.Add(new Tuple<string, bool>(nodePep.RawTextId, nodePep.IsProteomic)); var uniquePrefixGenerator = new UniquePrefixGenerator(sequences, 3); int pointListCount = 0; var dictTypeToSet = new Dictionary<IsotopeLabelType, int>(); bool onePointPerPeptide = PeptideOrder == SummaryPeptideOrder.document && null != paneKey.IsotopeLabelType; // Figure out how many point lists to create bool displayTotals = (displayType == DisplayTypeChrom.total); if (displayTotals) { foreach (var nodeGroup in document.MoleculeTransitionGroups) { if (!paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } IsotopeLabelType labelType = nodeGroup.TransitionGroup.LabelType; if (!dictTypeToSet.ContainsKey(labelType)) dictTypeToSet.Add(labelType, pointListCount++); } } else { foreach (var nodeGroup in document.MoleculeTransitionGroups) { if (!paneKey.IncludesTransitionGroup(nodeGroup)) { continue; } pointListCount = Math.Max(pointListCount, GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).Count()); } } // Build the list of points to show. var listPoints = new List<GraphPointData>(); foreach (PeptideGroupDocNode nodeGroupPep in document.MoleculeGroups) { if (AreaGraphController.AreaScope == AreaScope.protein) { if (!ReferenceEquals(nodeGroupPep, selectedProtein)) continue; } foreach (PeptideDocNode nodePep in nodeGroupPep.Children) { bool addBlankPoint = onePointPerPeptide && !nodePep.TransitionGroups.Any(paneKey.IncludesTransitionGroup); foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { var path = new IdentityPath(nodeGroupPep.PeptideGroup, nodePep.Peptide, nodeGroup.TransitionGroup); var graphPointData = new GraphPointData(nodePep, nodeGroup, path); if (addBlankPoint || paneKey.IncludesTransitionGroup(nodeGroup)) { listPoints.Add(graphPointData); } if (addBlankPoint) { break; } } } } // Sort into correct order var peptideOrder = PeptideOrder; if (peptideOrder == SummaryPeptideOrder.time) { if (displayTotals) listPoints.Sort(ComparePeptideTimes); else listPoints.Sort(CompareGroupTimes); } else if (peptideOrder == SummaryPeptideOrder.area) { listPoints.Sort(CompareGroupAreas); } // Init calculated values var pointPairLists = new List<PointPairList>(); var labels = new List<string>(); var xscalePaths = new List<IdentityPath>(); double maxY = 0; double minY = double.MaxValue; int selectedIndex = -1; for (int i = 0; i < pointListCount; i++) pointPairLists.Add(new PointPairList()); // Calculate lists and values PeptideDocNode nodePepCurrent = null; int chargeCount = 0, chargeCurrent = 0; foreach (var dataPoint in listPoints) { var nodePep = dataPoint.NodePep; var nodeGroup = dataPoint.NodeGroup; if (!ReferenceEquals(nodePep, nodePepCurrent)) { nodePepCurrent = nodePep; chargeCount = GetChargeCount(nodePep); chargeCurrent = 0; } bool addLabel = !displayTotals; if (displayTotals && nodeGroup.TransitionGroup.PrecursorCharge != chargeCurrent) { LevelPointPairLists(pointPairLists); addLabel = true; } chargeCurrent = nodeGroup.TransitionGroup.PrecursorCharge; var transitionGroup = nodeGroup.TransitionGroup; int iGroup = labels.Count; if (addLabel) { string label = uniquePrefixGenerator.GetUniquePrefix(nodePep.RawTextId, nodePep.IsProteomic) + (chargeCount > 1 ? Transition.GetChargeIndicator(transitionGroup.PrecursorCharge) : string.Empty); if (!displayTotals && null == paneKey.IsotopeLabelType) label += transitionGroup.LabelTypeText; if (peptideOrder == SummaryPeptideOrder.time) { label += string.Format(" ({0:F01})", displayTotals ? // Not L10N dataPoint.TimePepCharge : dataPoint.TimeGroup); } labels.Add(label); xscalePaths.Add(dataPoint.IdentityPath); } double groupMaxY = 0; double groupMinY = double.MaxValue; // ReSharper disable DoNotCallOverridableMethodsInConstructor int? resultIndex = iResult.HasValue && iResult >= 0 ? iResult : null; if (RTLinearRegressionGraphPane.ShowReplicate == ReplicateDisplay.best && nodePep != null) { resultIndex = null; int iBest = nodePep.BestResult; if (iBest !=-1) resultIndex = iBest; } if (displayTotals) { var labelType = nodeGroup.TransitionGroup.LabelType; if (dictTypeToSet.ContainsKey(labelType)) { if (paneKey.IncludesTransitionGroup(nodeGroup)) { pointPairLists[dictTypeToSet[labelType]].Add(CreatePointPair(iGroup, nodeGroup, ref groupMaxY, ref groupMinY, resultIndex)); } else { pointPairLists[dictTypeToSet[labelType]].Add(PointPairMissing(iGroup)); } } } else { if (paneKey.IncludesTransitionGroup(nodeGroup)) { var nodeTrans = GraphChromatogram.GetDisplayTransitions(nodeGroup, displayType).ToArray(); for (int i = 0; i < pointListCount; i++) { var pointPairList = pointPairLists[i]; pointPairList.Add(i >= nodeTrans.Length ? CreatePointPairMissing(iGroup) : CreatePointPair(iGroup, nodeTrans[i], ref groupMaxY, ref groupMinY, resultIndex)); } } else { for (int i = 0; i < pointListCount; i++) { pointPairLists[i].Add(CreatePointPairMissing(iGroup)); } } } // ReSharper restore DoNotCallOverridableMethodsInConstructor // Save the selected index and its y extent if (ReferenceEquals(selectedGroup, nodeGroup)) { selectedIndex = labels.Count - 1; SelectedMaxY = groupMaxY; SelectedMinY = groupMinY; } // If multiple groups in the selection, make sure y extent is max of them else if (selectedIndex == labels.Count - 1) { SelectedMaxY = Math.Max(groupMaxY, SelectedMaxY); SelectedMinY = Math.Min(groupMinY, SelectedMinY); } maxY = Math.Max(maxY, groupMaxY); minY = Math.Min(minY, groupMinY); } PointPairLists = pointPairLists; Labels = labels.ToArray(); XScalePaths = xscalePaths.ToArray(); SelectedIndex = selectedIndex; MaxY = maxY; if (minY != double.MaxValue) MinY = minY; }