X Axis Tick Format

The above example shows you how to create LineChart using D3 package. In this example, for purpose of chart demonstration only, we do use mock-up data from array. As you can see, the KoolReport's widget in general support dataSource could be DataStore, Process, DataSource or even simple array.

The example show how to create line chart with x axis tick format.

A function to format tick value. Format string is also available for timeseries data.

For example:

...
"options" => array(
    "data" => array(
        "x" => 'x'
    ),
    "axis" => array(
        "x" => array(
            "type" => 'timeseries',
            "tick" => array(
                "format" => '%Y'
            )
        )
    )
)
...
<?php
require_once "../../../../load.koolreport.php";
require_once "MyReport.php";
$report = new MyReport;
$report->run();
$report->render();
<?php

class MyReport extends \koolreport\KoolReport
{

}
<h1 class='title'>X Axis Tick Format</h1>
<?php
$data = [
    ['x' => '2010-01-01', 'sample' => 30],
    ['x' => '2011-01-01', 'sample' => 200],
    ['x' => '2012-01-01', 'sample' => 100],
    ['x' => '2013-01-01', 'sample' => 400],
    ['x' => '2014-01-01', 'sample' => 150],
    ['x' => '2015-01-01', 'sample' => 250]
];

\koolreport\d3\LineChart::create(array(
    "dataSource" => $data,
    "columns" => array(
        'x',
        'sample'
    ),
    "options" => array(
        "data" => array(
            "x" => 'x'
        ),
        "axis" => array(
            "x" => array(
                "type" => 'timeseries',
                "tick" => array(
                    "format" => '%Y'
                )
            )
        )
    )
));

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro