3 <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
4 <meta content="utf-8" http-equiv="encoding">
5 <script src="Chart.js/Chart.js"></script>
9 $r=open_database("freqwatch", "select count(id) as tot,freq from freqs group by freq asc limit 1000");
10 $num=mysql_numrows($r);
13 $tot=mysql_result($r,$i,"tot");
14 $freq=mysql_result($r,$i,"freq");
16 $labels=$labels.'"'.$freq.'",';
19 # $labels=$labels.'" ",';
21 $data=$data.'"'.$tot.'",';
26 $labels=rtrim($labels,',');
27 $data=rtrim($data,",");
30 <div style="width: 75%">
31 <canvas id="canvas" height="800" width="<? echo $num*5; ?>"></canvas>
37 labels : [<? echo $labels; ?>],
40 label: "My First dataset",
41 fillColor : "rgba(220,220,220,0.2)",
42 strokeColor : "rgba(220,220,220,1)",
43 pointColor : "rgba(220,220,220,1)",
44 pointStrokeColor : "#fff",
45 pointHighlightFill : "#fff",
46 pointHighlightStroke : "rgba(220,220,220,1)",
48 data : [<? echo $data; ?>]
52 window.onload = function(){
53 var ctx = document.getElementById("canvas").getContext("2d");
54 window.myLine = new Chart(ctx).Line(lineChartData, {
56 scaleShowLabels: true,
57 pointHitDetectionRadius : 1,
60 //barStrokeWidth : 0.01,
64 canvas.onclick = function(evt){
65 var activePoints = myLine.getPointsAtEvent(evt);
66 console.log(activePoints);
67 alert(activePoints[0].label);
68 // => activePoints is an array of points on the canvas that are at the same position as the click event.
75 function open_database($dab,$sqlquery)
77 $db = mysql_connect("localhost", "freqwatch", "anyoldpasswordwilldo");
79 echo "Cant connect to server.<br>";
82 if (! @mysql_select_db($dab)) {
83 echo "Cant connect to DB.<br>";
86 $result=mysql_query($sqlquery);