AreaChart

This example shows how to create beautiful AreaChart

The above example shows you how to create AreaChart using ApexCharts 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.

<?php

require_once "../../../../load.koolreport.php";
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php

class MyReport extends \koolreport\KoolReport
{

}
<div class="report-content">
    <div class="text-center">
        <h1>AreaChart</h1>
        <p class="lead">
            This example shows how to create beautiful AreaChart
        </p>
    </div>

    <style>
        .apexcharts-canvas {
            margin: 0 auto;
        }

        .toolbar {
            margin-left: 10%;
        }

        button {
            background: #fff;
            color: #222;
            border: 1px solid #e7e7e7;
            border-bottom: 2px solid #ddd;
            border-radius: 2px;
            padding: 4px 17px;
        }

        button.active {
            color: #fff;
            background: #008FFB;
            border: 1px solid blue;
            border-bottom: 2px solid blue;
        }

        button:focus {
            outline: 0;
        }
    </style>


    <div style="margin-bottom:50px;">
        <div class="toolbar">
            <button id="one_month">
                1M
            </button>

            <button id="six_months">
                6M
            </button>

            <button id="one_year">
                1Y
            </button>

            <button id="ytd">
                YTD
            </button>

            <button id="all" class="active">
                ALL
            </button>
        </div>
        <?php
        $data = [
            [
                "date",
                "series1"
            ],
            [
                '1/24/2012',
                30.95
            ],
            [
                '1/25/2012',
                31.34
            ],
            [
                '1/26/2012',
                31.18
            ],
            [
                '1/27/2012',
                31.05
            ],
            [
                '1/30/2012',
                31
            ],
            [
                '1/31/2012',
                30.95
            ],
            [
                '2/1/2012',
                31.24
            ],
            [
                '2/2/2012',
                31.29
            ],
            [
                '2/3/2012',
                31.85
            ],
            [
                '2/6/2012',
                31.86
            ],
            [
                '2/7/2012',
                32.28
            ],
            [
                '2/8/2012',
                32.1
            ],
            [
                '2/9/2012',
                32.65
            ],
            [
                '2/10/2012',
                32.21
            ],
            [
                '2/13/2012',
                32.35
            ],
            [
                '2/14/2012',
                32.44
            ],
            [
                '2/15/2012',
                32.46
            ],
            [
                '2/16/2012',
                32.86
            ],
            [
                '2/17/2012',
                32.75
            ],
            [
                '2/21/2012',
                32.54
            ],
            [
                '2/22/2012',
                32.33
            ],
            [
                '2/23/2012',
                32.97
            ],
            [
                '2/24/2012',
                33.41
            ],
            [
                '2/27/2012',
                33.27
            ],
            [
                '2/28/2012',
                33.27
            ],
            [
                '2/29/2012',
                32.89
            ],
            [
                '3/1/2012',
                33.1
            ],
            [
                '3/2/2012',
                33.73
            ],
            [
                '3/5/2012',
                33.22
            ],
            [
                '3/6/2012',
                31.99
            ],
            [
                '3/7/2012',
                32.41
            ],
            [
                '3/8/2012',
                33.05
            ],
            [
                '3/9/2012',
                33.64
            ],
            [
                '3/12/2012',
                33.56
            ],
            [
                '3/13/2012',
                34.22
            ],
            [
                '3/14/2012',
                33.77
            ],
            [
                '3/15/2012',
                34.17
            ],
            [
                '3/16/2012',
                33.82
            ],
            [
                '3/19/2012',
                34.51
            ],
            [
                '3/20/2012',
                33.16
            ],
            [
                '3/21/2012',
                33.56
            ],
            [
                '3/22/2012',
                33.71
            ],
            [
                '3/23/2012',
                33.81
            ],
            [
                '3/26/2012',
                34.4
            ],
            [
                '3/27/2012',
                34.63
            ],
            [
                '3/28/2012',
                34.46
            ],
            [
                '3/29/2012',
                34.48
            ],
            [
                '3/30/2012',
                34.31
            ],
            [
                '4/2/2012',
                34.7
            ],
            [
                '4/3/2012',
                34.31
            ],
            [
                '4/4/2012',
                33.46
            ],
            [
                '4/5/2012',
                33.59
            ],
            [
                '4/9/2012',
                33.22
            ],
            [
                '4/10/2012',
                32.61
            ],
            [
                '4/11/2012',
                33.01
            ],
            [
                '4/12/2012',
                33.55
            ],
            [
                '4/13/2012',
                33.18
            ],
            [
                '4/16/2012',
                32.84
            ],
            [
                '4/17/2012',
                33.84
            ],
            [
                '4/18/2012',
                33.39
            ],
            [
                '4/19/2012',
                32.91
            ],
            [
                '4/20/2012',
                33.06
            ],
            [
                '4/23/2012',
                32.62
            ],
            [
                '4/24/2012',
                32.4
            ],
            [
                '4/25/2012',
                33.13
            ],
            [
                '4/26/2012',
                33.26
            ],
            [
                '4/27/2012',
                33.58
            ],
            [
                '4/30/2012',
                33.55
            ],
            [
                '5/1/2012',
                33.77
            ],
            [
                '5/2/2012',
                33.76
            ],
            [
                '5/3/2012',
                33.32
            ],
            [
                '5/4/2012',
                32.61
            ],
            [
                '5/7/2012',
                32.52
            ],
            [
                '5/8/2012',
                32.67
            ],
            [
                '5/9/2012',
                32.52
            ],
            [
                '5/10/2012',
                31.92
            ],
            [
                '5/11/2012',
                32.2
            ],
            [
                '5/14/2012',
                32.23
            ],
            [
                '5/15/2012',
                32.33
            ],
            [
                '5/16/2012',
                32.36
            ],
            [
                '5/17/2012',
                32.01
            ],
            [
                '5/18/2012',
                31.31
            ],
            [
                '5/21/2012',
                32.01
            ],
            [
                '5/22/2012',
                32.01
            ],
            [
                '5/23/2012',
                32.18
            ],
            [
                '5/24/2012',
                31.54
            ],
            [
                '5/25/2012',
                31.6
            ],
            [
                '5/29/2012',
                32.05
            ],
            [
                '5/30/2012',
                31.29
            ],
            [
                '5/31/2012',
                31.05
            ],
            [
                '6/1/2012',
                29.82
            ],
            [
                '6/4/2012',
                30.31
            ],
            [
                '6/5/2012',
                30.7
            ],
            [
                '6/6/2012',
                31.69
            ],
            [
                '6/7/2012',
                31.32
            ],
            [
                '6/8/2012',
                31.65
            ],
            [
                '6/11/2012',
                31.13
            ],
            [
                '6/12/2012',
                31.77
            ],
            [
                '6/13/2012',
                31.79
            ],
            [
                '6/14/2012',
                31.67
            ],
            [
                '6/15/2012',
                32.39
            ],
            [
                '6/18/2012',
                32.63
            ],
            [
                '6/19/2012',
                32.89
            ],
            [
                '6/20/2012',
                31.99
            ],
            [
                '6/21/2012',
                31.23
            ],
            [
                '6/22/2012',
                31.57
            ],
            [
                '6/25/2012',
                30.84
            ],
            [
                '6/26/2012',
                31.07
            ],
            [
                '6/27/2012',
                31.41
            ],
            [
                '6/28/2012',
                31.17
            ],
            [
                '6/29/2012',
                32.37
            ],
            [
                '7/2/2012',
                32.19
            ],
            [
                '7/3/2012',
                32.51
            ],
            [
                '7/5/2012',
                32.53
            ],
            [
                '7/6/2012',
                31.37
            ],
            [
                '7/9/2012',
                30.43
            ],
            [
                '7/10/2012',
                30.44
            ],
            [
                '7/11/2012',
                30.2
            ],
            [
                '7/12/2012',
                30.14
            ],
            [
                '7/13/2012',
                30.65
            ],
            [
                '7/16/2012',
                30.4
            ],
            [
                '7/17/2012',
                30.65
            ],
            [
                '7/18/2012',
                31.43
            ],
            [
                '7/19/2012',
                31.89
            ],
            [
                '7/20/2012',
                31.38
            ],
            [
                '7/23/2012',
                30.64
            ],
            [
                '7/24/2012',
                30.02
            ],
            [
                '7/25/2012',
                30.33
            ],
            [
                '7/26/2012',
                30.95
            ],
            [
                '7/27/2012',
                31.89
            ],
            [
                '7/30/2012',
                31.01
            ],
            [
                '7/31/2012',
                30.88
            ],
            [
                '8/1/2012',
                30.69
            ],
            [
                '8/2/2012',
                30.58
            ],
            [
                '8/3/2012',
                32.02
            ],
            [
                '8/6/2012',
                32.14
            ],
            [
                '8/7/2012',
                32.37
            ],
            [
                '8/8/2012',
                32.51
            ],
            [
                '8/9/2012',
                32.65
            ],
            [
                '8/10/2012',
                32.64
            ],
            [
                '8/13/2012',
                32.27
            ],
            [
                '8/14/2012',
                32.1
            ],
            [
                '8/15/2012',
                32.91
            ],
            [
                '8/16/2012',
                33.65
            ],
            [
                '8/17/2012',
                33.8
            ],
            [
                '8/20/2012',
                33.92
            ],
            [
                '8/21/2012',
                33.75
            ],
            [
                '8/22/2012',
                33.84
            ],
            [
                '8/23/2012',
                33.5
            ],
            [
                '8/24/2012',
                32.26
            ],
            [
                '8/27/2012',
                32.32
            ],
            [
                '8/28/2012',
                32.06
            ],
            [
                '8/29/2012',
                31.96
            ],
            [
                '8/30/2012',
                31.46
            ],
            [
                '8/31/2012',
                31.27
            ],
            [
                '9/4/2012',
                31.43
            ],
            [
                '9/5/2012',
                32.26
            ],
            [
                '9/6/2012',
                32.79
            ],
            [
                '9/7/2012',
                32.46
            ],
            [
                '9/10/2012',
                32.13
            ],
            [
                '9/11/2012',
                32.43
            ],
            [
                '9/12/2012',
                32.42
            ],
            [
                '9/13/2012',
                32.81
            ],
            [
                '9/14/2012',
                33.34
            ],
            [
                '9/17/2012',
                33.41
            ],
            [
                '9/18/2012',
                32.57
            ],
            [
                '9/19/2012',
                33.12
            ],
            [
                '9/20/2012',
                34.53
            ],
            [
                '9/21/2012',
                33.83
            ],
            [
                '9/24/2012',
                33.41
            ],
            [
                '9/25/2012',
                32.9
            ],
            [
                '9/26/2012',
                32.53
            ],
            [
                '9/27/2012',
                32.8
            ],
            [
                '9/28/2012',
                32.44
            ],
            [
                '10/1/2012',
                32.62
            ],
            [
                '10/2/2012',
                32.57
            ],
            [
                '10/3/2012',
                32.6
            ],
            [
                '10/4/2012',
                32.68
            ],
            [
                '10/5/2012',
                32.47
            ],
            [
                '10/8/2012',
                32.23
            ],
            [
                '10/9/2012',
                31.68
            ],
            [
                '10/10/2012',
                31.51
            ],
            [
                '10/11/2012',
                31.78
            ],
            [
                '10/12/2012',
                31.94
            ],
            [
                '10/15/2012',
                32.33
            ],
            [
                '10/16/2012',
                33.24
            ],
            [
                '10/17/2012',
                33.44
            ],
            [
                '10/18/2012',
                33.48
            ],
            [
                '10/19/2012',
                33.24
            ],
            [
                '10/22/2012',
                33.49
            ],
            [
                '10/23/2012',
                33.31
            ],
            [
                '10/24/2012',
                33.36
            ],
            [
                '10/25/2012',
                33.4
            ],
            [
                '10/26/2012',
                34.01
            ],
            [
                '10/31/2012',
                34.02
            ],
            [
                '11/1/2012',
                34.36
            ],
            [
                '11/2/2012',
                34.39
            ],
            [
                '11/5/2012',
                34.24
            ],
            [
                '11/6/2012',
                34.39
            ],
            [
                '11/7/2012',
                33.47
            ],
            [
                '11/8/2012',
                32.98
            ],
            [
                '11/9/2012',
                32.9
            ],
            [
                '11/12/2012',
                32.7
            ],
            [
                '11/13/2012',
                32.54
            ],
            [
                '11/14/2012',
                32.23
            ],
            [
                '11/15/2012',
                32.64
            ],
            [
                '11/16/2012',
                32.65
            ],
            [
                '11/19/2012',
                32.92
            ],
            [
                '11/20/2012',
                32.64
            ],
            [
                '11/21/2012',
                32.84
            ],
            [
                '11/23/2012',
                33.4
            ],
            [
                '11/26/2012',
                33.3
            ],
            [
                '11/27/2012',
                33.18
            ],
            [
                '11/28/2012',
                33.88
            ],
            [
                '11/29/2012',
                34.09
            ],
            [
                '11/30/2012',
                34.61
            ],
            [
                '12/3/2012',
                34.7
            ],
            [
                '12/4/2012',
                35.3
            ],
            [
                '12/5/2012',
                35.4
            ],
            [
                '12/6/2012',
                35.14
            ],
            [
                '12/7/2012',
                35.48
            ],
            [
                '12/10/2012',
                35.75
            ],
            [
                '12/11/2012',
                35.54
            ],
            [
                '12/12/2012',
                35.96
            ],
            [
                '12/13/2012',
                35.53
            ],
            [
                '12/14/2012',
                37.56
            ],
            [
                '12/17/2012',
                37.42
            ],
            [
                '12/18/2012',
                37.49
            ],
            [
                '12/19/2012',
                38.09
            ],
            [
                '12/20/2012',
                37.87
            ],
            [
                '12/21/2012',
                37.71
            ],
            [
                '12/24/2012',
                37.53
            ],
            [
                '12/26/2012',
                37.55
            ],
            [
                '12/27/2012',
                37.3
            ],
            [
                '12/28/2012',
                36.9
            ],
            [
                '12/31/2012',
                37.68
            ],
            [
                '1/2/2013',
                38.34
            ],
            [
                '1/3/2013',
                37.75
            ],
            [
                '1/4/2013',
                38.13
            ],
            [
                '1/7/2013',
                37.94
            ],
            [
                '1/8/2013',
                38.14
            ],
            [
                '1/9/2013',
                38.66
            ],
            [
                '1/10/2013',
                38.62
            ],
            [
                '1/11/2013',
                38.09
            ],
            [
                '1/14/2013',
                38.16
            ],
            [
                '1/15/2013',
                38.15
            ],
            [
                '1/16/2013',
                37.88
            ],
            [
                '1/17/2013',
                37.73
            ],
            [
                '1/18/2013',
                37.98
            ],
            [
                '1/22/2013',
                37.95
            ],
            [
                '1/23/2013',
                38.25
            ],
            [
                '1/24/2013',
                38.1
            ],
            [
                '1/25/2013',
                38.32
            ],
            [
                '1/28/2013',
                38.24
            ],
            [
                '1/29/2013',
                38.52
            ],
            [
                '1/30/2013',
                37.94
            ],
            [
                '1/31/2013',
                37.83
            ],
            [
                '2/1/2013',
                38.34
            ],
            [
                '2/4/2013',
                38.1
            ],
            [
                '2/5/2013',
                38.51
            ],
            [
                '2/6/2013',
                38.4
            ],
            [
                '2/7/2013',
                38.07
            ],
            [
                '2/8/2013',
                39.12
            ],
            [
                '2/11/2013',
                38.64
            ],
            [
                '2/12/2013',
                38.89
            ],
            [
                '2/13/2013',
                38.81
            ],
            [
                '2/14/2013',
                38.61
            ],
            [
                '2/15/2013',
                38.63
            ],
            [
                '2/19/2013',
                38.99
            ],
            [
                '2/20/2013',
                38.77
            ],
            [
                '2/21/2013',
                38.34
            ],
            [
                '2/22/2013',
                38.55
            ],
            [
                '2/25/2013',
                38.11
            ],
            [
                '2/26/2013',
                38.59
            ],
            [
                '2/27/2013',
                39.6
            ]
        ];
        \koolreport\apexcharts\AreaChart::create(array(
            "name" => "datetimeAreaChart",
            // "title" => "Fundamental Analysis of Stocks",
            // "subtitle" => "Price Movements",
            "dataSource" => $data,
            "columns" => array(
                "date" => [
                    "label" => "Date",
                    "categoryType" => "datetime",
                ],
                "series1" => array(),
            ),
            "options" => [
                'annotations' => [
                    'yaxis' => [
                        [
                            'y' => 30,
                            'borderColor' => '#999',
                            'label' => [
                                'show' => true,
                                'text' => 'Support',
                                'style' => [
                                    'color' => '#fff',
                                    'background' => '#00E396'
                                ]
                            ]
                        ]
                    ],
                    'xaxis' => [
                        [
                            'x' => 1352826000000,
                            'borderColor' => '#999',
                            'yAxisIndex' => 0,
                            'label' => [
                                'show' => true,
                                'text' => 'Rally',
                                'style' => [
                                    'color' => '#fff',
                                    'background' => '#775DD0'
                                ]
                            ]
                        ]
                    ]
                ],
                'markers | style' => 'hollow',
                'xaxis | tickAmount' => 6,
                'tooltip | x | format' => 'dd MMM yyyy',
                'fill' => [
                    'type' => 'gradient',
                    'gradient' => [
                        'shadeIntensity' => 1,
                        'opacityFrom' => 0.7,
                        'opacityTo' => 0.9,
                        'stops' => [
                            0,
                            100
                        ]
                    ]
                ]
            ],
            "markerSize" => 0,
            "showLegend" => false,
            // "showLabel" => true,
            // "height" => "600px",
            // "width" => "85%",
            "maxWidth" => 800,
        ));
        ?>
    </div>

