Tuesday, 14 March 2017

Use Node.js data in HTML with HAPI

I have a server.js page and it get datas from database. I want to use this datas in a HTML page. How can I get this datas.

I don't use Express but Hapi (because i'm happy lol).

This is my code :

            <script>var ctx = document.getElementById('graph').getContext('2d');
            var graph = new Chart(ctx, {
              type: 'line',
              data: {
                labels: ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'],
                datasets: [{
                  label: 'CPU',
                  data: [22, 19, 25, 65, 30, 47, 14],
                  backgroundColor: "rgba(153,255,51,0.4)"
                }, {
                  label: 'RAM',
                  data: [31, 29, 31, 35, 28, 34, 30],
                  backgroundColor: "rgba(255,153,0,0.4)"
                }]
              }
            });
        </script>

I want to change "22, 19, 25, 65, 30, 47, 14" by the new values gets with postgreSQL.

Thanks for your help.



via Mat L

No comments:

Post a Comment