Adding Chart to Web Page

TLN_CANADA used Ask the Experts™
We have a MYSQL/PHP database and want to add a chart to the web[age that shows the total amount of exercise per day over a period of time. Is there a nice chart plugin we could use for this?

The fields in the table are called exercise_id, exercise_time and exercise_timestamp.

Thanks for the help,

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

I've used JPGraph with very good success.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Google charts is very easy to work with and produces customizable charts that blend seamlessly with your existing pages.
I pull data from SQL server, populate into an array and send the array to a Google API to produce this chart:
Screen shot of chart


Thanks everyone,

I'm looking to make a simple chart that shows a person's exercise practice over time. User's can track their exercise times in minutes in the database. I would like to setup a simple line chart that shows on the vertical axis the minutes they exercised and on the horizontal axis the month of the year. If the chart could automatically resize to the amount of user data in the database that would be ideal. (E.g. if they have only exercised for one month it would show each day in details whereas if they have a year's worth of data it would show the data in months on the horizontal access). Could anyone provide a simple example of this? I have tried to do this myself using 3 of the programs suggest above (Float Chart, Google Charts and PHPChart) but as I'm not a seasoned PHP developer I'm finding it difficult to set it up.

Thanks for your help,



If it helps, our database table is called exercise_table and the fields are:

exercise_id (ai)
exercise_duration (int in minutes)


I can get all the necessary information from the database, I just can't figure out how to link it with the charts and the best chart system to use so that the view is automatically adjusted based on the amount of content for that user.
Here is the classic ASP page I used to generate the line chart above with GOogle API.  ALl you need to do is get the data from your database, populate your chart fields into an array and call the API.

        dim fso, rsCount, rsTally, i, arrSize, arrDate(), arrCount(), arrTally(), arrPercent(), chartData
        ' Create the ADO connection object
        set fso = CreateObject("ADODB.Connection")
        ' Create the recordsets
        set rsCount = Server.CreateObject("ADODB.Recordset")
        set rsTally = Server.CreateObject("ADODB.Recordset")
        ' Open the database
        fso.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../../../../BR/LEAN/personalizationMetrics.mdb") & ";Persist Security Info=False;"
        mSQL = "SELECT entryDate, SUM([qty]) AS [SUM OF KEYPADS] FROM dataTable WHERE DateDiff('d', entryDate, Now()) <=30 AND (reqType = 0 OR reqType = 1) GROUP BY entryDate ORDER BY entryDate ASC;"
        rsCount.Open mSQL, fso, 1, 1
        arrSize = rsCount.RecordCount
        ReDim arrDate(arrSize)
        ReDim arrCount(arrSize)
        ReDim arrTally(arrSize)
        ReDim arrPercent(arrSize)
        Do While Not rsCount.eof
            If Not rsCount.eof Then
                arrDate(ctr) = rsCount("entryDate")
                arrCount(ctr) = rsCount("SUM OF KEYPADS")
                ctr = ctr+1
            End If
        mSQL = "SELECT entryDate, SUM([qty]) AS [SUM OF KEYPADS] FROM dataTable WHERE DateDiff('d', entryDate, Now()) <=30 AND (reqType = 0 OR reqType = 1) AND velocity = 0 GROUP BY entryDate ORDER BY entryDate ASC;"
        rsTally.Open mSQL, fso, 1, 1
        arrSize = rsTally.RecordCount
        Do While Not rsTally.eof
            If Not rsTally.eof Then
                arrTally(ctr) = rsTally("SUM OF KEYPADS")
                'Response.Write(ctr & ") " & arrDate(ctr) & ", " & arrCount(ctr) & ", " & arrTally(ctr) & "<br />")
                ctr= ctr+1
            End If
        'Response.Write("<br /><br /><br />")
        Do While ctr < arrSize
            arrPercent(ctr) = FormatNumber(eval((arrTally(ctr)/arrCount(ctr))*100),0)
            'Response.Write(ctr & ") " & arrDate(ctr) & ", " & arrPercent(ctr) & "<br />")
            chartData = chartData & ",['"&arrDate(ctr)&"', 100, "&arrPercent(ctr)&"]"
            ctr= ctr+1
    <!--Load the AJAX API-->
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        google.load("visualization", "1", { packages: ["corechart"] }); google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = google.visualization.arrayToDataTable([
            ['Date', 'Goal', 'Actual']
            var options = {colors: ['#A90000','#028837'], title: 'Percentage of Orders Entered within 24 Hours', curveType: 'function', titleTextStyle: {fontSize: 24}, backgroundColor: '#F0F0F0', legend: 'bottom', hAxis: {slantedTextAngle: 90}, vAxis: {viewWindowMode:'explicit', viewWindow:{ max:110, min:0}}};
            var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
    <!--Div that will hold the chart-->    
        <div id="chart_div" style="width: 1000px; height: 600px;"></div>

Open in new window


Hi dimmergeek, we are using PHP/MYSQL. Will this work in the example you presented also?
Yes, the data source does not matter.  Once you have your data, you just build an array table with it and then call the API.
Thanks for the points and good luck!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial