public ScottPlotGraphForm(ScottPlotGraph graphModel) { InitializeComponent(); GraphModel = graphModel; DataContext = GraphModel; PlotGraph(GraphModel); }
public void PlotLocationAxis(ScottPlotGraph graphModel) { string[] labels = new string[graphModel.LocationList.Count]; int k = 0; foreach (var label in graphModel.LocationList) { labels[k] = label.LocationAbbreviation; k++; } TimetableGraph.plt.XTicks(labels); }
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); } }
public void PlotGraph(ScottPlotGraph graphModel) { var locationCount = GraphModel.LocationList.Count; var serviceCount = GraphModel.TimeGraphUI.Count; var pointCount = locationCount * serviceCount; scatterDataX = new double[pointCount + 1]; scatterDataY = new double[pointCount + 1]; highlightedTimeGraphUiModels = new TimeGraphUIModel[pointCount + 1]; scatterIndex = 0; int i = 0; foreach (var graph in GraphModel.TimeGraphUI) { graph.Plot = PlotService(graphModel, graph, GraphModel.TimeGraphUI[i].ServiceAbbreviation); i++; } PlotTimeAxis(graphModel.Zoom, graphModel.Pan); PlotLocationAxis(graphModel); if (marker != null) { //redraw marker marker = TimetableGraph.plt.PlotScatter(marker.xs, marker.ys, Color.Red, markerShape: MarkerShape.openCircle, markerSize: 15); } if (GraphModel.SelectedTimeGraph != null) { GraphModel.SelectedTimeGraph.Plot.lineWidth = 3; } TimetableGraph.plt.Style(figBg: GetResourceColor("WindowBackground")); TimetableGraph.plt.Style(dataBg: GetResourceColor("ControlBackground")); TimetableGraph.plt.Grid(enable: true, color: GetResourceColor("GridLine")); scatterHighLight = TimetableGraph.plt.PlotScatterHighlight(scatterDataX, scatterDataY, lineWidth: 0, markerSize: 0.5); TimetableGraph.Configure(enablePanning: false, enableScrollWheelZoom: false, enableRightClickZoom: false); TimetableGraph.Render(); }