fixed caching, increased duration choices

This commit is contained in:
Joshua Seigler 2016-07-02 00:30:02 -04:00
parent 46764e6879
commit c476b92a68
2 changed files with 18 additions and 14 deletions

View file

@ -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' ];

View file

@ -77,8 +77,8 @@
<section>
<h2>SVG and PNG charts with your favorite cryptocurrencies</h2>
<figure>
<img src="/charts/light/dash-btc/7d/svg" alt="Poloniex Dash/BTC price">
<figcaption>7 Day Dash price in BTC <code>http://cryptohistory.org/charts/light/dash-btc/7d/svg</code></figcaption>
<img src="/charts/light/dash-btc/30d/svg" alt="Poloniex Dash/BTC price">
<figcaption>30 Day Dash price in BTC <code>http://cryptohistory.org/charts/light/dash-btc/30d/svg</code></figcaption>
</figure>
</section>
<section>
@ -87,14 +87,14 @@
<code>http://cryptohistory.org/charts/{theme}/{currency}-btc/{timespan}/{format}</code></p>
<p>Theme: <code>dark</code> or <code>light</code>. (More planned)</p>
<p>Currency: anything active on Poloniex. Prices are all in bitcoin.</p>
<p>Timespan: <code>7d</code> or <code>24h</code>. (More planned)</p>
<p>Timespan: <code>1y</code>, <code>30d</code>, <code>7d</code>, or <code>24h</code>.</p>
<p>Format: <code>svg</code> (best) or <code>png</code>.</p>
</section>
<section>
<h2>Examples:</h2>
<p>Ethereum 24h, dark SVG: <code><a href="/charts/dark/eth-btc/24h/svg" target="_blank">http://cryptohistory.org/charts/dark/eth-btc/24h/svg</a></code></p>
<p>Litecoin 7d, light colored PNG: <code><a href="/charts/dark/ltc-btc/7d/png" target="_blank">http://cryptohistory.org/charts/dark/ltc-btc/7d/png</a></code></p>
<p>Factom 7d, dark SVG: <code><a href="/charts/dark/fct-btc/24h/svg" target="_blank">http://cryptohistory.org/charts/dark/fct-btc/24h/svg</a></code></p>
<p>Litecoin 30d, light colored PNG: <code><a href="/charts/dark/ltc-btc/7d/png" target="_blank">http://cryptohistory.org/charts/dark/ltc-btc/30d/png</a></code></p>
<p>Doge 1y, dark SVG: <code><a href="/charts/dark/fct-btc/24h/svg" target="_blank">http://cryptohistory.org/charts/dark/doge-btc/30d/svg</a></code></p>
</section>
</main>
<footer>