Dashboard

SVG, Flexbox wallboard engine

HTML

<script src="https://d3js.org/d3.v3.min.js"></script>
<!--script type="text/javascript" src="https://d3js.org/d3.v3.min.js"></script-->
<body id="board" class="viewport">
  <!--header>Header</header>
  <section class="block hbox space-between">
    <nav>Nav</nav>
    <article>Article</article>
    <aside>Aside</aside>
  </section>
  <footer>Footer</footer-->
</body>

CSS

/* some basic styles. nothing to do with flexbox */
      header, footer,
      section, nav, article, aside {
        border: 1px solid black;
        padding: 0.25em;
        margin: 0.25em;
        border-radius: 0.25em;
      }
 
      /*
        Force full width & height.
 
        If this block is removed, the layout height/length will be determined by
        the amount of content in the page. That might result in a page which has
        a footer only a few inches from the top of the viewport, or one which
        scrolls beyond the viewport.
 
        This forces the layout to always be full screen regardless of how much,
        or how little, content is in place. Neither is "right" or "wrong", there
        are valid cases for each. I just want to be clear what's controlling the
        page/viewport height.
      */
      html, body, .viewport {
        width: 100%;
        height: 100%;
        margin: 0;
      }
 
      /* encapsulate the various syntax in helper clases */
      /* inspired by http://infrequently.org/2009/08/css-3-progress/ */
 
      /* items flex/expand vertically */
      .vbox {
        /* previous syntax */
        display: -webkit-box;
        display:    -moz-box;
        display:         box;
 
        -webkit-box-orient: vertical;
           -moz-box-orient: vertical;
            -ms-box-orient: vertical;
                box-orient: vertical;
 
        /* current syntax */
        display: -webkit-flex;
        display:    -moz-flex;
        display:     -ms-flex;
        display:         flex;
 
        -webkit-flex-direction: column;
           -moz-flex-direction: column;
            -ms-flex-direction: column;
                flex-direction: column;
      }
 
      /* items flex/expand horizontally */
      .hbox {
        /* previous syntax */
        display: -webkit-box;
        display:    -moz-box;
        display:     -ms-box;
        display:         box;
 
        -webkit-box-orient: horizontal;
          ...

JavaScript

// ******************************************
//  ENGINE
// ******************************************

function buildBlocks(container, data){
    //debugger;
    if (null == data){
        return;
    }
    container.style("display", "flex");
    var blocks = container.selectAll("section")
        .data(data.blocks)
        .enter()
        .append("section");
    blocks.attr("class", function(b, i){
        return "block " + (b.presentation.isHorizontal ? "hbox" : "vbox" )});
    blocks.style("flex", function(b, i){
        return b.presentation.size
    });
    blocks.each(function(){
        debugger;
        buildBlocks(this, d3.select(this).data().blocks)});
}

function buildBoard(data){
    //debugger;
    var tabData = data.tabs[0];
    var board = d3.select("#board").data(data).attr("class", function(){
        return tabData.isHorizontal ? "hbox" : "vbox" });
    buildBlocks(board, tabData);
/*    var blocks = board.selectAll("section")
        .data(tabData.blocks)
        .enter()
        .append("section");
    blocks.attr("class", function(b, i){
        return "block " + (b.presentation.isHorizontal ? "hbox" : "vbox" )});*/
}


// ******************************************
//  DATA
// ******************************************

// dummy board with a collection of tabs
var testBoard = {
    name: "Test Board",
    tabs: []
};

// add a single tab
testBoard.tabs.push(
    {
        caption: "",
        isHorizontal: true,
        blocks: []
    });

// add some dummy Blocks - remove later
var inboundQueue = {
        caption: "Inbound Queue Today",
        presentation: {
            fontColor: "#000000",
            italics: false,
            bold: true,
            isHorizontal: false,
            refreshRate: NaN,
            size: 2
        },
        blocks: [],
        kpis: []
    };
currentlyQueued = {
        caption: "Currently Queued Calls",
        presentation: {
            fontColor: "#000000",
            italics: false,
           ...