| 214 | } |
| 215 | |
| 216 | function do_plot($data) { |
| 217 | $labels = array(); |
| 218 | $bugs = array(); |
| 219 | $bugs_wo_undef = array(); |
| 220 | |
| 221 | foreach ($data as $t) { |
| 222 | $labels[] = format_date($t[6]); |
| 223 | $bugs[] = $t[1]; |
| 224 | $bugs_wo_undef[] = $t[2]; |
| 225 | } |
| 226 | |
| 227 | $labels = implode("',\n'", $labels); |
| 228 | $bugs = implode(",\n", $bugs); |
| 229 | $bugs_wo_undef = implode(",\n", $bugs_wo_undef); |
| 230 | |
| 231 | echo <<< HTML |
| 232 | <div style="width:75%"> |
| 233 | <canvas id="llvmbugs"></canvas> |
| 234 | </div> |
| 235 | <script> |
| 236 | var ctx = document.getElementById('llvmbugs').getContext('2d'); |
| 237 | new Chart(ctx, { |
| 238 | type: 'line', |
| 239 | data: { |
| 240 | labels: ['$labels'], |
| 241 | datasets: [{ |
| 242 | label: 'Failures', |
| 243 | fill: false, |
| 244 | backgroundColor: 'rgba(255, 0, 0, 0.5)', |
| 245 | borderColor: 'rgba(255, 0, 0, 0.5)', |
| 246 | data: [ |
| 247 | $bugs |
| 248 | ] |
| 249 | }, { |
| 250 | label: 'Failures if undef ignored', |
| 251 | fill: false, |
| 252 | backgroundColor: 'rgba(0, 0, 255, 0.5)', |
| 253 | borderColor: 'rgba(0, 0, 255, 0.5)', |
| 254 | data: [ |
| 255 | $bugs_wo_undef |
| 256 | ], |
| 257 | }] |
| 258 | }, |
| 259 | options: { |
| 260 | tooltips: { |
| 261 | mode: 'index', |
| 262 | intersect: false, |
| 263 | }, |
| 264 | hover: { |
| 265 | mode: 'nearest', |
| 266 | intersect: true |
| 267 | }, |
| 268 | scales: { |
| 269 | xAxes: [{ |
| 270 | display: true, |
| 271 | scaleLabel: { |
| 272 | display: true, |
| 273 | labelString: 'Date' |