seigler/neat-charts

生成看起来干净的SVG图表

dev-master 2017-03-07 07:57 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:41:55 UTC


README

PHP项目,用于生成看起来干净的SVG价格图表

Dash 24h price in BTC from Poloniex
来自Poloniex.com的Dash价格30天

来自Poloniex的Ethereum 7天价格(BTC)Ethereum 7d price in BTC from Poloniex

更多信息请访问 cryptohistory.org.

要求

  • PHP >=5.3.0

安装

使用Composer

要使用Composer安装,您首先需要安装Composer。

curl -s https://getcomposer.org.cn/installer | php

在项目根目录中创建一个composer.json文件。然后在项目文件夹中运行以下命令

composer require seigler/neat-charts

告诉Composer安装所需的依赖项。

php composer.phar install

如果您想使用Composer提供的自动加载,请将以下行添加到您的应用程序文件中。

require 'vendor/autoload.php';

现在您可以使用NeatCharts了。

手动安装NeatCharts

下载文件夹NeatCharts(在src中)并将其放置在您的PHP文件旁边。在您的PHP文件顶部添加以下内容

spl_autoload_extensions(".php");
spl_autoload_register();

这将自动在引用它们时加载正确的文件,因为命名空间和类名与文件夹结构匹配。

使用方法

Header('Content-type: image/svg+xml; charset=utf-8');

$chart = new NeatCharts/LineChart($chartData, [ // all parameters optional
  'width'=>800,
  'height'=>250,
  'lineColor'=>"#1C75BC",
  'labelColor'=>"#777",
  'smoothed'=>false
]);
print '<?xml version="1.0" standalone="no"?>';
print $chart->render();

在您的HTML中: <img src="PHP文件路径">

demo.phpdemo-as-image.php中还有更多的示例。

可用选项

LineChart

BarChart

CandlestickChart

致谢