Exemple #1
0
void
ChartRenderer::DrawLineGraph(const LeastSquares &lsdata, const Pen &pen)
{
  const auto &slots = lsdata.GetSlots();
  assert(slots.size() >= 2);

  const unsigned n = slots.size();
  RasterPoint *points = point_buffer.get(n);

  RasterPoint *p = points;
  for (const auto &i : slots)
    *p++ = ToScreen(i.x, i.y);
  assert(p == points + n);

  canvas.Select(pen);
  canvas.DrawPolyline(points, n);
}
Exemple #2
0
void
ChartRenderer::DrawFilledLineGraph(const LeastSquares &lsdata)
{
  const auto &slots = lsdata.GetSlots();
  assert(slots.size() >= 2);

  const unsigned n = slots.size() + 2;
  RasterPoint *points = point_buffer.get(n);

  RasterPoint *p = points;
  for (const auto &i : slots)
    *p++ = ToScreen(i.x, i.y);
  const RasterPoint &last = p[-1];
  *p++ = RasterPoint{ last.x, rc.bottom - padding_bottom };
  *p++ = RasterPoint{ points[0].x, rc.bottom - padding_bottom };

  assert(p == points + n);

  canvas.DrawPolygon(points, n);
}
Exemple #3
0
void
ChartRenderer::DrawBarChart(const LeastSquares &lsdata)
{
  if (x.unscaled || y.unscaled)
    return;

  canvas.Select(look.bar_brush);
  canvas.SelectNullPen();

  const auto &slots = lsdata.GetSlots();
  for (unsigned i = 0, n = slots.size(); i != n; i++) {
    int xmin((i + 1.2) * x.scale
             + (rc.left + padding_left));
    int ymin = ScreenY(y.min);
    int xmax((i + 1.8) * x.scale
             + (rc.left + padding_left));
    int ymax = ScreenY(slots[i].y);
    canvas.Rectangle(xmin, ymin, xmax, ymax);
  }
}