This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function renderChart(data, labels) { | |
| var ctx = document.getElementById("myChart").getContext('2d'); | |
| var myChart = new Chart(ctx, { | |
| type: 'line', | |
| data: { | |
| labels: labels, | |
| datasets: [{ | |
| label: 'This week', | |
| data: data, | |
| }] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Exploring Chart.js</title> | |
| </head> | |
| <style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function float2dollar(value){ | |
| return "U$ "+(value).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); | |
| } | |
| function renderChart(data, labels) { | |
| var ctx = document.getElementById("myChart").getContext('2d'); | |
| var myChart = new Chart(ctx, { | |
| type: 'line', | |
| data: { | |
| labels: labels, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "chartData": { | |
| "labels": [ | |
| "sunday", | |
| "monday", | |
| "tuesday", | |
| "wednesday", | |
| "thursday", | |
| "friday", | |
| "saturday" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getChartData() { | |
| $("#loadingMessage").html('<img src="./giphy.gif" alt="" srcset="">'); | |
| $.ajax({ | |
| url: "http://localhost:3000/chartdata", | |
| success: function (result) { | |
| $("#loadingMessage").html(""); | |
| var data = []; | |
| data.push(result.thisWeek); | |
| data.push(result.lastWeek); | |
| var labels = result.labels; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style> | |
| .container { | |
| width: 50%; | |
| height: 50%; | |
| position: relative; | |
| } | |
| #loadingMessage{ | |
| position: absolute; | |
| left: 50%; | |
| top: 50%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "chartData": { | |
| "labels": [ | |
| "sunday", | |
| "monday", | |
| "tuesday", | |
| "wednesday", | |
| "thursday", | |
| "friday", | |
| "saturday" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function float2dollar(value) { | |
| return "U$ " + (value).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); | |
| } | |
| function renderChart(data, labels) { | |
| var ctx = document.getElementById("myChart").getContext('2d'); | |
| var myChart = new Chart(ctx, { | |
| type: 'line', | |
| data: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var labels = [ | |
| "Vote for blue", | |
| "vote for red", | |
| ]; | |
| var data = [ | |
| 70, | |
| 30, | |
| ]; | |
| var pie = document.getElementById("pieChart").getContext('2d'); | |
| var myChart = new Chart(pie, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var labels = [ | |
| "sunday", | |
| "monday", | |
| "tuesday", | |
| "wednesday", | |
| "thursday", | |
| "friday", | |
| "saturday" | |
| ]; |
OlderNewer