Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2294)

Unified Diff: pkg/js/example/chart_js_example.dart

Issue 1411503002: pkg/js: improved readme, added example (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: nits Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/js/example/chart.dart ('k') | pkg/js/example/index.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/js/example/chart_js_example.dart
diff --git a/pkg/js/example/chart_js_example.dart b/pkg/js/example/chart_js_example.dart
new file mode 100644
index 0000000000000000000000000000000000000000..bbd5cef2c35d009f49d21f3cd7603890f21c1a31
--- /dev/null
+++ b/pkg/js/example/chart_js_example.dart
@@ -0,0 +1,67 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library chart.example;
+
+// Based off the Javascript example
+// https://github.com/nnnick/Chart.js/blob/b8691c9581bff0eeecb34f98e678dc045a18f33e/samples/line.html
+// On 2015-10-15
+
+import 'dart:html';
+import 'dart:math';
+
+import 'chart.dart';
+
+void main() {
+ var ctx = (querySelector('#canvas') as CanvasElement).context2D;
+
+ var rnd = new Random();
+
+ var data = new Data(labels: [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July"
+ ], datasets: <DataSet>[
+ new DataSet(
+ label: "My First dataset",
+ fillColor: "rgba(220,220,220,0.2)",
+ strokeColor: "rgba(220,220,220,1)",
+ pointColor: "rgba(220,220,220,1)",
+ pointStrokeColor: "#fff",
+ pointHighlightFill: "#fff",
+ pointHighlightStroke: "rgba(220,220,220,1)",
+ data: [
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100)
+ ]),
+ new DataSet(
+ label: "My Second dataset",
+ fillColor: "rgba(151,187,205,0.2)",
+ strokeColor: "rgba(151,187,205,1)",
+ pointColor: "rgba(151,187,205,1)",
+ pointStrokeColor: "#fff",
+ pointHighlightFill: "#fff",
+ pointHighlightStroke: "rgba(151,187,205,1)",
+ data: [
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100),
+ rnd.nextInt(100)
+ ])
+ ]);
+
+ new Chart(ctx).Line(data, new Options(responsive: true));
+}
« no previous file with comments | « pkg/js/example/chart.dart ('k') | pkg/js/example/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698