| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:html'; | 5 import 'dart:html'; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:charted/charted.dart'; | 7 import 'package:charted/charted.dart'; |
| 8 import "package:charted/charts/charts.dart"; | 8 import "package:charted/charts/charts.dart"; |
| 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 10 import 'package:observatory/src/elements/helpers/tag.dart'; | 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 @override | 41 @override |
| 42 void detached() { | 42 void detached() { |
| 43 super.detached(); | 43 super.detached(); |
| 44 children = []; | 44 children = []; |
| 45 _r.disable(notify: true); | 45 _r.disable(notify: true); |
| 46 _subscription.cancel(); | 46 _subscription.cancel(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 static final _columns = [ |
| 50 new ChartColumnSpec(label: 'Type', type: ChartColumnSpec.TYPE_STRING), |
| 51 new ChartColumnSpec(label: 'Percent', formatter: (v) => v.toString()) |
| 52 ]; |
| 53 |
| 54 final _series = [new ChartSeries("Work", const [1], new PieChartRenderer( |
| 55 sortDataByValue: false |
| 56 ))]; |
| 57 |
| 49 void render() { | 58 void render() { |
| 50 var areaHost; | 59 final areaHost = new DivElement()..classes = const ['host']; |
| 51 var legendHost; | 60 final legendHost = new DivElement()..classes = const ['legend']; |
| 52 children = [ | 61 children = [areaHost, legendHost]; |
| 53 areaHost = new DivElement()..classes = ['host'], | 62 final rect = areaHost.getBoundingClientRect(); |
| 54 legendHost = new DivElement()..classes = ['legend'] | 63 final minSize = new Rect.size(rect.width, rect.height); |
| 55 ]; | 64 final config = new ChartConfig(_series, const [0]) |
| 56 final series = new ChartSeries("Work", [1], new PieChartRenderer( | |
| 57 sortDataByValue: false | |
| 58 )); | |
| 59 var rect = areaHost.getBoundingClientRect(); | |
| 60 var minSize = new Rect.size(rect.width, rect.height); | |
| 61 final config = new ChartConfig([series], [0]) | |
| 62 ..minimumSize = minSize | 65 ..minimumSize = minSize |
| 63 ..legend = new ChartLegend(legendHost, showValues: true); | 66 ..legend = new ChartLegend(legendHost, showValues: true); |
| 64 final data = new ChartData([ | 67 final data = new ChartData(_columns, _counters.keys |
| 65 new ChartColumnSpec(label: 'Type', type: ChartColumnSpec.TYPE_STRING), | |
| 66 new ChartColumnSpec(label: 'Percent', formatter: (v) => v.toString()) | |
| 67 ], _counters.keys | |
| 68 .map((key) => [key, double.parse(_counters[key].split('%')[0])]) | 68 .map((key) => [key, double.parse(_counters[key].split('%')[0])]) |
| 69 .toList()); | 69 .toList()); |
| 70 | 70 |
| 71 new LayoutArea(areaHost, data, config, state: new ChartState(), | 71 new LayoutArea(areaHost, data, config, state: new ChartState(), |
| 72 autoUpdate: true) | 72 autoUpdate: false) |
| 73 ..addChartBehavior(new Hovercard()) | 73 ..addChartBehavior(new Hovercard()) |
| 74 ..addChartBehavior(new AxisLabelTooltip()) | 74 ..addChartBehavior(new AxisLabelTooltip()) |
| 75 ..draw(); | 75 ..draw(); |
| 76 } | 76 } |
| 77 } | 77 } |
| OLD | NEW |