Graphs

bkim

Member
I have a fairly simple database that I want to extract data from and display as a graph to analyze some of the data. Is there any program or way that I can get this functionality on dadabik with minimal fuss?
 

eugenio

Administrator
Staff member
I've personally used http://www.chartjs.org/ together with a custom PHP page in DaDaBIK.
 

bkim

Member
Is there anything special that you did to have graphs using Chartjs to appear under the php custom page? I can't seem to get it to work no matter what work around I'm trying. This is pretty much what I have in trying to get the chart to show:

<script src="Chart.min.js"></script>
<canvas id="ponum" width="600" height="400"></canvas>
var barChartData = {
labels : <?php echo $js_labels?>,
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
data : <?php echo print_r($js_cols,true)?>
}
]
}
var ponum = document.getElementById('ponum').getContext("2d");
new Chart(ponum).Bar(barChartData);
 

eugenio

Administrator
Staff member
If it doesn't work, you should see a javascript error message in the console of your browser.
Does your code work in a normal html page? If yes, it should work even in a DaDaBIK page.
 

bkim

Member
No errors. I grabbed the info from the page source and copy pasted into a new html file and it worked. This is what got printed out into the page source:

<script src='Chart.min.js'></script>
<canvas id="ponum" width="1000" height="400"></canvas>
<script>
var barChartData = {
labels : ["1"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
data : [14033756] }
]
}

var ponum = document.getElementById('ponum').getContext("2d");
new Chart(ponum).Bar(barChartData);
</script>

The only issue I can think of is that I put the Chart.min.js file in the wrong location, but I put that sucker in any folder that I could think of that already contained js files as well as in the custom_php_files folder.
 

bkim

Member
Looks like the Chart.min.js file was in the wrong folder! For some reason I thought the src="Chart.min.js" would point towards the folder that the custom php file was, and didn't think that it would be under the root folder of dadabik. Thanks for your help!
 
Top