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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/observatory/chart.dart

Issue 148153007: Add Google Charts to Observatory and use it in allocation profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 part of observatory;
6
7 // Static utility methods hiding dart:js interop calls.
8 class Chart extends Observable {
turnidge 2014/01/28 18:28:08 See my other comment. I am suggesting getting awa
9 static var _gviz;
10 static get gviz {
11 return _gviz;
12 }
13
14 static Future initOnce() {
15 Completer c = new Completer();
16 context['google'].callMethod('load',
17 ['visualization', '1', new JsObject.jsify({
18 'packages': ['corechart', 'table'],
19 'callback': new JsFunction.withThis(c.complete)
20 })]);
21 return c.future.then(_initOnceOnComplete);
22 }
23
24 static _initOnceOnComplete(_) {
25 Logger.root.info('Google Charts API loaded');
26 _gviz = context['google']['visualization'];
27 assert(_gviz != null);
28 return _gviz;
29 }
30
31 /// Create a Google Chart of [chartType]. e.g. 'Table', 'BarChart', the
32 /// chart is rendered inside [element].
33 static createChart(String chartType, Element element) {
34 return new JsObject(gviz[chartType], [element]);
35 }
36
37 /// Create a new DataTable.
38 static createDataTable() {
39 return new JsObject(gviz['DataTable']);
40 }
41
42 /// Add a column to [dataTable] with [type] and [label].
43 static addColumn(var dataTable, String type, String label) {
44 dataTable.callMethod('addColumn', [type, label]);
45 }
46
47 static addAnnotationColumn(var dataTable, String type, String label) {
48 dataTable.callMethod('addColumn', [new JsObject.jsify({
49 'type': type,
50 'label': label,
51 'role': 'annotation',
52 })]);
53 }
54
55 static addIntervalColumn(var dataTable, String type, String label) {
56 dataTable.callMethod('addColumn', [new JsObject.jsify({
57 'type': type,
58 'label': label,
59 'role': 'interval',
60 })]);
61 }
62
63 static clearRows(var dataTable) {
64 var rows = dataTable.callMethod('getNumberOfRows');
65 dataTable.callMethod('removeRows', [0, rows]);
66 }
67
68 static addRow(var dataTable, List row) {
69 dataTable.callMethod('addRow', [new JsArray.from(row)]);
70 }
71
72 static bool hasRows(var dataTable) {
73 var rows = dataTable.callMethod('getNumberOfRows');
74 return rows > 0;
75 }
76
77 static int numRows(var dataTable) {
78 return dataTable.callMethod('getNumberOfRows');
79 }
80
81 static bool hasColumns(var dataTable) {
82 var cols = dataTable.callMethod('getNumberOfColumns');
83 return cols > 0;
84 }
85
86 static int numColumns(var dataTable) {
87 return dataTable.callMethod('getNumberOfColumns');
88 }
89
90 static refreshTableChartDrawOptions(var chart, var options) {
91 var props = chart.callMethod('getSortInfo');
92 if (props != null) {
93 options['sortColumn'] = props['column'];
94 options['sortAscending'] = props['ascending'];
95 }
96 }
97
98 static draw(var chart, var table, var options) {
99 chart.callMethod('draw', [table, options]);
100 }
101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698