Skip to content

Upgrading from 2.5 to 3.0

Kevin Hill edited this page Apr 25, 2016 · 7 revisions

Important Changes

Chart Constructors

In an effort to keep chart creation terse, the chart constructor has been extended. Charts now set the DataTable with the second parameter, and options if needed with the third.

Old 2.x syntax:

    $data = $lava->DataTable();

    $lava->LineChart('StockPrices')
        ->datatable($data)
        ->setOptions(array(
            'title' => 'Github Stock Price'
        ));

New 3.x syntax:

    $data = $lava->DataTable();

    $lava->LineChart('StockPrices', $data, [
        'title' => 'Github Stock Price'
    ]);

Config Objects / Customizing

Again, with the effort of minimal typing to create your charts, ConfigObjects are no longer required to be instantiated manually. Just pass in the same config array you would have to the constructor, as a value to the key. Internally, a ConfigObject (now called JsonConfigs) will be created and options will be checked/verified/assigned and applied to the chart as before.

Old 2.x syntax:

    $data = $lava->DataTable();

    $lava->LineChart('StockPrices')->datatable($data)->setOptions(array(
        'titleTextStyle' => $lava->TextStyle(array(
            'fontName' => 'Arial',
            'fontColor' => 'blue'
        )),
        'legend' => $lava->Legend(array(
            'position' => 'top'
        )) 
    ));

New 3.x syntax:

   $data = $lava->DataTable();

   $lava->LineChart('StockPrices', $data, [
        'titleTextStyle' => [
            'fontName' => 'Arial',
            'fontColor' => 'blue'
        ],
        'legend' => [
            'position' => 'top'
        ]
    ]);