--- /dev/null
+<html>
+<head>
+<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
+<meta content="utf-8" http-equiv="encoding">
+<script src="Chart.js/Chart.js"></script>
+</head>
+<body>
+<?
+ $r=open_database("freqwatch", "select count(id) as tot,freq from freqs group by freq asc limit 1000");
+ $num=mysql_numrows($r);
+ $skipper=50;
+ while ($i<$num) {
+ $tot=mysql_result($r,$i,"tot");
+ $freq=mysql_result($r,$i,"freq");
+ #if ($skipper==50) {
+ $labels=$labels.'"'.$freq.'",';
+ # $skipper=0;
+ #} else {
+ # $labels=$labels.'" ",';
+ #}
+ $data=$data.'"'.$tot.'",';
+ $i++;
+ #$skipper++;
+ #echo $freq;
+ }
+ $labels=rtrim($labels,',');
+ $data=rtrim($data,",");
+ #$num=150;
+?>
+ <div style="width: 75%">
+ <canvas id="canvas" height="800" width="<? echo $num*5; ?>"></canvas>
+ </div>
+
+
+ <script>
+ var lineChartData = {
+ labels : [<? echo $labels; ?>],
+ datasets : [
+ {
+ label: "My First dataset",
+ fillColor : "rgba(220,220,220,0.2)",
+ strokeColor : "rgba(220,220,220,1)",
+ pointColor : "rgba(220,220,220,1)",
+ pointStrokeColor : "#fff",
+ pointHighlightFill : "#fff",
+ pointHighlightStroke : "rgba(220,220,220,1)",
+
+ data : [<? echo $data; ?>]
+ }
+ ]
+ }
+ window.onload = function(){
+ var ctx = document.getElementById("canvas").getContext("2d");
+ window.myLine = new Chart(ctx).Line(lineChartData, {
+ animation: false,
+ scaleShowLabels: true,
+ pointHitDetectionRadius : 1,
+ showScale: false,
+ //scaleLineWidth: 1,
+ //barStrokeWidth : 0.01,
+ responsive : false
+ });
+ //}
+ canvas.onclick = function(evt){
+ var activePoints = myLine.getPointsAtEvent(evt);
+ console.log(activePoints);
+ alert(activePoints[0].label);
+ // => activePoints is an array of points on the canvas that are at the same position as the click event.
+ };
+ }
+ </script>
+</body>
+</html>
+<?
+function open_database($dab,$sqlquery)
+{
+ $db = mysql_connect("localhost", "freqwatch", "anyoldpasswordwilldo");
+ if (!$db) {
+ echo "Cant connect to server.<br>";
+ exit();
+ }
+ if (! @mysql_select_db($dab)) {
+ echo "Cant connect to DB.<br>";
+ exit();
+ }
+ $result=mysql_query($sqlquery);
+ return($result);
+}
+?>