SHARE
TWEET

Untitled

a guest Jun 15th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var numbers = [];
  2. var context = document.getElementById("chart");
  3. var config = {
  4.   type: 'doughnut',
  5.   data: {
  6.     datasets: [
  7.        {
  8.        backgroundColor: ['orange', 'blue', 'yellow'],
  9.        data: numbers,
  10.        borderWidth: 0,          
  11.        }
  12.     ]
  13.   },
  14.   options: {
  15.        responsive: false,
  16.   }    
  17. }
  18. var chart = new Chart(context, config);
  19.  
  20. const socket = io();
  21.  
  22. var someValue = 7;
  23.  
  24. socket.emit('add', someValue);
  25.  
  26. socket.on('update', (arr) => {
  27.     numbers = arr;
  28.     console.log(numbers);
  29. });
  30.      
  31. const chartArray = [];
  32.  
  33. io.on('connection', (socket) => {
  34.     socket.on('add', (data) => {
  35.         chartArray.push(data);
  36.     });
  37.  
  38.     setInterval(function() {
  39.         socket.emit('update', chartArray);
  40.     },1000/25);
  41. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top