</div>
<script>
    var resetCssClasses = function(activeEl) {
        var els = document.querySelectorAll('button')
        Array.prototype.forEach.call(els, function(el) {
            el.classList.remove('active')
        })

        activeEl.target.classList.add('active')
    }


    document
        .querySelector('#one_month')
        .addEventListener('click', function(e) {
            resetCssClasses(e)
            var chart = datetimeAreaChart.chart();
            chart.zoomX(
                new Date('28 Jan 2013').getTime(),
                new Date('27 Feb 2013').getTime()
            )
        })

    document
        .querySelector('#six_months')
        .addEventListener('click', function(e) {
            resetCssClasses(e)
            var chart = datetimeAreaChart.chart();

            chart.zoomX(
                new Date('27 Sep 2012').getTime(),
                new Date('27 Feb 2013').getTime()
            )
        })

    document
        .querySelector('#one_year')
        .addEventListener('click', function(e) {
            resetCssClasses(e)
            var chart = datetimeAreaChart.chart();
            chart.zoomX(
                new Date('27 Feb 2012').getTime(),
                new Date('27 Feb 2013').getTime()
            )
        })

    document.querySelector('#ytd').addEventListener('click', function(e) {
        resetCssClasses(e)
        var chart = datetimeAreaChart.chart();

        chart.zoomX(
            new Date('01 Jan 2013').getTime(),
            new Date('27 Feb 2013').getTime()
        )
    })

    document.querySelector('#all').addEventListener('click', function(e) {
        resetCssClasses(e)
        var chart = datetimeAreaChart.chart();
        chart.zoomX(
            new Date('23 Jan 2012').getTime(),
            new Date('27 Feb 2013').getTime()
        )
    })
</script>

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