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

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

Issue 1310153002: Switch from Google charts to Charted (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 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';
7 import 'observatory_element.dart'; 8 import 'observatory_element.dart';
8 import 'package:observatory/app.dart'; 9 import 'package:charted/charted.dart';
10 import "package:charted/charts/charts.dart";
9 import 'package:observatory/service.dart'; 11 import 'package:observatory/service.dart';
10 import 'package:polymer/polymer.dart'; 12 import 'package:polymer/polymer.dart';
11 13
12 @CustomTag('isolate-summary') 14 @CustomTag('isolate-summary')
13 class IsolateSummaryElement extends ObservatoryElement { 15 class IsolateSummaryElement extends ObservatoryElement {
14 IsolateSummaryElement.created() : super.created(); 16 IsolateSummaryElement.created() : super.created();
15 17
16 @published Isolate isolate; 18 @published Isolate isolate;
17 } 19 }
18 20
(...skipping 12 matching lines...) Expand all
31 } 33 }
32 34
33 @CustomTag('isolate-shared-summary') 35 @CustomTag('isolate-shared-summary')
34 class IsolateSharedSummaryElement extends ObservatoryElement { 36 class IsolateSharedSummaryElement extends ObservatoryElement {
35 IsolateSharedSummaryElement.created() : super.created(); 37 IsolateSharedSummaryElement.created() : super.created();
36 38
37 @published Isolate isolate; 39 @published Isolate isolate;
38 } 40 }
39 41
40 class CounterChart { 42 class CounterChart {
41 var _table = new DataTable(); 43 final HtmlElement _wrapper;
42 var _chart; 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 }
43 75
44 void update(Map counters) { 76 void update(Map counters) {
45 if (_table.columns == 0) { 77 var rows = [];
46 // Initialize.
47 _table.addColumn('string', 'Name');
48 _table.addColumn('number', 'Value');
49 }
50 _table.clearRows();
51 for (var key in counters.keys) { 78 for (var key in counters.keys) {
52 var value = double.parse(counters[key].split('%')[0]); 79 var value = double.parse(counters[key].split('%')[0]);
53 _table.addRow([key, value]); 80 rows.add([key, value]);
54 } 81 }
55 } 82 _area.data = new ChartData(_columns, rows);
56 83 _area.draw();
57 void draw(var element) {
58 if (_chart == null) {
59 assert(element != null);
60 _chart = new Chart('PieChart', element);
61 }
62 _chart.draw(_table);
63 } 84 }
64 } 85 }
65 86
66 @CustomTag('isolate-counter-chart') 87 @CustomTag('isolate-counter-chart')
67 class IsolateCounterChartElement extends ObservatoryElement { 88 class IsolateCounterChartElement extends ObservatoryElement {
68 IsolateCounterChartElement.created() : super.created(); 89 IsolateCounterChartElement.created() : super.created();
69 90
70 @published ObservableMap counters; 91 @published ObservableMap counters;
71 CounterChart chart; 92 CounterChart chart;
72 93
94 attached() {
95 super.attached();
96 chart =
97 new CounterChart(shadowRoot.querySelector('#isolate-counter-chart'));
98 }
99
73 void countersChanged(oldValue) { 100 void countersChanged(oldValue) {
74 if (counters == null) { 101 if (counters == null) {
75 return; 102 return;
76 } 103 }
77 // Lazily create the chart.
78 if (GoogleChart.ready && chart == null) {
79 chart = new CounterChart();
80 }
81 if (chart == null) { 104 if (chart == null) {
82 return; 105 return;
83 } 106 }
84 chart.update(counters); 107 chart.update(counters);
85 var element = shadowRoot.querySelector('#counterPieChart');
86 if (element != null) {
87 chart.draw(element);
88 }
89 } 108 }
90 } 109 }
91
92
93
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/heap_profile.html ('k') | runtime/observatory/lib/src/elements/isolate_summary.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698