Advertisement
tomuwhu

Normális eloszlás

Jan 20th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div class="cc">
  2.     <canvas id="myChart"></canvas>
  3. </div>
  4. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
  5. <script>
  6. var x = 10, t1=Array(20).fill(0), t2=Array(20).fill(0), t3=Array(20).fill(0)
  7. Array(1000).fill(0).forEach( () => {
  8.      t1[Math.round(
  9.             Array(40).fill(0).reduce( o => o += Math.random(), 0 )
  10.     )-10]++
  11.     t2[Math.round(
  12.             Array(10).fill(0).reduce( o => o += Math.random(), 0 ) + 5
  13.     )]++
  14.     t3[Math.round(Math.random()*20)]++
  15. })
  16. var ctx = document.getElementById('myChart').getContext('2d');
  17. var chart = new Chart(ctx, {
  18.     type: 'line',
  19.     data: {
  20.         labels: Array(20).fill(0).map( (v, i) => i + 1 ),
  21.         datasets: [
  22.             { label: 'Normális eloszlás 1', data: t1, borderColor: 'rgb(255, 132, 70)' },
  23.             { label: 'Normális eloszlás 2', data: t2, borderColor: 'rgb(255, 99, 132)' },
  24.             { label: 'Egyenletes eloszlás', data: t3, borderColor: 'rgb(20, 175, 162)' }
  25.         ]
  26.     },
  27.     options: {}
  28. })
  29. </script>
  30.  
  31. <style>
  32. div.cc {
  33.     width:90%;
  34.     text-align: center;
  35.     margin: 20px;
  36. }
  37. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement