/// <inheritdoc /> protected override void OnPaint(object sender, NvgContext e) { int i; float x = Location.X; float y = Location.Y; e.BeginPath(); e.Rect(x, y, Width, Height); e.FillColor(NanoVg.Rgba(255, 255, 255, 64)); e.Fill(); e.BeginPath(); if (Fill) { e.MoveTo(x, y + Height); } else { var v0 = _values[_head % HistoryCount]; v0 = F6Math.RemapClamp(v0, Min, Max, 0, Height); e.MoveTo(x, y + Height - v0); } for (i = 0; i < HistoryCount; i++) { var v = _values[(_head + i) % HistoryCount]; var vx = x + (float)i / (HistoryCount - 1) * Width; var vy = y + Height - F6Math.RemapClamp(v, Min, Max, 0, Height); e.LineTo(vx, vy); } if (Fill) { e.LineTo(x + Width, y + Height); e.FillColor(NanoVg.Rgba(Color)); e.Fill(); } else { e.StrokeColor(NanoVg.Rgba(Color)); e.Stroke(); } var avgY = F6Math.RemapClamp(_avg, Min, Max, 0, Height); e.BeginPath(); e.MoveTo(x, y + Height - avgY); e.LineTo(x + Width, y + Height - avgY); e.StrokeColor(NanoVg.Rgba(255, 255, 255, 128)); e.Stroke(); e.FontFace(FontFamily); if (Title != null) { e.FontSize(14.0f); e.TextAlign(NvgAlign.Left | NvgAlign.Top); e.FillColor(NanoVg.Rgba(240, 240, 240, 192)); e.Text(x + 3, y + 1, Title); } e.FontSize(16.0f); e.TextAlign(NvgAlign.Right | NvgAlign.Top); e.FillColor(NanoVg.Rgba(240, 240, 240, 255)); var str = string.Format(Number, _avg.ToString(NumberFormatStyle)); e.Text(x + Width - 3, y + 1, str); if (Unit != null) { e.FontSize(15.0f); e.TextAlign(NvgAlign.Right | NvgAlign.Bottom); e.FillColor(NanoVg.Rgba(240, 240, 240, 160)); e.Text(x + Width - 3, y + Height - 1, Unit); } base.OnPaint(sender, e); }