Commit 77fb530c authored by Paul Asmuth's avatar Paul Asmuth
Browse files

document: add width and height properties

parent dd8ef398
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include "element_factory.h"
#include "graphics/layer.h"
#include "graphics/layout.h"
#include "common/config_helpers.h"

namespace plotfx {

@@ -41,9 +42,23 @@ Document::Document() :

ReturnCode buildDocument(
    const PropertyList& plist,
    Document* tree) {
    Document* doc) {
  static const ParserDefinitions pdefs = {
    {"width", std::bind(&parseMeasureProp, std::placeholders::_1, &doc->width)},
    {"height", std::bind(&parseMeasureProp, std::placeholders::_1, &doc->height)},
  };

  if (auto rc = parseAll(plist, pdefs); !rc.isSuccess()) {
    return rc;
  }

  for (size_t i = 0; i < plist.size(); ++i) {
    const auto& elem_name = plist[i].name;

    if (!plist[i].child) {
      continue;
    }

    const auto& elem_config = plist[i].child.get();

    std::unique_ptr<Element> elem;
@@ -51,7 +66,7 @@ ReturnCode buildDocument(
      return rc;
    }

    tree->roots.emplace_back(std::move(elem));
    doc->roots.emplace_back(std::move(elem));
  }

  return ReturnCode::success();

manual/doc_settings.md

0 → 100644
+45 −0
Original line number Diff line number Diff line
Document Settings
=================

Lorem ipsum dolor sit amet.

#### Example:

    width: 1200px;
    height: auto;
    dpi: 96;

#### Properties:

<table>
  <tbody>
    <tr>
      <td><code><strong>width</strong></code></td>
      <td>Here be dragons</td>
    </tr>
    <tr>
      <td><code><strong>height</strong></code></td>
      <td>Here be dragons</td>
    </tr>
  </tbody>
</table>


## Settings

### width

Lorem ipsum dolor sit amet.

    width: <size>;

--

### height

Lorem ipsum dolor sit amet.

    height: <size>;


## Examples
+8 −1
Original line number Diff line number Diff line
@@ -25,10 +25,17 @@ documentation:
        url: "/documentation/faq"
        file: "faq"


  -
    title: "Charts & Visualizations"
    pages:
      -
        title: "Document Setup"
        url: "/documentation/document-settings"
        file: "doc_settings"
      -
        title: "Units & Formatters"
        url: "/documentation/formatter"
        file: "formatters"
      -
        title: "Plot: Domains"
        url: "/documentation/plot-domains"
+3 −0
Original line number Diff line number Diff line
width: 1200px;
height: 600px;

plot {
  axis-top: off;
  axis-right: off;