public void AddLine(string lineName, double[] xValues, double[] yValues, Color lineColor, int lineThickness, bool display) { if (allLines.ContainsKey(lineName)) { MonoBehaviour.print("Error: A Line with that name already exists"); return; } if (xValues.Length != yValues.Length) { MonoBehaviour.print("Error: X and Y value arrays are different lengths"); return; } KerbalGraphLine newLine = new KerbalGraphLine((int)drawRect.width, (int)drawRect.height); newLine.InputData(xValues, yValues); newLine.SetBoundaries(bounds); newLine.lineColor = lineColor; newLine.lineThickness = lineThickness; newLine.backgroundColor = backgroundColor; newLine.displayInLegend = display; allLines.Add(lineName, newLine); Update(); }
public void AddLine(string lineName) { if (allLines.ContainsKey(lineName)) { MonoBehaviour.print("Error: A Line with that name already exists"); return; } KerbalGraphLine newLine = new KerbalGraphLine((int)drawRect.width, (int)drawRect.height); newLine.SetBoundaries(bounds); allLines.Add(lineName, newLine); Update(); }
public void RemoveLine(string lineName) { if (!allLines.ContainsKey(lineName)) { MonoBehaviour.print("Error: No line with that name exists"); return; } KerbalGraphLine line = allLines[lineName]; allLines.Remove(lineName); line.ClearTextures(); Update(); }
/// <summary> /// Dumps a set number of lines to a file at a specific path /// </summary> /// <param name="pathName">The file path; must end with a slash: ex: GameData/KerbalGraph/</param> /// <param name="fileName">The file name; must include file type: ex: KerbalGraphStuff.csv</param> /// <param name="linesToDump">A list of the lines to dump; is case-sensitive</param> public void DumpDataToCSV(string pathName, string fileName, List <string> linesToDump) { List <string> columnHeadings = new List <string>(); List <KerbalGraphLine> linesToPrint = new List <KerbalGraphLine>(); for (int i = 0; i < linesToDump.Count; i++) { string lineName = linesToDump[i]; linesToPrint.Add(allLines[lineName]); columnHeadings.Add(horizontalLabel); columnHeadings.Add(lineName); } int maxNumElements = 0; for (int i = 0; i < linesToDump.Count; i++) { KerbalGraphLine line = linesToPrint[i]; maxNumElements = Math.Max(maxNumElements, line.GetNumDataPoints()); } double[,] dataArray = new double[2 * linesToPrint.Count, maxNumElements]; int colIndex = 0; for (int i = 0; i < linesToDump.Count; i++) { KerbalGraphLine line = linesToPrint[i]; double[] rawX = line.GetRawDataX(); double[] rawY = line.GetRawDataY(); for (int j = 0; j < rawX.Length; j++) { dataArray[colIndex, j] = rawX[j]; dataArray[colIndex + 1, j] = rawY[j]; } colIndex += 2; } string fileNameAndPath = pathName + fileName; KerbalGraphIO.WriteToFile(fileNameAndPath, columnHeadings, dataArray); }