Commit cf1e6fb9 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

line chart data labels :)

parent 9663ad11
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ class Canvas {
public:
  static const int kAxisPadding = 0; // FIXPAUL make configurable
  static const int kTickLength = 5; // FIXPAUL make configurable
  static const int kAxisLabelHeight = 20; // FIXPAUL make configurable
  static const int kAxisLabelHeight = 25; // FIXPAUL make configurable
  static const int kAxisLabelWidth = 50; // FIXPAUL make configurable
  static const int kAxisTitleLength = 20; // FIXPAUL make configurable
  static const int kCharWidth = 6.0f; // FIXPAUL make configurable
+0 −1
Original line number Diff line number Diff line
@@ -429,7 +429,6 @@ public:

  const std::vector<double> getTicks() const {
    if (empty()) {
      abort();
      return std::vector<double>{};
    } else {
      return domain_->getTicks();
+13 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ namespace ui {
 */
class LineChart : public Drawable {
public:
  static const constexpr int kLabelPadding = 10;
  static char kDefaultLineStyle[];
  static char kDefaultLineWidth[];
  static char kDefaultPointStyle[];
@@ -215,6 +216,17 @@ void LineChart2D<TX, TY>::render(
      auto y = y_domain_.getAs<Domain<TY>>()->scale(point.y());
      auto ss_x = viewport->paddingLeft() + x * viewport->innerWidth();
      auto ss_y = viewport->paddingTop() + (1.0 - y) * viewport->innerHeight();
      auto label = series->labelFor(&point);

      if (show_labels_) {
        target->drawText(
            label,
            ss_x,
            ss_y - point_size * 0.5f - kLabelPadding,
            "middle",
            "text-after-edge",
            "label");
      }

      target->drawPoint(
          ss_x,
@@ -223,7 +235,7 @@ void LineChart2D<TX, TY>::render(
          point_size,
          color,
          "point",
          series->labelFor(&point),
          label,
          series->name());

      coords.emplace_back(ss_x, ss_y);
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,10 @@ static const std::string kStyleSheetDefault = R"(
    font-size: 10px;
  }

  .fm-chart text.label {
    fill: #666;
  }

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