mirror of
https://github.com/seigler/neat-charts
synced 2025-07-27 01:16:09 +00:00
enhanced README, fixed Dash chart to match new options
This commit is contained in:
parent
1ed50094fd
commit
29a36eb63f
3 changed files with 29 additions and 3 deletions
22
README.md
22
README.md
|
@ -11,7 +11,27 @@ PHP project to generate cached SVG price charts
|
|||
Extract the files from https://github.com/seigler/Dash-SVG-chart/archive/master.zip where you want to use the chart, or from the command line run `git clone "https://github.com/seigler/Dash-SVG-chart" .` in the folder where you want the charts served from.
|
||||
|
||||
## Usage
|
||||
`<img src="path to the folder where you cloned this project">`
|
||||
In your PHP file:
|
||||
|
||||
```php
|
||||
Header('Content-type: image/svg+xml; charset=utf-8');
|
||||
Header('Content-Disposition: inline; filename="Dash-24h-chart-' . date('Y-m-d\THisT') . '.svg"');
|
||||
include 'buffer.php';
|
||||
include 'SVGChartBuilder.php';
|
||||
|
||||
/* your code here to generate $chartData */
|
||||
|
||||
print SVGChartBuilder::renderStockChart($chartData, [
|
||||
'width'=>800,
|
||||
'height'=>250,
|
||||
'lineColor'=>"#1C75BC",
|
||||
'labelColor'=>"#777",
|
||||
'smoothed'=>false
|
||||
]);
|
||||
```
|
||||
|
||||
In your HTML:
|
||||
`<img src="path to the PHP file">`
|
||||
|
||||
## Credits
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class SVGChartBuilder {
|
|||
http://vis4.net/blog/posts/doing-the-line-charts-right/
|
||||
*/
|
||||
$aspectRatio = max(0.25, min(0.75, 1 / $averageAbsSlope));
|
||||
$height = floor($aspectRatio * $width);
|
||||
$height = $height ?? floor($aspectRatio * $width);
|
||||
|
||||
function labelFormat($float, $places, $minPlaces = 0) {
|
||||
$value = number_format($float, max($minPlaces, $places));
|
||||
|
|
|
@ -25,4 +25,10 @@ foreach ($last24h as $item) {
|
|||
$chartData[$item->date] = $item->weightedAverage;
|
||||
}
|
||||
|
||||
print SVGChartBuilder::renderStockChart($chartData, 700, "#1C75BC");
|
||||
print SVGChartBuilder::renderStockChart($chartData, [
|
||||
'width'=>800,
|
||||
'height'=>250,
|
||||
'lineColor'=>"#1C75BC",
|
||||
'labelColor'=>"#777",
|
||||
'smoothed'=>false
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue