public static List <LineSeries> AsLineSeries(this SensorDataLogResults results, DateIndexLookup dil) { var ret = new List <LineSeries>(); foreach (var id in results.sessionIds) { var ls = new LineSeries() { StrokeThickness = 1, MarkerType = MarkerType.Circle, MarkerSize = 0, MarkerStroke = OxyColors.Transparent, MarkerStrokeThickness = 1, }; foreach (var dlm in results[id]) { ls.Points.Add(new DataPoint(dil[dlm.recordedDate], dlm.measurement.ConvertTo(dlm.measurement.unit.standardUnit).amount)); } ret.Add(ls); } return(ret); }
// Implemented for IGraphRenderer public void Render(Canvas canvas, DateIndexLookup dil, SensorDataLogResults results) { var sensor = results.sensor; var serial = sensor.device.serialNumber; var indices = dil.count; var series = results.AsLineSeries(dil); model.Subtitle = serial.ToString() + "(" + sensor.type.GetTypeString() + ")"; xAxis.Minimum = 0; xAxis.Maximum = indices - 1; xAxis.MajorStep = (xAxis.Maximum - xAxis.Minimum) / Math.Min(10, indices); xAxis.LabelFormatter = (arg) => { var date = dil.GetDateTimeFromIndex((int)arg); return(date.ToLongTimeString()); }; yAxis.Minimum = results.minimum.amount; yAxis.Maximum = results.maximum.amount; yAxis.MajorStep = (yAxis.Maximum - yAxis.Minimum) / 5; if (yAxis.MajorStep == 0) { yAxis.MajorStep = 1; } yAxis.LabelFormatter = (arg) => { var su = sensor.unit.standardUnit; return(SensorUtils.ToFormattedString(su.OfScalar(arg).ConvertTo(sensor.unit))); }; yAxis.Title = sensor.unit.ToString(); model.Series.Clear(); foreach (var s in series) { var colors = sensor.GetColorForSensor(context); s.Color = OxyColor.FromUInt32((uint)colors.Item1.ToArgb()); model.Series.Add(s); } model.InvalidatePlot(true); var widthSpec = View.MeasureSpec.MakeMeasureSpec(800, MeasureSpecMode.Exactly); var heightSpec = View.MeasureSpec.MakeMeasureSpec(400, MeasureSpecMode.Exactly); plot.Measure(widthSpec, heightSpec); plot.Layout(0, 0, plot.MeasuredWidth, plot.MeasuredHeight); plot.Draw(canvas); if (plot.Model.GetLastPlotException() != null) { throw plot.Model.GetLastPlotException(); } }
// Implemented for IGraphRenderer public void Render(Canvas canvas, DateIndexLookup dil, SensorDataLogResults results) { var sensor = results.sensor; var serial = sensor.device.serialNumber; var indices = dil.count; var series = results.AsLineSeries(dil); model.Title = serial.ToString(); model.Subtitle = "(" + sensor.type.GetTypeString() + ")"; xAxis.Minimum = 0; xAxis.Maximum = indices - 1; xAxis.MajorStep = (xAxis.Maximum - xAxis.Minimum) / Math.Min(10, indices); yAxis.Minimum = results.minimum.amount; yAxis.Maximum = results.maximum.amount; yAxis.MajorStep = (yAxis.Maximum - yAxis.Minimum) / 5; if (yAxis.MajorStep == 0) { yAxis.MajorStep = 1; } model.Series.Clear(); foreach (var s in series) { var c = sensor.GetColorForSensor(context); s.Color = OxyColor.FromUInt32((uint)c.Item1.ToArgb()); model.Series.Add(s); } model.InvalidatePlot(true); var widthSpec = View.MeasureSpec.MakeMeasureSpec(800, MeasureSpecMode.Exactly); var heightSpec = View.MeasureSpec.MakeMeasureSpec(400, MeasureSpecMode.Exactly); plot.Measure(widthSpec, heightSpec); plot.Layout(0, 0, plot.MeasuredWidth, plot.MeasuredHeight); plot.Draw(canvas); if (plot.Model.GetLastPlotException() != null) { throw plot.Model.GetLastPlotException(); } }