StockChart PHP Class Overview

The Kendo UI StockChart for PHP is a server-side wrapper for the Kendo UI StockChart widget.

Getting Started

The Basics

There are two ways to bind a Kendo UI StockChart for PHP:

  • Locally—Local binding binds the StockChart to a PHP array.
  • Remotely—During remote binding the StockChart makes AJAX requests and is bound to the JSON result.


Below are listed the steps for you to follow when configuring the Kendo UI StockChart for PHP.

Step 1 Make sure you followed all the steps from the introductory article on Telerik UI for PHP—include the autoloader, JavaScript, and CSS files.

Step 2 Create an array to which the StockChart will be bound to.

    $data = array(
        array('Date' => '2014-04-01', 'Open' => 10, 'High' => 20, 'Low' => 9, 'Close' => 12),
        array('Date' => '2014-04-02', 'Open' => 12, 'High' => 19, 'Low' => 10, 'Close' => 14)

Step 3 Create the dataSource and set its data.

    $dataSource = new \Kendo\Data\DataSource();

Step 4 Create a StockChart and configure it.

    $chart = new \Kendo\Dataviz\UI\StockChart('stock-chart');

    $series = new \Kendo\Dataviz\UI\StockChartSeriesItem();

    $navigator = new \Kendo\Dataviz\UI\StockChartNavigator();
    $navigator->addSeriesItem(array('type' => 'area', 'field' => 'Close'));


Step 5 Output the StockChart by echoing the result of the render method.

    <?php echo $chart->render(); ?>

Event Handling

You can subscribe to all StockChart events.

Specify Function Names

The example below demonstrates how to subscribe for events by specifying a JavaScript function name.

    $chart = new \Kendo\Dataviz\UI\StockChart('stock-chart');

    // The 'chart_dataBound' JavaScript function will handle the 'dataBound' event of the chart

    echo $chart->render();
    function chart_dataBound() {
        // Handle the dataBound event

Provide Inline Code

The example below demonstrates how to subscribe to events by providing inline JavaScript code.

    $chart = new \Kendo\Dataviz\UI\StockChart('stock-chart');

    // Provide inline JavaScript code that will handle the 'dataBound' event of the chart
    $chart->dataBound('function() { /* Handle the dataBound event */ }');

    echo $chart->render();


Client-Side Instances

You are able to reference an existing StockChart instance through the method. Once a reference is established, use the StockChart API to control its behavior.

      // Put this after your Kendo UI StockChart for PHP render() call
          $(function() {
              // Notice that the name of the chart is used to get its client-side instance
              var chart = $("#stockChart").data("kendoStockChart");

See Also

In this article