private void btnRun_Click(object sender, EventArgs e) { //create PPT document and load file Presentation ppt = new Presentation(); ppt.LoadFromFile(@"..\..\..\..\..\..\Data\Chart.pptx"); //get the chart IChart chart = ppt.Slides[0].Shapes[0] as IChart; //initialize an instances of dataPoint ChartDataPoint cdp = new ChartDataPoint(chart.Series[0]); //specific the dataPoint cdp.Index = 2; //fill the dataPoint cdp.Fill.FillType = FillFormatType.Solid; cdp.Fill.SolidColor.KnownColor = KnownColors.Yellow; //add the dataPoint to first series chart.Series[0].DataPoints.Add(cdp); ppt.SaveToFile("SetDatapointColor.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("SetDatapointColor.pptx"); }
public void SingleChartDataPoint() { //ExStart:WorkWithSingleChartDataPoint Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.InsertChart(ChartType.Line, 432, 252); Chart chart = shape.Chart; ChartSeries series0 = chart.Series[0]; ChartSeries series1 = chart.Series[1]; ChartDataPointCollection dataPointCollection = series0.DataPoints; ChartDataPoint dataPoint00 = dataPointCollection[0]; ChartDataPoint dataPoint01 = dataPointCollection[1]; dataPoint00.Explosion = 50; dataPoint00.Marker.Symbol = MarkerSymbol.Circle; dataPoint00.Marker.Size = 15; dataPoint01.Marker.Symbol = MarkerSymbol.Diamond; dataPoint01.Marker.Size = 20; ChartDataPoint dataPoint12 = series1.DataPoints[2]; dataPoint12.InvertIfNegative = true; dataPoint12.Marker.Symbol = MarkerSymbol.Star; dataPoint12.Marker.Size = 20; doc.Save(ArtifactsDir + "WorkingWithCharts.SingleChartDataPoint.docx"); //ExEnd:WorkWithSingleChartDataPoint }
public virtual Task StoreDatumAsync(Datum datum, CancellationToken cancellationToken) { // track the most recent datum and call timestamp regardless of whether the datum is null or whether we're storing data MostRecentDatum = datum; _mostRecentStoreTimestamp = DateTimeOffset.UtcNow; // datum is allowed to be null, indicating the the probe attempted to obtain data but it didn't find any (in the case of polling probes). if (datum != null) { datum.ProtocolId = Protocol.Id; if (_storeData) { ChartDataPoint chartDataPoint = GetChartDataPointFromDatum(datum); if (chartDataPoint != null) { lock (_chartData) { _chartData.Add(chartDataPoint); while (_chartData.Count > 0 && _chartData.Count > _maxChartDataCount) { _chartData.RemoveAt(0); } } } return(_protocol.LocalDataStore.AddAsync(datum, cancellationToken, _runLocalCommitOnStore)); } } return(Task.FromResult(false)); }
/// <summary> /// Stores a <see cref="Datum"/> within the <see cref="LocalDataStore"/>. Will not throw an <see cref="Exception"/>. /// </summary> /// <returns>The datum async.</returns> /// <param name="datum">Datum.</param> /// <param name="cancellationToken">Cancellation token.</param> public virtual Task <bool> StoreDatumAsync(Datum datum, CancellationToken?cancellationToken) { // track the most recent datum regardless of whether the datum is null or whether we're storing data Datum previousDatum = _mostRecentDatum; _mostRecentDatum = datum; _mostRecentStoreTimestamp = DateTimeOffset.UtcNow; // fire events to notify observers of the stored data and associated UI values MostRecentDatumChanged?.Invoke(this, new Tuple <Datum, Datum>(previousDatum, _mostRecentDatum)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SubCaption))); // datum is allowed to be null, indicating the the probe attempted to obtain data but it didn't find any (in the case of polling probes). if (datum != null) { datum.ProtocolId = Protocol.Id; if (_storeData) { ChartDataPoint chartDataPoint = null; try { chartDataPoint = GetChartDataPointFromDatum(datum); } catch (NotImplementedException) { } if (chartDataPoint != null) { lock (_chartData) { _chartData.Add(chartDataPoint); while (_chartData.Count > 0 && _chartData.Count > _maxChartDataCount) { _chartData.RemoveAt(0); } } } // catch any exceptions, as the caller (e.g., a probe listening) could very well be unprotected on the UI thread. throwing // an exception here can crash the app. try { return(_protocol.LocalDataStore.WriteDatumAsync(datum, cancellationToken.GetValueOrDefault())); } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Failed to write datum: " + ex, LoggingLevel.Normal, GetType()); } } } return(Task.FromResult(false)); }
/// <summary> /// Applies a number of data points to a series /// </summary> private void ApplyDataPoints(ChartSeries series, int dataPointsCount, MarkerSymbol markerSymbol, int dataPointSize) { for (int i = 0; i < dataPointsCount; i++) { ChartDataPoint point = series.DataPoints.Add(i); point.Marker.Symbol = markerSymbol; point.Marker.Size = dataPointSize; Assert.AreEqual(i, point.Index); } }
public static BarChartData GetRenewableEnergyData() { var data = new ChartDataPoint[] { new ChartDataPoint(0.0224, "Solar hot water"), new ChartDataPoint(0.1497, "Hydroelectricity"), new ChartDataPoint(0.3310, "Bioenergy - wood and woodwaste"), new ChartDataPoint(0.0600, "Bioenergy - biogas and biofuels"), new ChartDataPoint(0.3859, "Bioenergy - bagasse"), new ChartDataPoint(0.0490, "Wind"), new ChartDataPoint(0.0014, "Solar - solar electricity"), }; return(new BarChartData(data)); }
public static void Run() { //ExStart:WorkWithSingleChartDataPoint // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithCharts(); Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.InsertChart(ChartType.Line, 432, 252); Chart chart = shape.Chart; // Get first series. ChartSeries series0 = shape.Chart.Series[0]; // Get second series. ChartSeries series1 = shape.Chart.Series[1]; ChartDataPointCollection dataPointCollection = series0.DataPoints; // Add data point to the first and second point of the first series. ChartDataPoint dataPoint00 = dataPointCollection.Add(0); ChartDataPoint dataPoint01 = dataPointCollection.Add(1); // Set explosion. dataPoint00.Explosion = 50; // Set marker symbol and size. dataPoint00.Marker.Symbol = MarkerSymbol.Circle; dataPoint00.Marker.Size = 15; dataPoint01.Marker.Symbol = MarkerSymbol.Diamond; dataPoint01.Marker.Size = 20; // Add data point to the third point of the second series. ChartDataPoint dataPoint12 = series1.DataPoints.Add(2); dataPoint12.InvertIfNegative = true; dataPoint12.Marker.Symbol = MarkerSymbol.Star; dataPoint12.Marker.Size = 20; dataDir = dataDir + @"SingleChartDataPoint_out_.docx"; doc.Save(dataDir); //ExEnd:WorkWithSingleChartDataPoint Console.WriteLine("\nSingle line chart created successfully.\nFile saved at " + dataDir); }
void RemoveRecord(DreamRecord record) { string emotion = record.Emotion.ToString(); ChartDataPoint point = null; for (int index = 0; index < _points.Count; index++) { point = _points[index]; //Console.WriteLine($"{point.XValue} {record.DateRecorded}"); if (point.XValue.Equals(emotion)) { _points.Remove(point); point.YValue--; _points.Add(point); break; } } }
public void CheckAddBloodSugarDataPoint() { PluginCollector coll = new PluginCollector(); MonitoringPluginPageModel model = new MonitoringPluginPageModel(coll); model.AddDatapoints(DataPoints.BloodSugar); AddBloodSugarPageModel bmodel = new AddBloodSugarPageModel(coll); bmodel.BloodSugarValue = 40; DateTime tmpDate = DateTime.Now; bmodel.Date = tmpDate; var x = bmodel.AddDataPoint; model.LoadData(); ChartDataPoint bsPoint = (from ChartDataPoint poi in model.BloodSugarDataPoints where (DateTime)poi.XValue == tmpDate select poi).ToList().FirstOrDefault(); Assert.True((DateTime)bsPoint.XValue == tmpDate); }
public void LoadData() { SettingsModel.BloodSugarDataPoints = SettingsModel.BloodSugarDataPoints.OrderBy(o => o.Date).ToList(); SettingsModel.MealDataPoints = SettingsModel.MealDataPoints.OrderBy(o => o.Date).ToList(); SettingsModel.MedicineDataPoints = SettingsModel.MedicineDataPoints.OrderBy(o => o.Date).ToList(); BloodSugarDataPoints.Clear(); MealDataPoints.Clear(); MedDataPoints.Clear(); foreach (BloodSugarDataPoint tmpPoint in SettingsModel.BloodSugarDataPoints) { ChartDataPoint point = new ChartDataPoint(tmpPoint.Date, tmpPoint.BloodSugarLevel); BloodSugarDataPoints.Add(point); } BloodSugarDataPoints = new List <ChartDataPoint>(BloodSugarDataPoints); foreach (MealDataPoint tmpPoint in SettingsModel.MealDataPoints) { ChartDataPoint point = new ChartDataPoint(tmpPoint.Date, 0); point.YValue = calcDataPointsYValue(point); tmpPoint.YValue = point.YValue; MealDataPoints.Add(point); } foreach (MedicineDataPoint tmpPoint in SettingsModel.MedicineDataPoints) { ChartDataPoint point = new ChartDataPoint(tmpPoint.Date, 0); point.YValue = calcDataPointsYValue(point); tmpPoint.YValue = point.YValue; MedDataPoints.Add(point); } }
void RemoveRecord(DreamRecord record) { if (_seriesData.ContainsKey(record.Emotion)) { ObservableCollection <ChartDataPoint> list = _seriesData[record.Emotion]; ChartDataPoint point = null; for (int index = 0; index < list.Count; index++) { point = list[index]; //Console.WriteLine($"{point.XValue} {record.DateRecorded}"); if (point.XValue.Equals(record.DateRecorded)) { list.Remove(point); point.YValue--; list.Add(point); break; } } } }
public void PieChartExplosion() { //ExStart //ExFor:Charts.IChartDataPoint.Explosion //ExSummary:Shows how to manipulate the position of the portions of a pie chart. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.InsertChart(ChartType.Pie, 500, 350); Chart chart = shape.Chart; // In a pie chart, the portions are the data points, which cannot have markers or sizes applied to them // However, we can set this variable to move any individual "slice" away from the center of the chart ChartDataPoint cdp = chart.Series[0].DataPoints.Add(0); cdp.Explosion = 10; cdp = chart.Series[0].DataPoints.Add(1); cdp.Explosion = 40; doc.Save(ArtifactsDir + "Charts.PieChartExplosion.docx"); //ExEnd }
public double calcDataPointsYValue(ChartDataPoint point) { List <ChartDataPoint> tmpList = new List <ChartDataPoint>(BloodSugarDataPoints); tmpList.Add(point); tmpList = tmpList.OrderBy(o => o.XValue).ToList(); int index = tmpList.IndexOf(point); if (index > 0 && tmpList.Count > 2) { double yValAncestor = tmpList[index - 1].YValue; double xValAncetor = ((DateTime)tmpList[index - 1].XValue).Ticks; double yValFollower = tmpList[index + 1].YValue; double xValFollower = ((DateTime)tmpList[index + 1].XValue).Ticks; double xPoint = ((DateTime)point.XValue).Ticks; double m = (yValFollower - yValAncestor) / (xValFollower - xValAncetor); double y = m * (xPoint - xValAncetor) + yValAncestor; point.YValue = y; } return(point.YValue); }
protected override View GetView(ChartSeries p0, ChartDataPoint p1, int p2) { LinearLayout parentLayout = new LinearLayout(Chart.Context); parentLayout.SetPadding(2, 2, 2, 2); parentLayout.Orientation = Orientation.Horizontal; LinearLayout layout = new LinearLayout(Chart.Context); layout.Orientation = Orientation.Vertical; ImageView image = new ImageView(Chart.Context); image.LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams ((int)(Chart.Context.Resources.DisplayMetrics.Density * 40), (int)(Chart.Context.Resources.DisplayMetrics.Density * 40))); image.SetPadding(0, 2, 0, 2); image.SetImageResource(Resource.Drawable.eficon); TextView text1 = new TextView(Chart.Context); text1.SetTextColor(Color.White); text1.Text = p1.GetY().ToString() + " %"; text1.TextSize = 12; text1.SetTypeface(Typeface.SansSerif, TypefaceStyle.Bold); layout.AddView(text1); TextView text2 = new TextView(Chart.Context); text2.Text = "Efficiency"; text2.TextSize = 10; text2.SetTextColor(Color.White); layout.AddView(text2); layout.SetPadding(5, (int)(Chart.Context.Resources.DisplayMetrics.Density * 5), 2, 0); parentLayout.AddView(image); parentLayout.AddView(layout); return(parentLayout); }
public BarChartStackData(ChartDataPoint dataPoint, string label) : this(new[] {dataPoint}, label) { }
public BarChartGroupData(ChartDataPoint dataPoint) : this(new[] { dataPoint }) { }
private static DeclarationList CreateCurrentDeclarations() { DeclarationList declarationList = new DeclarationList(); int num = 1; declarationList[num++] = IDOwner.GetDeclaration(); declarationList[num++] = ReportItem.GetDeclaration(); num++; declarationList[num++] = Report.GetDeclaration(); declarationList[num++] = PageSection.GetDeclaration(); declarationList[num++] = Line.GetDeclaration(); declarationList[num++] = Rectangle.GetDeclaration(); declarationList[num++] = Image.GetDeclaration(); num++; declarationList[num++] = CheckBox.GetDeclaration(); declarationList[num++] = TextBox.GetDeclaration(); declarationList[num++] = SubReport.GetDeclaration(); declarationList[num++] = ActiveXControl.GetDeclaration(); declarationList[num++] = DataRegion.GetDeclaration(); num++; declarationList[num++] = ReportHierarchyNode.GetDeclaration(); declarationList[num++] = Grouping.GetDeclaration(); declarationList[num++] = Sorting.GetDeclaration(); declarationList[num++] = List.GetDeclaration(); declarationList[num++] = Pivot.GetDeclaration(); declarationList[num++] = Matrix.GetDeclaration(); declarationList[num++] = PivotHeading.GetDeclaration(); declarationList[num++] = MatrixHeading.GetDeclaration(); declarationList[num++] = MatrixColumn.GetDeclaration(); num++; declarationList[num++] = MatrixRow.GetDeclaration(); num++; declarationList[num++] = Subtotal.GetDeclaration(); declarationList[num++] = Table.GetDeclaration(); declarationList[num++] = TableColumn.GetDeclaration(); num++; declarationList[num++] = TableGroup.GetDeclaration(); declarationList[num++] = TableRow.GetDeclaration(); num++; declarationList[num++] = OWCChart.GetDeclaration(); declarationList[num++] = ChartColumn.GetDeclaration(); num++; declarationList[num++] = ReportItemCollection.GetDeclaration(); declarationList[num++] = ReportItemIndexer.GetDeclaration(); num++; declarationList[num++] = Style.GetDeclaration(); num++; declarationList[num++] = AttributeInfo.GetDeclaration(); declarationList[num++] = Visibility.GetDeclaration(); declarationList[num++] = ExpressionInfo.GetDeclaration(); num++; declarationList[num++] = DataAggregateInfo.GetDeclaration(); num++; declarationList[num++] = RunningValueInfo.GetDeclaration(); num++; num++; declarationList[num++] = Filter.GetDeclaration(); num++; declarationList[num++] = DataSource.GetDeclaration(); num++; declarationList[num++] = DataSet.GetDeclaration(); num++; declarationList[num++] = ReportQuery.GetDeclaration(); declarationList[num++] = Field.GetDeclaration(); num++; declarationList[num++] = ParameterValue.GetDeclaration(); num++; num++; num++; num++; declarationList[num++] = ReportSnapshot.GetDeclaration(); declarationList[num++] = SenderInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = ReceiverInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = DocumentMapNode.GetDeclaration(); declarationList[num++] = InfoBase.GetDeclaration(); declarationList[num++] = OffsetInfo.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = ReportItemInstanceInfo.GetDeclaration(); declarationList[num++] = ReportInstanceInfo.GetDeclaration(); declarationList[num++] = ReportItemColInstanceInfo.GetDeclaration(); declarationList[num++] = LineInstanceInfo.GetDeclaration(); declarationList[num++] = TextBoxInstanceInfo.GetDeclaration(); declarationList[num++] = RectangleInstanceInfo.GetDeclaration(); declarationList[num++] = CheckBoxInstanceInfo.GetDeclaration(); declarationList[num++] = ImageInstanceInfo.GetDeclaration(); declarationList[num++] = SubReportInstanceInfo.GetDeclaration(); declarationList[num++] = ActiveXControlInstanceInfo.GetDeclaration(); declarationList[num++] = ListInstanceInfo.GetDeclaration(); declarationList[num++] = ListContentInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixHeadingInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixCellInstanceInfo.GetDeclaration(); declarationList[num++] = TableInstanceInfo.GetDeclaration(); declarationList[num++] = TableGroupInstanceInfo.GetDeclaration(); declarationList[num++] = TableRowInstanceInfo.GetDeclaration(); declarationList[num++] = OWCChartInstanceInfo.GetDeclaration(); declarationList[num++] = ChartInstanceInfo.GetDeclaration(); declarationList[num++] = NonComputedUniqueNames.GetDeclaration(); declarationList[num++] = InstanceInfoOwner.GetDeclaration(); declarationList[num++] = ReportItemInstance.GetDeclaration(); num++; declarationList[num++] = ReportInstance.GetDeclaration(); declarationList[num++] = ReportItemColInstance.GetDeclaration(); declarationList[num++] = LineInstance.GetDeclaration(); declarationList[num++] = TextBoxInstance.GetDeclaration(); declarationList[num++] = RectangleInstance.GetDeclaration(); declarationList[num++] = CheckBoxInstance.GetDeclaration(); declarationList[num++] = ImageInstance.GetDeclaration(); declarationList[num++] = SubReportInstance.GetDeclaration(); declarationList[num++] = ActiveXControlInstance.GetDeclaration(); declarationList[num++] = ListInstance.GetDeclaration(); declarationList[num++] = ListContentInstance.GetDeclaration(); num++; declarationList[num++] = MatrixInstance.GetDeclaration(); declarationList[num++] = MatrixHeadingInstance.GetDeclaration(); num++; declarationList[num++] = MatrixCellInstance.GetDeclaration(); num++; num++; declarationList[num++] = TableInstance.GetDeclaration(); declarationList[num++] = TableRowInstance.GetDeclaration(); declarationList[num++] = TableColumnInstance.GetDeclaration(); declarationList[num++] = TableGroupInstance.GetDeclaration(); num++; declarationList[num++] = OWCChartInstance.GetDeclaration(); declarationList[num++] = ParameterInfo.GetDeclaration(); num++; num++; num++; declarationList[num++] = InstanceInfo.GetDeclaration(); num++; declarationList[num++] = RecordSetInfo.GetDeclaration(); declarationList[num++] = RecordRow.GetDeclaration(); declarationList[num++] = RecordField.GetDeclaration(); declarationList[num++] = ValidValue.GetDeclaration(); num++; declarationList[num++] = ParameterDataSource.GetDeclaration(); declarationList[num++] = ParameterDef.GetDeclaration(); num++; declarationList[num++] = ParameterBase.GetDeclaration(); num++; declarationList[num++] = ProcessingMessage.GetDeclaration(); declarationList[num++] = MatrixSubtotalHeadingInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixSubtotalCellInstance.GetDeclaration(); declarationList[num++] = CodeClass.GetDeclaration(); num++; declarationList[num++] = TableDetail.GetDeclaration(); declarationList[num++] = TableDetailInstance.GetDeclaration(); num++; declarationList[num++] = TableDetailInstanceInfo.GetDeclaration(); num++; declarationList[num++] = Action.GetDeclaration(); declarationList[num++] = ActionInstance.GetDeclaration(); declarationList[num++] = Chart.GetDeclaration(); declarationList[num++] = ChartHeading.GetDeclaration(); declarationList[num++] = ChartDataPoint.GetDeclaration(); num++; declarationList[num++] = MultiChart.GetDeclaration(); declarationList[num++] = MultiChartInstance.GetDeclaration(); num++; declarationList[num++] = Axis.GetDeclaration(); declarationList[num++] = AxisInstance.GetDeclaration(); declarationList[num++] = ChartTitle.GetDeclaration(); declarationList[num++] = ChartTitleInstance.GetDeclaration(); declarationList[num++] = ThreeDProperties.GetDeclaration(); declarationList[num++] = PlotArea.GetDeclaration(); declarationList[num++] = Legend.GetDeclaration(); declarationList[num++] = GridLines.GetDeclaration(); declarationList[num++] = ChartDataLabel.GetDeclaration(); declarationList[num++] = ChartInstance.GetDeclaration(); declarationList[num++] = ChartHeadingInstance.GetDeclaration(); declarationList[num++] = ChartHeadingInstanceInfo.GetDeclaration(); num++; declarationList[num++] = ChartDataPointInstance.GetDeclaration(); declarationList[num++] = ChartDataPointInstanceInfo.GetDeclaration(); num++; num++; declarationList[num++] = RenderingPagesRanges.GetDeclaration(); num++; declarationList[num++] = IntermediateFormatVersion.GetDeclaration(); declarationList[num++] = ImageInfo.GetDeclaration(); declarationList[num++] = ActionItem.GetDeclaration(); declarationList[num++] = ActionItemInstance.GetDeclaration(); num++; num++; declarationList[num++] = DataValue.GetDeclaration(); declarationList[num++] = DataValueInstance.GetDeclaration(); num++; num++; declarationList[num++] = Tablix.GetDeclaration(); declarationList[num++] = TablixHeading.GetDeclaration(); declarationList[num++] = CustomReportItem.GetDeclaration(); declarationList[num++] = CustomReportItemInstance.GetDeclaration(); declarationList[num++] = CustomReportItemHeading.GetDeclaration(); declarationList[num++] = CustomReportItemHeadingInstance.GetDeclaration(); num++; num++; num++; num++; declarationList[num++] = CustomReportItemCellInstance.GetDeclaration(); num++; num++; declarationList[num++] = DataValueCRIList.GetDeclaration(); declarationList[num++] = BookmarkInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = DrillthroughInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); num++; declarationList[num++] = CustomReportItemInstanceInfo.GetDeclaration(); declarationList[num++] = ImageMapAreaInstanceList.GetDeclaration(); declarationList[num++] = ImageMapAreaInstance.GetDeclaration(); num++; declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = SortFilterEventInfo.GetDeclaration(); declarationList[num++] = EndUserSort.GetDeclaration(); num++; num++; declarationList[num++] = RecordSetPropertyNames.GetDeclaration(); num++; num++; num++; declarationList[num++] = PageSectionInstance.GetDeclaration(); num++; declarationList[num++] = PageSectionInstanceInfo.GetDeclaration(); declarationList[num++] = SimpleTextBoxInstanceInfo.GetDeclaration(); declarationList[num++] = ScopeLookupTable.GetDeclaration(); num++; declarationList[num++] = ReportDrillthroughInfo.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); Global.Tracer.Assert(declarationList.Count == num, "(current.Count == index)"); return(declarationList); }
/// <summary> /// Stores a <see cref="Datum"/> within the <see cref="LocalDataStore"/>. Will not throw an <see cref="Exception"/>. /// </summary> /// <param name="datum">Datum.</param> /// <param name="cancellationToken">Cancellation token.</param> public async Task StoreDatumAsync(Datum datum, CancellationToken?cancellationToken = null) { // it's possible for the current method to be called when the protocol is not running. the obvious case is when // the protocol is paused, but there are other race-like conditions. we try to prevent this (e.g., by forcing // the user to start the protocol before taking a survey saved from a previous run of the app), but there are // probably corner cases we haven't accounted for. at the very least, there are race conditions (e.g., taking a // survey when a protocol is about to stop) that could cause data to be stored without a running protocol. if (_protocol.State != ProtocolState.Running) { return; } // track/limit the raw rate of non-null data. all null data will pass this test, and this is // fine given such data are generated by polling probes when no data were retrieved. such // return values from polling probes are used to indicate that the poll was completed, which // will be reflected in the _mostRecentStoreTimestamp below. if (datum != null) { // impose a limit on the raw data rate if (_rawRateCalculator.Add(datum) == DataRateCalculator.SamplingAction.Drop) { return; } // set properties that we were unable to set within the datum constructor. datum.ProtocolId = Protocol.Id; datum.ParticipantId = Protocol.ParticipantId; // tag the data if we're in tagging mode, indicated with a non-null event id on the protocol. avoid // any race conditions related to starting/stopping a tagging by getting the required values and // then checking both for validity. we need to guarantee that any tagged datum has both an id and tags. string taggedEventId = Protocol.TaggedEventId; List <string> taggedEventTags = Protocol.TaggedEventTags.ToList(); if (!string.IsNullOrWhiteSpace(taggedEventId) && taggedEventTags.Count > 0) { datum.TaggedEventId = taggedEventId; datum.TaggedEventTags = taggedEventTags; } // if the protocol is configured with a sensing agent, if (Protocol.Agent != null) { datum.SensingAgentStateDescription = Protocol.Agent.StateDescription; } } // store non-null data if (_storeData && datum != null) { #region update chart data ChartDataPoint chartDataPoint = null; try { chartDataPoint = GetChartDataPointFromDatum(datum); } catch (NotImplementedException) { } if (chartDataPoint != null) { lock (_chartData) { _chartData.Add(chartDataPoint); while (_chartData.Count > 0 && _chartData.Count > _maxChartDataCount) { _chartData.RemoveAt(0); } } } #endregion // write datum to local data store. catch any exceptions, as the caller (e.g., a listening // probe) could very well be unprotected on the UI thread. throwing an exception here can crash the app. try { _protocol.LocalDataStore.WriteDatum(datum, cancellationToken.GetValueOrDefault()); // track the storage rate _storageRateCalculator.Add(datum); } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Failed to write datum: " + ex, LoggingLevel.Normal, GetType()); } } // update the timestamp of the most recent store. this is used to calculate storage latency, so we // do not restrict its values to those obtained when non-null data are stored (see above). some // probes call this method with null data to signal that they have run their collection to completion. _mostRecentStoreTimestamp = DateTimeOffset.UtcNow; // don't update the UI too often, as doing so at really high rates causes UI deadlocks. always let // null data update the UI, as these are only generated by polling probes at low rates. if (datum == null || _uiUpdateRateCalculator.Add(datum) == DataRateCalculator.SamplingAction.Keep) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SubCaption))); } // track the most recent datum regardless of whether the datum is null or whether we're storing data Datum previousDatum = _mostRecentDatum; _mostRecentDatum = datum; // notify observers of the stored data and associated UI values await(MostRecentDatumChanged?.Invoke(previousDatum, _mostRecentDatum) ?? Task.CompletedTask); // let the script probe's agent observe the data, as long as the probe is enabled and there is an agent. Protocol.TryGetProbe(typeof(ScriptProbe), out Probe scriptProbe); if (scriptProbe?.Enabled ?? false) { // agents might be third-party and badly behaving...catch their exceptions. try { await((scriptProbe as ScriptProbe).Agent?.ObserveAsync(datum) ?? Task.CompletedTask); } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Exception while script probe agent was observing datum: " + ex.Message, LoggingLevel.Normal, GetType()); } } // let the protocol's sensing agent observe the data, and schedule any returned control // completion check. agents might be third-party and badly behaving...catch their exceptions. try { await Protocol.ScheduleAgentControlCompletionCheckAsync(await (Protocol.Agent?.ObserveAsync(datum, cancellationToken.GetValueOrDefault()) ?? Task.FromResult <ControlCompletionCheck>(null))); } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Exception while sensing agent was observing datum: " + ex.Message, LoggingLevel.Normal, GetType()); } }
public BarChartStackData(ChartDataPoint dataPoint, string label) : this(new[] { dataPoint }, label) { }
public BarChartGroupData(ChartDataPoint dataPoint) : this(new[] {dataPoint}) { }
public BarChartStackData(ChartDataPoint dataPoint) : this(new[] { dataPoint }) { }
public IPersistable CreateRIFObject(ObjectType objectType, ref IntermediateFormatReader context) { IPersistable persistable = null; if (objectType == ObjectType.Null) { return(null); } IDOwner parentIDOwner = this.m_parentIDOwner; ReportItem parentReportItem = this.m_parentReportItem; switch (objectType) { case ObjectType.PageSection: persistable = new PageSection(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.Line: persistable = new Line(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.Rectangle: persistable = new Rectangle(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.Image: persistable = new Image(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.TextBox: persistable = new TextBox(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.SubReport: persistable = new SubReport(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.Grouping: persistable = new Grouping(ConstructionPhase.Deserializing); break; case ObjectType.Sorting: persistable = new Sorting(ConstructionPhase.Deserializing); break; case ObjectType.ReportItemCollection: persistable = new ReportItemCollection(); break; case ObjectType.ReportItemIndexer: persistable = (IPersistable)(object)default(ReportItemIndexer); break; case ObjectType.Style: persistable = new Style(ConstructionPhase.Deserializing); break; case ObjectType.AttributeInfo: persistable = new AttributeInfo(); break; case ObjectType.Visibility: persistable = new Visibility(); break; case ObjectType.ExpressionInfo: persistable = new ExpressionInfo(); break; case ObjectType.ExpressionInfoTypeValuePair: persistable = new ExpressionInfoTypeValuePair(); break; case ObjectType.DataAggregateInfo: persistable = new DataAggregateInfo(); break; case ObjectType.RunningValueInfo: persistable = new RunningValueInfo(); break; case ObjectType.Filter: persistable = new Filter(); break; case ObjectType.DataSource: persistable = new DataSource(); break; case ObjectType.DataSet: persistable = new DataSet(); break; case ObjectType.ReportQuery: persistable = new ReportQuery(); break; case ObjectType.Field: persistable = new Field(); break; case ObjectType.ParameterValue: persistable = new ParameterValue(); break; case ObjectType.ReportSnapshot: persistable = new ReportSnapshot(); break; case ObjectType.DocumentMapNode: persistable = new DocumentMapNode(); break; case ObjectType.DocumentMapBeginContainer: persistable = DocumentMapBeginContainer.Instance; break; case ObjectType.DocumentMapEndContainer: persistable = DocumentMapEndContainer.Instance; break; case ObjectType.ReportInstance: persistable = new ReportInstance(); break; case ObjectType.ParameterInfo: persistable = new ParameterInfo(); break; case ObjectType.ValidValue: persistable = new ValidValue(); break; case ObjectType.ParameterDataSource: persistable = new ParameterDataSource(); break; case ObjectType.ParameterDef: persistable = new ParameterDef(); break; case ObjectType.ProcessingMessage: persistable = new ProcessingMessage(); break; case ObjectType.CodeClass: persistable = (IPersistable)(object)default(CodeClass); break; case ObjectType.Action: persistable = new Action(); break; case ObjectType.RenderingPagesRanges: persistable = (IPersistable)(object)default(RenderingPagesRanges); break; case ObjectType.IntermediateFormatVersion: persistable = new IntermediateFormatVersion(); break; case ObjectType.ImageInfo: persistable = new ImageInfo(); break; case ObjectType.ActionItem: persistable = new ActionItem(); break; case ObjectType.DataValue: persistable = new DataValue(); break; case ObjectType.CustomReportItem: persistable = new CustomReportItem(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.SortFilterEventInfoMap: persistable = new SortFilterEventInfoMap(); break; case ObjectType.SortFilterEventInfo: persistable = new SortFilterEventInfo(); break; case ObjectType.EndUserSort: persistable = new EndUserSort(); break; case ObjectType.ScopeLookupTable: persistable = new ScopeLookupTable(); break; case ObjectType.Tablix: persistable = new Tablix(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.TablixHeader: persistable = new TablixHeader(); break; case ObjectType.TablixMember: persistable = new TablixMember(); break; case ObjectType.TablixColumn: persistable = new TablixColumn(); break; case ObjectType.TablixRow: persistable = new TablixRow(); break; case ObjectType.TablixCornerCell: persistable = new TablixCornerCell(); break; case ObjectType.TablixCell: persistable = new TablixCell(); break; case ObjectType.Chart: persistable = new Chart(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.ChartMember: persistable = new ChartMember(); break; case ObjectType.ChartSeries: persistable = new ChartSeries(); break; case ObjectType.ChartDataPoint: persistable = new ChartDataPoint(); break; case ObjectType.ChartDataPointValues: persistable = new ChartDataPointValues(); break; case ObjectType.ChartArea: persistable = new ChartArea(); break; case ObjectType.ChartLegend: persistable = new ChartLegend(); break; case ObjectType.ChartLegendTitle: persistable = new ChartLegendTitle(); break; case ObjectType.ChartAxis: persistable = new ChartAxis(); break; case ObjectType.ThreeDProperties: persistable = new ChartThreeDProperties(); break; case ObjectType.ChartDataLabel: persistable = new ChartDataLabel(); break; case ObjectType.ChartMarker: persistable = new ChartMarker(); break; case ObjectType.ChartTitle: persistable = new ChartTitle(); break; case ObjectType.ChartAxisScaleBreak: persistable = new ChartAxisScaleBreak(); break; case ObjectType.ChartDerivedSeries: persistable = new ChartDerivedSeries(); break; case ObjectType.ChartBorderSkin: persistable = new ChartBorderSkin(); break; case ObjectType.ChartNoDataMessage: persistable = new ChartNoDataMessage(); break; case ObjectType.ChartItemInLegend: persistable = new ChartItemInLegend(); break; case ObjectType.ChartEmptyPoints: persistable = new ChartEmptyPoints(); break; case ObjectType.ChartNoMoveDirections: persistable = new ChartNoMoveDirections(); break; case ObjectType.ChartFormulaParameter: persistable = new ChartFormulaParameter(); break; case ObjectType.ChartLegendColumn: persistable = new ChartLegendColumn(); break; case ObjectType.ChartLegendColumnHeader: persistable = new ChartLegendColumnHeader(); break; case ObjectType.ChartLegendCustomItem: persistable = new ChartLegendCustomItem(); break; case ObjectType.ChartLegendCustomItemCell: persistable = new ChartLegendCustomItemCell(); break; case ObjectType.ChartAlignType: persistable = new ChartAlignType(); break; case ObjectType.ChartElementPosition: persistable = new ChartElementPosition(); break; case ObjectType.ChartSmartLabel: persistable = new ChartSmartLabel(); break; case ObjectType.ChartStripLine: persistable = new ChartStripLine(); break; case ObjectType.ChartAxisTitle: persistable = new ChartAxisTitle(); break; case ObjectType.ChartCustomPaletteColor: persistable = new ChartCustomPaletteColor(); break; case ObjectType.GridLines: persistable = new ChartGridLines(); break; case ObjectType.ChartTickMarks: persistable = new ChartTickMarks(); break; case ObjectType.DataMember: persistable = new DataMember(); break; case ObjectType.CustomDataRow: persistable = new CustomDataRow(); break; case ObjectType.DataCell: persistable = new DataCell(); break; case ObjectType.Variable: persistable = new Variable(); break; case ObjectType.Page: persistable = new Page(); break; case ObjectType.Paragraph: persistable = new Paragraph(); break; case ObjectType.TextRun: persistable = new TextRun(); break; case ObjectType.Report: persistable = new Report(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.GaugePanel: persistable = new GaugePanel(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.GaugeMember: persistable = new GaugeMember(); break; case ObjectType.GaugeRow: persistable = new GaugeRow(); break; case ObjectType.GaugeCell: persistable = new GaugeCell(); break; case ObjectType.BackFrame: persistable = new BackFrame(); break; case ObjectType.CapImage: persistable = new CapImage(); break; case ObjectType.FrameBackground: persistable = new FrameBackground(); break; case ObjectType.FrameImage: persistable = new FrameImage(); break; case ObjectType.CustomLabel: persistable = new CustomLabel(); break; case ObjectType.GaugeImage: persistable = new GaugeImage(); break; case ObjectType.GaugeInputValue: persistable = new GaugeInputValue(); break; case ObjectType.GaugeLabel: persistable = new GaugeLabel(); break; case ObjectType.GaugePanelItem: persistable = new GaugePanelItem(); break; case ObjectType.GaugeTickMarks: persistable = new GaugeTickMarks(); break; case ObjectType.LinearGauge: persistable = new LinearGauge(); break; case ObjectType.LinearPointer: persistable = new LinearPointer(); break; case ObjectType.LinearScale: persistable = new LinearScale(); break; case ObjectType.NumericIndicator: persistable = new NumericIndicator(); break; case ObjectType.PinLabel: persistable = new PinLabel(); break; case ObjectType.PointerCap: persistable = new PointerCap(); break; case ObjectType.PointerImage: persistable = new PointerImage(); break; case ObjectType.RadialGauge: persistable = new RadialGauge(); break; case ObjectType.RadialPointer: persistable = new RadialPointer(); break; case ObjectType.RadialScale: persistable = new RadialScale(); break; case ObjectType.ScaleLabels: persistable = new ScaleLabels(); break; case ObjectType.ScalePin: persistable = new ScalePin(); break; case ObjectType.ScaleRange: persistable = new ScaleRange(); break; case ObjectType.IndicatorImage: persistable = new IndicatorImage(); break; case ObjectType.StateIndicator: persistable = new StateIndicator(); break; case ObjectType.Thermometer: persistable = new Thermometer(); break; case ObjectType.TickMarkStyle: persistable = new TickMarkStyle(); break; case ObjectType.TopImage: persistable = new TopImage(); break; case ObjectType.LookupInfo: persistable = new LookupInfo(); break; case ObjectType.LookupDestinationInfo: persistable = new LookupDestinationInfo(); break; case ObjectType.ReportSection: persistable = new ReportSection(); break; case ObjectType.MapFieldDefinition: persistable = new MapFieldDefinition(); break; case ObjectType.MapFieldName: persistable = new MapFieldName(); break; case ObjectType.MapLineLayer: persistable = new MapLineLayer(); break; case ObjectType.MapShapefile: persistable = new MapShapefile(); break; case ObjectType.MapPolygonLayer: persistable = new MapPolygonLayer(); break; case ObjectType.MapSpatialDataRegion: persistable = new MapSpatialDataRegion(); break; case ObjectType.MapSpatialDataSet: persistable = new MapSpatialDataSet(); break; case ObjectType.MapPointLayer: persistable = new MapPointLayer(); break; case ObjectType.MapTile: persistable = new MapTile(); break; case ObjectType.MapTileLayer: persistable = new MapTileLayer(); break; case ObjectType.MapField: persistable = new MapField(); break; case ObjectType.MapLine: persistable = new MapLine(); break; case ObjectType.MapPolygon: persistable = new MapPolygon(); break; case ObjectType.MapPoint: persistable = new MapPoint(); break; case ObjectType.MapLineTemplate: persistable = new MapLineTemplate(); break; case ObjectType.MapPolygonTemplate: persistable = new MapPolygonTemplate(); break; case ObjectType.MapMarkerTemplate: persistable = new MapMarkerTemplate(); break; case ObjectType.Map: persistable = new Map(this.m_parentReportItem); this.m_parentReportItem = (ReportItem)persistable; break; case ObjectType.MapBorderSkin: persistable = new MapBorderSkin(); break; case ObjectType.MapDataRegion: persistable = new MapDataRegion(this.m_parentReportItem); break; case ObjectType.MapMember: persistable = new MapMember(); break; case ObjectType.MapRow: persistable = new MapRow(); break; case ObjectType.MapCell: persistable = new MapCell(); break; case ObjectType.MapLocation: persistable = new MapLocation(); break; case ObjectType.MapSize: persistable = new MapSize(); break; case ObjectType.MapGridLines: persistable = new MapGridLines(); break; case ObjectType.MapBindingFieldPair: persistable = new MapBindingFieldPair(); break; case ObjectType.MapCustomView: persistable = new MapCustomView(); break; case ObjectType.MapDataBoundView: persistable = new MapDataBoundView(); break; case ObjectType.MapElementView: persistable = new MapElementView(); break; case ObjectType.MapViewport: persistable = new MapViewport(); break; case ObjectType.MapLimits: persistable = new MapLimits(); break; case ObjectType.MapColorScale: persistable = new MapColorScale(); break; case ObjectType.MapColorScaleTitle: persistable = new MapColorScaleTitle(); break; case ObjectType.MapDistanceScale: persistable = new MapDistanceScale(); break; case ObjectType.MapTitle: persistable = new MapTitle(); break; case ObjectType.MapLegend: persistable = new MapLegend(); break; case ObjectType.MapLegendTitle: persistable = new MapLegendTitle(); break; case ObjectType.MapBucket: persistable = new MapBucket(); break; case ObjectType.MapColorPaletteRule: persistable = new MapColorPaletteRule(); break; case ObjectType.MapColorRangeRule: persistable = new MapColorRangeRule(); break; case ObjectType.MapCustomColorRule: persistable = new MapCustomColorRule(); break; case ObjectType.MapCustomColor: persistable = new MapCustomColor(); break; case ObjectType.MapLineRules: persistable = new MapLineRules(); break; case ObjectType.MapPolygonRules: persistable = new MapPolygonRules(); break; case ObjectType.MapSizeRule: persistable = new MapSizeRule(); break; case ObjectType.MapMarkerImage: persistable = new MapMarkerImage(); break; case ObjectType.MapMarker: persistable = new MapMarker(); break; case ObjectType.MapMarkerRule: persistable = new MapMarkerRule(); break; case ObjectType.MapPointRules: persistable = new MapPointRules(); break; case ObjectType.PageBreak: persistable = new PageBreak(); break; case ObjectType.DataScopeInfo: persistable = new DataScopeInfo(); break; case ObjectType.LinearJoinInfo: persistable = new LinearJoinInfo(); break; case ObjectType.IntersectJoinInfo: persistable = new IntersectJoinInfo(); break; case ObjectType.BucketedDataAggregateInfos: persistable = new BucketedDataAggregateInfos(); break; case ObjectType.DataAggregateInfoBucket: persistable = new DataAggregateInfoBucket(); break; case ObjectType.NumericIndicatorRange: persistable = new NumericIndicatorRange(); break; case ObjectType.IndicatorState: persistable = new IndicatorState(); break; case ObjectType.SharedDataSetQuery: persistable = new SharedDataSetQuery(); break; case ObjectType.DataSetCore: persistable = new DataSetCore(); break; case ObjectType.DataSetParameterValue: persistable = new DataSetParameterValue(); break; case ObjectType.RIFVariantContainer: persistable = new RIFVariantContainer(); break; case ObjectType.IdcRelationship: persistable = new IdcRelationship(); break; case ObjectType.DefaultRelationship: persistable = new DefaultRelationship(); break; case ObjectType.JoinCondition: persistable = new Relationship.JoinCondition(); break; case ObjectType.BandLayoutOptions: persistable = new BandLayoutOptions(); break; case ObjectType.LabelData: persistable = new LabelData(); break; case ObjectType.Slider: persistable = new Slider(); break; case ObjectType.Coverflow: persistable = new Coverflow(); break; case ObjectType.PlayAxis: persistable = new PlayAxis(); break; case ObjectType.BandNavigationCell: persistable = new BandNavigationCell(); break; case ObjectType.Tabstrip: persistable = new Tabstrip(); break; case ObjectType.NavigationItem: persistable = new NavigationItem(); break; case ObjectType.ScopedFieldInfo: persistable = new ScopedFieldInfo(); break; default: Global.Tracer.Assert(false, "Unsupported object type: " + objectType.ToString()); break; } IDOwner iDOwner = persistable as IDOwner; if (iDOwner != null) { iDOwner.ParentInstancePath = this.m_parentIDOwner; this.m_parentIDOwner = iDOwner; } persistable.Deserialize(context); this.m_parentIDOwner = parentIDOwner; this.m_parentReportItem = parentReportItem; return(persistable); }
private void ParseXML( XDocument what, int i, RadCartesianChart targetChart, RadCustomHubTile rt1, RadCustomHubTile rt2, RadCustomHubTile rt3, TextBlock t1, TextBlock t2, TextBlock t3, // stats numbers TextBlock tb, // total info String sDate, String eDate, TextBlock tr1, // total info number TextBlock tr2, // total info date/time range int targetSeries // if it is basic or compare function ) { Debug.WriteLine("Processing..." + what); DataSource.getChartData()[i,targetSeries] = from query in what.Descendants("day") select new ChartDataPoint { Value = (double)query.Attribute("value"), Label = (string)query.Attribute("date") }; Debug.WriteLine("Setting DataContext of loaded data"); /* var mydate = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("month day"); var mydatepattern = mydate.Patterns[0]; sDate = String.Format(mydatepattern, DateTime.Parse(sDate)); eDate = String.Format(mydatepattern, DateTime.Parse(eDate)); */ if (targetSeries > 0) { // progressBar.Visibility = System.Windows.Visibility.Visible; rt1.IsFrozen = false; rt2.IsFrozen = false; rt3.IsFrozen = false; tb.Visibility = Visibility.Visible; tr2.Visibility = Visibility.Visible; tr2.Text = "(" + sDate + " - " + eDate + ")"; } else // reset compare chart { TextBlock[] totals = { info4Text1, info4Text2, info4Text3, info4Text4, info4Text5, info4Text6, info4Text7, info4Text8 }; if (i < 8) { totals[i].Visibility = Visibility.Collapsed; } targetChart.Series[1].ItemsSource = null; tr1.Visibility = Visibility.Visible; tr2.Visibility = Visibility.Collapsed; tr1.Text = "(" + sDate + " - " + eDate + ")"; rt1.IsFlipped = false; rt2.IsFlipped = false; rt3.IsFlipped = false; rt1.IsFrozen = true; rt2.IsFrozen = true; rt3.IsFrozen = true; } Debug.WriteLine("Setting DataContext targetSeries:" + targetSeries); if (targetSeries > 0) // if it's compare we have to fake time { var previousData = DataSource.getChartData()[i, 0]; ObservableCollection<ChartDataPoint> newData = new ObservableCollection<ChartDataPoint>(); IEnumerator<ChartDataPoint> enumerator = previousData.GetEnumerator() as System.Collections.Generic.IEnumerator<ChartDataPoint>; int p = 0; while (enumerator.MoveNext()) { ChartDataPoint c = enumerator.Current; Debug.WriteLine("Old Label:" + DataSource.getChartData()[i, 1].ElementAt<ChartDataPoint>(p).Label + " New Label:" + c.Label); ChartDataPoint n = new ChartDataPoint { Value = DataSource.getChartData()[i, 1].ElementAt<ChartDataPoint>(p).Value, Label = c.Label }; newData.Add(n); Debug.WriteLine("New label set:" + DataSource.getChartData()[i, 1].ElementAt<ChartDataPoint>(p).Label); p++; } DataSource.getChartData()[i, 1] = newData; } targetChart.Series[targetSeries].ItemsSource = DataSource.getChartData()[i, targetSeries]; targetChart.HorizontalAxis.LabelInterval = Util.getLabelIntervalByCount(DataSource.getChartData()[i, targetSeries].Count()); // count max,min,latest,total for display purposes double latest = 0, minim = 9999999999999, maxim = 0, totalCount = 0; IEnumerator<ChartDataPoint> Myenum = DataSource.getChartData()[i,targetSeries].GetEnumerator(); while (Myenum.MoveNext()) { ChartDataPoint oneValue = Myenum.Current; latest = oneValue.Value; minim = Math.Min(minim, oneValue.Value); maxim = Math.Max(maxim, oneValue.Value); totalCount = totalCount + oneValue.Value; } t1.Text = latest.ToString(); t2.Text = minim.ToString(); t3.Text = maxim.ToString(); switch (AppMetricsNames[i]) { case "MedianSessionLength": case "AvgSessionLength": tb.Text = "N/A"; // makes no sense for these metrics break; default: tb.Text = totalCount.ToString(); break; } tb.Visibility = Visibility.Visible; } // ParseXML
public BarChartStackData(ChartDataPoint dataPoint) : this(new[] {dataPoint}) { }
/// <summary> /// Stores a <see cref="Datum"/> within the <see cref="LocalDataStore"/>. Will not throw an <see cref="Exception"/>. /// </summary> /// <param name="datum">Datum.</param> /// <param name="cancellationToken">Cancellation token.</param> public void StoreDatum(Datum datum, CancellationToken?cancellationToken = null) { // track/limit the raw rate if (_rawRateCalculator.Add(datum) == DataRateCalculator.SamplingAction.Drop) { return; } // track the storage rate _storageRateCalculator.Add(datum); // set properties that we were unable to set within the datum constructor. datum is allowed to // be null, indicating the the probe attempted to obtain data but it didn't find any (in the // case of polling probes). if (datum != null) { datum.ProtocolId = Protocol.Id; datum.ParticipantId = Protocol.ParticipantId; } // track the most recent datum regardless of whether the datum is null or whether we're storing data Datum previousDatum = _mostRecentDatum; _mostRecentDatum = datum; _mostRecentStoreTimestamp = DateTimeOffset.UtcNow; // fire events to notify observers of the stored data and associated UI values MostRecentDatumChanged?.Invoke(this, new Tuple <Datum, Datum>(previousDatum, _mostRecentDatum)); // don't update the UI too often, as doing so at really high rates causes UI deadlocks. if (_uiUpdateRateCalculator.Add(datum) == DataRateCalculator.SamplingAction.Keep) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SubCaption))); } // store non-null data if (_storeData && datum != null) { #region update chart data ChartDataPoint chartDataPoint = null; try { chartDataPoint = GetChartDataPointFromDatum(datum); } catch (NotImplementedException) { } if (chartDataPoint != null) { lock (_chartData) { _chartData.Add(chartDataPoint); while (_chartData.Count > 0 && _chartData.Count > _maxChartDataCount) { _chartData.RemoveAt(0); } } } #endregion // write datum to local data store. catch any exceptions, as the caller (e.g., a listening // probe) could very well be unprotected on the UI thread. throwing an exception here can crash the app. try { _protocol.LocalDataStore.WriteDatum(datum, cancellationToken.GetValueOrDefault()); } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Failed to write datum: " + ex, LoggingLevel.Normal, GetType()); } } }