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

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, 3 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 /// Remove [count] columns starting with [start].
70 void removeRows(int start, int end) { 70 void removeColumns(int start, int count) {
71 _table.callMethod('removeRows', [start, end]); 71 _table.callMethod('removeColumns', [start, count]);
72 }
73
74 /// Remove all columns in the table.
75 void clearColumns() {
76 removeColumns(0, columns);
77 }
78
79 /// Remove [count] rows starting with [start].
80 void removeRows(int start, int count) {
81 _table.callMethod('removeRows', [start, count]);
72 } 82 }
73 83
74 /// Remove all rows in the table. 84 /// Remove all rows in the table.
75 void clearRows() { 85 void clearRows() {
76 removeRows(0, rows); 86 removeRows(0, rows);
77 } 87 }
78 88
79 /// Adds a new row to the table. [row] must have an entry for each 89 /// Adds a new row to the table. [row] must have an entry for each
80 /// column in the table. 90 /// column in the table.
81 void addRow(List row) { 91 void addRow(List row) {
82 _table.callMethod('addRow', [new JsArray.from(row)]); 92 _table.callMethod('addRow', [new JsArray.from(row)]);
83 } 93 }
94
95 void addTimeOfDayValue(DateTime dt, value) {
96 var array = new JsArray.from([dt.hour, dt.minute, dt.second]);
97 addRow([array, value]);
98 }
84 } 99 }
85 100
86 class Chart { 101 class Chart {
87 var _chart; 102 var _chart;
88 final Map options = new Map(); 103 final Map options = new Map();
89 104
90 /// Create a Google Chart of [chartType]. e.g. 'Table', 'AreaChart', 105 /// Create a Google Chart of [chartType]. e.g. 'Table', 'AreaChart',
91 /// 'BarChart', the chart is rendered inside [element]. 106 /// 'BarChart', the chart is rendered inside [element].
92 Chart(String chartType, Element element) { 107 Chart(String chartType, Element element) {
93 _chart = new JsObject(GoogleChart.api[chartType], [element]); 108 _chart = new JsObject(GoogleChart.api[chartType], [element]);
(...skipping 10 matching lines...) Expand all
104 options['sortAscending'] = props['ascending']; 119 options['sortAscending'] = props['ascending'];
105 } 120 }
106 } 121 }
107 122
108 /// Draw this chart using [table] and the current [options]. 123 /// Draw this chart using [table] and the current [options].
109 void draw(DataTable table) { 124 void draw(DataTable table) {
110 var jsOptions = new JsObject.jsify(options); 125 var jsOptions = new JsObject.jsify(options);
111 _chart.callMethod('draw', [table._table, jsOptions]); 126 _chart.callMethod('draw', [table._table, jsOptions]);
112 } 127 }
113 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698