index.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. </head>
  6. <body>
  7. <canvas id="draw" width="550px" height="550px"></canvas>
  8. <script src="chart.js"></script>
  9. <script type="text/javascript">
  10. var data = {
  11. labels: [],
  12. data: [],
  13. fillColor: [],
  14. strokeColor: []
  15. }
  16. for (var ind = 0; ind < 10; ++ind) {
  17. data.labels.push('Label');
  18. if (ind % 3 == 0) data.data.push(Math.random() * 10000); else
  19. data.data.push([Math.random() * 10000,Math.random() * 10000]);
  20. var r = Math.floor(Math.random() * 256)
  21. var g = Math.floor(Math.random() * 256)
  22. var b = Math.floor(Math.random() * 256)
  23. r+= ','
  24. g+=','
  25. data.fillColor.push('rgb(' + r + g + b + ')');
  26. data.strokeColor.push('rgb(' + r + g + b + ')');
  27. }
  28. var canvas;
  29. var c = new BarChart((canvas = document.getElementById('draw')).getContext('2d'),{
  30. fillColorBackground: 'rgb(255, 255, 255)',
  31. fillColorBars: 'rgba(180, 180, 180, 0.30)',
  32. //fontWeight: 'lighter',
  33. fontSizeTitle: 18,
  34. fontSizeLabels: 16,
  35. fontSizeAxes: 18,
  36. paddingPercentBars: 0.3,
  37. maxWidthBars: 100,
  38. paddingPercentTicks: 1.0,
  39. //barStyle: 'error',
  40. barStyle: 'line',
  41. //scaleStyle: 'log2',
  42. radiusDot: 0,
  43. fillRegion: 'background',
  44. // tickFormatter: (tick) => {
  45. // if (tick >= 1000) {
  46. // return (tick / 1000) + 'k';
  47. // }
  48. // return tick;
  49. // },
  50. // tickFormatterMeasure: '##k'
  51. });
  52. /*c.update({
  53. //title: 'Graph 1: Processor Results',
  54. xAxis: 'Machines',
  55. yAxis: 'Seconds',
  56. labels: [ '1', '2', '4', '8', '16', '32', '64', '128', '256', '512', '1024' ],
  57. data:
  58. [ [ 102.56, 101.992, 101.68, 102.374, 102.416 ],
  59. [ 53.267, 53.278, 53.865, 53.593, 53.251 ],
  60. [ 28.564, 29.282, 28.361, 28.347, 28.726 ],
  61. [ 16.982, 21.037, 17.063, 16.841, 17.075 ],
  62. [ 11.201, 11.122, 11.289, 10.767, 10.577, 10.547 ],
  63. [ 8.527, 7.918, 8.006, 7.514, 7.344 ],
  64. [ 7.017, 6.256, 5.887, 6.082, 6.051 ],
  65. [ 7.175, 6.641, 6.155, 7.154, 6.571 ],
  66. [ 6.737, 9.314, 8.515, 6.83, 8.124 ],
  67. [ 7.044, 7.432, 7.362, 6.913, 7.453 ],
  68. [ 8.154, 7.82, 8.565, 10.645, 9.04 ] ],
  69. meta:
  70. [ { average: 102.204, sd: 0.361, tests: 5, se: 0.161 },
  71. { average: 53.451, sd: 0.272, tests: 5, se: 0.122 },
  72. { average: 28.656, sd: 0.383, tests: 5, se: 0.171 },
  73. { average: 17.8, sd: 1.812, tests: 5, se: 0.81 },
  74. { average: 10.917, sd: 0.327, tests: 6, se: 0.134 },
  75. { average: 7.862, sd: 0.462, tests: 5, se: 0.207 },
  76. { average: 6.259, sd: 0.444, tests: 5, se: 0.198 },
  77. { average: 6.739, sd: 0.43, tests: 5, se: 0.193 },
  78. { average: 7.904, sd: 1.11, tests: 5, se: 0.496 },
  79. { average: 7.241, sd: 0.246, tests: 5, se: 0.11 },
  80. { average: 8.845, sd: 1.105, tests: 5, se: 0.494 } ] })*/
  81. /*c.update({
  82. labels: ['testtesttest', 'testtestesttetest', 'stesttesttest', 'testtesttesttest', 'testtesttesttest'],
  83. xAxis:'WWWWWWWWW',
  84. data: [0.04, 0.05, 0.05, 0.04, 0.04],
  85. //balls: [{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 }],
  86. })*/
  87. //c.update(data);
  88. //show current value on top of bar
  89. c.update({
  90. labels: [['label 1a', 'label 1b'], ['label 2a','label 2b'], 'a', 'c','b'],
  91. data: [[20, 30, 10, 10], [25, 25, 15, 25], 15,15, [10,12,15]],
  92. hints: [['bla\nblalas','bla1','bla3','bla4'],['1bla','bala1','bala3','bala4']],
  93. dataTags: [['long tag tesasster more', 'b', 'c', 'd'], ['a', 'b', 'c', 'd']],
  94. hints: ['Testing', 'Testing2', 'Testing3'],
  95. topLabels: ['label 3', 'label 4'],
  96. fillColor: [['rgba(100, 200, 200, 0.5)', 'rgba(50, 30, 20, 0.5)', 'rgba(100, 50, 200, 0.5)', 'rgba(100, 200, 0, 0.5)'],['rgba(100, 200, 200, 0.5)', 'rgba(50, 30, 20, 0.5)', 'rgba(100, 50, 200, 0.5)', 'rgba(100, 200, 0, 0.5)']],
  97. legend: [
  98. { color: 'rgba(100, 200, 200, 1)', label: 'abc' },
  99. { color: 'rgba(50, 30, 20, 1)', label: 'asfasa' },
  100. { color: 'rgba(100, 50, 200, 1)', label: 'asfasaf' },
  101. { color: 'rgba(100, 200, 0, 1)', label: '124j1i2j' },
  102. { color: 'rgba(100, 200, 200, 1)', label: 'abc' },
  103. { color: 'rgba(50, 30, 20, 1)', label: 'asfasa' },
  104. { color: 'rgba(100, 50, 200, 1)', label: 'asfasaf' },
  105. { color: 'rgba(100, 200, 0, 1)', label: '124j1i2j' },
  106. { color: 'rgba(100, 200, 200, 1)', label: 'abc' },
  107. { color: 'rgba(50, 30, 20, 1)', label: 'asfasa' },
  108. { color: 'rgba(100, 50, 200, 1)', label: 'asfasaf' },
  109. { color: 'rgba(100, 200, 0, 1)', label: '124j1i2j' },
  110. { color: 'rgba(100, 200, 200, 1)', label: 'abc' },
  111. { color: 'rgba(50, 30, 20, 1)', label: 'asfasa' },
  112. { color: 'rgba(100, 50, 200, 1)', label: 'asfasaf' },
  113. { color: 'rgba(100, 200, 0, 1)', label: '124j1i2j' }
  114. ],
  115. bars: [{ style: 'rgb(255, 0, 0)', value: 50 },{ style: 'rgb(255, 0, 0)', value: 10 }],
  116. balls: [{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 },{ radius: 5, fill: 'rgb(0,255,0)', stroke: 'rgb(255,0,0)', value: 0 }],
  117. title:'Bla bla'
  118. });
  119. canvas.addEventListener('mousemove', function(e) {
  120. var rect = canvas.getBoundingClientRect();
  121. c.mousemove(e.clientX - rect.left, e.clientY - rect.top);
  122. //console.log(c.labelPositions)
  123. console.log(c.fillRegions)
  124. });
  125. </script>
  126. </body>
  127. </html>