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

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

Issue 457803002: Initial UI for Metrics in Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of app; 5 part of app;
6 6
7 class GoogleChart { 7 class GoogleChart {
8 static var _api; 8 static var _api;
9 9
10 /// Get access to the JsObject containing the Google Chart API: 10 /// Get access to the JsObject containing the Google Chart API:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 /// Number of rows. 49 /// Number of rows.
50 int get rows => _table.callMethod('getNumberOfRows'); 50 int get rows => _table.callMethod('getNumberOfRows');
51 51
52 /// Add a new column with [type] and [label]. 52 /// Add a new column with [type] and [label].
53 /// type must be: 'string', 'number', or 'boolean'. 53 /// type must be: 'string', 'number', or 'boolean'.
54 void addColumn(String type, String label) { 54 void addColumn(String type, String label) {
55 _table.callMethod('addColumn', [type, label]); 55 _table.callMethod('addColumn', [type, label]);
56 } 56 }
57 57
58 /// Add a new column with [type], [label] and [role]. 58 /// Add a new column with [type], [label] and [role].
59 /// Roles are used for metadata such as 'interval' or 'annotation'. 59 /// Roles are used for metadata such as 'interval', 'annotation', or 'domain'.
60 /// type must be: 'string', 'number', or 'boolean'. 60 /// type must be: 'string', 'number', or 'boolean'.
61 void addRoleColumn(String type, String label, String role) { 61 void addRoleColumn(String type, String label, String role) {
62 _table.callMethod('addColumn', [new JsObject.jsify({ 62 _table.callMethod('addColumn', [new JsObject.jsify({
63 'type': type, 63 'type': type,
64 'label': label, 64 'label': label,
65 'role': role, 65 'role': role,
66 })]); 66 })]);
67 } 67 }
68 68
69 /// Remove rows [start, end). 69 int findColumnIndexWithLabel(String label) {
koda 2014/08/11 16:34:53 Is this used? Implementation suggests not.
Cutch 2014/08/27 22:25:39 Done.
70 void removeRows(int start, int end) { 70 return 0;
71 _table.callMethod('removeRows', [start, end]); 71 }
72
73 /// Remove [count] columns starting with [start].
74 void removeColumns(int start, int count) {
75 _table.callMethod('removeColumns', [start, count]);
76 }
77
78 /// Remove all columns in the table.
79 void clearColumns() {
80 removeColumns(0, columns);
81 }
82
83 /// Remove [count] rows starting with [start].
84 void removeRows(int start, int count) {
85 _table.callMethod('removeRows', [start, count]);
72 } 86 }
73 87
74 /// Remove all rows in the table. 88 /// Remove all rows in the table.
75 void clearRows() { 89 void clearRows() {
76 removeRows(0, rows); 90 removeRows(0, rows);
77 } 91 }
78 92
79 /// Adds a new row to the table. [row] must have an entry for each 93 /// Adds a new row to the table. [row] must have an entry for each
80 /// column in the table. 94 /// column in the table.
81 void addRow(List row) { 95 void addRow(List row) {
82 _table.callMethod('addRow', [new JsArray.from(row)]); 96 _table.callMethod('addRow', [new JsArray.from(row)]);
83 } 97 }
98
99 void addTimeOfDayValue(DateTime dt, value) {
100 var array = new JsArray.from([dt.hour, dt.minute, dt.second]);
101 addRow([array, value]);
102 }
84 } 103 }
85 104
86 class Chart { 105 class Chart {
87 var _chart; 106 var _chart;
88 final Map options = new Map(); 107 final Map options = new Map();
89 108
90 /// Create a Google Chart of [chartType]. e.g. 'Table', 'AreaChart', 109 /// Create a Google Chart of [chartType]. e.g. 'Table', 'AreaChart',
91 /// 'BarChart', the chart is rendered inside [element]. 110 /// 'BarChart', the chart is rendered inside [element].
92 Chart(String chartType, Element element) { 111 Chart(String chartType, Element element) {
93 _chart = new JsObject(GoogleChart.api[chartType], [element]); 112 _chart = new JsObject(GoogleChart.api[chartType], [element]);
(...skipping 10 matching lines...) Expand all
104 options['sortAscending'] = props['ascending']; 123 options['sortAscending'] = props['ascending'];
105 } 124 }
106 } 125 }
107 126
108 /// Draw this chart using [table] and the current [options]. 127 /// Draw this chart using [table] and the current [options].
109 void draw(DataTable table) { 128 void draw(DataTable table) {
110 var jsOptions = new JsObject.jsify(options); 129 var jsOptions = new JsObject.jsify(options);
111 _chart.callMethod('draw', [table._table, jsOptions]); 130 _chart.callMethod('draw', [table._table, jsOptions]);
112 } 131 }
113 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698