OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library chart.example; |
| 6 |
| 7 // Based off the Javascript example |
| 8 // https://github.com/nnnick/Chart.js/blob/b8691c9581bff0eeecb34f98e678dc045a18f
33e/samples/line.html |
| 9 // On 2015-10-15 |
| 10 |
| 11 import 'dart:html'; |
| 12 import 'dart:math'; |
| 13 |
| 14 import 'chart.dart'; |
| 15 |
| 16 void main() { |
| 17 var ctx = (querySelector('#canvas') as CanvasElement).context2D; |
| 18 |
| 19 var rnd = new Random(); |
| 20 |
| 21 var data = new Data(labels: [ |
| 22 "January", |
| 23 "February", |
| 24 "March", |
| 25 "April", |
| 26 "May", |
| 27 "June", |
| 28 "July" |
| 29 ], datasets: <DataSet>[ |
| 30 new DataSet( |
| 31 label: "My First dataset", |
| 32 fillColor: "rgba(220,220,220,0.2)", |
| 33 strokeColor: "rgba(220,220,220,1)", |
| 34 pointColor: "rgba(220,220,220,1)", |
| 35 pointStrokeColor: "#fff", |
| 36 pointHighlightFill: "#fff", |
| 37 pointHighlightStroke: "rgba(220,220,220,1)", |
| 38 data: [ |
| 39 rnd.nextInt(100), |
| 40 rnd.nextInt(100), |
| 41 rnd.nextInt(100), |
| 42 rnd.nextInt(100), |
| 43 rnd.nextInt(100), |
| 44 rnd.nextInt(100), |
| 45 rnd.nextInt(100) |
| 46 ]), |
| 47 new DataSet( |
| 48 label: "My Second dataset", |
| 49 fillColor: "rgba(151,187,205,0.2)", |
| 50 strokeColor: "rgba(151,187,205,1)", |
| 51 pointColor: "rgba(151,187,205,1)", |
| 52 pointStrokeColor: "#fff", |
| 53 pointHighlightFill: "#fff", |
| 54 pointHighlightStroke: "rgba(151,187,205,1)", |
| 55 data: [ |
| 56 rnd.nextInt(100), |
| 57 rnd.nextInt(100), |
| 58 rnd.nextInt(100), |
| 59 rnd.nextInt(100), |
| 60 rnd.nextInt(100), |
| 61 rnd.nextInt(100), |
| 62 rnd.nextInt(100) |
| 63 ]) |
| 64 ]); |
| 65 |
| 66 new Chart(ctx).Line(data, new Options(responsive: true)); |
| 67 } |
OLD | NEW |