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

Unified Diff: samples/total/client/ClientChart.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/total/client/Chart.dart ('k') | samples/total/client/ColorPicker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/total/client/ClientChart.dart
===================================================================
--- samples/total/client/ClientChart.dart (revision 9011)
+++ samples/total/client/ClientChart.dart (working copy)
@@ -1,112 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-class ClientChart extends Chart {
-
- static final List<String> _strokeColors =
- const ["#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff", "#00ffff", "#000000"];
-
- CanvasElement _canvas;
-
- ClientChart(this._canvas) : super() { }
-
- void render() { }
-}
-
-class ClientLineChart extends ClientChart {
-
- ClientLineChart(CanvasElement canvas) : super(canvas) {
- _width = _canvas.width;
- _height = _canvas.height;
- }
-
- void render() {
- CanvasRenderingContext2D ctx = _canvas.getContext("2d");
- ctx.setFillColor("#ffffff");
- ctx.clearRect(0, 0, _width, _height);
-
- int tickStep;
- int tickMin;
- int tickMax;
-
- double range = _maxValue - _minValue;
- if (range == 0) {
- tickStep = 1;
- int m = _minValue.floor().toInt();
- tickMin = m - 5;
- tickMax = m + 5;
- } else {
- double log10Range = Math.log(range) / Math.log(10.0);
- tickStep = Math.pow(10.0, (log10Range).floor()).toInt() ~/ 2;
- tickMin = (_minValue / tickStep).floor().toInt() * tickStep;
- tickMax = (_maxValue / tickStep).floor().toInt() * tickStep;
- }
-
- int padding = 30;
-
- ctx.font = "Gill Sans 8px";
- ctx.lineWidth = 1.0;
-
- ctx.setStrokeColor("#000000");
- ctx.beginPath();
- ctx.moveTo(padding, padding);
- ctx.lineTo(padding, height - padding);
- ctx.lineTo(width - padding, height - padding);
- ctx.stroke();
-
- int scaleY = (height - 2 * padding) ~/ range;
- double zeroY = (height - padding) - ((0.0 - _minValue) * scaleY);
- if (zeroY >= padding && zeroY <= height - padding) {
- ctx.beginPath();
- ctx.moveTo(padding, zeroY);
- ctx.lineTo(width - padding, zeroY);
- ctx.stroke();
-
- double textWidth = ctx.measureText("0").width.toDouble();
- ctx.fillText("0", padding - textWidth, zeroY);
- }
-
- int tickLen = 6;
- for (int tick = tickMin; tick <= tickMax; tick += tickStep) {
- double y = (height - padding) - ((tick - _minValue) * scaleY);
- if (y >= padding && y <= height - padding) {
- ctx.beginPath();
- ctx.moveTo(padding - tickLen / 2, y);
- ctx.lineTo(padding + tickLen / 2, y);
- ctx.stroke();
-
- String label = tick.toString();
- double textWidth = ctx.measureText(label).width.toDouble();
- ctx.fillText(label, padding - textWidth, y);
- }
- }
-
- for (int tick = padding; tick <= width - padding; tick += 50) {
- ctx.beginPath();
- ctx.moveTo(tick, height - padding - tickLen / 2);
- ctx.lineTo(tick, height - padding + tickLen / 2);
- ctx.stroke();
- }
-
- for (int col = _firstCol; col <= _lastCol; col++) {
- List<double> data = getSeries(col);
- int scaleX = (width - 2 * padding) ~/ data.length;
- scaleY = (height - 2 * padding) ~/ range;
-
- ctx.setStrokeColor(_strokeColors[col - _firstCol]);
- ctx.beginPath();
-
- for (int row = 0; row < data.length; row++) {
- double x = row * scaleX + padding;
- double y = (height - padding) - ((data[row] - _minValue) * scaleY);
- if (row == 0) {
- ctx.moveTo(x, y);
- } else {
- ctx.lineTo(x, y);
- }
- }
- ctx.stroke();
- }
- }
-}
« no previous file with comments | « samples/total/client/Chart.dart ('k') | samples/total/client/ColorPicker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698