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

Unified Diff: charted/lib/svg/shapes/line.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « charted/lib/svg/shapes/area.dart ('k') | charted/lib/svg/shapes/rect.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: charted/lib/svg/shapes/line.dart
diff --git a/charted/lib/svg/shapes/line.dart b/charted/lib/svg/shapes/line.dart
deleted file mode 100644
index 8b663ec5b0b41957e8000bcc1fc03568d4242dec..0000000000000000000000000000000000000000
--- a/charted/lib/svg/shapes/line.dart
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// Copyright 2014 Google Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file or at
-// https://developers.google.com/open-source/licenses/bsd
-//
-
-part of charted.svg.shapes;
-
-/// Function to convert a list of points to path.
-typedef String LineInterpolator(Iterable<math.Point> points, int tension);
-
-///
-/// [SvgLine] provides a data-driven way to create path descriptions
-/// that can be used to draw lines.
-///
-class SvgLine implements SvgShape {
- static const LINE_INTERPOLATOR_LINEAR = 'linear';
-
- static final LINE_INTERPOLATORS = {
- LINE_INTERPOLATOR_LINEAR: _linear
- };
-
- /// Callback to access/convert datum to x coordinate value.
- final SelectionValueAccessor<num> xValueAccessor;
-
- /// Callback to access/convert datum to y coordinate value.
- final SelectionValueAccessor<num> yValueAccessor;
-
- /// Callback that is used to determine if a value is considered valid.
- /// If [isDefined] returns false at any time, the value isn't part
- /// of the line - the line would be split.
- final SelectionCallback<bool> isDefined;
-
- /// Interpolator that is used for creating the path.
- final LineInterpolator interpolator;
-
- /// Tension of the line, as used by a few interpolators.
- final int tension;
-
- SvgLine({
- this.xValueAccessor: defaultDataToX,
- this.yValueAccessor: defaultDataToY,
- this.isDefined: defaultIsDefined,
- this.tension: 0,
- String interpolate: LINE_INTERPOLATOR_LINEAR })
- : interpolator = LINE_INTERPOLATORS[interpolate] {
- assert(interpolator != null);
- }
-
- /// Generates path for drawing a line based in the selected [interpolator]
- @override
- String path(data, int index, Element e) {
- assert(data is Iterable);
- var segments = new StringBuffer(),
- points = [];
- for (int i = 0, len = data.length; i < len; ++i) {
- final d = data.elementAt(i);
- if (isDefined(d, i, e)) {
- points.add(new math.Point(xValueAccessor(d, i), yValueAccessor(d, i)));
- } else if (points.isNotEmpty){
- segments.write('M${interpolator(points, tension)}');
- points.clear();
- }
- }
- if (points.isNotEmpty) {
- segments.write('M${interpolator(points, tension)}');
- }
- return segments.toString();
- }
-
- /// Default implementation of [xValueAccessor].
- /// Returns the first element if [d] is an iterable, otherwise returns [d].
- static num defaultDataToX(d, i) => d is Iterable ? d.first : d;
-
- /// Default implementation of [yValueAccessor].
- /// Returns the second element if [d] is an iterable, otherwise returns [d].
- static num defaultDataToY(d, i) => d is Iterable ? d.elementAt(1) : d;
-
- /// Default implementation of [isDefined].
- /// Returns true for all non-null values of [d].
- static bool defaultIsDefined(d, i, e) => d != null;
-
- /// Linear interpolator.
- static String _linear(Iterable points, _) =>
- points.map((pt) => '${pt.x},${pt.y}').join('L');
-}
« no previous file with comments | « charted/lib/svg/shapes/area.dart ('k') | charted/lib/svg/shapes/rect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698