Commit 2b2fbd83 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

legend...

parent 255a2fc7
Loading
Loading
Loading
Loading
+22 −10
Original line number Diff line number Diff line
@@ -385,7 +385,13 @@ void Canvas::renderOutsideLegends(
    Viewport* viewport) const {
  for (const auto& legend : legends_) {
    target->beginGroup("legend");
    renderOutsideTopLegend(target, viewport, legend.get(), 25.0f);

    renderTopRightLegend(
        target,
        viewport,
        legend.get(),
        kLegendOutsideHorizPadding);

    target->finishGroup();
  }
}
@@ -397,16 +403,22 @@ void Canvas::renderInsideLegends(

  for (const auto& legend : legends_) {
    target->beginGroup("legend");
    viewport->setPaddingTop(viewport->paddingTop() + 10.0f);
    renderOutsideTopLegend(target, viewport, legend.get(), 15.0f);
    viewport->setPaddingTop(viewport->paddingTop() + 10.0f);
    viewport->setPaddingTop(viewport->paddingTop() + kLegendInsideVertPadding);

    renderTopRightLegend(
        target,
        viewport,
        legend.get(),
        kLegendInsideHorizPadding);

    viewport->setPaddingTop(viewport->paddingTop() + kLegendInsideVertPadding);
    target->finishGroup();
  }

  viewport->setPadding(orig_padding);
}

void Canvas::renderOutsideTopLegend(
void Canvas::renderTopRightLegend(
    RenderTarget* target,
    Viewport* viewport,
    LegendDefinition* legend,
@@ -439,19 +451,19 @@ void Canvas::renderOutsideTopLegend(

    target->drawPoint(
        lx,
        viewport->paddingTop() + 6 + height,
        viewport->paddingTop() + kLegendPointY + height,
        "circle",
        4,
        kLegendPointSize,
        entry.second,
        "circle");
        "point");

    target->drawText(
      entry.first,
      lx - 8.0f,
      lx - kLegendPointWidth,
      viewport->paddingTop() + height,
      "end",
      "text-before-edge",
      "title");
      "label");

    lx -= this_len;
  }
+7 −2
Original line number Diff line number Diff line
@@ -29,9 +29,14 @@ public:
  static const int kAxisLabelWidth = 50.0f; // FIXPAUL make configurable
  static const int kAxisTitleLength = 20.0f; // FIXPAUL make configurable
  static const int kCharWidth = 6.0f; // FIXPAUL make configurable
  static const int kLegendOutsideHorizPadding = 20.0f; // FIXPAUL make configurable
  static const int kLegendLabelPadding = 20.0f; // FIXPAUL make configurable
  static const int kLegendLineHeight = 20.0f; // FIXPAUL make configurable
  static const int kLegendInsideVertPadding = 10.0f;
  static const int kLegendInsideHorizPadding = 15.0f;
  static const int kLegendOutsideHorizPadding = 25.0f;
  static const int kLegendPointY = 6;
  static const int kLegendPointWidth = 8;
  static const int kLegendPointSize = 3;

  Canvas();

@@ -168,7 +173,7 @@ protected:
   */
  void renderInsideLegends(RenderTarget* target, Viewport* viewport) const;

  void renderOutsideTopLegend(
  void renderTopRightLegend(
      RenderTarget* target,
      Viewport* viewport,
      LegendDefinition* legend,
+5 −0
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@ static const std::string kStyleSheetDefault = R"(

  .legend text {
    font-size: 10px;
    fill: #333;
  }

  .legend text.title {
    fill: #666;
  }

  .chart .line {