From c476b92a68bb2de901e5832cb421b900c1bff53f Mon Sep 17 00:00:00 2001
From: Joshua Seigler
Date: Sat, 2 Jul 2016 00:30:02 -0400
Subject: [PATCH] fixed caching, increased duration choices
---
views/chart.php | 22 +++++++++++++---------
views/index.php | 10 +++++-----
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/views/chart.php b/views/chart.php
index 578b7a0..92be1e0 100644
--- a/views/chart.php
+++ b/views/chart.php
@@ -32,17 +32,21 @@ function renderChart(
) {
$durations = [
-// '30d'=> [
-// 'duration' => 60 * 60 * 24 * 30,
-// 'resolution' => 7200 // 2h
-// ],
+ '1y'=> [
+ 'duration' => 60 * 60 * 24 * 365,
+ 'resolution' => 86400 // 1d
+ ],
+ '30d'=> [
+ 'duration' => 60 * 60 * 24 * 30,
+ 'resolution' => 7200 // 2h
+ ],
'7d'=> [
'duration' => 60 * 60 * 24 * 7,
'resolution' => 1800 // 30m
],
'24h' => [
'duration' => 60 * 60 * 24 * 1,
- 'resolution' => 900 // 15m
+ 'resolution' => 300 // 15m
]
];
@@ -92,12 +96,12 @@ function renderChart(
}
$poloniexChart = new NeatCharts\LineChart($chartData, [
- 'width'=>800,
- 'height'=>200,
+ 'width'=>$width,
+ 'height'=>$height,
'lineColor'=>($theme == 'dark' ? '#000' : '#fff'),
'labelColor'=>($theme == 'dark' ? '#000' : '#fff'),
'smoothed'=>false,
- 'fontSize'=>12
+ 'fontSize'=>$fontSize
]);
$result = $poloniexChart->render();
@@ -110,7 +114,7 @@ function renderChart(
$im->clear();
$im->destroy();
}
- CacheManager::set($chartCacheKey, $result);
+ CacheManager::set($chartCacheKey, $result, $dataResolution);
$resultExpires = time() + $dataResolution;
} else {
$resultExpires = CacheManager::getInfo($chartCacheKey)[ 'expired_time' ];
diff --git a/views/index.php b/views/index.php
index 36a8e0b..12b8612 100644
--- a/views/index.php
+++ b/views/index.php
@@ -77,8 +77,8 @@
SVG and PNG charts with your favorite cryptocurrencies
-
- 7 Day Dash price in BTC http://cryptohistory.org/charts/light/dash-btc/7d/svg
+
+ 30 Day Dash price in BTC http://cryptohistory.org/charts/light/dash-btc/30d/svg
@@ -87,14 +87,14 @@
http://cryptohistory.org/charts/{theme}/{currency}-btc/{timespan}/{format}
Theme: dark
or light
. (More planned)
Currency: anything active on Poloniex. Prices are all in bitcoin.
- Timespan: 7d
or 24h
. (More planned)
+ Timespan: 1y
, 30d
, 7d
, or 24h
.
Format: svg
(best) or png
.