gfazioli/morris-php

morris.js 的 PHP 辅助类

0.6.0 2017-01-31 16:57 UTC

This package is auto-updated.

Last update: 2024-09-20 05:23:56 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

本项目是 Morris.js ( http://morrisjs.github.io/morris.js/ ) 的 PHP 部分。

您可以使用此 PHP 类来封装 Morris Javascript 类

入门指南

  1. http://morrisjs.github.io/morris.js/ 下载 Morris Javascript 库
  2. 包含主文件 morris.php
  3. 包含图表基础文件 morris-charts.php
  4. 包含您想使用的所有或单个图表

使用 Composer 入门

  1. 使用 composer.json

示例

public function draw()
{
  ?>
  <div id="my-charts"></div>
<?php
  $morris = new Line( 'my-charts' );
  $morris->xkey = array( 'date' );
  $morris->ykeys = array( 'value' );
  $morris->labels = array( 'Money' );
  $morris->data = array(
    array( 'date' => '2010', 'value' => 88 ),
    array( 'date' => '2011', 'value' => 18 ),
    array( 'date' => '2012', 'value' => 28 ),
    array( 'date' => '2013', 'value' => 48 ),
  );
  echo $morris;
}