PHP code example of ob / statusboard

1. Go to this page and download the library: Download ob/statusboard library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ob / statusboard example snippets




eate a Table widget
$widget = new StatusBoard\Widget\TableWidget();
$widget->setRows(array(
    array('Project', 'Version', 'Lang', 'Status'),
    array('StatusBoard', '0.1.0', 'PHP', 'Ok'),
    array('ObHighchartsBundle', '1.0.0', 'PHP', 'Fail')
));

// Register an HTML renderer
// You could also easily write your own renderer if the stock one doesn't fit your needs
$renderer = new StatusBoard\Renderer\WidgetRenderer();
$renderer->setRenderers(array(
    new StatusBoard\Renderer\HtmlRenderer()
));

echo $renderer->render($widget);



gister a Json renderer
$renderer = new StatusBoard\Renderer\WidgetRenderer();
$renderer->setRenderers(array(
    new StatusBoard\Renderer\JsonRenderer()
));

// Create a Graph widget
$widget = new StatusBoard\Widget\GraphWidget();
$data1 = new \StatusBoard\Model\GraphData();
$data2 = new \StatusBoard\Model\GraphData();

// First dataset
$data1->setTitle('Visits')
    ->setColor('blue')
    ->addDataPoint('2012', 3963)
    ->addDataPoint('2013', 4561);

// Second dataset
$data2->setTitle('Unique Visits')
    ->setColor('orange')
    ->addDataPoint('2012', 2105)
    ->addDataPoint('2013', 3001);

$widget->setTitle("Visits")
    ->showTotal(true)
    ->addDataPoints($data1)
    ->addDataPoints($data2);

header('Content-Type: application/json');

echo $renderer->render($widget);



eate a DIY widget
$widget = new StatusBoard\Widget\DiyWidget();

// You should get your HTML from a template engine
$widget->setHtml('
    <style type="text/css">
        html,
        body,
        .container {
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
        body {
            color: white;
            font-family: Roadgeek2005SeriesC, sans-serif;
        }
        .container {
            text-align: center;
        }
        h1 {
            font-size: 60px;
            line-height: 120px;
            margin-top: 50px;
        }
    </style>
    <div class="container">
        <h1>HTML!</h1>
    </div>
');

// Register an HTML renderer
$renderer = new StatusBoard\Renderer\WidgetRenderer();
$renderer->setRenderers(array(
    new StatusBoard\Renderer\HtmlRenderer()
));

echo $renderer->render($widget);