定制 catchamonkey/phighcharts 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

catchamonkey/phighcharts

Composer 安装命令:

composer require catchamonkey/phighcharts

包简介

A PHP library for the Highcharts JavaScript charting library

README 文档

README

#Phighcharts Project Build Status SensioLabsInsight A PHP (Requires PHP 5.3) library for the Highcharts JavaScript charting library

##Installation

composer require "catchamonkey/phighcharts"

##What does it do? Along with providing a nice OO interface to create your charts, it also extends the functionality by adding such useful tools as "Sticky Keys"

###Sticky Keys A sticky key, is a configuration option that allows you to always use the same colour for certain keys. For example, you may want to always use green for apples when charting apples vs oranges.

##Example Pie Chart

<?php

    use Phighchart\Chart;
    use Phighchart\Options\Container;
    use Phighchart\Options\ExtendedContainer;
    use Phighchart\Data;
    use Phighchart\Renderer\Pie;
    use Phighchart\Renderer\Line;

    $extOptions = new ExtendedContainer();
    $extOptions->setStickyColour('apples', '#629632');
    $extOptions->setStickyColour('oranges', '#CD3700');

    $options = new Container('chart');
    $options->setRenderTo('chart_example_59');
    $options->setMarginRight(130);
    $options->setMarginBottom(25);

    $titleOptions = new Container('title');
    $titleOptions->setText('Monthly Details');
    $titleOptions->setX(-20);

    $data = new Data();
    $data
        ->addCount('Apples', 32)
        ->addCount('Oranges', 68)
        ->addSeries('Apples', array(
            '2012-05-01' => 12,
            '2012-05-02' => 3,
            '2012-05-03' => 33
        ))
        ->addSeries('Oranges', array(
            '2012-05-01' => 32,
            '2012-05-02' => 36,
            '2012-05-03' => 18
        ));

    // put it all together
    $chart  = new Chart();
    $chart
        ->addOptions($options)
        ->addOptions($titleOptions)
        ->addOptions($extOptions)
        ->setData($data)
        ->setRenderer(new Pie());

    // a line chart is similar, and our data container holds series data for this
    $lineChart = clone $chart;
    $options = new Container('chart');
    $options->setRenderTo('chart_example_60');
    $options->setMarginRight(130);
    $options->setMarginBottom(25);
    $lineChart->addOptions($options)->setRenderer(new Line());

    // and render in the template
    $chart->renderContainer();
    // or to change the element rendered
    // $chart->renderContainer('span');
    $chart->render();

    // and for the line
    $lineChart->renderContainer();
    $lineChart->render();
?>

for rendering the labels as datetime format, provide an instance of the format class. Note: Phighchart uses the Linear format by default

<?php

    use Phighchart\Format\Datetime;

    //set up chart and chart data
    $dateTimeFormat = new Datetime();
    $chart->setFormat($dateTimeFormat);

?>

The Datetime formatter will now attempt to parse the chart data keys as DateTime objects. The Datetime format class can parse the standard PHP date time string formats out-of-the-box.

See

For parsing custom date time string formats, provide the datetime string pattern to the Phighchart Datetime format class as follows:

<?php

    use Phighchart\Format\Datetime;

    //set up chart and chart data
    $dateTimeFormat = new Datetime();
    //for parsing date time string of pattern "1st August, 2012 12:09:32"
    $dateTimeFormat->setDateTimeFormat('jS F, Y H:i:s');
    $chart->setFormat($dateTimeFormat);

?>

##Unit Tests

You can run the Unit Test suite with;

phpunit -c . tests/

统计信息

  • 总下载量: 3.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-05-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固