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

Unified Diff: packages/charted/lib/charts/behaviors/hovercard.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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
Index: packages/charted/lib/charts/behaviors/hovercard.dart
diff --git a/packages/charted/lib/charts/behaviors/hovercard.dart b/packages/charted/lib/charts/behaviors/hovercard.dart
index 3654ea84aad5b1c61adfee68792be424aa474f0d..e60cb45f2f2ada8c466794d09f235385279c8cd1 100644
--- a/packages/charted/lib/charts/behaviors/hovercard.dart
+++ b/packages/charted/lib/charts/behaviors/hovercard.dart
@@ -51,6 +51,7 @@ typedef Element HovercardBuilder(int column, int row);
/// single row. Eg: Would not work with a water-fall chart.
///
class Hovercard implements ChartBehavior {
+ static const _HOVERCARD_OFFSET = 20;
final HovercardBuilder builder;
bool _isMouseTracking;
@@ -66,7 +67,6 @@ class Hovercard implements ChartBehavior {
'left',
'orientation'
];
- int offset = 20;
ChartArea _area;
ChartState _state;
@@ -181,7 +181,7 @@ class Hovercard implements ChartBehavior {
}
void _positionAtMousePointer(ChartEvent e) =>
- _positionAtPoint(e.chartX, e.chartY, offset, offset, false, false);
+ _positionAtPoint(e.chartX, e.chartY, _HOVERCARD_OFFSET, _HOVERCARD_OFFSET, false, false);
void _positionOnLayout(column, row) {
// Currently for layouts, when hovercard is triggered due to change
@@ -198,7 +198,7 @@ class Hovercard implements ChartBehavior {
var dimensionCol = area.config.dimensions.first,
dimensionScale = area.dimensionScales.first,
measureScale = _getScaleForColumn(column),
- dimensionOffset = this.offset,
+ dimensionOffset = _HOVERCARD_OFFSET,
dimensionCenterOffset = 0;
// If we are using bands on the one axis that is shown
@@ -228,16 +228,18 @@ class Hovercard implements ChartBehavior {
});
} else {
var value = rowData.elementAt(column);
- isNegative = value < 0;
- measurePosition = measureScale.scale(rowData.elementAt(column));
+ if (value != null) {
+ isNegative = value < 0;
+ measurePosition = measureScale.scale(value);
+ }
}
if (area.config.isLeftAxisPrimary) {
- _positionAtPoint(measurePosition, dimensionPosition, 0, dimensionOffset,
- isNegative, true);
+ _positionAtPoint(measurePosition, dimensionPosition, _HOVERCARD_OFFSET,
+ dimensionOffset, isNegative, true);
} else {
- _positionAtPoint(dimensionPosition, measurePosition, dimensionOffset, 0,
- isNegative, false);
+ _positionAtPoint(dimensionPosition, measurePosition, dimensionOffset,
+ _HOVERCARD_OFFSET, isNegative, false);
}
}
@@ -288,8 +290,8 @@ class Hovercard implements ChartBehavior {
// Check if the popup is contained in the RenderArea.
// If not, try other placements.
- if (top > 0 &&
- left > 0 &&
+ if (top >= 0 &&
+ left >= 0 &&
top + height < renderAreaHeight &&
left + width < renderAreaWidth) {
break;

Powered by Google App Engine
This is Rietveld 408576698