/// <summary> /// Draws all points directly onto the graph /// </summary> public void DrawSeries(GraphView graph, Rect drawBounds, RectangleF graphBounds) { if (Fill.Color.HasValue) { Application.Driver.SetAttribute(Fill.Color.Value); } foreach (var p in Points.Where(p => graphBounds.Contains(p))) { var screenPoint = graph.GraphSpaceToScreen(p); graph.AddRune(screenPoint.X, screenPoint.Y, Fill.Rune); } }
/// <summary> /// Draws the Legend and all entries into the area within <see cref="Bounds"/> /// </summary> /// <param name="graph"></param> public void Render(GraphView graph) { if (Border) { graph.DrawFrame(Bounds, 0, true); } // start the legend at int y = Bounds.Top + (Border ? 1 : 0); int x = Bounds.Left + (Border ? 1 : 0); // how much horizontal space is available for writing legend entries? int availableWidth = Bounds.Width - (Border ? 2 : 0); int availableHeight = Bounds.Height - (Border ? 2 : 0); int linesDrawn = 0; foreach (var entry in entries) { if (entry.Item1.Color.HasValue) { Application.Driver.SetAttribute(entry.Item1.Color.Value); } else { graph.SetDriverColorToGraphColor(); } // add the symbol graph.AddRune(x, y + linesDrawn, entry.Item1.Rune); // switch to normal coloring (for the text) graph.SetDriverColorToGraphColor(); // add the text graph.Move(x + 1, y + linesDrawn); string str = TruncateOrPad(entry.Item2, availableWidth - 1); Application.Driver.AddStr(str); linesDrawn++; // Legend has run out of space if (linesDrawn >= availableHeight) { break; } } }
protected override void DrawBarLine(GraphView graph, Terminal.Gui.Point start, Terminal.Gui.Point end, Bar beingDrawn) { var driver = Application.Driver; int x = start.X; for (int y = end.Y; y <= start.Y; y++) { var height = graph.ScreenToGraphSpace(x, y).Y; if (height >= 85) { driver.SetAttribute(red); } else if (height >= 66) { driver.SetAttribute(brightred); } else if (height >= 45) { driver.SetAttribute(brightyellow); } else if (height >= 25) { driver.SetAttribute(brightgreen); } else { driver.SetAttribute(green); } graph.AddRune(x, y, beingDrawn.Fill.Rune); } }