private void PrepareDataSet() { TimeGraphUI = new BindableCollection <TimeGraphUIModel>(); var serviceList = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(TimetableId)); foreach (var service in serviceList) { var item = new TimeGraphUIModel(); var serviceTemplateId = service.ServiceTemplateId; item.TimeEventList = new BindableCollection <ExtendedFullTimeEventModel>(FullTimeEventDataAccess.GetAllExtendedFullTimeEventsPerServiceTemplate(serviceTemplateId)); item.ServiceName = service.ServiceName; item.ServiceAbbreviation = service.ServiceAbbreviation; int actualTime = service.StartTime; foreach (var fullTimeEvent in item.TimeEventList) { actualTime += fullTimeEvent.ArrivalTime; DataPoint point = GetFirstDataPoint(fullTimeEvent, actualTime); item.DataLine.Add(point); if (fullTimeEvent.WaitTime > 0) { actualTime += fullTimeEvent.WaitTime; DataPoint point2 = GetSecondDataPoint(actualTime, point.X); item.DataLine.Add(point2); } } TimeGraphUI.Add(item); } }
private void OnMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { var mousePos = e.MouseDevice.GetPosition(TimetableGraph); double mouseX = TimetableGraph.plt.CoordinateFromPixelX(mousePos.X); double mouseY = TimetableGraph.plt.CoordinateFromPixelY(mousePos.Y); scatterHighLight.HighlightClear(); var(x, y, index) = scatterHighLight.HighlightPointNearest(mouseX, mouseY); TimeGraphUIModel graph = highlightedTimeGraphUiModels[index]; if (graph != null) { double[] xs = { x }; double[] ys = { y }; if (marker != null) { marker.markerShape = MarkerShape.none; } marker = TimetableGraph.plt.PlotScatter(xs, ys, Color.Red, markerShape: MarkerShape.openCircle, markerSize: 15); if (GraphModel.SelectedTimeGraph != null && GraphModel.SelectedTimeGraph.Plot != null) { GraphModel.SelectedTimeGraph.Plot.lineWidth = 1; } graph.Plot.lineWidth = 3; GraphModel.SelectedTimeGraph = graph; TimetableGraph.Render(); } TimetableGraph.Render(); }
public PlottableScatter PlotService(ScottPlotGraph model, TimeGraphUIModel graph, string serviceAbbreviation) { int startTime = TimeConverters.TimeToMinutes(model.StartTimeText); int endTime = TimeConverters.TimeToMinutes(model.EndTimeText); double[] dataX = new double[graph.DataLine.Count]; double[] dataY = new double[graph.DataLine.Count]; int j = 0; if (graph.DataLine[0].Y >= startTime && graph.DataLine[0].Y < endTime) { foreach (var dataSet in graph.DataLine) { dataX[j] = dataSet.X; dataY[j] = -dataSet.Y; scatterDataX[scatterIndex] = dataSet.X; scatterDataY[scatterIndex] = -dataSet.Y; highlightedTimeGraphUiModels[scatterIndex] = graph; scatterIndex++; j++; } double xOffset = 0; double yOffset = 5; TextAlignment alignment; if (dataX[0] < dataX.GetLength(0) / 2) { alignment = TextAlignment.upperLeft; } else { alignment = TextAlignment.upperRight; } TimetableGraph.plt.PlotText(serviceAbbreviation, dataX[0] + xOffset, dataY[0] + yOffset, fontName: "Arial", fontSize: 10, color: GetResourceColor("GraphText"), bold: true, alignment: alignment); return(TimetableGraph.plt.PlotScatterHighlight(dataX, dataY, GetLineColor(graph.ServiceType))); } else { return(null); } }
private void PrepareDataSet() { TimeGraphUI = new ObservableCollection <TimeGraphUIModel>(); ServiceClassList = ServiceClassDataAccess.GetAllServiceClasses(); var serviceList = new ObservableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(TimetableId)); foreach (var service in serviceList) { var item = new TimeGraphUIModel(); var serviceTemplateId = service.ServiceTemplateId; var serviceTemplate = ServiceTemplateDataAccess.GetServiceTemplateById(serviceTemplateId); item.TimeEventList = new BindableCollection <ExtendedFullTimeEventModel>(FullTimeEventDataAccess.GetAllExtendedFullTimeEventsPerServiceTemplate(serviceTemplateId)); item.ServiceName = service.ServiceName; item.ServiceAbbreviation = service.ServiceAbbreviation; item.ServiceType = serviceTemplate.ServiceType; item.StartTimeText = service.StartTimeText; item.EndTimeText = service.EndTimeText; int actualTime = service.StartTime; foreach (var fullTimeEvent in item.TimeEventList) { actualTime += fullTimeEvent.ArrivalTime; fullTimeEvent.ArrivalTimeText = TimeConverters.MinutesToString(actualTime); DataPoint point = GetFirstDataPoint(fullTimeEvent, actualTime); item.DataLine.Add(point); if (fullTimeEvent.WaitTime > 0) { actualTime += fullTimeEvent.WaitTime; DataPoint point2 = GetSecondDataPoint(actualTime, point.X); item.DataLine.Add(point2); } fullTimeEvent.DepartureTimeText = TimeConverters.MinutesToString(actualTime); } TimeGraphUI.Add(item); } OnPropertyChanged("TimeGraphUI"); }