Advertisement
FOXRAGE

chart.js

Feb 21st, 2020
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. $(document).ready(function(){
  2.   $.ajax({
  3.     url : "gleichrichter_mix.php",
  4.     type : "GET",
  5.     success : function(data){
  6.       console.log(data);
  7.  
  8.       var ID = [];
  9.       var Gesamtwirkleistung = [];
  10.       var Gesamtscheinleistung = [];
  11.       var Gesamtblindleistung = [];
  12.  
  13.       for(var i in data) {
  14.         ID.push("ID " + data[i].ID);
  15.         Gesamtwirkleistung.push(data[i].Gesamtwirkleistung);
  16.         Gesamtscheinleistung.push(data[i].Gesamtscheinleistung);
  17.         Gesamtblindleistung.push(data[i].Gesamtblindleistung);
  18.       }
  19.  
  20.       var chartdata = {
  21.         labels: ID,
  22.         datasets: [
  23.           {
  24.             label: "Gesamtwirkleistung",
  25.             fill: false,
  26.             lineTension: 0.1,
  27.             backgroundColor: "rgba(59, 89, 152, 0.75)",
  28.             borderColor: "rgba(59, 89, 152, 1)",
  29.             pointHoverBackgroundColor: "rgba(59, 89, 152, 1)",
  30.             pointHoverBorderColor: "rgba(59, 89, 152, 1)",
  31.             data: Gesamtwirkleistung
  32.           },
  33.           {
  34.             label: "Gesamtscheinleistung",
  35.             fill: false,
  36.             lineTension: 0.1,
  37.             backgroundColor: "rgba(29, 202, 255, 0.75)",
  38.             borderColor: "rgba(29, 202, 255, 1)",
  39.             pointHoverBackgroundColor: "rgba(29, 202, 255, 1)",
  40.             pointHoverBorderColor: "rgba(29, 202, 255, 1)",
  41.             data: Gesamtscheinleistung
  42.           },
  43.           {
  44.             label: "Gesamtblindleistung",
  45.             fill: false,
  46.             lineTension: 0.1,
  47.             backgroundColor: "rgba(211, 72, 54, 0.75)",
  48.             borderColor: "rgba(211, 72, 54, 1)",
  49.             pointHoverBackgroundColor: "rgba(211, 72, 54, 1)",
  50.             pointHoverBorderColor: "rgba(211, 72, 54, 1)",
  51.             data: Gesamtblindleistung
  52.           }
  53.         ]
  54.       };
  55.  
  56.       var ctx = $("#mycanvas");
  57.  
  58.       var LineGraph = new Chart(ctx, {
  59.         type: 'line',
  60.         data: chartdata
  61.       });
  62.     },
  63.     error : function(data) {
  64.  
  65.     }
  66.   });
  67. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement