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

Side by Side Diff: runtime/observatory/lib/src/elements/isolate_summary.dart

Issue 2217723004: Converted Observatory isolate-summary element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Removed patch file Created 4 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library isolate_summary_element; 5 library isolate_summary_element;
6 6
7 import 'dart:html';
8 import 'observatory_element.dart'; 7 import 'observatory_element.dart';
9 import 'package:charted/charted.dart';
10 import "package:charted/charts/charts.dart";
11 import 'package:observatory/service.dart'; 8 import 'package:observatory/service.dart';
12 import 'package:polymer/polymer.dart'; 9 import 'package:polymer/polymer.dart';
13 10
14 @CustomTag('isolate-summary') 11 @CustomTag('isolate-summary')
15 class IsolateSummaryElement extends ObservatoryElement { 12 class IsolateSummaryElement extends ObservatoryElement {
16 IsolateSummaryElement.created() : super.created(); 13 IsolateSummaryElement.created() : super.created();
17 14
18 @published Isolate isolate; 15 @published Isolate isolate;
19 } 16 }
20 17
21 @CustomTag('isolate-run-state') 18 @CustomTag('isolate-run-state')
22 class IsolateRunStateElement extends ObservatoryElement { 19 class IsolateRunStateElement extends ObservatoryElement {
23 IsolateRunStateElement.created() : super.created(); 20 IsolateRunStateElement.created() : super.created();
24 21
25 @published Isolate isolate; 22 @published Isolate isolate;
26 } 23 }
27 24
28 @CustomTag('isolate-location') 25 @CustomTag('isolate-location')
29 class IsolateLocationElement extends ObservatoryElement { 26 class IsolateLocationElement extends ObservatoryElement {
30 IsolateLocationElement.created() : super.created(); 27 IsolateLocationElement.created() : super.created();
31 28
32 @published Isolate isolate; 29 @published Isolate isolate;
33 } 30 }
34
35 @CustomTag('isolate-shared-summary')
36 class IsolateSharedSummaryElement extends ObservatoryElement {
37 IsolateSharedSummaryElement.created() : super.created();
38
39 @published Isolate isolate;
40 }
41
42 class CounterChart {
43 final HtmlElement _wrapper;
44 HtmlElement _areaHost;
45 HtmlElement _legendHost;
46 LayoutArea _area;
47 ChartData _data;
48 final _columns = [
49 new ChartColumnSpec(label: 'Type', type: ChartColumnSpec.TYPE_STRING),
50 new ChartColumnSpec(label: 'Percent', formatter: (v) => v.toString())
51 ];
52
53 CounterChart(this._wrapper) {
54 assert(_wrapper != null);
55 _areaHost = _wrapper.querySelector('.chart-host');
56 assert(_areaHost != null);
57 _areaHost.clientWidth;
58 _legendHost = _wrapper.querySelector('.chart-legend-host');
59 assert(_legendHost != null);
60 var series = new ChartSeries("Work", [1], new PieChartRenderer(
61 sortDataByValue: false
62 ));
63 var config = new ChartConfig([series], [0]);
64 config.minimumSize = new Rect(200, 200);
65 config.legend = new ChartLegend(_legendHost, showValues: true);
66 _data = new ChartData(_columns, []);
67 _area = new LayoutArea(_areaHost,
68 _data,
69 config,
70 state: new ChartState(),
71 autoUpdate: false);
72 _area.addChartBehavior(new Hovercard());
73 _area.addChartBehavior(new AxisLabelTooltip());
74 }
75
76 void update(Map counters) {
77 var rows = [];
78 for (var key in counters.keys) {
79 var value = double.parse(counters[key].split('%')[0]);
80 rows.add([key, value]);
81 }
82 _area.data = new ChartData(_columns, rows);
83 _area.draw();
84 }
85 }
86
87 @CustomTag('isolate-counter-chart')
88 class IsolateCounterChartElement extends ObservatoryElement {
89 IsolateCounterChartElement.created() : super.created();
90
91 @published ObservableMap counters;
92 CounterChart chart;
93
94 attached() {
95 super.attached();
96 chart =
97 new CounterChart(shadowRoot.querySelector('#isolate-counter-chart'));
98 }
99
100 detached() {
101 super.detached();
102 var host = shadowRoot.querySelector('#isolate-counter-chart-host');
103 host.children.clear();
104 var legendHost =
105 shadowRoot.querySelector('#isolate-counter-chart-legend-host');
106 legendHost.children.clear();
107 }
108
109 void countersChanged(oldValue) {
110 if (counters == null) {
111 return;
112 }
113 if (chart == null) {
114 return;
115 }
116 chart.update(counters);
117 }
118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698