public static IList <LineChartTypes> ParseLineChartType(string[] s) { IList <LineChartTypes> r = new List <LineChartTypes>(); foreach (String column in s) { try { LineChartTypes t = (LineChartTypes)Enum.Parse(typeof(LineChartTypes), column, true); //Compatibility w previous, where DifTime/DiffDist could be speced directly if (t == LineChartTypes.DiffDist || t == LineChartTypes.DiffTime) { if (!r.Contains(LineChartTypes.DiffDistTime)) { r.Add(LineChartTypes.DiffDistTime); } } else { r.Add(t); } } catch { } } return(r); }
/************************************************/ /// <summary> /// Some chartTypes share axis. Could be changeable in the chart /// </summary> /// <param name="chart"></param> /// <returns></returns> public static LineChartTypes ChartToAxis(LineChartTypes chart) { LineChartTypes axis = chart; if (chart == LineChartTypes.DeviceSpeed) { axis = LineChartTypes.Speed; } else if (chart == LineChartTypes.DevicePace) { axis = LineChartTypes.Pace; } else if (chart == LineChartTypes.DevicePace2) { axis = LineChartTypes.Pace2; } else if (chart == LineChartTypes.DeviceElevation) { axis = LineChartTypes.Elevation; } else if (chart == LineChartTypes.DeviceDiffDist) { axis = LineChartTypes.DiffDist; } return(axis); }
private bool SetLineChartChecked(LineChartTypes t) { if (!m_expanded) { return(Data.Settings.MultiChartType.Contains(t)); } else { return(Data.Settings.MultiGraphType.Contains(t)); } }
public static bool IsDiffType(LineChartTypes YAxisReferential) { if (YAxisReferential == LineChartTypes.DiffTime || YAxisReferential == LineChartTypes.DiffDist || YAxisReferential == LineChartTypes.DiffDistTime || YAxisReferential == LineChartTypes.DeviceDiffDist) { return(true); } return(false); }
private void RefreshChart(LineChartTypes t) { if (!m_expanded) { Data.Settings.ToggleMultiChartType = t; } else { Data.Settings.ToggleMultiGraphType = t; } this.RefreshChart(); }
private bool FillSingleDataSerie(LineChartTypes chartType, ChartDataSeries dataSerie) { INumericTimeDataSeries graphPoints = GetSmoothedActivityTrack(chartType); if (graphPoints.Count > 0) { TimeSpan trackStartDiffWithActivity = graphPoints.StartTime - m_ActivityInfoCache.ActualTrackStart; float trackSecondDifference = (float)trackStartDiffWithActivity.TotalSeconds; if (XAxisReferential == XAxisValue.Time) { graphPoints = Utils.Utils.RemovePausedTimesInTrack(graphPoints, Activity); foreach (ITimeValueEntry <float> entry in graphPoints) { float key = trackSecondDifference + entry.ElapsedSeconds; if (!dataSerie.Points.ContainsKey(key)) { dataSerie.Points.Add(key, new PointF(trackSecondDifference + entry.ElapsedSeconds, entry.Value)); } } } else if (m_ActivityInfoCache.MovingDistanceMetersTrack != null) { IDistanceDataTrack distanceTrack = m_ActivityInfoCache.MovingDistanceMetersTrack; int pointCount = Math.Min(distanceTrack.Count, graphPoints.Count); ITimeValueEntry <float> startEntry = distanceTrack.GetInterpolatedValue(graphPoints.StartTime); foreach (ITimeValueEntry <float> entry in graphPoints) { ITimeValueEntry <float> interpolatedEntry = distanceTrack.GetInterpolatedValue(graphPoints.StartTime + new TimeSpan(0, 0, (int)entry.ElapsedSeconds)); if (interpolatedEntry != null) { float distanceAtTime = interpolatedEntry.Value; float distanceValue = (float)Length.Convert(distanceAtTime, Length.Units.Meter, Activity.Category.DistanceUnits); float key = trackSecondDifference + entry.ElapsedSeconds; if (!dataSerie.Points.ContainsKey(key)) { dataSerie.Points.Add(key, new PointF(distanceValue, entry.Value)); } } } } return(true); } return(false); }
private void PowerToolStripMenuItem_Click(object sender, EventArgs e) { LineChartTypes t = LineChartTypes.Unknown; if (sender == powerToolStripMenuItem) { t = LineChartTypes.Power; } else if (sender == PowerBalanceToolStripMenuItem) { t = LineChartTypes.PowerBalance; } else if (sender == TemperatureToolStripMenuItem) { t = LineChartTypes.Temperature; } else if (sender == GroundContactTimeToolStripMenuItem) { t = LineChartTypes.GroundContactTime; } else if (sender == VerticalOscillationToolStripMenuItem) { t = LineChartTypes.VerticalOscillation; } else if (sender == SaturatedHemoglobinToolStripMenuItem) { t = LineChartTypes.SaturatedHemoglobin; } else if (sender == TotalHemoglobinConcentrationToolStripMenuItem) { t = LineChartTypes.TotalHemoglobinConcentration; } if (t != LineChartTypes.Unknown) { RefreshChart(t); } else { Debug.Assert(false, "Unknown object" + sender.ToString()); } }
public static String GetYAxisLabel(LineChartTypes chartType, IActivity activity) { string yAxisLabel = GetShortYAxisLabel(chartType, activity); switch (chartType) { case LineChartTypes.Cadence: { yAxisLabel += " (" + CommonResources.Text.LabelRPM + ")"; break; } case LineChartTypes.Elevation: { if (activity != null) { yAxisLabel += " (" + Length.LabelPlural(activity.Category.ElevationUnits) + ")"; } break; } case LineChartTypes.Speed: { if (activity != null) { yAxisLabel += " (" + Utils.Utils.GetSpeedUnitLabelForActivity(activity) + ")"; } break; } case LineChartTypes.Power: { yAxisLabel += " (" + CommonResources.Text.LabelWatts + ")"; break; } } return(yAxisLabel); }
private void SetupAxisStripes(IAxis yAxis, LineChartTypes chartType) { if (yAxis != null && Activity != null) { yAxis.Stripes.Clear(); if (Options.Instance.ShowZonesInChart && ShownZones != null) { foreach (INamedLowHighZone zone in ShownZones.Zones) { AxisStripe stripe = new AxisStripe(zone.Low, zone.High, Color.FromArgb(16, 0, 0, 0)); yAxis.Stripes.Add(stripe); // Setup default parameters stripe.Name = zone.Name; stripe.LineColor = Color.FromArgb(128, 0, 0, 0); stripe.LineStyle = DashStyle.Dash; stripe.LineWidth = 2; // Some types need to override the low/high values switch (chartType) { case LineChartTypes.HeartRatePercentMax: { IAthleteInfoEntry lastAthleteEntry = PluginMain.GetApplication().Logbook.Athlete.InfoEntries.LastEntryAsOfDate(m_ActivityInfoCache.ActualTrackStart); // Value is in BPM so convert to the % max HR if we have the info if (!float.IsNaN(lastAthleteEntry.MaximumHeartRatePerMinute)) { stripe.From = (zone.Low / lastAthleteEntry.MaximumHeartRatePerMinute) * 100; stripe.To = (zone.High / lastAthleteEntry.MaximumHeartRatePerMinute) * 100; } else { // Cancel the add, we don't have the data yAxis.Stripes.Remove(stripe); } break; } case LineChartTypes.Speed: { stripe.From = Length.Convert(zone.Low, Length.Units.Meter, Utils.Utils.MajorLengthUnit(Activity.Category.DistanceUnits)) * Utils.Constants.SecondsPerHour; stripe.To = Length.Convert(zone.High, Length.Units.Meter, Utils.Utils.MajorLengthUnit(Activity.Category.DistanceUnits)) * Utils.Constants.SecondsPerHour;; break; } default: { break; } } } if (MainChart != null) { MainChart.Invalidate(); } } } }
public static String GetShortYAxisLabel(LineChartTypes chartType, IActivity activity) { string yAxisLabel = String.Empty; switch (chartType) { case LineChartTypes.Cadence: { yAxisLabel = CommonResources.Text.LabelCadence; break; } case LineChartTypes.Elevation: { yAxisLabel = CommonResources.Text.LabelElevation; break; } case LineChartTypes.Grade: { yAxisLabel = CommonResources.Text.LabelGrade; break; } case LineChartTypes.HeartRateBPM: { yAxisLabel = CommonResources.Text.LabelHeartRate + " (" + CommonResources.Text.LabelBPM + ")"; break; } case LineChartTypes.HeartRatePercentMax: { yAxisLabel = CommonResources.Text.LabelHeartRate + " (" + CommonResources.Text.LabelPercentOfMax + ")"; break; } case LineChartTypes.Power: { yAxisLabel = CommonResources.Text.LabelPower; break; } //case LineChartTypes.Pace: case LineChartTypes.Speed: { if (activity != null && activity.Category.SpeedUnits == Speed.Units.Pace) { yAxisLabel = CommonResources.Text.LabelPace; } else { yAxisLabel = CommonResources.Text.LabelSpeed; } break; } default: { Debug.Assert(false); break; } } return(yAxisLabel); }
public ChartTypeDefinition(LineChartTypes chartKey) { this.chartKey = chartKey; }
public static INumericTimeDataSeries GetSmoothedActivityTrack(Data.TrailResult result, LineChartTypes lineChart, TrailResult refRes) { // Fail safe INumericTimeDataSeries track; switch (lineChart) { case LineChartTypes.Cadence: { track = result.CadencePerMinuteTrack0(refRes); break; } case LineChartTypes.Elevation: { track = result.ElevationMetersTrack0(refRes); break; } case LineChartTypes.HeartRateBPM: { track = result.HeartRatePerMinuteTrack0(refRes); break; } //case LineChartTypes.HeartRatePercentMax: // { // track = result.HeartRatePerMinutePercentMaxTrack; // break; // } case LineChartTypes.Power: { track = result.PowerWattsTrack0(refRes); break; } case LineChartTypes.Grade: { track = result.GradeTrack0(refRes); break; } case LineChartTypes.Speed: case LineChartTypes.Pace2: { track = result.SpeedTrack0(refRes); break; } case LineChartTypes.Pace: { track = result.PaceTrack0(refRes); break; } case LineChartTypes.PowerBalance: { track = result.PowerBalanceTrack0(refRes); break; } case LineChartTypes.Temperature: { track = result.TemperatureTrack0(refRes); break; } case LineChartTypes.GroundContactTime: { track = result.GroundContactTimeTrack0(refRes); break; } case LineChartTypes.VerticalOscillation: { track = result.VerticalOscillationTrack0(refRes); break; } case LineChartTypes.SaturatedHemoglobin: { track = result.SaturatedHemoglobinTrack0(refRes); break; } case LineChartTypes.TotalHemoglobinConcentration: { track = result.TotalHemoglobinConcentrationTrack0(refRes); break; } case LineChartTypes.DiffTime: { track = result.DiffTimeTrack0(refRes); break; } case LineChartTypes.DiffDist: { track = result.DiffDistTrack0(refRes); break; } case LineChartTypes.DeviceSpeed: case LineChartTypes.DevicePace2: { track = result.DeviceSpeedPaceTrack0(refRes, false); break; } case LineChartTypes.DevicePace: { track = result.DeviceSpeedPaceTrack0(refRes, true); break; } case LineChartTypes.DeviceElevation: { track = result.DeviceElevationTrack0(refRes); break; } case LineChartTypes.DeviceDiffDist: { track = result.DeviceDiffDistTrack0(refRes); break; } default: { Debug.Assert(false, string.Format("Unexpecteded LineChartTypes {0}", lineChart)); // Fail safe track = new TrackUtil.NumericTimeDataSeries(); break; } } return(track); }
public static string GetSmoothingString(LineChartTypes YAxisReferential) { string res = ""; switch (YAxisReferential) { case LineChartTypes.Cadence: res = "CadenceSmoothingSeconds"; break; case LineChartTypes.Elevation: case LineChartTypes.DeviceElevation: case LineChartTypes.Grade: res = "ElevationSmoothingSeconds"; break; case LineChartTypes.HeartRateBPM: case LineChartTypes.DiffHeartRateBPM: res = "HeartRateSmoothingSeconds"; break; case LineChartTypes.Power: res = "PowerSmoothingSeconds"; break; case LineChartTypes.Speed: case LineChartTypes.Pace: case LineChartTypes.Pace2: case LineChartTypes.DeviceSpeed: case LineChartTypes.DevicePace: case LineChartTypes.DevicePace2: res = "SpeedSmoothingSeconds"; break; case LineChartTypes.PowerBalance: res = "PowerBalanceSmoothingSeconds"; break; case LineChartTypes.Temperature: res = "TemperatureSmoothingSeconds"; break; case LineChartTypes.GroundContactTime: res = "GroundContactTimeSmoothingSeconds"; break; case LineChartTypes.VerticalOscillation: res = "VerticalOscillationSmoothingSeconds"; break; case LineChartTypes.SaturatedHemoglobin: res = "SaturatedHemoglobinSmoothingSeconds"; break; case LineChartTypes.TotalHemoglobinConcentration: res = "TotalHemoglobinConcentrationSmoothingSeconds"; break; case LineChartTypes.DiffDist: case LineChartTypes.DiffTime: case LineChartTypes.DiffDistTime: case LineChartTypes.DeviceDiffDist: break; default: Debug.Assert(false, "Unknown smoothing LineChartType" + YAxisReferential); break; } return(res); }
public static string LineChartTypesString(LineChartTypes YAxisReferential, bool yAxis) { string yAxisLabel = ""; switch (YAxisReferential) { case LineChartTypes.Cadence: { yAxisLabel = CommonResources.Text.LabelCadence; break; } case LineChartTypes.Elevation: case LineChartTypes.DeviceElevation: { yAxisLabel = CommonResources.Text.LabelElevation; break; } case LineChartTypes.HeartRateBPM: case LineChartTypes.DiffHeartRateBPM: //Unused - need name changes { yAxisLabel = CommonResources.Text.LabelHeartRate; break; } //case LineChartTypes.HeartRatePercentMax: // { // yAxisLabel = CommonResources.Text.LabelHeartRate; // break; // } case LineChartTypes.Power: { yAxisLabel = CommonResources.Text.LabelPower; break; } case LineChartTypes.Speed: case LineChartTypes.DeviceSpeed: { yAxisLabel = CommonResources.Text.LabelSpeed; break; } case LineChartTypes.Pace: case LineChartTypes.DevicePace: { yAxisLabel = CommonResources.Text.LabelPace; break; } case LineChartTypes.Pace2: case LineChartTypes.DevicePace2: { yAxisLabel = Properties.Resources.UI_Chart_PaceInverted; break; } case LineChartTypes.SpeedPace: //Only chart selector case LineChartTypes.DeviceSpeedPace: //Only chart selector { yAxisLabel = CommonResources.Text.LabelSpeed + " / " + CommonResources.Text.LabelPace; break; } case LineChartTypes.Grade: { yAxisLabel = CommonResources.Text.LabelGrade; break; } case LineChartTypes.PowerBalance: { yAxisLabel = CommonResources.Text.LabelPowerBalance; break; } case LineChartTypes.Temperature: { yAxisLabel = CommonResources.Text.LabelTemperature; break; } case LineChartTypes.GroundContactTime: { yAxisLabel = CommonResources.Text.LabelGroundContactTime; break; } case LineChartTypes.VerticalOscillation: { yAxisLabel = CommonResources.Text.LabelVerticalOscillation; break; } case LineChartTypes.SaturatedHemoglobin: { yAxisLabel = CommonResources.Text.LabelSaturatedHemoglobinPercent; break; } case LineChartTypes.TotalHemoglobinConcentration: { yAxisLabel = CommonResources.Text.LabelTotalHemoglobinConcentration; break; } case LineChartTypes.Distance: case LineChartTypes.DiffDist: //Only for yaxis label { yAxisLabel = CommonResources.Text.LabelDistance; break; } case LineChartTypes.DeviceDiffDist: { if (yAxis) { yAxisLabel = CommonResources.Text.LabelDistance; } else { yAxisLabel = Properties.Resources.UI_Chart_Difference; } break; } case LineChartTypes.Time: case LineChartTypes.DiffTime: //Only for yaxis label { yAxisLabel = CommonResources.Text.LabelTime; break; } case LineChartTypes.DiffDistTime: //Only chart selector { yAxisLabel = Properties.Resources.UI_Chart_Difference; break; } default: { Debug.Assert(false, string.Format("Unexpecteded LineChartTypes {0}", YAxisReferential)); break; } } return(yAxisLabel); }
public static string ChartTypeString(LineChartTypes x) { return(LineChartTypesString(x, true)); }
private void SetupYAxisFromType(IAxis yAxis, LineChartTypes chartType) { IAxisFormatter yAxisFormatter = new Formatter.General(); yAxis.Label = GetYAxisLabel(chartType, Activity); switch (chartType) { case LineChartTypes.Cadence: { break; } case LineChartTypes.Elevation: { if (PluginMain.GetApplication() != null) { Length.Units elevationUnit = PluginMain.GetApplication().SystemPreferences.ElevationUnits; if (Activity != null) { elevationUnit = Activity.Category.ElevationUnits; } } break; } case LineChartTypes.Grade: { ((Formatter.General)yAxisFormatter).MinPrecision = 1; break; } case LineChartTypes.HeartRateBPM: { break; } case LineChartTypes.HeartRatePercentMax: { yAxisFormatter = new Formatter.Percent(); break; } case LineChartTypes.Power: { break; } case LineChartTypes.Speed: { if (Activity != null && Activity.Category.SpeedUnits == Speed.Units.Pace) { yAxisFormatter = new Formatter.SecondsToTime(); } else { ((Formatter.General)yAxisFormatter).MinPrecision = 2; } break; } default: { Debug.Assert(false); break; } } yAxis.Formatter = yAxisFormatter; }
private void SetupYAxisAndDataColorFromType(IAxis yAxis, ChartDataSeries dataSerie, LineChartTypes chartType) { yAxis.LabelColor = Utils.Constants.LineChartTypesColors[(int)chartType]; dataSerie.LineColor = Utils.Constants.LineChartTypesColors[(int)chartType]; }
public static void SetupYAxisFormatter(LineChartTypes axisType, IAxis axis, IActivity activity) { axis.SmartZoom = true; axis.LabelColor = ColorUtil.ChartColor[axisType].LineNormal; switch (axisType) { case LineChartTypes.Cadence: { axis.Formatter = new Formatter.General(UnitUtil.Cadence.DefaultDecimalPrecision); axis.Label = CommonResources.Text.LabelCadence + UnitUtil.Cadence.LabelAbbr2; break; } case LineChartTypes.Grade: { axis.Formatter = new Formatter.General(UnitUtil.Grade.DefaultDecimalPrecision); axis.Label = UnitUtil.Grade.LabelAxis; break; } case LineChartTypes.Elevation: case LineChartTypes.DeviceElevation: { axis.Formatter = new Formatter.General(UnitUtil.Elevation.DefaultDecimalPrecision); axis.Label = CommonResources.Text.LabelElevation + UnitUtil.Elevation.LabelAbbrAct2(activity); break; } case LineChartTypes.HeartRateBPM: case LineChartTypes.DiffHeartRateBPM: { axis.Formatter = new Formatter.General(UnitUtil.HeartRate.DefaultDecimalPrecision); axis.Label = CommonResources.Text.LabelHeartRate + UnitUtil.HeartRate.LabelAbbr2; break; } //case LineChartTypes.HeartRatePercentMax: // { // axis.Label = CommonResources.Text.LabelHeartRate + " (" + // CommonResources.Text.LabelPercentOfMax + ")"; // break; // } case LineChartTypes.Power: { axis.Formatter = new Formatter.General(UnitUtil.Power.DefaultDecimalPrecision); axis.Label = CommonResources.Text.LabelPower + UnitUtil.Power.LabelAbbr2; break; } case LineChartTypes.Speed: case LineChartTypes.DeviceSpeed: { axis.Formatter = new Formatter.General(UnitUtil.Speed.DefaultDecimalPrecision); axis.Label = CommonResources.Text.LabelSpeed + UnitUtil.Speed.LabelAbbrAct2(activity); break; } case LineChartTypes.Pace: case LineChartTypes.DevicePace: { axis.Formatter = new Formatter.SecondsToTime(); axis.Label = CommonResources.Text.LabelPace + UnitUtil.Pace.LabelAbbrAct2(activity); break; } case LineChartTypes.Pace2: case LineChartTypes.DevicePace2: { axis.Formatter = new PaceFormatter(); axis.Label = CommonResources.Text.LabelPace + UnitUtil.Pace.LabelAbbrAct2(activity); break; } case LineChartTypes.PowerBalance: { axis.Formatter = new Formatter.Percent(); axis.Label = CommonResources.Text.LabelPowerBalance; break; } case LineChartTypes.Temperature: { axis.Formatter = new Formatter.General(UnitUtil.Temperature.DefaultDecimalPrecision); axis.Label = CommonResources.Text.LabelTemperature + UnitUtil.Temperature.LabelAbbr2; break; } case LineChartTypes.GroundContactTime: { axis.Formatter = new Formatter.General(1); axis.Label = CommonResources.Text.LabelGroundContactTime + " (ms)"; break; } case LineChartTypes.VerticalOscillation: { axis.Formatter = new Formatter.General(); axis.Label = CommonResources.Text.LabelVerticalOscillation + " (" + Length.LabelAbbr(Length.Units.Centimeter) + ")"; break; } case LineChartTypes.SaturatedHemoglobin: { axis.Formatter = new Formatter.Percent(); axis.Label = CommonResources.Text.LabelSaturatedHemoglobinPercent; break; } case LineChartTypes.TotalHemoglobinConcentration: { axis.Formatter = new Formatter.General(); axis.Label = CommonResources.Text.LabelTotalHemoglobinConcentration; break; } case LineChartTypes.DiffTime: case LineChartTypes.Time: { axis.Formatter = new Formatter.SecondsToTime(); axis.Label = CommonResources.Text.LabelTime; break; } case LineChartTypes.DiffDist: case LineChartTypes.DeviceDiffDist: { axis.Formatter = new Formatter.General(UnitUtil.Elevation.DefaultDecimalPrecision - 1); axis.Label = CommonResources.Text.LabelDistance + UnitUtil.Elevation.LabelAbbrAct2(activity); break; } case LineChartTypes.Distance: { axis.Formatter = new Formatter.General(UnitUtil.Distance.DefaultDecimalPrecision); axis.Label = CommonResources.Text.LabelDistance + UnitUtil.Distance.LabelAbbrAct2(activity); break; } default: { Debug.Assert(false, string.Format("Unexpecteded LineChartTypes {0}", axisType)); break; } } }
private INumericTimeDataSeries GetSmoothedActivityTrack(LineChartTypes chartType) { // Fail safe INumericTimeDataSeries result = new NumericTimeDataSeries(); if (Activity != null) { switch (chartType) { case LineChartTypes.Cadence: { result = m_ActivityInfoCache.SmoothedCadenceTrack; break; } case LineChartTypes.Elevation: { INumericTimeDataSeries tempResult = m_ActivityInfoCache.SmoothedElevationTrack; // Value is in meters so convert to the right unit result = new NumericTimeDataSeries(); foreach (ITimeValueEntry <float> entry in tempResult) { double temp = Length.Convert(entry.Value, Length.Units.Meter, Activity.Category.ElevationUnits); result.Add(tempResult.EntryDateTime(entry), (float)temp); } break; } case LineChartTypes.Grade: { result = new NumericTimeDataSeries(); INumericTimeDataSeries tempResult = m_ActivityInfoCache.SmoothedGradeTrack; foreach (ITimeValueEntry <float> entry in tempResult) { result.Add(tempResult.EntryDateTime(entry), entry.Value * 100.0f); } break; } case LineChartTypes.HeartRateBPM: { result = m_ActivityInfoCache.SmoothedHeartRateTrack; break; } case LineChartTypes.HeartRatePercentMax: { result = new NumericTimeDataSeries(); IAthleteInfoEntry lastAthleteEntry = PluginMain.GetApplication().Logbook.Athlete.InfoEntries.LastEntryAsOfDate(m_ActivityInfoCache.ActualTrackStart); // Value is in BPM so convert to the % max HR if we have the info if (!float.IsNaN(lastAthleteEntry.MaximumHeartRatePerMinute)) { INumericTimeDataSeries tempResult = m_ActivityInfoCache.SmoothedHeartRateTrack; foreach (ITimeValueEntry <float> entry in tempResult) { double temp = (entry.Value / lastAthleteEntry.MaximumHeartRatePerMinute) * 100; result.Add(tempResult.EntryDateTime(entry), (float)temp); } } break; } case LineChartTypes.Power: { result = m_ActivityInfoCache.SmoothedPowerTrack; break; } case LineChartTypes.Speed: { INumericTimeDataSeries tempResult = m_ActivityInfoCache.SmoothedSpeedTrack; // Value is in m/sec so convert to the right unit and to // pace if necessary result = new NumericTimeDataSeries(); foreach (ITimeValueEntry <float> entry in tempResult) { double temp = Length.Convert(entry.Value, Length.Units.Meter, Utils.Utils.MajorLengthUnit(Activity.Category.DistanceUnits)) * Utils.Constants.SecondsPerHour; if (Activity.Category.SpeedUnits == Speed.Units.Pace) { // Convert to pace and then in second temp = Utils.Utils.SpeedToPace(temp) * Utils.Constants.SecondsPerMinute; } result.Add(tempResult.EntryDateTime(entry), (float)temp); } break; } default: { Debug.Assert(false); break; } } } return(result); }
public void RefreshChart() { if (m_showPage && this.ChartVisible) { LineChartTypes speedPaceChart = LineChartTypes.Speed; LineChartTypes deviceSpeedPaceChart = LineChartTypes.DeviceSpeed; if (Controller.TrailController.Instance.ReferenceActivity != null && Controller.TrailController.Instance.ReferenceActivity.Category.SpeedUnits.Equals(Speed.Units.Pace)) { speedPaceChart = LineChartTypes.Pace; deviceSpeedPaceChart = LineChartTypes.DevicePace; } LineChartTypes diffChart = LineChartTypes.DiffDist; if (Data.Settings.XAxisValue == XAxisValue.Distance) { diffChart = LineChartTypes.DiffTime; } bool isData = Controller.TrailController.Instance.CurrentActivityTrailIsSelected; IList <Data.TrailResult> selectedPresentableResults = TrailResultWrapper.TrailResults(Controller.TrailController.Instance.SelectedResults); if (selectedPresentableResults.Count > Data.Settings.MaxChartResults) { //Move summary first, so it is not truncated for (int i = 0; i < selectedPresentableResults.Count; i++) { TrailResult t = selectedPresentableResults[i]; if (t is SummaryTrailResult) { selectedPresentableResults.RemoveAt(i); selectedPresentableResults.Insert(0, t); break; } } ((List <Data.TrailResult>)selectedPresentableResults).RemoveRange(Data.Settings.MaxChartResults, selectedPresentableResults.Count - Data.Settings.MaxChartResults); } m_multiChart.ChartTypes = new List <LineChartTypes>(); multiChart.ShowPage = false; //TODO: Temporary handling. Cleanup and decide multiple graphs and charts TrailLineChart updateChart = m_multiChart; if (!m_expanded) { foreach (TrailLineChart chart in m_lineCharts) { chart.ShowPage = false; } m_multiChart.BeginUpdate(); m_multiChart.XAxisReferential = Data.Settings.XAxisValue; m_multiChart.TrailResults = selectedPresentableResults; foreach (LineChartTypes t in Data.Settings.MultiChartType) { LineChartTypes t2 = t; if (t2 == LineChartTypes.SpeedPace) { t2 = speedPaceChart; } else if (t2 == LineChartTypes.DeviceSpeedPace) { t2 = deviceSpeedPaceChart; } else if (t2 == LineChartTypes.DiffDistTime) { t2 = diffChart; } if (!m_multiChart.ChartTypes.Contains(t2) && m_multiChart.HasValues(t2)) { m_multiChart.ChartTypes.Add(t2); } } m_multiChart.ShowPage = true; if (!m_multiChart.AnyData()) { m_multiChart.ShowPage = false; m_multiChart.LeftChartType = speedPaceChart; m_multiChart.ShowPage = true; } this.ChartBanner.Text = LineChartUtil.ChartTypeString(m_multiChart.LeftChartType) + " / " + LineChartUtil.XAxisValueString(m_multiChart.XAxisReferential); m_multiChart.EndUpdate(true); } else { foreach (TrailLineChart chart in m_lineCharts) { bool visible = false; if (m_expanded && (Data.Settings.MultiGraphType.Contains(chart.LeftChartType) || chart.LeftChartType == speedPaceChart && (Data.Settings.MultiGraphType.Contains(LineChartTypes.SpeedPace) || Data.Settings.MultiGraphType.Contains(LineChartTypes.DeviceSpeedPace)) || chart.LeftChartType == diffChart && (Data.Settings.MultiGraphType.Contains(LineChartTypes.DiffDistTime) || Data.Settings.MultiGraphType.Contains(LineChartTypes.DeviceDiffDist))) || !m_expanded && (chart.LeftChartType == Data.Settings.ChartType || chart.LeftChartType == speedPaceChart && (LineChartTypes.SpeedPace == Data.Settings.ChartType || LineChartTypes.DeviceSpeedPace == Data.Settings.ChartType) || chart.LeftChartType == diffChart && (LineChartTypes.DiffDistTime == Data.Settings.ChartType || LineChartTypes.DiffDistTime == Data.Settings.ChartType))) { visible = true; } updateChart = chart; updateChart.BeginUpdate(); chart.ShowPage = false; if (visible && isData) { updateChart.XAxisReferential = Data.Settings.XAxisValue; updateChart.TrailResults = selectedPresentableResults; if (!m_expanded && updateChart.ChartTypes.Count == 1) { this.ChartBanner.Text = LineChartUtil.ChartTypeString(chart.LeftChartType) + " / " + LineChartUtil.XAxisValueString(chart.XAxisReferential); } if (updateChart.HasValues(chart.LeftChartType)) { updateChart.ShowPage = visible; } else { if (visible && !updateChart.HasValues(chart.LeftChartType)) { chart.ShowPage = false; //Replace empty chart if (!m_expanded && chart.LeftChartType != speedPaceChart) { foreach (TrailLineChart replaceChart in m_lineCharts) { if (replaceChart.LeftChartType == speedPaceChart) { replaceChart.BeginUpdate(); replaceChart.ShowPage = false; replaceChart.XAxisReferential = Data.Settings.XAxisValue; replaceChart.TrailResults = selectedPresentableResults; if (!m_expanded) { this.ChartBanner.Text = LineChartUtil.ChartTypeString(replaceChart.LeftChartType) + " / " + LineChartUtil.XAxisValueString(replaceChart.XAxisReferential); } replaceChart.ShowPage = visible; replaceChart.EndUpdate(true); } } } } } } updateChart.EndUpdate(true); } } RefreshRows(); RefreshChartMenu(); } }