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

Unified Diff: packages/charted/lib/core/text_metrics.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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
Index: packages/charted/lib/core/text_metrics.dart
diff --git a/packages/charted/lib/core/text_metrics.dart b/packages/charted/lib/core/text_metrics.dart
index 59335947249dcf8d388fd5411fbb853c091f8aef..9fb7d06d93eba4c4c4c818f5984f03f9af8cdede 100644
--- a/packages/charted/lib/core/text_metrics.dart
+++ b/packages/charted/lib/core/text_metrics.dart
@@ -57,17 +57,17 @@ class TextMetrics {
double getTextWidth(String text, {String fontStyle}) {
assert(text.length <= MAX_STRING_LENGTH);
setFontStyle(fontStyle);
- return context.measureText(text).width;
+ return context.measureText(text).width.toDouble();
}
/// Gets length of the longest string in the given [strings].
/// Optionally, uses [fontStyle] instead of using the default style.
double getLongestTextWidth(Iterable<String> strings, {String fontStyle}) {
setFontStyle(fontStyle);
- double maxWidth = 0.0;
+ num maxWidth = 0.0;
for (int i = 0; i < strings.length; ++i) {
assert(strings.elementAt(i).length <= MAX_STRING_LENGTH);
- double width = context.measureText(strings.elementAt(i)).width;
+ double width = context.measureText(strings.elementAt(i)).width.toDouble();
if (width > maxWidth) {
maxWidth = width;
}
@@ -79,14 +79,16 @@ class TextMetrics {
/// Truncates given [text] to fit in [width]. Adds an ellipsis to the
/// returned string, if it needed to be truncated.
/// Optionally, uses [fontStyle] instead of using the default style.
- String ellipsizeText(String text, double width, {String fontStyle}) {
+ String ellipsizeText(String text, num width, {String fontStyle}) {
assert(text.length <= MAX_STRING_LENGTH);
setFontStyle(fontStyle);
- double computedWidth = context.measureText(text).width;
+ double computedWidth = context.measureText(text).width.toDouble();
if (computedWidth > width) {
var indices = graphemeBreakIndices(text);
var position = 0,
- min = 0, max = indices.length - 1, mid,
+ min = 0,
+ max = indices.length - 1,
+ mid,
ellipsis = context.measureText('…').width;
width = width - ellipsis;
while (max >= min) {
@@ -108,6 +110,5 @@ class TextMetrics {
/// if it had to be truncated.
/// Calling this method may force a layout on the document. For better
/// performance, use [TextMetrics.ellipsizeText].
- static ellipsizeTextElement() {
- }
+ static ellipsizeTextElement() {}
}
« no previous file with comments | « packages/charted/lib/core/scales/time_scale.dart ('k') | packages/charted/lib/core/text_metrics/segmentation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698