Here is a javascript implementation of a “fake” boot counter that seems the same for everyone. This always returns the same results for each each time and does not require a database or files for this. It also gracefully handles a case where you are not requesting new data at the same time, it will look natural the next time you request a day.
https://jsfiddle.net/Lru1tenL/1/
Counter = { time:Date.now(), count:0, rate:0.45 }; Counter.seed = function(seed, startTime) { this.time = startTime, this.count = 0, this.prng = new Math.seedrandom(seed); this.prng.getRandomInt = function(min, max) { return Math.floor(this() * (max - min)) + min; }; }; Counter.getNext = function(t){ var diff = t - this.time; console.log(diff); if(diff <= 0) return this.count; this.time = t; var max = Math.ceil(diff/100 * this.rate); console.log("max: " + max); this.count += this.prng.getRandomInt(0,max); return this.count; }; var results = []; var today = Date.now(); Counter.seed("My Random Seed", today); for (var i = 0; i < 7; i++) { if(i === 4) { results.push(null); } else { var future = today + 86400000 * i; results.push(Counter.getNext(future)); } } console.log(results); var data = { labels: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"], datasets: [ { label: "My Second dataset", fillColor: "rgba(151,187,205,0.2)", strokeColor: "rgba(151,187,205,1)", pointColor: "rgba(151,187,205,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", pointHighlightStroke: "rgba(151,187,205,1)", data: results } ] }; var ctx = document.getElementById("myChart").getContext("2d"); var myLineChart = new Chart(ctx).Line(data);
Is javascript. It creates a counter object, which increases with the request depending on the time of the previous request. Repeatability enters through the third-party seedrandom library, and the chart is drawn using charts.
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/seedrandom/2.4.0/seedrandom.min.js"> </script> <body> <canvas id="myChart" width="600" height="400"></canvas> </body> </html>