//IN PROGRESS #region ANNOTATION GRAPH private void CreateDiaryGraph(GraphPane gp, string filepath, string dirpath_colors, string title, int yoffset, string type) { gp.BarSettings.Base = BarBase.Y; gp.BarSettings.ClusterScaleWidth = 200.0; gp.BarSettings.Type = BarType.Overlay; PointPairList labelList = new PointPairList(); if (filepath.Contains(".csv")) { string[] values = FileReadWrite.ReadLinesFromFile(filepath); for (int i = 1; i < values.Length; i++) { try { string[] split = values[i].Split(','); DateTime dtStart = DateTime.MinValue; DateTime dtEnd = DateTime.MaxValue; double startx = 0; double endx = 0; if (split.Length > 0 && split[0].Length > 0) { dtStart = DateTimeParse(split[0]); startx = (double)new XDate(dtStart); } if (split.Length > 1 && split[1].Length > 0) { dtEnd = DateTimeParse(split[1]); endx = (double)new XDate(dtEnd); } Color color = Color.White; bool isSolid = false; string clabel = ""; if (startx >= startX && endx >= endX) { if (split.Length > 2 && split[2].Length > 0) { clabel = split[2]; if (!DataViewForm.annotationColorMap.ContainsKey(clabel)) { DataViewForm.annotationColorMap.Add(clabel, DataViewForm._annotationColorPalette[DataViewForm.annotationColorMap.Count]); } color = DataViewForm.annotationColorMap[clabel]; isSolid = true; labelList = new PointPairList(); labelList.Add(endx, yoffset, startx, String.Format("{3}: {0} - {1}\n {2}", dtStart.ToLongTimeString(), dtEnd.ToLongTimeString(), clabel, title)); HiLowBarItem myBar = gp.AddHiLowBar(title, labelList, color); myBar.Bar.Border.IsVisible = false; if (isSolid) { myBar.Bar.Fill.Type = FillType.Solid; } else { myBar.Bar.Fill.Type = FillType.None; } } } } catch { } } } else if (filepath.Contains(".xml")) { XmlDocument doc = new XmlDocument(); doc.Load(filepath); XmlNodeList nodes = doc.GetElementsByTagName("ANNOTATION"); foreach (XmlNode xn in nodes) { try { DateTime dtStart = DateTimeParse(xn["START_DT"].InnerText); DateTime dtEnd = DateTimeParse(xn["STOP_DT"].InnerText); double startx = (double)new XDate(dtStart); double endx = (double)new XDate(dtEnd); Color color = Color.White; bool isSolid = false; string clabel = xn["LABEL"].InnerText; if (startx >= (double)startX && endx >= (double)endX) { if (!DataViewForm.annotationColorMap.ContainsKey(clabel)) { DataViewForm.annotationColorMap.Add(clabel, DataViewForm._annotationColorPalette[DataViewForm.annotationColorMap.Count]); } color = DataViewForm.annotationColorMap[clabel]; isSolid = true; labelList = new PointPairList(); labelList.Add(endx, yoffset, startx, String.Format("{3}: {0} - {1}\n {2}", dtStart.ToLongTimeString(), dtEnd.ToLongTimeString(), clabel, title)); HiLowBarItem myBar = gp.AddHiLowBar(title, labelList, color); myBar.Bar.Border.IsVisible = false; if (isSolid) { myBar.Bar.Fill.Type = FillType.Solid; } else { myBar.Bar.Fill.Type = FillType.None; } } } catch { } } } }
// POSSIBLY READY #region GENERIC GRAPH private void CreateGenericGraph(GraphPane gp, string filePath) { string[] values = FileReadWrite.ReadLinesFromFile(filePath); string[] headers = values[0].Split(','); PointPairList[] listDataPoints = new PointPairList[headers.Length - 1]; for (int j = 0; j < listDataPoints.Length; j++) { listDataPoints[j] = new PointPairList(); } //for each row, add values to PointPairLists for (int i = 1; i < values.Length; i++) { try { string[] split = values[i].Split(','); for (int j = 1; j < split.Length; j++) { if (split.Length > 1) //TimeStamp + at least one data value { // TIMESTAMP - X VALUE DateTime dt = DateTimeParse(split[0]); //TimeStamp, Column 0 double x = (double)new XDate(dt); //x value is numeric representation of TimeStamp if (x >= (double)startX && x <= (double)endX) { double y = 0; string label = "EMPTY LABEL"; if ((split.Length > 1) && (split[j].Length > 0)) { y = Convert.ToDouble(split[j]);//Column 3/C if (_isUsingLabels) { label = String.Format("{0}\n{1} {2}", headers[j], dt.ToLongTimeString(), y); listDataPoints[j - 1].Add(x, y, label); } else { listDataPoints[j - 1].Add(x, y); } } } } } } catch { } } LineItem[] pointsCurves = new LineItem[headers.Length - 1]; for (int j = 0; j < pointsCurves.Length; j++) { pointsCurves[j] = new LineItem("TEST_LABEL"); pointsCurves[j] = gp.AddCurve(headers[j], listDataPoints[j], DataViewForm._seriesColorPalette[j], SymbolType.Circle); pointsCurves[j].Symbol.Fill = new Fill(DataViewForm._seriesColorPalette[j]); if (!_isAdaptingPointSize) { pointsCurves[j].Symbol.Size = 1F; } // **** JPN SET TO TRUE IF A LINE IS DESIRED pointsCurves[j].Line.IsVisible = true; pointsCurves[j].Tag = "THIS IS A TAG"; _alLinesWithSymbols.Add(pointsCurves[j]); WidenDatesIfNeeded(listDataPoints[j]); } }