Giter Club home page Giter Club logo

amnl-gcdatatable's Introduction

GC DataTable

Build Status Latest Stable Version Total Downloads

This library is meant to simplify the dynamic generation of a JSON-representation of a DataTable when using PHP. DataTables are used by the Google Visualization API / Chart Tools, see this reference on developers.google.com for more info.

Problems? Suggestions?

Create a new issue to tell me about your suggestions and/or problems. I'd love to hear your opinion!

Example

For the time being you can have a look at "Populating Data Using Server Side Code". The code below basically replaces getData.php and sampleData.json and allows you to dynamically change the output.

<?php

/*
 * A bunch of use-statements
 * (assuming you have some kind of autoloading mechanism)
 */
use AMNL\Google\Chart\Table;
use AMNL\Google\Chart\Column;
use AMNL\Google\Chart\Row;
use AMNL\Google\Chart\Type as T;

/* The actual code */
$pizzaTable = new Table(
    new Column(new T\String(), 'Topping'),
    new Column(new T\Number(), 'Slices')
);

$pizzaTable->addRow(new Row('Mushrooms', 3));
$pizzaTable->addRow(new Row('Onions', 1));
$pizzaTable->addRow(new Row('Olives', 1));
$pizzaTable->addRow(new Row('Zucchini', 1));
$pizzaTable->addRow(new Row('Pepperoni', 2));

/* JSON Output */
header('Content-Type: application/json');
echo $pizzaTable->toJson();

amnl-gcdatatable's People

Contributors

itavero avatar

Stargazers

Dennis Iversen avatar  avatar  avatar  avatar

Watchers

 avatar James Cloos avatar

amnl-gcdatatable's Issues

Support for JsonSerializable (PHP 5.4)

I'm planning on adding support for JsonSerializable to the AMNL\Google\Chart\Table.
The way I see it I've got two options:

  • Extend the current class to a special version for PHP 5.4 (and loose code portability).
  • Implement the interface and provide a stub somehow.

What are your opinions on this?

Row::_construct should accept a single array as well

I realized that for those who use the MySQL functions offered by PHP, like mysql_fetch_row and mysqli_fetch_assoc, it would be nice if they could put the output of those functions straight into the Row-constructor.

Note to self: Keep in mind that the keys should be numbers from 0 and up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.