Web charts common update (#111)

pull/117/head
Brett Morgan 5 years ago committed by GitHub
parent eac7833d1d
commit 3af5bbf125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1 @@
build/

@ -0,0 +1,32 @@
include: package:pedantic/analysis_options.yaml
analyzer:
# strong-mode:
# implicit-casts: false
# implicit-dynamic: false
linter:
rules:
- avoid_types_on_closure_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- close_sinks
# TODO(domesticmouse): rename constants
# - constant_identifier_names
- control_flow_in_finally
- empty_statements
# TODO(domesticmouse): implement hashCode methods
# - hash_and_equals
- implementation_imports
- non_constant_identifier_names
- package_api_docs
- package_names
- package_prefixed_library_names
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_new
- unnecessary_statements

@ -37,7 +37,6 @@ class BarChart extends OrdinalCartesianChart {
@override
SeriesRenderer<String> makeDefaultRenderer() {
return new BarRenderer<String>()
..rendererId = SeriesRenderer.defaultRendererId;
return BarRenderer<String>()..rendererId = SeriesRenderer.defaultRendererId;
}
}

@ -33,9 +33,9 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
static const _defaultLabelPadding = 5;
static const _defaultLabelAnchor = BarLabelAnchor.start;
static final _defaultInsideLabelStyle =
new TextStyleSpec(fontSize: 12, color: Color.white);
TextStyleSpec(fontSize: 12, color: Color.white);
static final _defaultOutsideLabelStyle =
new TextStyleSpec(fontSize: 12, color: Color.black);
TextStyleSpec(fontSize: 12, color: Color.black);
/// Configures [TextStyleSpec] for labels placed inside the bars.
final TextStyleSpec insideLabelStyleSpec;

@ -37,7 +37,7 @@ import 'base_bar_renderer_element.dart' show BaseBarRendererElement;
///
/// In grouped stacked mode, this list will contain a combination of domain
/// value and series category.
const domainValuesKey = const AttributeKey<Set>('BarLaneRenderer.domainValues');
const domainValuesKey = AttributeKey<Set>('BarLaneRenderer.domainValues');
/// Renders series data as a series of bars with lanes.
///
@ -63,17 +63,16 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
/// as the data was given to the chart. For the case where both grouping and
/// stacking are disabled, this means that bars for data later in the series
/// will be drawn "on top of" bars earlier in the series.
final _barLaneStackMap = new LinkedHashMap<String, List<AnimatedBar<D>>>();
final _barLaneStackMap = LinkedHashMap<String, List<AnimatedBar<D>>>();
/// Store a map of flags to track whether all measure values for a given
/// domain value are null, for every series on the chart.
final _allMeasuresForDomainNullMap = new LinkedHashMap<D, bool>();
final _allMeasuresForDomainNullMap = LinkedHashMap<D, bool>();
factory BarLaneRenderer({BarLaneRendererConfig config, String rendererId}) {
rendererId ??= 'bar';
config ??= new BarLaneRendererConfig();
return new BarLaneRenderer._internal(
config: config, rendererId: rendererId);
config ??= BarLaneRendererConfig();
return BarLaneRenderer._internal(config: config, rendererId: rendererId);
}
BarLaneRenderer._internal({BarLaneRendererConfig config, String rendererId})
@ -86,11 +85,11 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
_allMeasuresForDomainNullMap.clear();
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
final domainFn = series.domainFn;
final measureFn = series.rawMeasureFn;
final domainValues = new Set<D>();
final domainValues = Set<D>();
for (var barIndex = 0; barIndex < series.data.length; barIndex++) {
final domain = domainFn(barIndex);
@ -118,7 +117,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
super.update(seriesList, isAnimatingThisDraw);
// Add gray bars to render under every bar stack.
seriesList.forEach((ImmutableSeries<D> series) {
seriesList.forEach((series) {
Set<D> domainValues = series.getAttr(domainValuesKey) as Set<D>;
final domainAxis = series.getAttr(domainAxisKey) as ImmutableAxis<D>;
@ -133,14 +132,14 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
// Create a fake series for [BarLabelDecorator] to use when looking up the
// index of each datum.
final laneSeries = new MutableSeries<D>.clone(seriesList[0]);
final laneSeries = MutableSeries<D>.clone(seriesList[0]);
laneSeries.data = [];
// Don't render any labels on the swim lanes.
laneSeries.labelAccessorFn = (int index) => '';
laneSeries.labelAccessorFn = (index) => '';
var laneSeriesIndex = 0;
domainValues.forEach((D domainValue) {
domainValues.forEach((domainValue) {
// Skip adding any background bars if they will be covered up by the
// domain-spanning null bar.
if (_allMeasuresForDomainNullMap[domainValue] == true) {
@ -168,8 +167,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
barStackMapKey, () => <AnimatedBar<D>>[]);
// If we already have an AnimatingBar for that index, use it.
var animatingBar = barStackList.firstWhere(
(AnimatedBar bar) => bar.key == barKey,
var animatingBar = barStackList.firstWhere((bar) => bar.key == barKey,
orElse: () => null);
// If we don't have any existing bar element, create a new bar and have
@ -183,7 +181,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
previousBarGroupWeight: previousBarGroupWeight,
barGroupWeight: barGroupWeight,
color: (config as BarLaneRendererConfig).backgroundBarColor,
details: new BarRendererElement<D>(),
details: BarRendererElement<D>(),
domainValue: domainValue,
domainAxis: domainAxis,
domainWidth: domainAxis.rangeBand.round(),
@ -212,7 +210,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
previousBarGroupWeight: previousBarGroupWeight,
barGroupWeight: barGroupWeight,
color: (config as BarLaneRendererConfig).backgroundBarColor,
details: new BarRendererElement<D>(),
details: BarRendererElement<D>(),
domainValue: domainValue,
domainAxis: domainAxis,
domainWidth: domainAxis.rangeBand.round(),
@ -252,15 +250,15 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
// Create a fake series for [BarLabelDecorator] to use when looking up the
// index of each datum. We don't care about any other series values for
// the merged lanes, so just clone the first series.
final mergedSeries = new MutableSeries<D>.clone(seriesList[0]);
final mergedSeries = MutableSeries<D>.clone(seriesList[0]);
mergedSeries.data = [];
// Add a label accessor that returns the empty lane label.
mergedSeries.labelAccessorFn =
(int index) => (config as BarLaneRendererConfig).emptyLaneLabel;
(index) => (config as BarLaneRendererConfig).emptyLaneLabel;
var mergedSeriesIndex = 0;
_allMeasuresForDomainNullMap.forEach((D domainValue, bool allNull) {
_allMeasuresForDomainNullMap.forEach((domainValue, allNull) {
if (allNull) {
// Add a fake datum to the series for [BarLabelDecorator].
final datum = {'index': mergedSeriesIndex};
@ -274,8 +272,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
barStackMapKey, () => <AnimatedBar<D>>[]);
// If we already have an AnimatingBar for that index, use it.
var animatingBar = barStackList.firstWhere(
(AnimatedBar bar) => bar.key == barKey,
var animatingBar = barStackList.firstWhere((bar) => bar.key == barKey,
orElse: () => null);
// If we don't have any existing bar element, create a new bar and have
@ -289,7 +286,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
previousBarGroupWeight: previousBarGroupWeight,
barGroupWeight: barGroupWeight,
color: (config as BarLaneRendererConfig).backgroundBarColor,
details: new BarRendererElement<D>(),
details: BarRendererElement<D>(),
domainValue: domainValue,
domainAxis: domainAxis,
domainWidth: domainAxis.rangeBand.round(),
@ -318,7 +315,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
previousBarGroupWeight: previousBarGroupWeight,
barGroupWeight: barGroupWeight,
color: (config as BarLaneRendererConfig).backgroundBarColor,
details: new BarRendererElement<D>(),
details: BarRendererElement<D>(),
domainValue: domainValue,
domainAxis: domainAxis,
domainWidth: domainAxis.rangeBand.round(),
@ -352,13 +349,12 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
/// Paints the current bar data on the canvas.
@override
void paint(ChartCanvas canvas, double animationPercent) {
_barLaneStackMap.forEach((String stackKey, List<AnimatedBar<D>> barStack) {
_barLaneStackMap.forEach((stackKey, barStack) {
// Turn this into a list so that the getCurrentBar isn't called more than
// once for each animationPercent if the barElements are iterated more
// than once.
List<BarRendererElement<D>> barElements = barStack
.map((AnimatedBar<D> animatingBar) =>
animatingBar.getCurrentBar(animationPercent))
.map((animatingBar) => animatingBar.getCurrentBar(animationPercent))
.toList();
paintBar(canvas, animationPercent, barElements);

@ -75,8 +75,7 @@ class BarLaneRendererConfig extends BarRendererConfig<String> {
@override
BarLaneRenderer<String> build() {
return new BarLaneRenderer<String>(
config: this, rendererId: customRendererId);
return BarLaneRenderer<String>(config: this, rendererId: customRendererId);
}
@override

@ -52,8 +52,8 @@ class BarRenderer<D>
factory BarRenderer({BarRendererConfig config, String rendererId}) {
rendererId ??= 'bar';
config ??= new BarRendererConfig();
return new BarRenderer.internal(config: config, rendererId: rendererId);
config ??= BarRendererConfig();
return BarRenderer.internal(config: config, rendererId: rendererId);
}
/// This constructor is protected because it is used by child classes, which
@ -99,20 +99,20 @@ class BarRenderer<D>
Point<double> chartPosition;
if (renderingVertically) {
chartPosition = new Point<double>(
chartPosition = Point<double>(
(bounds.left + (bounds.width / 2)).toDouble(), bounds.top.toDouble());
} else {
chartPosition = new Point<double>(
chartPosition = Point<double>(
isRtl ? bounds.left.toDouble() : bounds.right.toDouble(),
(bounds.top + (bounds.height / 2)).toDouble());
}
return new DatumDetails.from(details, chartPosition: chartPosition);
return DatumDetails.from(details, chartPosition: chartPosition);
}
@override
BarRendererElement<D> getBaseDetails(dynamic datum, int index) {
return new BarRendererElement<D>();
return BarRendererElement<D>();
}
CornerStrategy get cornerStrategy {
@ -145,7 +145,7 @@ class BarRenderer<D>
int numBarGroups,
bool measureIsNull,
bool measureIsNegative}) {
return new AnimatedBar<D>(
return AnimatedBar<D>(
key: key, datum: datum, series: series, domainValue: domainValue)
..setNewTarget(makeBarRendererElement(
color: color,
@ -192,7 +192,7 @@ class BarRenderer<D>
int numBarGroups,
bool measureIsNull,
bool measureIsNegative}) {
return new BarRendererElement<D>()
return BarRendererElement<D>()
..color = color
..dashPattern = dashPattern
..fillColor = fillColor
@ -238,7 +238,7 @@ class BarRenderer<D>
if (bar != unmodifiedBar) {
bounds = renderingVertically
? new Rectangle<int>(
? Rectangle<int>(
bar.bounds.left,
max(
0,
@ -247,7 +247,7 @@ class BarRenderer<D>
bar.bounds.width,
max(0, bar.bounds.height - _stackedBarPadding),
)
: new Rectangle<int>(
: Rectangle<int>(
max(
0,
bar.bounds.left +
@ -258,7 +258,7 @@ class BarRenderer<D>
);
}
bars.add(new CanvasRect(bounds,
bars.add(CanvasRect(bounds,
dashPattern: bar.dashPattern,
fill: bar.fillColor,
pattern: bar.fillPattern,
@ -292,7 +292,7 @@ class BarRenderer<D>
roundBottomRight = renderingVertically || isRtl ? false : true;
}
final barStack = new CanvasBarStack(
final barStack = CanvasBarStack(
bars,
radius: cornerStrategy.getRadius(maxBarWidth),
stackedBarPadding: _stackedBarPadding,
@ -370,7 +370,7 @@ class BarRenderer<D>
final width = right - left;
final height = bottom - top;
return new Rectangle(left, top, width, height);
return Rectangle(left, top, width, height);
}
/// Generates a set of bounds that describe a bar.
@ -442,11 +442,11 @@ class BarRenderer<D>
Rectangle<int> bounds;
if (this.renderingVertically) {
// Rectangle clamps to zero width/height
bounds = new Rectangle<int>(domainStart, measureEnd,
domainEnd - domainStart, measureStart - measureEnd);
bounds = Rectangle<int>(domainStart, measureEnd, domainEnd - domainStart,
measureStart - measureEnd);
} else {
// Rectangle clamps to zero width/height
bounds = new Rectangle<int>(min(measureStart, measureEnd), domainStart,
bounds = Rectangle<int>(min(measureStart, measureEnd), domainStart,
(measureEnd - measureStart).abs(), domainEnd - domainStart);
}
return bounds;
@ -511,8 +511,8 @@ class BarRendererElement<D> extends BaseBarRendererElement
var left = ((targetBounds.left - previousBounds.left) * animationPercent) +
previousBounds.left;
bounds = new Rectangle<int>(left.round(), top.round(),
(right - left).round(), (bottom - top).round());
bounds = Rectangle<int>(left.round(), top.round(), (right - left).round(),
(bottom - top).round());
roundPx = localTarget.roundPx;
@ -533,7 +533,7 @@ class AnimatedBar<D> extends BaseAnimatedBar<D, BarRendererElement<D>> {
final BarRendererElement localTarget = target;
// TODO: Animate out bars in the middle of a stack.
localTarget.bounds = new Rectangle<int>(
localTarget.bounds = Rectangle<int>(
localTarget.bounds.left + (localTarget.bounds.width / 2).round(),
localTarget.measureAxisPosition.round(),
0,
@ -552,5 +552,5 @@ class AnimatedBar<D> extends BaseAnimatedBar<D, BarRendererElement<D>> {
@override
BarRendererElement<D> clone(BarRendererElement bar) =>
new BarRendererElement<D>.clone(bar);
BarRendererElement<D>.clone(bar);
}

@ -56,7 +56,7 @@ class BarRendererConfig<D> extends BaseBarRendererConfig<D> {
@override
BarRenderer<D> build() {
return new BarRenderer<D>(config: this, rendererId: customRendererId);
return BarRenderer<D>(config: this, rendererId: customRendererId);
}
@override

@ -45,13 +45,13 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
final _barGroupInnerPadding = 2;
/// Standard color for all bar target lines.
final _color = new Color(r: 0, g: 0, b: 0, a: 153);
final _color = Color(r: 0, g: 0, b: 0, a: 153);
factory BarTargetLineRenderer(
{BarTargetLineRendererConfig<D> config,
String rendererId = 'barTargetLine'}) {
config ??= new BarTargetLineRendererConfig<D>();
return new BarTargetLineRenderer._internal(
config ??= BarTargetLineRendererConfig<D>();
return BarTargetLineRenderer._internal(
config: config, rendererId: rendererId);
}
@ -64,7 +64,7 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
@override
void configureSeries(List<MutableSeries<D>> seriesList) {
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
series.colorFn ??= (_) => _color;
series.fillColorFn ??= (_) => _color;
});
@ -97,21 +97,21 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
Point<double> chartPosition;
if (renderingVertically) {
chartPosition = new Point<double>(
chartPosition = Point<double>(
(points[0].x + (points[1].x - points[0].x) / 2).toDouble(),
points[0].y.toDouble());
} else {
chartPosition = new Point<double>(points[0].x.toDouble(),
chartPosition = Point<double>(points[0].x.toDouble(),
(points[0].y + (points[1].y - points[0].y) / 2).toDouble());
}
return new DatumDetails.from(details, chartPosition: chartPosition);
return DatumDetails.from(details, chartPosition: chartPosition);
}
@override
_BarTargetLineRendererElement getBaseDetails(dynamic datum, int index) {
final BarTargetLineRendererConfig<D> localConfig = config;
return new _BarTargetLineRendererElement()
return _BarTargetLineRendererElement()
..roundEndCaps = localConfig.roundEndCaps;
}
@ -141,7 +141,7 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
double strokeWidthPx,
bool measureIsNull,
bool measureIsNegative}) {
return new _AnimatedBarTargetLine(
return _AnimatedBarTargetLine(
key: key, datum: datum, series: series, domainValue: domainValue)
..setNewTarget(makeBarRendererElement(
color: color,
@ -188,7 +188,7 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
int numBarGroups,
bool measureIsNull,
bool measureIsNegative}) {
return new _BarTargetLineRendererElement()
return _BarTargetLineRendererElement()
..color = color
..dashPattern = dashPattern
..fillColor = fillColor
@ -217,7 +217,7 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
double animationPercent,
Iterable<_BarTargetLineRendererElement> barElements,
) {
barElements.forEach((_BarTargetLineRendererElement bar) {
barElements.forEach((bar) {
// TODO: Combine common line attributes into
// GraphicsFactory.lineStyle or similar.
canvas.drawLine(
@ -299,13 +299,13 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
List<Point<int>> points;
if (renderingVertically) {
points = [
new Point<int>(domainStart, measureStart),
new Point<int>(domainEnd, measureStart)
Point<int>(domainStart, measureStart),
Point<int>(domainEnd, measureStart)
];
} else {
points = [
new Point<int>(measureStart, domainStart),
new Point<int>(measureStart, domainEnd)
Point<int>(measureStart, domainStart),
Point<int>(measureStart, domainEnd)
];
}
return points;
@ -318,13 +318,13 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
int bottom;
int left;
int right;
points.forEach((Point<int> p) {
points.forEach((p) {
top = top != null ? min(top, p.y) : p.y;
left = left != null ? min(left, p.x) : p.x;
bottom = bottom != null ? max(bottom, p.y) : p.y;
right = right != null ? max(right, p.x) : p.x;
});
return new Rectangle<int>(left, top, right - left, bottom - top);
return Rectangle<int>(left, top, right - left, bottom - top);
}
}
@ -336,7 +336,7 @@ class _BarTargetLineRendererElement extends BaseBarRendererElement {
_BarTargetLineRendererElement.clone(_BarTargetLineRendererElement other)
: super.clone(other) {
points = new List<Point<int>>.from(other.points);
points = List<Point<int>>.from(other.points);
roundEndCaps = other.roundEndCaps;
}
@ -362,7 +362,7 @@ class _BarTargetLineRendererElement extends BaseBarRendererElement {
previousPoint = previousPoints[pointIndex];
lastPoint = previousPoint;
} else {
previousPoint = new Point<int>(targetPoint.x, lastPoint.y);
previousPoint = Point<int>(targetPoint.x, lastPoint.y);
}
var x = ((targetPoint.x - previousPoint.x) * animationPercent) +
@ -372,9 +372,9 @@ class _BarTargetLineRendererElement extends BaseBarRendererElement {
previousPoint.y;
if (points.length - 1 >= pointIndex) {
points[pointIndex] = new Point<int>(x.round(), y.round());
points[pointIndex] = Point<int>(x.round(), y.round());
} else {
points.add(new Point<int>(x.round(), y.round()));
points.add(Point<int>(x.round(), y.round()));
}
}
@ -410,13 +410,13 @@ class _AnimatedBarTargetLine<D>
for (var index = 0; index < localTarget.points.length; index++) {
final targetPoint = localTarget.points[index];
newPoints.add(new Point<int>(
targetPoint.x, localTarget.measureAxisPosition.round()));
newPoints.add(
Point<int>(targetPoint.x, localTarget.measureAxisPosition.round()));
}
localTarget.points = newPoints;
}
@override
_BarTargetLineRendererElement clone(_BarTargetLineRendererElement bar) =>
new _BarTargetLineRendererElement.clone(bar);
_BarTargetLineRendererElement.clone(bar);
}

@ -57,14 +57,13 @@ class BarTargetLineRendererConfig<D> extends BaseBarRendererConfig<D> {
layoutPaintOrder: layoutPaintOrder,
minBarLengthPx: minBarLengthPx,
strokeWidthPx: strokeWidthPx,
symbolRenderer: symbolRenderer ?? new LineSymbolRenderer(),
symbolRenderer: symbolRenderer ?? LineSymbolRenderer(),
weightPattern: weightPattern,
);
@override
BarTargetLineRenderer<D> build() {
return new BarTargetLineRenderer<D>(
config: this, rendererId: customRendererId);
return BarTargetLineRenderer<D>(config: this, rendererId: customRendererId);
}
@override

@ -34,20 +34,19 @@ import 'base_bar_renderer_config.dart' show BaseBarRendererConfig;
import 'base_bar_renderer_element.dart'
show BaseAnimatedBar, BaseBarRendererElement;
const barGroupIndexKey = const AttributeKey<int>('BarRenderer.barGroupIndex');
const barGroupIndexKey = AttributeKey<int>('BarRenderer.barGroupIndex');
const barGroupCountKey = const AttributeKey<int>('BarRenderer.barGroupCount');
const barGroupCountKey = AttributeKey<int>('BarRenderer.barGroupCount');
const barGroupWeightKey =
const AttributeKey<double>('BarRenderer.barGroupWeight');
const barGroupWeightKey = AttributeKey<double>('BarRenderer.barGroupWeight');
const previousBarGroupWeightKey =
const AttributeKey<double>('BarRenderer.previousBarGroupWeight');
AttributeKey<double>('BarRenderer.previousBarGroupWeight');
const stackKeyKey = const AttributeKey<String>('BarRenderer.stackKey');
const stackKeyKey = AttributeKey<String>('BarRenderer.stackKey');
const barElementsKey =
const AttributeKey<List<BaseBarRendererElement>>('BarRenderer.elements');
AttributeKey<List<BaseBarRendererElement>>('BarRenderer.elements');
/// Base class for bar renderers that implements common stacking and grouping
/// logic.
@ -85,7 +84,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
/// as the data was given to the chart. For the case where both grouping and
/// stacking are disabled, this means that bars for data later in the series
/// will be drawn "on top of" bars earlier in the series.
final _barStackMap = new LinkedHashMap<String, List<B>>();
final _barStackMap = LinkedHashMap<String, List<B>>();
// Store a list of bar stacks that exist in the series data.
//
@ -95,7 +94,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
final _currentKeys = <String>[];
/// Stores a list of stack keys for each group key.
final _currentGroupsStackKeys = new LinkedHashMap<D, Set<String>>();
final _currentGroupsStackKeys = LinkedHashMap<D, Set<String>>();
/// Optimization for getNearest to avoid scanning all data if possible.
ImmutableAxis<D> _prevDomainAxis;
@ -105,8 +104,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
: super(
rendererId: rendererId,
layoutPaintOrder: layoutPaintOrder,
symbolRenderer:
config?.symbolRenderer ?? new RoundedRectSymbolRenderer(),
symbolRenderer: config?.symbolRenderer ?? RoundedRectSymbolRenderer(),
);
@override
@ -126,7 +124,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
final orderedSeriesList = getOrderedSeriesList(seriesList);
orderedSeriesList.forEach((MutableSeries<D> series) {
orderedSeriesList.forEach((series) {
var elements = <BaseBarRendererElement>[];
var domainFn = series.domainFn;
@ -255,7 +253,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
// Compute bar group weights.
final barWeights = _calculateBarWeights(numBarGroups);
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
series.setAttr(barGroupCountKey, numBarGroups);
if (barWeights.isNotEmpty) {
@ -290,7 +288,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
if (config.weightPattern != null) {
if (numBarGroups > config.weightPattern.length) {
throw new ArgumentError('Number of series exceeds length of weight '
throw ArgumentError('Number of series exceeds length of weight '
'pattern ${config.weightPattern}');
}
@ -327,7 +325,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
// Given that charts can only have one domain axis, just grab it from the
// first series.
final domainAxis = seriesList.first.getAttr(domainAxisKey);
domainAxis.setRangeBandConfig(new RangeBandConfig.styleAssignedPercent());
domainAxis.setRangeBandConfig(RangeBandConfig.styleAssignedPercent());
}
}
@ -337,7 +335,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
final orderedSeriesList = getOrderedSeriesList(seriesList);
orderedSeriesList.forEach((final ImmutableSeries<D> series) {
orderedSeriesList.forEach((final series) {
final domainAxis = series.getAttr(domainAxisKey) as ImmutableAxis<D>;
final domainFn = series.domainFn;
final measureAxis = series.getAttr(measureAxisKey) as ImmutableAxis<num>;
@ -384,7 +382,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
var barStackList = _barStackMap.putIfAbsent(barStackMapKey, () => []);
// If we already have an AnimatingBarfor that index, use it.
var animatingBar = barStackList.firstWhere((B bar) => bar.key == barKey,
var animatingBar = barStackList.firstWhere((bar) => bar.key == barKey,
orElse: () => null);
// If we don't have any existing bar element, create a new bar and have
@ -438,7 +436,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
// Store off stack keys for each bar group to help getNearest identify
// groups of stacks.
_currentGroupsStackKeys
.putIfAbsent(domainValue, () => new Set<String>())
.putIfAbsent(domainValue, () => <String>{})
.add(barStackMapKey);
// Get the barElement we are going to setup.
@ -469,7 +467,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
});
// Animate out bars that don't exist anymore.
_barStackMap.forEach((String key, List<B> barStackList) {
_barStackMap.forEach((key, barStackList) {
for (var barIndex = 0; barIndex < barStackList.length; barIndex++) {
final bar = barStackList[barIndex];
if (_currentKeys.contains(bar.key) != true) {
@ -541,11 +539,11 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
void paint(ChartCanvas canvas, double animationPercent) {
// Clean up the bars that no longer exist.
if (animationPercent == 1.0) {
final keysToRemove = new HashSet<String>();
final keysToRemove = HashSet<String>();
_barStackMap.forEach((String key, List<B> barStackList) {
_barStackMap.forEach((key, barStackList) {
barStackList.retainWhere(
(B bar) => !bar.animatingOut && !bar.targetBar.measureIsNull);
(bar) => !bar.animatingOut && !bar.targetBar.measureIsNull);
if (barStackList.isEmpty) {
keysToRemove.add(key);
@ -563,12 +561,12 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
});
}
_barStackMap.forEach((String stackKey, List<B> barStack) {
_barStackMap.forEach((stackKey, barStack) {
// Turn this into a list so that the getCurrentBar isn't called more than
// once for each animationPercent if the barElements are iterated more
// than once.
final barElements = barStack
.map((B animatingBar) => animatingBar.getCurrentBar(animationPercent))
.map((animatingBar) => animatingBar.getCurrentBar(animationPercent))
.toList();
if (barElements.isNotEmpty) {
@ -663,7 +661,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
? _currentGroupsStackKeys[domainValue]
: _currentGroupsStackKeys.values
.reduce((allKeys, keys) => allKeys..addAll(keys));
stackKeys?.forEach((String stackKey) {
stackKeys?.forEach((stackKey) {
if (where != null) {
matchingSegments.addAll(_barStackMap[stackKey].where(where));
} else {
@ -678,23 +676,21 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
// we can't use the optimized comparison for [OrdinalAxis].
List<DatumDetails<D>> _getVerticalDetailsForDomainValue(
D domainValue, Point<double> chartPoint) {
return new List<DatumDetails<D>>.from(_getSegmentsForDomainValue(
domainValue,
where: (BaseAnimatedBar<D, R> bar) => !bar.series.overlaySeries)
.map<DatumDetails<D>>((BaseAnimatedBar<D, R> bar) {
return List<DatumDetails<D>>.from(_getSegmentsForDomainValue(domainValue,
where: (bar) => !bar.series.overlaySeries).map<DatumDetails<D>>((bar) {
final barBounds = getBoundsForBar(bar.currentBar);
final segmentDomainDistance =
_getDistance(chartPoint.x.round(), barBounds.left, barBounds.right);
final segmentMeasureDistance =
_getDistance(chartPoint.y.round(), barBounds.top, barBounds.bottom);
final nearestPoint = new Point<double>(
final nearestPoint = Point<double>(
clamp(chartPoint.x, barBounds.left, barBounds.right).toDouble(),
clamp(chartPoint.y, barBounds.top, barBounds.bottom).toDouble());
final relativeDistance = chartPoint.distanceTo(nearestPoint);
return new DatumDetails<D>(
return DatumDetails<D>(
series: bar.series,
datum: bar.datum,
domain: bar.domainValue,
@ -707,17 +703,15 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
List<DatumDetails<D>> _getHorizontalDetailsForDomainValue(
D domainValue, Point<double> chartPoint) {
return new List<DatumDetails<D>>.from(_getSegmentsForDomainValue(
domainValue,
where: (BaseAnimatedBar<D, R> bar) => !bar.series.overlaySeries)
.map((BaseAnimatedBar<D, R> bar) {
return List<DatumDetails<D>>.from(_getSegmentsForDomainValue(domainValue,
where: (bar) => !bar.series.overlaySeries).map((bar) {
final barBounds = getBoundsForBar(bar.currentBar);
final segmentDomainDistance =
_getDistance(chartPoint.y.round(), barBounds.top, barBounds.bottom);
final segmentMeasureDistance =
_getDistance(chartPoint.x.round(), barBounds.left, barBounds.right);
return new DatumDetails<D>(
return DatumDetails<D>(
series: bar.series,
datum: bar.datum,
domain: bar.domainValue,
@ -748,7 +742,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
List<S> seriesList) {
return (renderingVertically && config.stacked)
? config.grouped
? new _ReversedSeriesIterable(seriesList)
? _ReversedSeriesIterable(seriesList)
: seriesList.reversed
: seriesList;
}
@ -763,7 +757,7 @@ class _ReversedSeriesIterable<S extends ImmutableSeries> extends Iterable<S> {
_ReversedSeriesIterable(this.seriesList);
@override
Iterator<S> get iterator => new _ReversedSeriesIterator(seriesList);
Iterator<S> get iterator => _ReversedSeriesIterator(seriesList);
}
/// Iterator that keeps reverse series order but keeps category order.

@ -82,7 +82,7 @@ abstract class BaseBarRendererConfig<D> extends LayoutViewConfig
/// Not used for stacked bars.
final List<int> weightPattern;
final rendererAttributes = new RendererAttributes();
final rendererAttributes = RendererAttributes();
BaseBarRendererConfig(
{this.customRendererId,
@ -95,7 +95,7 @@ abstract class BaseBarRendererConfig<D> extends LayoutViewConfig
this.strokeWidthPx = 0.0,
SymbolRenderer symbolRenderer,
this.weightPattern})
: this.symbolRenderer = symbolRenderer ?? new RoundedRectSymbolRenderer();
: this.symbolRenderer = symbolRenderer ?? RoundedRectSymbolRenderer();
/// Whether or not the bars should be organized into groups.
bool get grouped =>
@ -112,10 +112,8 @@ abstract class BaseBarRendererConfig<D> extends LayoutViewConfig
if (identical(this, other)) {
return true;
}
if (!(other is BaseBarRendererConfig)) {
return false;
}
return other.customRendererId == customRendererId &&
return other is BaseBarRendererConfig &&
other.customRendererId == customRendererId &&
other.dashPattern == dashPattern &&
other.fillPattern == fillPattern &&
other.groupingType == groupingType &&
@ -123,7 +121,7 @@ abstract class BaseBarRendererConfig<D> extends LayoutViewConfig
other.stackHorizontalSeparator == stackHorizontalSeparator &&
other.strokeWidthPx == strokeWidthPx &&
other.symbolRenderer == symbolRenderer &&
new ListEquality().equals(other.weightPattern, weightPattern);
ListEquality().equals(other.weightPattern, weightPattern);
}
int get hashcode {

@ -35,12 +35,11 @@ abstract class BaseBarRendererElement {
BaseBarRendererElement.clone(BaseBarRendererElement other) {
barStackIndex = other.barStackIndex;
color =
other.color != null ? new Color.fromOther(color: other.color) : null;
color = other.color != null ? Color.fromOther(color: other.color) : null;
cumulativeTotal = other.cumulativeTotal;
dashPattern = other.dashPattern;
fillColor = other.fillColor != null
? new Color.fromOther(color: other.fillColor)
? Color.fromOther(color: other.fillColor)
: null;
fillPattern = other.fillPattern;
measureAxisPosition = other.measureAxisPosition;

@ -46,9 +46,9 @@ import 'tick_formatter.dart'
show TickFormatter, OrdinalTickFormatter, NumericTickFormatter;
import 'tick_provider.dart' show TickProvider;
const measureAxisIdKey = const AttributeKey<String>('Axis.measureAxisId');
const measureAxisKey = const AttributeKey<Axis>('Axis.measureAxis');
const domainAxisKey = const AttributeKey<Axis>('Axis.domainAxis');
const measureAxisIdKey = AttributeKey<String>('Axis.measureAxisId');
const measureAxisKey = AttributeKey<Axis>('Axis.measureAxis');
const domainAxisKey = AttributeKey<Axis>('Axis.domainAxis');
/// Orientation of an Axis.
enum AxisOrientation { top, right, bottom, left }
@ -89,14 +89,8 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
/// Previous [Scale] of this axis, used to calculate tick animation.
MutableScale<D> _previousScale;
TickProvider<D> _tickProvider;
/// [TickProvider] for this axis.
TickProvider<D> get tickProvider => _tickProvider;
set tickProvider(TickProvider<D> tickProvider) {
_tickProvider = tickProvider;
}
TickProvider<D> tickProvider;
/// [TickFormatter] for this axis.
TickFormatter<D> _tickFormatter;
@ -122,9 +116,12 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
/// If the output range should be reversed.
bool reverseOutputRange = false;
/// Whether or not the axis will configure the viewport to have "niced" ticks
/// around the domain values.
bool _autoViewport = true;
/// Configures whether the viewport should be reset back to default values
/// when the domain is reset.
///
/// This should generally be disabled when the viewport will be managed
/// externally, e.g. from pan and zoom behaviors.
bool autoViewport = true;
/// If the axis line should always be drawn.
bool forceDrawAxisLine;
@ -143,7 +140,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
Rectangle<int> _componentBounds;
Rectangle<int> _drawAreaBounds;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
/// Order for chart layout painting.
///
@ -156,7 +153,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
TickFormatter<D> tickFormatter,
MutableScale<D> scale})
: this._scale = scale,
this._tickProvider = tickProvider,
this.tickProvider = tickProvider,
this._tickFormatter = tickFormatter;
@protected
@ -172,17 +169,6 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
@override
ScaleOutputExtent get range => _scale.range;
/// Configures whether the viewport should be reset back to default values
/// when the domain is reset.
///
/// This should generally be disabled when the viewport will be managed
/// externally, e.g. from pan and zoom behaviors.
set autoViewport(bool autoViewport) {
_autoViewport = autoViewport;
}
bool get autoViewport => _autoViewport;
void setRangeBandConfig(RangeBandConfig rangeBandConfig) {
mutableScale.rangeBandConfig = rangeBandConfig;
}
@ -222,7 +208,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
_scale.resetDomain();
reverseOutputRange = false;
if (_autoViewport) {
if (autoViewport) {
_scale.resetViewportSettings();
}
@ -243,7 +229,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
}
void setOutputRange(int start, int end) {
_scale.range = new ScaleOutputExtent(start, end);
_scale.range = ScaleOutputExtent(start, end);
}
/// Request update ticks from tick provider and update the painted ticks.
@ -268,7 +254,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
formatterValueCache: _formatterValueCache,
tickDrawStrategy: tickDrawStrategy,
orientation: axisOrientation,
viewportExtensionEnabled: _autoViewport);
viewportExtensionEnabled: autoViewport);
}
/// Updates the ticks that are actually used for drawing.
@ -277,7 +263,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
return;
}
final providedTicks = new List.from(_providedTicks ?? []);
final providedTicks = List.from(_providedTicks ?? []);
for (AxisTicks<D> animatedTick in _axisTicks) {
final tick = providedTicks?.firstWhere(
@ -302,7 +288,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
// Add new ticks
providedTicks?.forEach((tick) {
final animatedTick = new AxisTicks<D>(tick);
final animatedTick = AxisTicks<D>(tick);
if (_previousScale != null) {
animatedTick.animateInFrom(_previousScale[tick.value].toDouble());
}
@ -378,15 +364,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
//
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
@override
LayoutViewConfig get layoutConfig => new LayoutViewConfig(
LayoutViewConfig get layoutConfig => LayoutViewConfig(
paintOrder: layoutPaintOrder,
position: _layoutPosition,
positionOrder: LayoutViewPositionOrder.axis);
@ -457,8 +435,8 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
isVertical ? _componentBounds.top : _componentBounds.right;
final outputRange = reverseOutputRange
? new ScaleOutputExtent(outputEnd, outputStart)
: new ScaleOutputExtent(outputStart, outputEnd);
? ScaleOutputExtent(outputEnd, outputStart)
: ScaleOutputExtent(outputStart, outputEnd);
if (_scale.range != outputRange) {
_scale.range = outputRange;
@ -510,9 +488,9 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
class NumericAxis extends Axis<num> {
NumericAxis({TickProvider<num> tickProvider})
: super(
tickProvider: tickProvider ?? new NumericTickProvider(),
tickFormatter: new NumericTickFormatter(),
scale: new LinearScale(),
tickProvider: tickProvider ?? NumericTickProvider(),
tickFormatter: NumericTickFormatter(),
scale: LinearScale(),
);
void setScaleViewport(NumericExtents viewport) {
@ -529,7 +507,7 @@ class OrdinalAxis extends Axis<String> {
}) : super(
tickProvider: tickProvider ?? const OrdinalTickProvider(),
tickFormatter: tickFormatter ?? const OrdinalTickFormatter(),
scale: new SimpleOrdinalScale(),
scale: SimpleOrdinalScale(),
);
void setScaleViewport(OrdinalViewport viewport) {

@ -147,7 +147,7 @@ abstract class BaseTickDrawStrategy<D> implements TickDrawStrategy<D> {
CollisionReport collides(List<Tick<D>> ticks, AxisOrientation orientation) {
// If there are no ticks, they do not collide.
if (ticks == null) {
return new CollisionReport(
return CollisionReport(
ticksCollide: false, ticks: ticks, alternateTicksUsed: false);
}
@ -228,12 +228,12 @@ abstract class BaseTickDrawStrategy<D> implements TickDrawStrategy<D> {
}
if (collides) {
return new CollisionReport(
return CollisionReport(
ticksCollide: true, ticks: ticks, alternateTicksUsed: false);
}
}
return new CollisionReport(
return CollisionReport(
ticksCollide: false, ticks: ticks, alternateTicksUsed: false);
}
@ -245,13 +245,13 @@ abstract class BaseTickDrawStrategy<D> implements TickDrawStrategy<D> {
final maxHorizontalSliceWidth = ticks
.fold(
0.0,
(double prevMax, tick) => max(
(prevMax, tick) => max<double>(
prevMax,
tick.textElement.measurement.horizontalSliceWidth +
labelOffsetFromAxisPx))
.round();
return new ViewMeasuredSizes(
return ViewMeasuredSizes(
preferredWidth: maxHorizontalSliceWidth, preferredHeight: maxHeight);
}
@ -261,11 +261,11 @@ abstract class BaseTickDrawStrategy<D> implements TickDrawStrategy<D> {
final maxVerticalSliceWidth = ticks
.fold(
0.0,
(double prevMax, tick) =>
max(prevMax, tick.textElement.measurement.verticalSliceWidth))
(prevMax, tick) => max<double>(
prevMax, tick.textElement.measurement.verticalSliceWidth))
.round();
return new ViewMeasuredSizes(
return ViewMeasuredSizes(
preferredWidth: maxWidth,
preferredHeight: maxVerticalSliceWidth + labelOffsetFromAxisPx);
}

@ -56,7 +56,7 @@ class GridlineRendererSpec<D> extends SmallTickRendererSpec<D> {
@override
TickDrawStrategy<D> createDrawStrategy(
ChartContext context, GraphicsFactory graphicsFactory) =>
new GridlineTickDrawStrategy<D>(context, graphicsFactory,
GridlineTickDrawStrategy<D>(context, graphicsFactory,
tickLengthPx: tickLengthPx,
lineStyleSpec: lineStyle,
labelStyleSpec: labelStyle,
@ -125,34 +125,34 @@ class GridlineTickDrawStrategy<D> extends BaseTickDrawStrategy<D> {
switch (orientation) {
case AxisOrientation.top:
final x = tick.locationPx;
lineStart = new Point(x, axisBounds.bottom - tickLength);
lineEnd = new Point(x, drawAreaBounds.bottom);
lineStart = Point(x, axisBounds.bottom - tickLength);
lineEnd = Point(x, drawAreaBounds.bottom);
break;
case AxisOrientation.bottom:
final x = tick.locationPx;
lineStart = new Point(x, drawAreaBounds.top + tickLength);
lineEnd = new Point(x, axisBounds.top);
lineStart = Point(x, drawAreaBounds.top + tickLength);
lineEnd = Point(x, axisBounds.top);
break;
case AxisOrientation.right:
final y = tick.locationPx;
if (tickLabelAnchor == TickLabelAnchor.after ||
tickLabelAnchor == TickLabelAnchor.before) {
lineStart = new Point(axisBounds.right, y);
lineStart = Point(axisBounds.right, y);
} else {
lineStart = new Point(axisBounds.left + tickLength, y);
lineStart = Point(axisBounds.left + tickLength, y);
}
lineEnd = new Point(drawAreaBounds.left, y);
lineEnd = Point(drawAreaBounds.left, y);
break;
case AxisOrientation.left:
final y = tick.locationPx;
if (tickLabelAnchor == TickLabelAnchor.after ||
tickLabelAnchor == TickLabelAnchor.before) {
lineStart = new Point(axisBounds.left, y);
lineStart = Point(axisBounds.left, y);
} else {
lineStart = new Point(axisBounds.right - tickLength, y);
lineStart = Point(axisBounds.right - tickLength, y);
}
lineEnd = new Point(drawAreaBounds.right, y);
lineEnd = Point(drawAreaBounds.right, y);
break;
}

@ -42,7 +42,7 @@ class NoneRenderSpec<D> extends RenderSpec<D> {
@override
TickDrawStrategy<D> createDrawStrategy(
ChartContext context, GraphicsFactory graphicFactory) =>
new NoneDrawStrategy<D>(context, graphicFactory,
NoneDrawStrategy<D>(context, graphicFactory,
axisLineStyleSpec: axisLineStyle);
@override
@ -68,7 +68,7 @@ class NoneDrawStrategy<D> implements TickDrawStrategy<D> {
@override
CollisionReport collides(List<Tick> ticks, AxisOrientation orientation) =>
new CollisionReport(ticksCollide: false, ticks: ticks);
CollisionReport(ticksCollide: false, ticks: ticks);
@override
void decorateTicks(List<Tick> ticks) {
@ -125,12 +125,12 @@ class NoneDrawStrategy<D> implements TickDrawStrategy<D> {
@override
ViewMeasuredSizes measureHorizontallyDrawnTicks(
List<Tick> ticks, int maxWidth, int maxHeight) {
return new ViewMeasuredSizes(preferredWidth: 0, preferredHeight: 0);
return ViewMeasuredSizes(preferredWidth: 0, preferredHeight: 0);
}
@override
ViewMeasuredSizes measureVerticallyDrawnTicks(
List<Tick> ticks, int maxWidth, int maxHeight) {
return new ViewMeasuredSizes(preferredWidth: 0, preferredHeight: 0);
return ViewMeasuredSizes(preferredWidth: 0, preferredHeight: 0);
}
}

@ -57,7 +57,7 @@ class SmallTickRendererSpec<D> extends BaseRenderSpec<D> {
@override
TickDrawStrategy<D> createDrawStrategy(
ChartContext context, GraphicsFactory graphicsFactory) =>
new SmallTickDrawStrategy<D>(context, graphicsFactory,
SmallTickDrawStrategy<D>(context, graphicsFactory,
tickLengthPx: tickLengthPx,
lineStyleSpec: lineStyle,
labelStyleSpec: labelStyle,
@ -128,25 +128,25 @@ class SmallTickDrawStrategy<D> extends BaseTickDrawStrategy<D> {
switch (orientation) {
case AxisOrientation.top:
double x = tick.locationPx;
tickStart = new Point(x, axisBounds.bottom - tickLength);
tickEnd = new Point(x, axisBounds.bottom);
tickStart = Point(x, axisBounds.bottom - tickLength);
tickEnd = Point(x, axisBounds.bottom);
break;
case AxisOrientation.bottom:
double x = tick.locationPx;
tickStart = new Point(x, axisBounds.top);
tickEnd = new Point(x, axisBounds.top + tickLength);
tickStart = Point(x, axisBounds.top);
tickEnd = Point(x, axisBounds.top + tickLength);
break;
case AxisOrientation.right:
double y = tick.locationPx;
tickStart = new Point(axisBounds.left, y);
tickEnd = new Point(axisBounds.left + tickLength, y);
tickStart = Point(axisBounds.left, y);
tickEnd = Point(axisBounds.left + tickLength, y);
break;
case AxisOrientation.left:
double y = tick.locationPx;
tickStart = new Point(axisBounds.right - tickLength, y);
tickEnd = new Point(axisBounds.right, y);
tickStart = Point(axisBounds.right - tickLength, y);
tickEnd = Point(axisBounds.right, y);
break;
}

@ -54,12 +54,12 @@ class EndPointsTickProvider<D> extends BaseTickProvider<D> {
final labels = formatter.format([start, end], formatterValueCache,
stepSize: scale.domainStepSize);
ticks.add(new Tick(
ticks.add(Tick(
value: start,
textElement: graphicsFactory.createTextElement(labels[0]),
locationPx: scale[start]));
ticks.add(new Tick(
ticks.add(Tick(
value: end,
textElement: graphicsFactory.createTextElement(labels[1]),
locationPx: scale[end]));

@ -48,8 +48,7 @@ class BucketingNumericAxis extends NumericAxis {
/// [threshold] will be rendered at the baseline of the chart. The
bool _showBucket;
BucketingNumericAxis()
: super(tickProvider: new BucketingNumericTickProvider());
BucketingNumericAxis() : super(tickProvider: BucketingNumericTickProvider());
set threshold(num threshold) {
_threshold = threshold;

@ -83,7 +83,7 @@ class BucketingNumericTickProvider extends NumericTickProvider {
throw ('The showBucket flag must be set before getting ticks.');
}
final localFormatter = new _BucketingFormatter()
final localFormatter = _BucketingFormatter()
..threshold = _threshold
..originalFormatter = formatter;
@ -100,7 +100,7 @@ class BucketingNumericTickProvider extends NumericTickProvider {
assert(scale != null);
// Create a tick for the threshold.
final thresholdTick = new Tick<num>(
final thresholdTick = Tick<num>(
value: _threshold,
textElement: graphicsFactory
.createTextElement(localFormatter.formatValue(_threshold)),
@ -110,8 +110,8 @@ class BucketingNumericTickProvider extends NumericTickProvider {
tickDrawStrategy.decorateTicks(<Tick<num>>[thresholdTick]);
// Filter out ticks that sit below the threshold.
ticks.removeWhere((Tick<num> tick) =>
tick.value <= thresholdTick.value && tick.value != 0.0);
ticks.removeWhere(
(tick) => tick.value <= thresholdTick.value && tick.value != 0.0);
// Finally, add our threshold tick to the list.
ticks.add(thresholdTick);

@ -49,7 +49,7 @@ import 'linear_scale_viewport.dart' show LinearScaleViewportSettings;
class LinearScale implements NumericScale {
final LinearScaleDomainInfo _domainInfo;
final LinearScaleViewportSettings _viewportSettings;
final LinearScaleFunction _scaleFunction = new LinearScaleFunction();
final LinearScaleFunction _scaleFunction = LinearScaleFunction();
RangeBandConfig rangeBandConfig = const RangeBandConfig.none();
StepSizeConfig stepSizeConfig = const StepSizeConfig.auto();
@ -57,18 +57,18 @@ class LinearScale implements NumericScale {
bool _scaleReady = false;
LinearScale()
: _domainInfo = new LinearScaleDomainInfo(),
_viewportSettings = new LinearScaleViewportSettings();
: _domainInfo = LinearScaleDomainInfo(),
_viewportSettings = LinearScaleViewportSettings();
LinearScale._copy(LinearScale other)
: _domainInfo = new LinearScaleDomainInfo.copy(other._domainInfo),
: _domainInfo = LinearScaleDomainInfo.copy(other._domainInfo),
_viewportSettings =
new LinearScaleViewportSettings.copy(other._viewportSettings),
LinearScaleViewportSettings.copy(other._viewportSettings),
rangeBandConfig = other.rangeBandConfig,
stepSizeConfig = other.stepSizeConfig;
@override
LinearScale copy() => new LinearScale._copy(this);
LinearScale copy() => LinearScale._copy(this);
//
// Domain methods
@ -91,8 +91,8 @@ class LinearScale implements NumericScale {
}
@override
NumericExtents get dataExtent => new NumericExtents(
_domainInfo.dataDomainStart, _domainInfo.dataDomainEnd);
NumericExtents get dataExtent =>
NumericExtents(_domainInfo.dataDomainStart, _domainInfo.dataDomainEnd);
@override
num get minimumDomainStep => _domainInfo.minimumDetectedDomainStep;

@ -113,6 +113,6 @@ class LinearScaleDomainInfo {
tmpDomainEnd = _dataDomainEnd.isFinite ? _dataDomainEnd : 1.0;
}
return new NumericExtents(tmpDomainStart, tmpDomainEnd);
return NumericExtents(tmpDomainStart, tmpDomainEnd);
}
}

@ -135,7 +135,7 @@ class LinearScaleViewportSettings {
double viewportStart =
(-1.0 * translatePx / scaleScalingFactor) + domainInfo.extent.min;
_domainExtent =
new NumericExtents(viewportStart, viewportStart + viewportDomainDiff);
NumericExtents(viewportStart, viewportStart + viewportDomainDiff);
}
}
}

@ -41,7 +41,7 @@ class NumericExtents implements Extents<num> {
max = value;
}
}
return new NumericExtents(min, max);
return NumericExtents(min, max);
}
/// Returns the union of this and other.
@ -50,13 +50,13 @@ class NumericExtents implements Extents<num> {
if (max >= other.max) {
return this;
} else {
return new NumericExtents(min, other.max);
return NumericExtents(min, other.max);
}
} else {
if (other.max >= max) {
return other;
} else {
return new NumericExtents(other.min, max);
return NumericExtents(other.min, max);
}
}
}
@ -100,6 +100,6 @@ class NumericExtents implements Extents<num> {
String toString() => 'Extent($min, $max)';
static const NumericExtents unbounded =
const NumericExtents(double.negativeInfinity, double.infinity);
static const NumericExtents empty = const NumericExtents(0.0, 0.0);
NumericExtents(double.negativeInfinity, double.infinity);
static const NumericExtents empty = NumericExtents(0.0, 0.0);
}

@ -49,7 +49,7 @@ class NumericTickProvider extends BaseTickProvider<num> {
static const MIN_DIPS_BETWEEN_TICKS = 25;
/// Potential steps available to the baseTen value of the data.
static const DEFAULT_STEPS = const [
static const DEFAULT_STEPS = [
0.01,
0.02,
0.025,
@ -187,8 +187,8 @@ class NumericTickProvider extends BaseTickProvider<num> {
assert(steps != null && steps.isNotEmpty);
steps.sort();
final stepSet = new Set.from(steps);
_allowedSteps = new List<double>(stepSet.length * 3);
final stepSet = Set.from(steps);
_allowedSteps = List<double>(stepSet.length * 3);
int stepIndex = 0;
for (double step in stepSet) {
assert(1.0 <= step && step < 10.0);
@ -220,7 +220,7 @@ class NumericTickProvider extends BaseTickProvider<num> {
: (tickHint.start / stepSize).ceil()));
final tickStart =
(scale.viewportDomain.min / stepSize).ceil() * stepSize + tickZeroShift;
final stepInfo = new _TickStepInfo(stepSize.abs(), tickStart);
final stepInfo = _TickStepInfo(stepSize.abs(), tickStart);
final tickValues = _getTickValues(stepInfo, tickHint.tickCount);
// Create ticks from domain values.
@ -299,8 +299,7 @@ class NumericTickProvider extends BaseTickProvider<num> {
final tickValues = _getTickValues(stepInfo, tickCount);
if (viewportExtensionEnabled) {
mutableScale.viewportDomain =
new NumericExtents(firstTick, lastTick);
mutableScale.viewportDomain = NumericExtents(firstTick, lastTick);
}
// Create ticks from domain values.
@ -434,7 +433,7 @@ class NumericTickProvider extends BaseTickProvider<num> {
!(low < 0 &&
high > 0 &&
(negativeRegionCount == 0 || positiveRegionCount == 0)),
'Numeric tick provider cannot generate ${tickCount} '
'Numeric tick provider cannot generate $tickCount '
'ticks when the axis range contains both positive and negative '
'values. A minimum of three ticks are required to include zero.');
@ -467,7 +466,7 @@ class NumericTickProvider extends BaseTickProvider<num> {
double stepStart = negativeRegionCount > 0
? (-1 * tmpStepSize * negativeRegionCount)
: 0.0;
return new _TickStepInfo(tmpStepSize, stepStart);
return _TickStepInfo(tmpStepSize, stepStart);
}
}
} else {
@ -487,16 +486,16 @@ class NumericTickProvider extends BaseTickProvider<num> {
// But wait until the last step to prevent the cost of the formatter.
double tmpStepStart = _getStepLessThan(low, tmpStepSize);
if (tmpStepStart + (tmpStepSize * regionCount) >= high) {
return new _TickStepInfo(tmpStepSize, tmpStepStart);
return _TickStepInfo(tmpStepSize, tmpStepStart);
}
}
}
return new _TickStepInfo(1.0, low.floorToDouble());
return _TickStepInfo(1.0, low.floorToDouble());
}
List<double> _getTickValues(_TickStepInfo steps, int tickCount) {
final tickValues = new List<double>(tickCount);
final tickValues = List<double>(tickCount);
// We have our size and start, assign all the tick values to the given array.
for (int i = 0; i < tickCount; i++) {
tickValues[i] = dataToAxisUnitConverter.invert(

@ -27,11 +27,11 @@ class OrdinalExtents extends Extents<String> {
/// [D] is the domain class type for the elements in the extents.
OrdinalExtents(List<String> range) : _range = range {
// This asserts that all elements in [range] are unique.
final uniqueValueCount = new HashSet.from(_range).length;
final uniqueValueCount = HashSet.from(_range).length;
assert(uniqueValueCount == range.length);
}
factory OrdinalExtents.all(List<String> range) => new OrdinalExtents(range);
factory OrdinalExtents.all(List<String> range) => OrdinalExtents(range);
bool get isEmpty => _range.isEmpty;

@ -25,7 +25,7 @@ class OrdinalScaleDomainInfo {
int _index = 0;
/// A map of domain value and the order it was added.
final _domainsToOrder = new HashMap<String, int>();
final _domainsToOrder = HashMap<String, int>();
/// A list of domain values kept to support [getDomainAtIndex].
final _domainList = <String>[];
@ -33,7 +33,7 @@ class OrdinalScaleDomainInfo {
OrdinalScaleDomainInfo();
OrdinalScaleDomainInfo copy() {
return new OrdinalScaleDomainInfo()
return OrdinalScaleDomainInfo()
.._domainsToOrder.addAll(_domainsToOrder)
.._index = _index
.._domainList.addAll(_domainList);
@ -64,7 +64,7 @@ class OrdinalScaleDomainInfo {
bool get isEmpty => (_index == 0);
bool get isNotEmpty => !isEmpty;
OrdinalExtents get extent => new OrdinalExtents.all(_domainList);
OrdinalExtents get extent => OrdinalExtents.all(_domainList);
int get size => _index;

@ -32,12 +32,12 @@ import 'scale.dart'
/// width of the bar is [rangeBand] and the position of the bar is retrieved
/// by [[]].
class SimpleOrdinalScale implements OrdinalScale {
final _stepSizeConfig = new StepSizeConfig.auto();
final _stepSizeConfig = StepSizeConfig.auto();
OrdinalScaleDomainInfo _domain;
ScaleOutputExtent _range = new ScaleOutputExtent(0, 1);
ScaleOutputExtent _range = ScaleOutputExtent(0, 1);
double _viewportScale = 1.0;
double _viewportTranslatePx = 0.0;
RangeBandConfig _rangeBandConfig = new RangeBandConfig.styleAssignedPercent();
RangeBandConfig _rangeBandConfig = RangeBandConfig.styleAssignedPercent();
bool _scaleChanged = true;
double _cachedStepSizePixels;
@ -47,11 +47,11 @@ class SimpleOrdinalScale implements OrdinalScale {
int _viewportDataSize;
String _viewportStartingDomain;
SimpleOrdinalScale() : _domain = new OrdinalScaleDomainInfo();
SimpleOrdinalScale() : _domain = OrdinalScaleDomainInfo();
SimpleOrdinalScale._copy(SimpleOrdinalScale other)
: _domain = other._domain.copy(),
_range = new ScaleOutputExtent(other._range.start, other._range.end),
_range = ScaleOutputExtent(other._range.start, other._range.end),
_viewportScale = other._viewportScale,
_viewportTranslatePx = other._viewportTranslatePx,
_rangeBandConfig = other._rangeBandConfig;
@ -80,12 +80,12 @@ class SimpleOrdinalScale implements OrdinalScale {
@override
set rangeBandConfig(RangeBandConfig barGroupWidthConfig) {
if (barGroupWidthConfig == null) {
throw new ArgumentError.notNull('RangeBandConfig must not be null.');
throw ArgumentError.notNull('RangeBandConfig must not be null.');
}
if (barGroupWidthConfig.type == RangeBandType.fixedDomain ||
barGroupWidthConfig.type == RangeBandType.none) {
throw new ArgumentError(
throw ArgumentError(
'barGroupWidthConfig must not be NONE or FIXED_DOMAIN');
}
@ -99,7 +99,7 @@ class SimpleOrdinalScale implements OrdinalScale {
@override
set stepSizeConfig(StepSizeConfig config) {
if (config != null && config.type != StepSizeType.autoDetect) {
throw new ArgumentError(
throw ArgumentError(
'Ordinal scales only support StepSizeConfig of type Auto');
}
// Nothing is set because only auto is supported.
@ -205,7 +205,7 @@ class SimpleOrdinalScale implements OrdinalScale {
if (startingDomain != null &&
viewportDataSize != null &&
viewportDataSize <= 0) {
throw new ArgumentError('viewportDataSize can' 't be less than 1.');
throw ArgumentError('viewportDataSize can' 't be less than 1.');
}
_scaleChanged = true;
@ -280,7 +280,7 @@ class SimpleOrdinalScale implements OrdinalScale {
}
@override
SimpleOrdinalScale copy() => new SimpleOrdinalScale._copy(this);
SimpleOrdinalScale copy() => SimpleOrdinalScale._copy(this);
void _updateCachedFields(
double stepSizePixels, double rangeBandPixels, double rangeBandShift) {
@ -335,7 +335,7 @@ class SimpleOrdinalScale implements OrdinalScale {
case RangeBandType.fixedDomain:
case RangeBandType.none:
default:
throw new StateError('RangeBandType must not be NONE or FIXED_DOMAIN');
throw StateError('RangeBandType must not be NONE or FIXED_DOMAIN');
break;
}

@ -44,7 +44,7 @@ class AxisSpec<D> {
TickFormatterSpec<D> tickFormatterSpec,
bool showAxisLine,
}) {
return new AxisSpec(
return AxisSpec(
renderSpec: renderSpec ?? other.renderSpec,
tickProviderSpec: tickProviderSpec ?? other.tickProviderSpec,
tickFormatterSpec: tickFormatterSpec ?? other.tickFormatterSpec,

@ -80,8 +80,8 @@ class BucketingAxisSpec extends NumericAxisSpec {
tickProviderSpec:
tickProviderSpec ?? const BucketingNumericTickProviderSpec(),
tickFormatterSpec: tickFormatterSpec ??
new BasicNumericTickFormatterSpec.fromNumberFormat(
new NumberFormat.percentPattern()),
BasicNumericTickFormatterSpec.fromNumberFormat(
NumberFormat.percentPattern()),
showAxisLine: showAxisLine,
viewport: viewport ?? const NumericExtents(0.0, 1.0));
@ -104,7 +104,7 @@ class BucketingAxisSpec extends NumericAxisSpec {
}
@override
BucketingNumericAxis createAxis() => new BucketingNumericAxis();
BucketingNumericAxis createAxis() => BucketingNumericAxis();
@override
bool operator ==(Object other) =>
@ -155,7 +155,7 @@ class BucketingNumericTickProviderSpec extends BasicNumericTickProviderSpec {
@override
BucketingNumericTickProvider createTickProvider(ChartContext context) {
final provider = new BucketingNumericTickProvider()
final provider = BucketingNumericTickProvider()
..zeroBound = zeroBound
..dataIsInWholeNumbers = dataIsInWholeNumbers;

@ -85,7 +85,7 @@ class DateTimeAxisSpec extends AxisSpec<DateTime> {
/// Creates a [DateTimeAxis]. This should be called in place of createAxis.
DateTimeAxis createDateTimeAxis(DateTimeFactory dateTimeFactory) =>
new DateTimeAxis(dateTimeFactory);
DateTimeAxis(dateTimeFactory);
@override
bool operator ==(Object other) =>
@ -121,10 +121,10 @@ class AutoDateTimeTickProviderSpec implements DateTimeTickProviderSpec {
@override
AutoAdjustingDateTimeTickProvider createTickProvider(ChartContext context) {
if (includeTime) {
return new AutoAdjustingDateTimeTickProvider.createDefault(
return AutoAdjustingDateTimeTickProvider.createDefault(
context.dateTimeFactory);
} else {
return new AutoAdjustingDateTimeTickProvider.createWithoutTime(
return AutoAdjustingDateTimeTickProvider.createWithoutTime(
context.dateTimeFactory);
}
}
@ -151,8 +151,8 @@ class DayTickProviderSpec implements DateTimeTickProviderSpec {
/// when searching for the appropriate tick intervals.
@override
AutoAdjustingDateTimeTickProvider createTickProvider(ChartContext context) {
return new AutoAdjustingDateTimeTickProvider.createWith([
new TimeRangeTickProviderImpl(new DayTimeStepper(context.dateTimeFactory,
return AutoAdjustingDateTimeTickProvider.createWith([
TimeRangeTickProviderImpl(DayTimeStepper(context.dateTimeFactory,
allowedTickIncrements: increments))
]);
}
@ -175,7 +175,7 @@ class DateTimeEndPointsTickProviderSpec implements DateTimeTickProviderSpec {
/// two end points of the axis range
@override
EndPointsTickProvider<DateTime> createTickProvider(ChartContext context) {
return new EndPointsTickProvider<DateTime>();
return EndPointsTickProvider<DateTime>();
}
@override
@ -191,7 +191,7 @@ class StaticDateTimeTickProviderSpec implements DateTimeTickProviderSpec {
@override
StaticTickProvider<DateTime> createTickProvider(ChartContext context) =>
new StaticTickProvider<DateTime>(tickSpecs);
StaticTickProvider<DateTime>(tickSpecs);
@override
bool operator ==(Object other) =>
@ -285,19 +285,19 @@ class AutoDateTimeTickFormatterSpec implements DateTimeTickFormatterSpec {
_makeFormatter(year, CalendarField.year, context);
}
return new DateTimeTickFormatter(context.dateTimeFactory, overrides: map);
return DateTimeTickFormatter(context.dateTimeFactory, overrides: map);
}
TimeTickFormatterImpl _makeFormatter(TimeFormatterSpec spec,
CalendarField transitionField, ChartContext context) {
if (spec.noonFormat != null) {
return new HourTickFormatter(
return HourTickFormatter(
dateTimeFactory: context.dateTimeFactory,
simpleFormat: spec.format,
transitionFormat: spec.transitionFormat,
noonFormat: spec.noonFormat);
} else {
return new TimeTickFormatterImpl(
return TimeTickFormatterImpl(
dateTimeFactory: context.dateTimeFactory,
simpleFormat: spec.format,
transitionFormat: spec.transitionFormat,

@ -68,7 +68,7 @@ class NumericAxisSpec extends AxisSpec<num> {
bool showAxisLine,
NumericExtents viewport,
}) {
return new NumericAxisSpec(
return NumericAxisSpec(
renderSpec: renderSpec ?? other.renderSpec,
tickProviderSpec: tickProviderSpec ?? other.tickProviderSpec,
tickFormatterSpec: tickFormatterSpec ?? other.tickFormatterSpec,
@ -88,7 +88,7 @@ class NumericAxisSpec extends AxisSpec<num> {
}
@override
NumericAxis createAxis() => new NumericAxis();
NumericAxis createAxis() => NumericAxis();
@override
bool operator ==(Object other) =>
@ -141,7 +141,7 @@ class BasicNumericTickProviderSpec implements NumericTickProviderSpec {
@override
NumericTickProvider createTickProvider(ChartContext context) {
final provider = new NumericTickProvider();
final provider = NumericTickProvider();
if (zeroBound != null) {
provider.zeroBound = zeroBound;
}
@ -188,7 +188,7 @@ class NumericEndPointsTickProviderSpec implements NumericTickProviderSpec {
@override
EndPointsTickProvider<num> createTickProvider(ChartContext context) {
return new EndPointsTickProvider<num>();
return EndPointsTickProvider<num>();
}
@override
@ -204,7 +204,7 @@ class StaticNumericTickProviderSpec implements NumericTickProviderSpec {
@override
StaticTickProvider<num> createTickProvider(ChartContext context) =>
new StaticTickProvider<num>(tickSpecs);
StaticTickProvider<num>(tickSpecs);
@override
bool operator ==(Object other) =>
@ -232,8 +232,8 @@ class BasicNumericTickFormatterSpec implements NumericTickFormatterSpec {
@override
NumericTickFormatter createTickFormatter(ChartContext context) {
return numberFormat != null
? new NumericTickFormatter.fromNumberFormat(numberFormat)
: new NumericTickFormatter(formatter: formatter);
? NumericTickFormatter.fromNumberFormat(numberFormat)
: NumericTickFormatter(formatter: formatter);
}
@override

@ -66,7 +66,7 @@ class OrdinalAxisSpec extends AxisSpec<String> {
}
@override
OrdinalAxis createAxis() => new OrdinalAxis();
OrdinalAxis createAxis() => OrdinalAxis();
@override
bool operator ==(Object other) {
@ -94,7 +94,7 @@ class BasicOrdinalTickProviderSpec implements OrdinalTickProviderSpec {
@override
OrdinalTickProvider createTickProvider(ChartContext context) =>
new OrdinalTickProvider();
OrdinalTickProvider();
@override
bool operator ==(Object other) => other is BasicOrdinalTickProviderSpec;
@ -112,7 +112,7 @@ class StaticOrdinalTickProviderSpec implements OrdinalTickProviderSpec {
@override
StaticTickProvider<String> createTickProvider(ChartContext context) =>
new StaticTickProvider<String>(tickSpecs);
StaticTickProvider<String>(tickSpecs);
@override
bool operator ==(Object other) =>
@ -129,7 +129,7 @@ class BasicOrdinalTickFormatterSpec implements OrdinalTickFormatterSpec {
@override
OrdinalTickFormatter createTickFormatter(ChartContext context) =>
new OrdinalTickFormatter();
OrdinalTickFormatter();
@override
bool operator ==(Object other) => other is BasicOrdinalTickFormatterSpec;

@ -41,8 +41,8 @@ class PercentAxisSpec extends NumericAxisSpec {
tickProviderSpec: tickProviderSpec ??
const BasicNumericTickProviderSpec(dataIsInWholeNumbers: false),
tickFormatterSpec: tickFormatterSpec ??
new BasicNumericTickFormatterSpec.fromNumberFormat(
new NumberFormat.percentPattern()),
BasicNumericTickFormatterSpec.fromNumberFormat(
NumberFormat.percentPattern()),
showAxisLine: showAxisLine,
viewport: viewport ?? const NumericExtents(0.0, 1.0));

@ -76,7 +76,7 @@ class StaticTickProvider<D> extends TickProvider<D> {
// We still check if the spec is within the viewport because we do not
// extend the axis for OrdinalScale.
if (scale.compareDomainValueToViewport(spec.value) == 0) {
final tick = new Tick<D>(
final tick = Tick<D>(
value: spec.value,
textElement: graphicsFactory
.createTextElement(spec.label ?? formattedValues[i]),

@ -34,7 +34,7 @@ abstract class SimpleTickFormatterBase<D> implements TickFormatter<D> {
@override
List<String> format(List<D> tickValues, Map<D, String> cache,
{num stepSize}) =>
tickValues.map((D value) {
tickValues.map((value) {
// Try to use the cached formats first.
String formattedString = cache[value];
if (formattedString == null) {
@ -75,24 +75,24 @@ class NumericTickFormatter extends SimpleTickFormatterBase<num> {
/// [formatter] optionally specify a formatter to be used. Defaults to using
/// [NumberFormat.decimalPattern] if none is specified.
factory NumericTickFormatter({MeasureFormatter formatter}) {
formatter ??= _getFormatter(new NumberFormat.decimalPattern());
return new NumericTickFormatter._internal(formatter);
formatter ??= _getFormatter(NumberFormat.decimalPattern());
return NumericTickFormatter._internal(formatter);
}
/// Constructs a new [NumericTickFormatter] that formats using [numberFormat].
factory NumericTickFormatter.fromNumberFormat(NumberFormat numberFormat) {
return new NumericTickFormatter._internal(_getFormatter(numberFormat));
return NumericTickFormatter._internal(_getFormatter(numberFormat));
}
/// Constructs a new formatter that uses [NumberFormat.compactCurrency].
factory NumericTickFormatter.compactSimpleCurrency() {
return new NumericTickFormatter._internal(
_getFormatter(new NumberFormat.compactCurrency()));
return NumericTickFormatter._internal(
_getFormatter(NumberFormat.compactCurrency()));
}
/// Returns a [MeasureFormatter] that calls format on [numberFormat].
static MeasureFormatter _getFormatter(NumberFormat numberFormat) {
return (num value) => numberFormat.format(value);
return (value) => numberFormat.format(value);
}
@override

@ -73,7 +73,7 @@ abstract class BaseTickProvider<D> implements TickProvider<D> {
for (var i = 0; i < domainValues.length; i++) {
final value = domainValues[i];
final tick = new Tick(
final tick = Tick(
value: value,
textElement: graphicsFactory.createTextElement(labels[i]),
locationPx: scale[value]);

@ -54,7 +54,7 @@ class AutoAdjustingDateTimeTickProvider implements TickProvider<DateTime> {
/// Creates a default [AutoAdjustingDateTimeTickProvider] for day and time.
factory AutoAdjustingDateTimeTickProvider.createDefault(
DateTimeFactory dateTimeFactory) {
return new AutoAdjustingDateTimeTickProvider._internal([
return AutoAdjustingDateTimeTickProvider._internal([
createYearTickProvider(dateTimeFactory),
createMonthTickProvider(dateTimeFactory),
createDayTickProvider(dateTimeFactory),
@ -66,7 +66,7 @@ class AutoAdjustingDateTimeTickProvider implements TickProvider<DateTime> {
/// Creates a default [AutoAdjustingDateTimeTickProvider] for day only.
factory AutoAdjustingDateTimeTickProvider.createWithoutTime(
DateTimeFactory dateTimeFactory) {
return new AutoAdjustingDateTimeTickProvider._internal([
return AutoAdjustingDateTimeTickProvider._internal([
createYearTickProvider(dateTimeFactory),
createMonthTickProvider(dateTimeFactory),
createDayTickProvider(dateTimeFactory)
@ -80,11 +80,10 @@ class AutoAdjustingDateTimeTickProvider implements TickProvider<DateTime> {
factory AutoAdjustingDateTimeTickProvider.createWith(
List<TimeRangeTickProvider> potentialTickProviders) {
if (potentialTickProviders == null || potentialTickProviders.isEmpty) {
throw new ArgumentError('At least one TimeRangeTickProvider is required');
throw ArgumentError('At least one TimeRangeTickProvider is required');
}
return new AutoAdjustingDateTimeTickProvider._internal(
potentialTickProviders);
return AutoAdjustingDateTimeTickProvider._internal(potentialTickProviders);
}
/// Generates a list of ticks for the given data which should not collide
@ -157,21 +156,21 @@ class AutoAdjustingDateTimeTickProvider implements TickProvider<DateTime> {
static TimeRangeTickProvider createYearTickProvider(
DateTimeFactory dateTimeFactory) =>
new TimeRangeTickProviderImpl(new YearTimeStepper(dateTimeFactory));
TimeRangeTickProviderImpl(YearTimeStepper(dateTimeFactory));
static TimeRangeTickProvider createMonthTickProvider(
DateTimeFactory dateTimeFactory) =>
new TimeRangeTickProviderImpl(new MonthTimeStepper(dateTimeFactory));
TimeRangeTickProviderImpl(MonthTimeStepper(dateTimeFactory));
static TimeRangeTickProvider createDayTickProvider(
DateTimeFactory dateTimeFactory) =>
new TimeRangeTickProviderImpl(new DayTimeStepper(dateTimeFactory));
TimeRangeTickProviderImpl(DayTimeStepper(dateTimeFactory));
static TimeRangeTickProvider createHourTickProvider(
DateTimeFactory dateTimeFactory) =>
new TimeRangeTickProviderImpl(new HourTimeStepper(dateTimeFactory));
TimeRangeTickProviderImpl(HourTimeStepper(dateTimeFactory));
static TimeRangeTickProvider createMinuteTickProvider(
DateTimeFactory dateTimeFactory) =>
new TimeRangeTickProviderImpl(new MinuteTimeStepper(dateTimeFactory));
TimeRangeTickProviderImpl(MinuteTimeStepper(dateTimeFactory));
}

@ -57,7 +57,7 @@ abstract class BaseTimeStepper implements TimeStepper {
// Keep the steps iterable unless time extent changes, so the same iterator
// can be used and reset for different increments.
if (_stepsIterable == null || _stepsIterable.timeExtent != timeExtent) {
_stepsIterable = new _TimeStepIteratorFactoryImpl(timeExtent, this);
_stepsIterable = _TimeStepIteratorFactoryImpl(timeExtent, this);
}
return _stepsIterable;
}
@ -67,7 +67,7 @@ abstract class BaseTimeStepper implements TimeStepper {
final stepBefore = getStepTimeBeforeInclusive(timeExtent.start, 1);
final stepAfter = getStepTimeAfterInclusive(timeExtent.end, 1);
return new DateTimeExtents(start: stepBefore, end: stepAfter);
return DateTimeExtents(start: stepBefore, end: stepAfter);
}
DateTime getStepTimeAfterInclusive(DateTime time, int tickIncrement) {
@ -127,8 +127,8 @@ class _TimeStepIteratorFactoryImpl extends TimeStepIteratorFactory {
DateTimeExtents timeExtent, BaseTimeStepper stepper) {
final startTime = timeExtent.start;
final endTime = timeExtent.end;
return new _TimeStepIteratorFactoryImpl._internal(
new _TimeStepIteratorImpl(startTime, endTime, stepper), timeExtent);
return _TimeStepIteratorFactoryImpl._internal(
_TimeStepIteratorImpl(startTime, endTime, stepper), timeExtent);
}
@override

@ -28,11 +28,10 @@ class DateTimeAxis extends Axis<DateTime> {
{TickProvider tickProvider, TickFormatter tickFormatter})
: super(
tickProvider: tickProvider ??
new AutoAdjustingDateTimeTickProvider.createDefault(
dateTimeFactory),
AutoAdjustingDateTimeTickProvider.createDefault(dateTimeFactory),
tickFormatter:
tickFormatter ?? new DateTimeTickFormatter(dateTimeFactory),
scale: new DateTimeScale(dateTimeFactory),
tickFormatter ?? DateTimeTickFormatter(dateTimeFactory),
scale: DateTimeScale(dateTimeFactory),
);
void setScaleViewport(DateTimeExtents viewport) {

@ -27,7 +27,7 @@ class DateTimeScale extends MutableScale<DateTime> {
final DateTimeFactory dateTimeFactory;
final LinearScale _linearScale;
DateTimeScale(this.dateTimeFactory) : _linearScale = new LinearScale();
DateTimeScale(this.dateTimeFactory) : _linearScale = LinearScale();
DateTimeScale._copy(DateTimeScale other)
: dateTimeFactory = other.dateTimeFactory,
@ -82,7 +82,7 @@ class DateTimeScale extends MutableScale<DateTime> {
DateTimeExtents get viewportDomain {
final extents = _linearScale.viewportDomain;
return new DateTimeExtents(
return DateTimeExtents(
start: dateTimeFactory
.createDateTimeFromMilliSecondsSinceEpoch(extents.min.toInt()),
end: dateTimeFactory
@ -90,13 +90,13 @@ class DateTimeScale extends MutableScale<DateTime> {
}
set viewportDomain(DateTimeExtents extents) {
_linearScale.viewportDomain = new NumericExtents(
_linearScale.viewportDomain = NumericExtents(
extents.start.millisecondsSinceEpoch,
extents.end.millisecondsSinceEpoch);
}
@override
DateTimeScale copy() => new DateTimeScale._copy(this);
DateTimeScale copy() => DateTimeScale._copy(this);
@override
double get viewportTranslatePx => _linearScale.viewportTranslatePx;

@ -56,27 +56,27 @@ class DateTimeTickFormatter implements TickFormatter<DateTime> {
factory DateTimeTickFormatter(DateTimeFactory dateTimeFactory,
{Map<int, TimeTickFormatter> overrides}) {
final Map<int, TimeTickFormatter> map = {
MINUTE: new TimeTickFormatterImpl(
MINUTE: TimeTickFormatterImpl(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'mm',
transitionFormat: 'h mm',
transitionField: CalendarField.hourOfDay),
HOUR: new HourTickFormatter(
HOUR: HourTickFormatter(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'h',
transitionFormat: 'MMM d ha',
noonFormat: 'ha'),
23 * HOUR: new TimeTickFormatterImpl(
23 * HOUR: TimeTickFormatterImpl(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'd',
transitionFormat: 'MMM d',
transitionField: CalendarField.month),
28 * DAY: new TimeTickFormatterImpl(
28 * DAY: TimeTickFormatterImpl(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'MMM',
transitionFormat: 'MMM yyyy',
transitionField: CalendarField.year),
364 * DAY: new TimeTickFormatterImpl(
364 * DAY: TimeTickFormatterImpl(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'yyyy',
transitionFormat: 'yyyy',
@ -88,23 +88,23 @@ class DateTimeTickFormatter implements TickFormatter<DateTime> {
map.addAll(overrides);
}
return new DateTimeTickFormatter._internal(map);
return DateTimeTickFormatter._internal(map);
}
/// Creates a [DateTimeTickFormatter] without the time component.
factory DateTimeTickFormatter.withoutTime(DateTimeFactory dateTimeFactory) {
return new DateTimeTickFormatter._internal({
23 * HOUR: new TimeTickFormatterImpl(
return DateTimeTickFormatter._internal({
23 * HOUR: TimeTickFormatterImpl(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'd',
transitionFormat: 'MMM d',
transitionField: CalendarField.month),
28 * DAY: new TimeTickFormatterImpl(
28 * DAY: TimeTickFormatterImpl(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'MMM',
transitionFormat: 'MMM yyyy',
transitionField: CalendarField.year),
365 * DAY: new TimeTickFormatterImpl(
365 * DAY: TimeTickFormatterImpl(
dateTimeFactory: dateTimeFactory,
simpleFormat: 'yyyy',
transitionFormat: 'yyyy',
@ -119,7 +119,7 @@ class DateTimeTickFormatter implements TickFormatter<DateTime> {
///
/// [formatter] The format for all ticks.
factory DateTimeTickFormatter.uniform(TimeTickFormatter formatter) {
return new DateTimeTickFormatter._internal({ANY: formatter});
return DateTimeTickFormatter._internal({ANY: formatter});
}
/// Creates a [DateTimeTickFormatter] that formats ticks with [formatters].
@ -129,10 +129,10 @@ class DateTimeTickFormatter implements TickFormatter<DateTime> {
Map<int, TimeTickFormatter> formatters) {
// Formatters must be non empty.
if (formatters == null || formatters.isEmpty) {
throw new ArgumentError('At least one TimeTickFormatter is required.');
throw ArgumentError('At least one TimeTickFormatter is required.');
}
return new DateTimeTickFormatter._internal(formatters);
return DateTimeTickFormatter._internal(formatters);
}
DateTimeTickFormatter._internal(this._timeFormatters) {
@ -202,7 +202,7 @@ class DateTimeTickFormatter implements TickFormatter<DateTime> {
// Only need to check the first value, because the values after are expected
// to be greater.
if (prev <= 0) {
throw new ArgumentError('Formatter keys must be positive');
throw ArgumentError('Formatter keys must be positive');
}
while (valuesIterator.moveNext() && isSorted) {
@ -211,7 +211,7 @@ class DateTimeTickFormatter implements TickFormatter<DateTime> {
}
if (!isSorted) {
throw new ArgumentError(
throw ArgumentError(
'Formatters must be sorted with keys in increasing order');
}
}

@ -19,7 +19,7 @@ import 'base_time_stepper.dart' show BaseTimeStepper;
/// Day stepper.
class DayTimeStepper extends BaseTimeStepper {
// TODO: Remove the 14 day increment if we add week stepper.
static const _defaultIncrements = const [1, 2, 3, 7, 14];
static const _defaultIncrements = [1, 2, 3, 7, 14];
static const _hoursInDay = 24;
final List<int> _allowedTickIncrements;
@ -39,7 +39,7 @@ class DayTimeStepper extends BaseTimeStepper {
// All increments must be > 0.
assert(allowedTickIncrements.any((increment) => increment <= 0) == false);
return new DayTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
return DayTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
}
@override
@ -60,7 +60,7 @@ class DayTimeStepper extends BaseTimeStepper {
final dayRemainder = (time.day - 1) % tickIncrement;
// Subtract an extra hour in case stepping through a daylight saving change.
final dayBefore = dayRemainder > 0
? time.subtract(new Duration(hours: (_hoursInDay * dayRemainder) - 1))
? time.subtract(Duration(hours: (_hoursInDay * dayRemainder) - 1))
: time;
// Explicitly leaving off hours and beyond to truncate to start of day.
final stepBefore = dateTimeFactory.createDateTime(
@ -73,7 +73,7 @@ class DayTimeStepper extends BaseTimeStepper {
DateTime getNextStepTime(DateTime time, int tickIncrement) {
// Add an extra hour in case stepping through a daylight saving change.
final stepAfter =
time.add(new Duration(hours: (_hoursInDay * tickIncrement) + 1));
time.add(Duration(hours: (_hoursInDay * tickIncrement) + 1));
// Explicitly leaving off hours and beyond to truncate to start of day.
return dateTimeFactory.createDateTime(
stepAfter.year, stepAfter.month, stepAfter.day);

@ -18,7 +18,7 @@ import 'base_time_stepper.dart' show BaseTimeStepper;
/// Hour stepper.
class HourTimeStepper extends BaseTimeStepper {
static const _defaultIncrements = const [1, 2, 3, 4, 6, 12, 24];
static const _defaultIncrements = [1, 2, 3, 4, 6, 12, 24];
static const _hoursInDay = 24;
static const _millisecondsInHour = 3600 * 1000;
@ -41,8 +41,7 @@ class HourTimeStepper extends BaseTimeStepper {
.any((increment) => increment <= 0 || increment > 24) ==
false);
return new HourTimeStepper._internal(
dateTimeFactory, allowedTickIncrements);
return HourTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
}
@override
@ -60,7 +59,7 @@ class HourTimeStepper extends BaseTimeStepper {
DateTime getStepTimeBeforeInclusive(DateTime time, int tickIncrement) {
final nextDay = dateTimeFactory
.createDateTime(time.year, time.month, time.day)
.add(new Duration(hours: _hoursInDay + 1));
.add(Duration(hours: _hoursInDay + 1));
final nextDayStart = dateTimeFactory.createDateTime(
nextDay.year, nextDay.month, nextDay.day);
@ -83,6 +82,6 @@ class HourTimeStepper extends BaseTimeStepper {
/// [time] is expected to be a [DateTime] with the hour at start of the hour.
@override
DateTime getNextStepTime(DateTime time, int tickIncrement) {
return time.add(new Duration(hours: tickIncrement));
return time.add(Duration(hours: tickIncrement));
}
}

@ -18,7 +18,7 @@ import 'base_time_stepper.dart';
/// Minute stepper where ticks generated aligns with the hour.
class MinuteTimeStepper extends BaseTimeStepper {
static const _defaultIncrements = const [5, 10, 15, 20, 30];
static const _defaultIncrements = [5, 10, 15, 20, 30];
static const _millisecondsInMinute = 60 * 1000;
final List<int> _allowedTickIncrements;
@ -40,8 +40,7 @@ class MinuteTimeStepper extends BaseTimeStepper {
.any((increment) => increment <= 0 || increment > 60) ==
false);
return new MinuteTimeStepper._internal(
dateTimeFactory, allowedTickIncrements);
return MinuteTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
}
@override
@ -73,6 +72,6 @@ class MinuteTimeStepper extends BaseTimeStepper {
@override
DateTime getNextStepTime(DateTime time, int tickIncrement) {
return time.add(new Duration(minutes: tickIncrement));
return time.add(Duration(minutes: tickIncrement));
}
}

@ -18,7 +18,7 @@ import 'base_time_stepper.dart' show BaseTimeStepper;
/// Month stepper.
class MonthTimeStepper extends BaseTimeStepper {
static const _defaultIncrements = const [1, 2, 3, 4, 6, 12];
static const _defaultIncrements = [1, 2, 3, 4, 6, 12];
final List<int> _allowedTickIncrements;
@ -37,8 +37,7 @@ class MonthTimeStepper extends BaseTimeStepper {
// All increments must be > 0.
assert(allowedTickIncrements.any((increment) => increment <= 0) == false);
return new MonthTimeStepper._internal(
dateTimeFactory, allowedTickIncrements);
return MonthTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
}
@override

@ -18,7 +18,7 @@ import 'base_time_stepper.dart' show BaseTimeStepper;
/// Year stepper.
class YearTimeStepper extends BaseTimeStepper {
static const _defaultIncrements = const [1, 2, 5, 10, 50, 100, 500, 1000];
static const _defaultIncrements = [1, 2, 5, 10, 50, 100, 500, 1000];
final List<int> _allowedTickIncrements;
@ -37,8 +37,7 @@ class YearTimeStepper extends BaseTimeStepper {
// All increments must be > 0.
assert(allowedTickIncrements.any((increment) => increment <= 0) == false);
return new YearTimeStepper._internal(
dateTimeFactory, allowedTickIncrements);
return YearTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
}
@override

@ -55,14 +55,14 @@ class NumericCartesianChart extends CartesianChart<num> {
: super(
vertical: vertical,
layoutConfig: layoutConfig,
domainAxis: new NumericAxis(),
domainAxis: NumericAxis(),
primaryMeasureAxis: primaryMeasureAxis,
secondaryMeasureAxis: secondaryMeasureAxis,
disjointMeasureAxes: disjointMeasureAxes);
@protected
void initDomainAxis() {
_domainAxis.tickDrawStrategy = new SmallTickRendererSpec<num>()
_domainAxis.tickDrawStrategy = SmallTickRendererSpec<num>()
.createDrawStrategy(context, graphicsFactory);
}
}
@ -77,7 +77,7 @@ class OrdinalCartesianChart extends CartesianChart<String> {
: super(
vertical: vertical,
layoutConfig: layoutConfig,
domainAxis: new OrdinalAxis(),
domainAxis: OrdinalAxis(),
primaryMeasureAxis: primaryMeasureAxis,
secondaryMeasureAxis: secondaryMeasureAxis,
disjointMeasureAxes: disjointMeasureAxes);
@ -85,17 +85,17 @@ class OrdinalCartesianChart extends CartesianChart<String> {
@protected
void initDomainAxis() {
_domainAxis
..tickDrawStrategy = new SmallTickRendererSpec<String>()
..tickDrawStrategy = SmallTickRendererSpec<String>()
.createDrawStrategy(context, graphicsFactory);
}
}
abstract class CartesianChart<D> extends BaseChart<D> {
static final _defaultLayoutConfig = new LayoutConfig(
topSpec: new MarginSpec.fromPixel(minPixel: 20),
bottomSpec: new MarginSpec.fromPixel(minPixel: 20),
leftSpec: new MarginSpec.fromPixel(minPixel: 20),
rightSpec: new MarginSpec.fromPixel(minPixel: 20),
static final _defaultLayoutConfig = LayoutConfig(
topSpec: MarginSpec.fromPixel(minPixel: 20),
bottomSpec: MarginSpec.fromPixel(minPixel: 20),
leftSpec: MarginSpec.fromPixel(minPixel: 20),
rightSpec: MarginSpec.fromPixel(minPixel: 20),
);
bool vertical;
@ -148,8 +148,8 @@ abstract class CartesianChart<D> extends BaseChart<D> {
: vertical = vertical ?? true,
// [domainAxis] will be set to the new axis in [configurationChanged].
_newDomainAxis = domainAxis,
_primaryMeasureAxis = primaryMeasureAxis ?? new NumericAxis(),
_secondaryMeasureAxis = secondaryMeasureAxis ?? new NumericAxis(),
_primaryMeasureAxis = primaryMeasureAxis ?? NumericAxis(),
_secondaryMeasureAxis = secondaryMeasureAxis ?? NumericAxis(),
_disjointMeasureAxes = disjointMeasureAxes ?? <String, NumericAxis>{},
super(layoutConfig: layoutConfig ?? _defaultLayoutConfig) {
// As a convenience for chart configuration, set the paint order on any axis
@ -157,7 +157,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
_primaryMeasureAxis.layoutPaintOrder ??= LayoutViewPaintOrder.measureAxis;
_secondaryMeasureAxis.layoutPaintOrder ??= LayoutViewPaintOrder.measureAxis;
_disjointMeasureAxes.forEach((String axisId, NumericAxis axis) {
_disjointMeasureAxes.forEach((axisId, axis) {
axis.layoutPaintOrder ??= LayoutViewPaintOrder.measureAxis;
});
}
@ -166,17 +166,16 @@ abstract class CartesianChart<D> extends BaseChart<D> {
super.init(context, graphicsFactory);
_primaryMeasureAxis.context = context;
_primaryMeasureAxis.tickDrawStrategy = new GridlineRendererSpec<num>()
_primaryMeasureAxis.tickDrawStrategy = GridlineRendererSpec<num>()
.createDrawStrategy(context, graphicsFactory);
_secondaryMeasureAxis.context = context;
_secondaryMeasureAxis.tickDrawStrategy = new GridlineRendererSpec<num>()
_secondaryMeasureAxis.tickDrawStrategy = GridlineRendererSpec<num>()
.createDrawStrategy(context, graphicsFactory);
_disjointMeasureAxes.forEach((String axisId, NumericAxis axis) {
_disjointMeasureAxes.forEach((axisId, axis) {
axis.context = context;
axis.tickDrawStrategy =
new NoneDrawStrategy<num>(context, graphicsFactory);
axis.tickDrawStrategy = NoneDrawStrategy<num>(context, graphicsFactory);
});
}
@ -277,7 +276,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
/// A [LinkedHashMap] is used to ensure consistent ordering when painting the
/// axes.
set disjointMeasureAxisSpecs(LinkedHashMap<String, AxisSpec> axisSpecs) {
axisSpecs.forEach((String axisId, AxisSpec axisSpec) {
axisSpecs.forEach((axisId, axisSpec) {
axisSpec.configure(
_disjointMeasureAxes[axisId], context, graphicsFactory);
});
@ -299,7 +298,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
@override
SeriesRenderer<D> makeDefaultRenderer() {
return new BarRenderer()..rendererId = SeriesRenderer.defaultRendererId;
return BarRenderer()..rendererId = SeriesRenderer.defaultRendererId;
}
@override
@ -331,7 +330,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
}
// Add all disjoint axis views so that their range will be configured.
_disjointMeasureAxes.forEach((String axisId, NumericAxis axis) {
_disjointMeasureAxes.forEach((axisId, axis) {
addView(axis);
});
@ -340,7 +339,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
_primaryMeasureAxis.resetDomains();
_secondaryMeasureAxis.resetDomains();
_disjointMeasureAxes.forEach((String axisId, NumericAxis axis) {
_disjointMeasureAxes.forEach((axisId, axis) {
axis.resetDomains();
});
@ -363,7 +362,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
: AxisOrientation.right)
..reverseOutputRange = flipVerticalAxisOutput;
_disjointMeasureAxes.forEach((String axisId, NumericAxis axis) {
_disjointMeasureAxes.forEach((axisId, axis) {
axis
..axisOrientation = (reverseAxisDirection
? AxisOrientation.left
@ -385,7 +384,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
..axisOrientation = AxisOrientation.top
..reverseOutputRange = reverseAxisDirection;
_disjointMeasureAxes.forEach((String axisId, NumericAxis axis) {
_disjointMeasureAxes.forEach((axisId, axis) {
axis
..axisOrientation = AxisOrientation.top
..reverseOutputRange = reverseAxisDirection;
@ -394,8 +393,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
// Have each renderer configure the axes with their domain and measure
// values.
rendererToSeriesList
.forEach((String rendererId, List<MutableSeries<D>> seriesList) {
rendererToSeriesList.forEach((rendererId, seriesList) {
getSeriesRenderer(rendererId).configureDomainAxes(seriesList);
getSeriesRenderer(rendererId).configureMeasureAxes(seriesList);
});
@ -416,7 +414,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
_secondaryMeasureAxis.updateTicks();
}
_disjointMeasureAxes.forEach((String axisId, NumericAxis axis) {
_disjointMeasureAxes.forEach((axisId, axis) {
axis.updateTicks();
});
@ -449,11 +447,11 @@ abstract class CartesianChart<D> extends BaseChart<D> {
final measurePosition =
series.getAttr(measureAxisKey).getLocation(measure);
final chartPosition = new Point<double>(
final chartPosition = Point<double>(
vertical ? domainPosition : measurePosition,
vertical ? measurePosition : domainPosition);
entries.add(new DatumDetails(
entries.add(DatumDetails(
datum: datum,
domain: domain,
measure: measure,

@ -52,7 +52,7 @@ abstract class BaseCartesianRenderer<D> extends BaseSeriesRenderer<D>
@override
void configureDomainAxes(List<MutableSeries<D>> seriesList) {
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
if (series.data.isEmpty) {
return;
}
@ -100,7 +100,7 @@ abstract class BaseCartesianRenderer<D> extends BaseSeriesRenderer<D>
@override
void configureMeasureAxes(List<MutableSeries<D>> seriesList) {
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
if (series.data.isEmpty) {
return;
}

@ -66,7 +66,7 @@ abstract class BaseChart<D> {
/// initial draw cycle (e.g. a [Legend] may hide some series).
List<MutableSeries<D>> _currentSeriesList;
Set<String> _usingRenderers = new Set<String>();
Set<String> _usingRenderers = Set<String>();
Map<String, List<MutableSeries<D>>> _rendererToSeriesList;
final _seriesRenderers = <String, SeriesRenderer<D>>{};
@ -83,7 +83,7 @@ abstract class BaseChart<D> {
/// that does something with tap events, such as "click to select data."
bool get isTappable => _behaviorTappableMap.isNotEmpty;
final _gestureProxy = new ProxyGestureListener();
final _gestureProxy = ProxyGestureListener();
final _selectionModels = <SelectionModelType, MutableSelectionModel<D>>{};
@ -99,7 +99,7 @@ abstract class BaseChart<D> {
final _lifecycleListeners = <LifecycleListener<D>>[];
BaseChart({LayoutConfig layoutConfig}) {
_layoutManager = new LayoutManagerImpl(config: layoutConfig);
_layoutManager = LayoutManagerImpl(config: layoutConfig);
}
void init(ChartContext context, GraphicsFactory graphicsFactory) {
@ -109,8 +109,8 @@ abstract class BaseChart<D> {
if (this.graphicsFactory != graphicsFactory) {
this.graphicsFactory = graphicsFactory;
_layoutManager.applyToViews(
(LayoutView view) => view.graphicsFactory = graphicsFactory);
_layoutManager
.applyToViews((view) => view.graphicsFactory = graphicsFactory);
}
configurationChanged();
@ -154,8 +154,7 @@ abstract class BaseChart<D> {
/// Returns MutableSelectionModel for the given type. Lazy creates one upon first
/// request.
MutableSelectionModel<D> getSelectionModel(SelectionModelType type) {
return _selectionModels.putIfAbsent(
type, () => new MutableSelectionModel<D>());
return _selectionModels.putIfAbsent(type, () => MutableSelectionModel<D>());
}
/// Returns a list of datum details from selection model of [type].
@ -206,10 +205,9 @@ abstract class BaseChart<D> {
SeriesRenderer<D> makeDefaultRenderer();
bool pointWithinRenderer(Point<double> chartPosition) {
return _usingRenderers.any((String rendererId) =>
getSeriesRenderer(rendererId)
.componentBounds
.containsPoint(chartPosition));
return _usingRenderers.any((rendererId) => getSeriesRenderer(rendererId)
.componentBounds
.containsPoint(chartPosition));
}
/// Retrieves the datum details that are nearest to the given [drawAreaPoint].
@ -229,13 +227,13 @@ abstract class BaseChart<D> {
selectAcrossAllDrawAreaComponents ? drawableLayoutAreaBounds : null;
final details = <DatumDetails<D>>[];
_usingRenderers.forEach((String rendererId) {
_usingRenderers.forEach((rendererId) {
details.addAll(getSeriesRenderer(rendererId)
.getNearestDatumDetailPerSeries(
drawAreaPoint, selectNearestByDomain, boundsOverride));
});
details.sort((DatumDetails<D> a, DatumDetails<D> b) {
details.sort((a, b) {
// Sort so that the nearest one is first.
// Special sort, sort by domain distance first, then by measure distance.
if (selectNearestByDomain) {
@ -356,7 +354,7 @@ abstract class BaseChart<D> {
}
/// Returns a list of behaviors that have been added.
List<ChartBehavior<D>> get behaviors => new List.unmodifiable(_behaviorStack);
List<ChartBehavior<D>> get behaviors => List.unmodifiable(_behaviorStack);
//
// Layout methods
@ -423,7 +421,7 @@ abstract class BaseChart<D> {
}
var processedSeriesList =
new List<MutableSeries<D>>.from(seriesList.map(makeSeries));
List<MutableSeries<D>>.from(seriesList.map(makeSeries));
// Allow listeners to manipulate the seriesList.
fireOnDraw(processedSeriesList);
@ -464,9 +462,8 @@ abstract class BaseChart<D> {
void drawInternal(List<MutableSeries<D>> seriesList,
{bool skipAnimation, bool skipLayout}) {
seriesList = seriesList
.map((MutableSeries<D> series) => new MutableSeries<D>.clone(series))
.toList();
seriesList =
seriesList.map((series) => MutableSeries<D>.clone(series)).toList();
// TODO: Handle exiting renderers.
_animationsTemporarilyDisabled = skipAnimation;
@ -487,7 +484,7 @@ abstract class BaseChart<D> {
List<MutableSeries<D>> get currentSeriesList => _currentSeriesList;
MutableSeries<D> makeSeries(Series<dynamic, D> series) {
final s = new MutableSeries<D>(series);
final s = MutableSeries<D>(series);
// Setup the Renderer
final rendererId =
@ -505,14 +502,13 @@ abstract class BaseChart<D> {
// Build map of rendererIds to SeriesLists. This map can't be re-used later
// in the preprocessSeries call because some behaviors might alter the
// seriesList.
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
String rendererId = series.getAttr(rendererIdKey);
rendererToSeriesList.putIfAbsent(rendererId, () => []).add(series);
});
// Have each renderer add missing color functions to their seriesLists.
rendererToSeriesList
.forEach((String rendererId, List<MutableSeries<D>> seriesList) {
rendererToSeriesList.forEach((rendererId, seriesList) {
getSeriesRenderer(rendererId).configureSeries(seriesList);
});
}
@ -525,10 +521,10 @@ abstract class BaseChart<D> {
Map<String, List<MutableSeries<D>>> rendererToSeriesList = {};
var unusedRenderers = _usingRenderers;
_usingRenderers = new Set<String>();
_usingRenderers = Set<String>();
// Build map of rendererIds to SeriesLists.
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
String rendererId = series.getAttr(rendererIdKey);
rendererToSeriesList.putIfAbsent(rendererId, () => []).add(series);
@ -538,11 +534,10 @@ abstract class BaseChart<D> {
// Allow unused renderers to render out content.
unusedRenderers
.forEach((String rendererId) => rendererToSeriesList[rendererId] = []);
.forEach((rendererId) => rendererToSeriesList[rendererId] = []);
// Have each renderer preprocess their seriesLists.
rendererToSeriesList
.forEach((String rendererId, List<MutableSeries<D>> seriesList) {
rendererToSeriesList.forEach((rendererId, seriesList) {
getSeriesRenderer(rendererId).preprocessSeries(seriesList);
});
@ -555,8 +550,7 @@ abstract class BaseChart<D> {
void onPostLayout(Map<String, List<MutableSeries<D>>> rendererToSeriesList) {
// Update each renderer with
rendererToSeriesList
.forEach((String rendererId, List<MutableSeries<D>> seriesList) {
rendererToSeriesList.forEach((rendererId, seriesList) {
getSeriesRenderer(rendererId).update(seriesList, animatingThisDraw);
});
@ -574,7 +568,7 @@ abstract class BaseChart<D> {
void paint(ChartCanvas canvas) {
canvas.drawingView = 'BaseView';
_layoutManager.paintOrderedViews.forEach((LayoutView view) {
_layoutManager.paintOrderedViews.forEach((view) {
canvas.drawingView = view.runtimeType.toString();
view.paint(canvas, animatingThisDraw ? animationPercent : 1.0);
});
@ -594,7 +588,7 @@ abstract class BaseChart<D> {
@protected
fireOnDraw(List<MutableSeries<D>> seriesList) {
_lifecycleListeners.forEach((LifecycleListener<D> listener) {
_lifecycleListeners.forEach((listener) {
if (listener.onData != null) {
listener.onData(seriesList);
}
@ -603,7 +597,7 @@ abstract class BaseChart<D> {
@protected
fireOnPreprocess(List<MutableSeries<D>> seriesList) {
_lifecycleListeners.forEach((LifecycleListener<D> listener) {
_lifecycleListeners.forEach((listener) {
if (listener.onPreprocess != null) {
listener.onPreprocess(seriesList);
}
@ -612,7 +606,7 @@ abstract class BaseChart<D> {
@protected
fireOnPostprocess(List<MutableSeries<D>> seriesList) {
_lifecycleListeners.forEach((LifecycleListener<D> listener) {
_lifecycleListeners.forEach((listener) {
if (listener.onPostprocess != null) {
listener.onPostprocess(seriesList);
}
@ -621,7 +615,7 @@ abstract class BaseChart<D> {
@protected
fireOnAxisConfigured() {
_lifecycleListeners.forEach((LifecycleListener<D> listener) {
_lifecycleListeners.forEach((listener) {
if (listener.onAxisConfigured != null) {
listener.onAxisConfigured();
}
@ -630,7 +624,7 @@ abstract class BaseChart<D> {
@protected
fireOnPostrender(ChartCanvas canvas) {
_lifecycleListeners.forEach((LifecycleListener<D> listener) {
_lifecycleListeners.forEach((listener) {
if (listener.onPostrender != null) {
listener.onPostrender(canvas);
}
@ -639,7 +633,7 @@ abstract class BaseChart<D> {
@protected
fireOnAnimationComplete() {
_lifecycleListeners.forEach((LifecycleListener<D> listener) {
_lifecycleListeners.forEach((listener) {
if (listener.onAnimationComplete != null) {
listener.onAnimationComplete();
}
@ -654,8 +648,8 @@ abstract class BaseChart<D> {
}
_behaviorStack.clear();
_behaviorRoleMap.clear();
_selectionModels.values.forEach((MutableSelectionModel selectionModel) =>
selectionModel.clearAllListeners());
_selectionModels.values
.forEach((selectionModel) => selectionModel.clearAllListeners());
}
}
@ -707,6 +701,7 @@ class LifecycleListener<D> {
this.onAnimationComplete});
}
typedef LifecycleSeriesListCallback<D>(List<MutableSeries<D>> seriesList);
typedef LifecycleCanvasCallback(ChartCanvas canvas);
typedef LifecycleEmptyCallback();
typedef LifecycleSeriesListCallback<D> = Function(
List<MutableSeries<D>> seriesList);
typedef LifecycleCanvasCallback = Function(ChartCanvas canvas);
typedef LifecycleEmptyCallback = Function();

@ -57,10 +57,10 @@ abstract class A11yExploreBehavior<D> implements ChartBehavior<D> {
switch (exploreModeTrigger) {
case ExploreModeTrigger.pressHold:
_listener = new GestureListener(onLongPress: _toggleExploreMode);
_listener = GestureListener(onLongPress: _toggleExploreMode);
break;
case ExploreModeTrigger.tap:
_listener = new GestureListener(onTap: _toggleExploreMode);
_listener = GestureListener(onTap: _toggleExploreMode);
break;
}
}

@ -15,7 +15,7 @@
import 'dart:math' show Rectangle;
typedef void OnFocus();
typedef OnFocus = void Function();
/// Container for accessibility data.
class A11yNode {

@ -28,7 +28,8 @@ import 'a11y_explore_behavior.dart'
import 'a11y_node.dart' show A11yNode, OnFocus;
/// Returns a string for a11y vocalization from a list of series datum.
typedef String VocalizationCallback<D>(List<SeriesDatum<D>> seriesDatums);
typedef VocalizationCallback<D> = String Function(
List<SeriesDatum<D>> seriesDatums);
/// A simple vocalization that returns the domain value to string.
String domainVocalization<D>(List<SeriesDatum<D>> seriesDatums) {
@ -58,8 +59,7 @@ class DomainA11yExploreBehavior<D> extends A11yExploreBehavior<D> {
minimumWidth: minimumWidth,
exploreModeEnabledAnnouncement: exploreModeEnabledAnnouncement,
exploreModeDisabledAnnouncement: exploreModeDisabledAnnouncement) {
_lifecycleListener =
new LifecycleListener<D>(onPostprocess: _updateSeriesList);
_lifecycleListener = LifecycleListener<D>(onPostprocess: _updateSeriesList);
}
@override
@ -77,11 +77,11 @@ class DomainA11yExploreBehavior<D> extends A11yExploreBehavior<D> {
D domain = series.domainFn(index);
domainSeriesDatum[domain] ??= <SeriesDatum<D>>[];
domainSeriesDatum[domain].add(new SeriesDatum<D>(series, datum));
domainSeriesDatum[domain].add(SeriesDatum<D>(series, datum));
}
}
domainSeriesDatum.forEach((D domain, List<SeriesDatum<D>> seriesDatums) {
domainSeriesDatum.forEach((domain, seriesDatums) {
final a11yDescription = _vocalizationCallback(seriesDatums);
final firstSeries = seriesDatums.first.series;
@ -93,7 +93,7 @@ class DomainA11yExploreBehavior<D> extends A11yExploreBehavior<D> {
? domainAxis.stepSize
: minimumWidth;
nodes.add(new _DomainA11yNode(a11yDescription,
nodes.add(_DomainA11yNode(a11yDescription,
location: location,
stepSize: stepSize,
chartDrawBounds: _chart.drawAreaBounds,
@ -134,7 +134,7 @@ class DomainA11yExploreBehavior<D> extends A11yExploreBehavior<D> {
}
@override
String get role => 'DomainA11yExplore-${exploreModeTrigger}';
String get role => 'DomainA11yExplore-$exploreModeTrigger';
}
/// A11yNode with domain specific information.
@ -157,16 +157,16 @@ class _DomainA11yNode extends A11yNode implements Comparable<_DomainA11yNode> {
var top = chartDrawBounds.top;
var width = stepSize.round();
var height = chartDrawBounds.height;
boundingBox = new Rectangle(left, top, width, height);
boundingBox = Rectangle(left, top, width, height);
} else {
var left = chartDrawBounds.left;
var top = (location - stepSize / 2).round();
var width = chartDrawBounds.width;
var height = stepSize.round();
boundingBox = new Rectangle(left, top, width, height);
boundingBox = Rectangle(left, top, width, height);
}
return new _DomainA11yNode._internal(label, boundingBox,
return _DomainA11yNode._internal(label, boundingBox,
location: location,
isRtl: isRtl,
renderVertically: renderVertically,

@ -19,7 +19,7 @@ import '../../behavior/chart_behavior.dart' show ChartBehavior;
import '../../processed_series.dart' show MutableSeries;
const percentInjectedKey =
const AttributeKey<bool>('PercentInjector.percentInjected');
AttributeKey<bool>('PercentInjector.percentInjected');
/// Chart behavior that can inject series or domain percentages into each datum.
///
@ -49,7 +49,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
PercentInjector({this.totalType = PercentInjectorTotalType.domain}) {
// Set up chart draw cycle listeners.
_lifecycleListener =
new LifecycleListener<D>(onPreprocess: _preProcess, onData: _onData);
LifecycleListener<D>(onPreprocess: _preProcess, onData: _onData);
}
@override
@ -65,7 +65,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
/// Resets the state of the behavior when new data is drawn on the chart.
void _onData(List<MutableSeries<D>> seriesList) {
// Reset tracking of percentage injection for new data.
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
series.setAttr(percentInjectedKey, false);
});
}
@ -77,7 +77,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
/// the [seriesList] between chart redraws.
void _preProcess(List<MutableSeries<D>> seriesList) {
var percentInjected = true;
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
percentInjected = percentInjected && series.getAttr(percentInjectedKey);
});
@ -95,7 +95,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
// Walk the series and compute the domain total. Series total is
// automatically computed by [MutableSeries].
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
final seriesCategory = series.seriesCategory;
final rawMeasureFn = series.rawMeasureFn;
final domainFn = series.domainFn;
@ -118,10 +118,10 @@ class PercentInjector<D> implements ChartBehavior<D> {
});
// Add percent of domain and series accessor functions.
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
// Replace the default measure accessor with one that computes the
// percentage.
series.measureFn = (int index) {
series.measureFn = (index) {
final measure = series.rawMeasureFn(index);
if (measure == null || measure == 0.0) {
@ -140,7 +140,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
// Replace the default measure lower bound accessor with one that
// computes the percentage.
if (series.measureLowerBoundFn != null) {
series.measureLowerBoundFn = (int index) {
series.measureLowerBoundFn = (index) {
final measureLowerBound = series.rawMeasureLowerBoundFn(index);
if (measureLowerBound == null || measureLowerBound == 0.0) {
@ -160,7 +160,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
// Replace the default measure upper bound accessor with one that
// computes the percentage.
if (series.measureUpperBoundFn != null) {
series.measureUpperBoundFn = (int index) {
series.measureUpperBoundFn = (index) {
final measureUpperBound = series.rawMeasureUpperBoundFn(index);
if (measureUpperBound == null || measureUpperBound == 0.0) {
@ -183,16 +183,16 @@ class PercentInjector<D> implements ChartBehavior<D> {
break;
case PercentInjectorTotalType.series:
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
// Replace the default measure accessor with one that computes the
// percentage.
series.measureFn = (int index) =>
series.rawMeasureFn(index) / series.seriesMeasureTotal;
series.measureFn =
(index) => series.rawMeasureFn(index) / series.seriesMeasureTotal;
// Replace the default measure lower bound accessor with one that
// computes the percentage.
if (series.measureLowerBoundFn != null) {
series.measureLowerBoundFn = (int index) =>
series.measureLowerBoundFn = (index) =>
series.rawMeasureLowerBoundFn(index) /
series.seriesMeasureTotal;
}
@ -200,7 +200,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
// Replace the default measure upper bound accessor with one that
// computes the percentage.
if (series.measureUpperBoundFn != null) {
series.measureUpperBoundFn = (int index) =>
series.measureUpperBoundFn = (index) =>
series.rawMeasureUpperBoundFn(index) /
series.seriesMeasureTotal;
}
@ -211,7 +211,7 @@ class PercentInjector<D> implements ChartBehavior<D> {
break;
default:
throw new ArgumentError('Unsupported totalType: ${totalType}');
throw ArgumentError('Unsupported totalType: $totalType');
}
}

@ -47,9 +47,9 @@ class ChartTitle<D> implements ChartBehavior<D> {
static const _defaultTitleDirection = ChartTitleDirection.auto;
static const _defaultTitleOutsideJustification = OutsideJustification.middle;
static final _defaultTitleStyle =
new TextStyleSpec(fontSize: 18, color: StyleFactory.style.tickColor);
TextStyleSpec(fontSize: 18, color: StyleFactory.style.tickColor);
static final _defaultSubTitleStyle =
new TextStyleSpec(fontSize: 14, color: StyleFactory.style.tickColor);
TextStyleSpec(fontSize: 14, color: StyleFactory.style.tickColor);
static const _defaultInnerPadding = 10;
static const _defaultTitlePadding = 18;
static const _defaultOuterPadding = 10;
@ -79,7 +79,7 @@ class ChartTitle<D> implements ChartBehavior<D> {
TextStyleSpec titleStyleSpec,
String subTitle,
TextStyleSpec subTitleStyleSpec}) {
_config = new _ChartTitleConfig()
_config = _ChartTitleConfig()
..behaviorPosition = behaviorPosition ?? _defaultBehaviorPosition
..innerPadding = innerPadding ?? _defaultInnerPadding
..layoutMinSize = layoutMinSize
@ -96,7 +96,7 @@ class ChartTitle<D> implements ChartBehavior<D> {
..subTitleStyleSpec = subTitleStyleSpec ?? _defaultSubTitleStyle;
_lifecycleListener =
new LifecycleListener<D>(onAxisConfigured: _updateViewData);
LifecycleListener<D>(onAxisConfigured: _updateViewData);
}
/// Layout position for the title.
@ -228,7 +228,7 @@ class ChartTitle<D> implements ChartBehavior<D> {
void attachTo(BaseChart<D> chart) {
_chart = chart;
_view = new _ChartTitleLayoutView<D>(
_view = _ChartTitleLayoutView<D>(
layoutPaintOrder: LayoutViewPaintOrder.chartTitle,
config: _config,
chart: _chart);
@ -270,7 +270,7 @@ class _ChartTitleLayoutView<D> extends LayoutView {
Rectangle<int> _componentBounds;
Rectangle<int> _drawAreaBounds;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
/// Cached layout element for the title text.
///
@ -292,20 +292,12 @@ class _ChartTitleLayoutView<D> extends LayoutView {
@required this.chart})
: this._config = config {
// Set inside body to resolve [_layoutPosition].
_layoutConfig = new LayoutViewConfig(
_layoutConfig = LayoutViewConfig(
paintOrder: layoutPaintOrder,
position: _layoutPosition,
positionOrder: LayoutViewPositionOrder.chartTitle);
}
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
/// Sets the configuration for the title behavior.
set config(_ChartTitleConfig config) {
_config = config;
@ -415,7 +407,7 @@ class _ChartTitleLayoutView<D> extends LayoutView {
// Reset the cached text elements used during the paint step.
_resetTextElementCache();
return new ViewMeasuredSizes(
return ViewMeasuredSizes(
minWidth: minWidth,
minHeight: minHeight,
preferredWidth: preferredWidth,
@ -707,7 +699,7 @@ class _ChartTitleLayoutView<D> extends LayoutView {
labelY = (bounds.bottom - padding).round();
}
return new Point<int>(labelX, labelY);
return Point<int>(labelX, labelY);
}
/// Gets the resolved location for a title in the left or right margin.
@ -780,7 +772,7 @@ class _ChartTitleLayoutView<D> extends LayoutView {
labelX = (bounds.right - padding).round();
}
return new Point<int>(labelX, labelY);
return Point<int>(labelX, labelY);
}
// Helper function that converts [TextStyleSpec] to [TextStyle].

@ -35,7 +35,7 @@ class DomainHighlighter<D> implements ChartBehavior<D> {
DomainHighlighter([this.selectionModelType = SelectionModelType.info]) {
_lifecycleListener =
new LifecycleListener<D>(onPostprocess: _updateColorFunctions);
LifecycleListener<D>(onPostprocess: _updateColorFunctions);
}
void _selectionChanged(SelectionModel selectionModel) {
@ -45,11 +45,11 @@ class DomainHighlighter<D> implements ChartBehavior<D> {
void _updateColorFunctions(List<MutableSeries<D>> seriesList) {
SelectionModel selectionModel =
_chart.getSelectionModel(selectionModelType);
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
final origColorFn = series.colorFn;
if (origColorFn != null) {
series.colorFn = (int index) {
series.colorFn = (index) {
final origColor = origColorFn(index);
if (selectionModel.isDatumSelected(series, index)) {
return origColor.darker;

@ -40,7 +40,7 @@ class InitialSelection<D> implements ChartBehavior<D> {
{this.selectionModelType = SelectionModelType.info,
this.selectedDataConfig,
this.selectedSeriesConfig}) {
_lifecycleListener = new LifecycleListener<D>(onData: _setInitialSelection);
_lifecycleListener = LifecycleListener<D>(onData: _setInitialSelection);
}
void _setInitialSelection(List<MutableSeries<D>> seriesList) {
@ -49,7 +49,7 @@ class InitialSelection<D> implements ChartBehavior<D> {
}
_firstDraw = false;
final immutableModel = new SelectionModel<D>.fromConfig(
final immutableModel = SelectionModel<D>.fromConfig(
selectedDataConfig, selectedSeriesConfig, seriesList);
_chart.getSelectionModel(selectionModelType).updateSelection(

@ -44,7 +44,7 @@ class DatumLegend<D> extends Legend<D> {
}) : super(
selectionModelType: selectionModelType ?? SelectionModelType.info,
legendEntryGenerator:
legendEntryGenerator ?? new PerDatumLegendEntryGenerator(),
legendEntryGenerator ?? PerDatumLegendEntryGenerator(),
entryTextStyle: entryTextStyle) {
// Call the setters that include the setting for default.
this.showMeasures = showMeasures;

@ -51,28 +51,37 @@ import 'legend_entry_generator.dart';
/// Flutter, using widgets).
abstract class Legend<D> implements ChartBehavior<D>, LayoutView {
final SelectionModelType selectionModelType;
final legendState = new LegendState<D>();
final legendState = LegendState<D>();
final LegendEntryGenerator<D> legendEntryGenerator;
String _title;
/// Sets title text to display before legend entries.
String title;
BaseChart _chart;
LifecycleListener<D> _lifecycleListener;
Rectangle<int> _componentBounds;
Rectangle<int> _drawAreaBounds;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
BehaviorPosition _behaviorPosition = BehaviorPosition.end;
OutsideJustification _outsideJustification =
BehaviorPosition behaviorPosition = BehaviorPosition.end;
OutsideJustification outsideJustification =
OutsideJustification.startDrawArea;
InsideJustification _insideJustification = InsideJustification.topStart;
LegendCellPadding _cellPadding;
LegendCellPadding _legendPadding;
InsideJustification insideJustification = InsideJustification.topStart;
LegendCellPadding cellPadding;
LegendCellPadding legendPadding;
TextStyleSpec _titleTextStyle;
/// Text style of the legend title text.
TextStyleSpec titleTextStyle;
LegendTapHandling _legendTapHandling = LegendTapHandling.hide;
/// Configures the behavior of the legend when the user taps/clicks on an
/// entry. Defaults to no behavior.
///
/// Tapping on a legend entry will update the data visible on the chart. For
/// example, when [LegendTapHandling.hide] is configured, the series or datum
/// associated with that entry will be removed from the chart. Tapping on that
/// entry a second time will make the data visible again.
LegendTapHandling legendTapHandling = LegendTapHandling.hide;
List<MutableSeries<D>> _currentSeriesList;
@ -80,7 +89,7 @@ abstract class Legend<D> implements ChartBehavior<D>, LayoutView {
/// the legend entries.
List<MutableSeries<D>> _postProcessSeriesList;
static final _decimalPattern = new NumberFormat.decimalPattern();
static final _decimalPattern = NumberFormat.decimalPattern();
/// Default measure formatter for legends.
@protected
@ -89,50 +98,11 @@ abstract class Legend<D> implements ChartBehavior<D>, LayoutView {
}
Legend({this.selectionModelType, this.legendEntryGenerator, entryTextStyle}) {
_lifecycleListener = new LifecycleListener(
_lifecycleListener = LifecycleListener(
onPostprocess: _postProcess, onPreprocess: _preProcess, onData: onData);
legendEntryGenerator.entryTextStyle = entryTextStyle;
}
String get title => _title;
/// Sets title text to display before legend entries.
set title(String title) {
_title = title;
}
BehaviorPosition get behaviorPosition => _behaviorPosition;
set behaviorPosition(BehaviorPosition behaviorPosition) {
_behaviorPosition = behaviorPosition;
}
OutsideJustification get outsideJustification => _outsideJustification;
set outsideJustification(OutsideJustification outsideJustification) {
_outsideJustification = outsideJustification;
}
InsideJustification get insideJustification => _insideJustification;
set insideJustification(InsideJustification insideJustification) {
_insideJustification = insideJustification;
}
LegendCellPadding get cellPadding => _cellPadding;
set cellPadding(LegendCellPadding cellPadding) {
_cellPadding = cellPadding;
}
LegendCellPadding get legendPadding => _legendPadding;
set legendPadding(LegendCellPadding legendPadding) {
_legendPadding = legendPadding;
}
LegendTapHandling get legendTapHandling => _legendTapHandling;
/// Text style of the legend entry text.
TextStyleSpec get entryTextStyle => legendEntryGenerator.entryTextStyle;
@ -140,31 +110,13 @@ abstract class Legend<D> implements ChartBehavior<D>, LayoutView {
legendEntryGenerator.entryTextStyle = entryTextStyle;
}
/// Text style of the legend title text.
TextStyleSpec get titleTextStyle => _titleTextStyle;
set titleTextStyle(TextStyleSpec titleTextStyle) {
_titleTextStyle = titleTextStyle;
}
/// Configures the behavior of the legend when the user taps/clicks on an
/// entry. Defaults to no behavior.
///
/// Tapping on a legend entry will update the data visible on the chart. For
/// example, when [LegendTapHandling.hide] is configured, the series or datum
/// associated with that entry will be removed from the chart. Tapping on that
/// entry a second time will make the data visible again.
set legendTapHandling(LegendTapHandling legendTapHandling) {
_legendTapHandling = legendTapHandling;
}
/// Resets any hidden series data when new data is drawn on the chart.
@protected
void onData(List<MutableSeries<D>> seriesList) {}
/// Store off a copy of the series list for use when we render the legend.
void _preProcess(List<MutableSeries<D>> seriesList) {
_currentSeriesList = new List.from(seriesList);
_currentSeriesList = List.from(seriesList);
preProcessSeriesList(seriesList);
}
@ -251,17 +203,9 @@ abstract class Legend<D> implements ChartBehavior<D>, LayoutView {
bool get isRtl => _chart.context.isRtl;
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
@override
LayoutViewConfig get layoutConfig {
return new LayoutViewConfig(
return LayoutViewConfig(
position: _layoutPosition,
positionOrder: LayoutViewPositionOrder.legend,
paintOrder: LayoutViewPaintOrder.legend);
@ -270,7 +214,7 @@ abstract class Legend<D> implements ChartBehavior<D>, LayoutView {
/// Get layout position from legend position.
LayoutPosition get _layoutPosition {
LayoutPosition position;
switch (_behaviorPosition) {
switch (behaviorPosition) {
case BehaviorPosition.bottom:
position = LayoutPosition.Bottom;
break;
@ -296,7 +240,7 @@ abstract class Legend<D> implements ChartBehavior<D>, LayoutView {
ViewMeasuredSizes measure(int maxWidth, int maxHeight) {
// Native child classes should override this method to return real
// measurements.
return new ViewMeasuredSizes(preferredWidth: 0, preferredHeight: 0);
return ViewMeasuredSizes(preferredWidth: 0, preferredHeight: 0);
}
@override

@ -39,8 +39,7 @@ class PerDatumLegendEntryGenerator<D> implements LegendEntryGenerator<D> {
final series = seriesList[0];
for (var i = 0; i < series.data.length; i++) {
legendEntries.add(new LegendEntry<D>(
series, series.domainFn(i).toString(),
legendEntries.add(LegendEntry<D>(series, series.domainFn(i).toString(),
color: series.colorFn(i),
datum: series.data[i],
datumIndex: i,

@ -38,7 +38,7 @@ class PerSeriesLegendEntryGenerator<D> implements LegendEntryGenerator<D> {
@override
List<LegendEntry<D>> getLegendEntries(List<MutableSeries<D>> seriesList) {
final legendEntries = seriesList
.map((series) => new LegendEntry<D>(series, series.displayName,
.map((series) => LegendEntry<D>(series, series.displayName,
color: series.colorFn(0), textStyle: entryTextStyle))
.toList();
@ -72,7 +72,7 @@ class PerSeriesLegendEntryGenerator<D> implements LegendEntryGenerator<D> {
final seriesAndMeasure = <String, num>{};
// Hash set of series ID's that use the secondary measure axis
final secondaryAxisSeriesIDs = new HashSet<String>();
final secondaryAxisSeriesIDs = HashSet<String>();
for (SeriesDatum<D> selectedDatum in selectionModel.selectedDatum) {
final series = selectedDatum.series;

@ -31,7 +31,7 @@ import 'per_series_legend_entry_generator.dart';
/// By default this behavior creates a legend entry per series.
class SeriesLegend<D> extends Legend<D> {
/// List of currently hidden series, by ID.
final _hiddenSeriesList = new Set<String>();
final _hiddenSeriesList = Set<String>();
/// List of series IDs that should be hidden by default.
List<String> _defaultHiddenSeries;
@ -50,7 +50,7 @@ class SeriesLegend<D> extends Legend<D> {
}) : super(
selectionModelType: selectionModelType ?? SelectionModelType.info,
legendEntryGenerator:
legendEntryGenerator ?? new PerSeriesLegendEntryGenerator(),
legendEntryGenerator ?? PerSeriesLegendEntryGenerator(),
entryTextStyle: entryTextStyle) {
// Call the setters that include the setting for default.
this.showMeasures = showMeasures;
@ -134,14 +134,14 @@ class SeriesLegend<D> extends Legend<D> {
void onData(List<MutableSeries<D>> seriesList) {
// If a series was removed from the chart, remove it from our current list
// of hidden series.
final seriesIds = seriesList.map((MutableSeries<D> series) => series.id);
final seriesIds = seriesList.map((series) => series.id);
_hiddenSeriesList.removeWhere((String id) => !seriesIds.contains(id));
_hiddenSeriesList.removeWhere((id) => !seriesIds.contains(id));
}
@override
void preProcessSeriesList(List<MutableSeries<D>> seriesList) {
seriesList.removeWhere((MutableSeries<D> series) {
seriesList.removeWhere((series) {
return _hiddenSeriesList.contains(series.id);
});
}
@ -161,7 +161,7 @@ class SeriesLegend<D> extends Legend<D> {
/// color if it was previously hidden.
@protected
void showSeries(String seriesId) {
_hiddenSeriesList.removeWhere((String id) => id == seriesId);
_hiddenSeriesList.removeWhere((id) => id == seriesId);
}
/// Returns whether or not a given series [seriesId] is currently hidden.

@ -133,16 +133,16 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {
LinePointHighlighterFollowLineType.nearest,
dashPattern = dashPattern ?? [1, 3],
drawFollowLinesAcrossChart = drawFollowLinesAcrossChart ?? true,
symbolRenderer = symbolRenderer ?? new CircleSymbolRenderer() {
symbolRenderer = symbolRenderer ?? CircleSymbolRenderer() {
_lifecycleListener =
new LifecycleListener<D>(onAxisConfigured: _updateViewData);
LifecycleListener<D>(onAxisConfigured: _updateViewData);
}
@override
void attachTo(BaseChart<D> chart) {
_chart = chart;
_view = new _LinePointLayoutView<D>(
_view = _LinePointLayoutView<D>(
chart: chart,
layoutPaintOrder: LayoutViewPaintOrder.linePointHighlighter,
showHorizontalFollowLine: showHorizontalFollowLine,
@ -205,7 +205,7 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {
? detail.radiusPx.toDouble() + radiusPaddingPx
: defaultRadiusPx;
final pointKey = '${lineKey}::${detail.domain}';
final pointKey = '$lineKey::${detail.domain}';
// If we already have a point for that key, use it.
_AnimatedPoint<D> animatingPoint;
@ -213,16 +213,16 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {
animatingPoint = _seriesPointMap[pointKey];
} else {
// Create a new point and have it animate in from axis.
final point = new _DatumPoint<D>(
final point = _DatumPoint<D>(
datum: datum,
domain: detail.domain,
series: series,
x: domainAxis.getLocation(detail.domain),
y: measureAxis.getLocation(0.0));
animatingPoint = new _AnimatedPoint<D>(
animatingPoint = _AnimatedPoint<D>(
key: pointKey, overlaySeries: series.overlaySeries)
..setNewTarget(new _PointRendererElement<D>()
..setNewTarget(_PointRendererElement<D>()
..point = point
..color = detail.color
..fillColor = detail.fillColor
@ -235,7 +235,7 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {
newSeriesMap[pointKey] = animatingPoint;
// Create a new line using the final point locations.
final point = new _DatumPoint<D>(
final point = _DatumPoint<D>(
datum: datum,
domain: detail.domain,
series: series,
@ -246,7 +246,7 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {
_currentKeys.add(pointKey);
// Get the point element we are going to setup.
final pointElement = new _PointRendererElement<D>()
final pointElement = _PointRendererElement<D>()
..point = point
..color = detail.color
..fillColor = detail.fillColor
@ -259,7 +259,7 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {
}
// Animate out points that don't exist anymore.
_seriesPointMap.forEach((String key, _AnimatedPoint<D> point) {
_seriesPointMap.forEach((key, point) {
if (_currentKeys.contains(point.key) != true) {
point.animateOut();
newSeriesMap[point.key] = point;
@ -293,7 +293,7 @@ class _LinePointLayoutView<D> extends LayoutView {
final SymbolRenderer symbolRenderer;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
/// Store a map of series drawn on the chart, mapped by series name.
///
@ -309,7 +309,7 @@ class _LinePointLayoutView<D> extends LayoutView {
@required this.symbolRenderer,
this.dashPattern,
this.drawFollowLinesAcrossChart,
}) : this.layoutConfig = new LayoutViewConfig(
}) : this.layoutConfig = LayoutViewConfig(
paintOrder: LayoutViewPaintOrder.linePointHighlighter,
position: LayoutPosition.DrawArea,
positionOrder: layoutPaintOrder);
@ -318,14 +318,6 @@ class _LinePointLayoutView<D> extends LayoutView {
_seriesPointMap = value;
}
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
@override
ViewMeasuredSizes measure(int maxWidth, int maxHeight) {
return null;
@ -346,17 +338,17 @@ class _LinePointLayoutView<D> extends LayoutView {
if (animationPercent == 1.0) {
final keysToRemove = <String>[];
_seriesPointMap.forEach((String key, _AnimatedPoint<D> point) {
_seriesPointMap.forEach((key, point) {
if (point.animatingOut) {
keysToRemove.add(key);
}
});
keysToRemove.forEach((String key) => _seriesPointMap.remove(key));
keysToRemove.forEach((key) => _seriesPointMap.remove(key));
}
final points = <_PointRendererElement<D>>[];
_seriesPointMap.forEach((String key, _AnimatedPoint<D> point) {
_seriesPointMap.forEach((key, point) {
points.add(point.getCurrentPoint(animationPercent));
});
@ -449,8 +441,8 @@ class _LinePointLayoutView<D> extends LayoutView {
canvas.drawLine(
points: [
new Point<num>(leftBound, pointElement.point.y),
new Point<num>(rightBound, pointElement.point.y),
Point<num>(leftBound, pointElement.point.y),
Point<num>(rightBound, pointElement.point.y),
],
stroke: StyleFactory.style.linePointHighlighterColor,
strokeWidthPx: 1.0,
@ -473,8 +465,8 @@ class _LinePointLayoutView<D> extends LayoutView {
canvas.drawLine(
points: [
new Point<num>(pointElement.point.x, topBound),
new Point<num>(
Point<num>(pointElement.point.x, topBound),
Point<num>(
pointElement.point.x, drawBounds.top + drawBounds.height),
],
stroke: StyleFactory.style.linePointHighlighterColor,
@ -500,7 +492,7 @@ class _LinePointLayoutView<D> extends LayoutView {
continue;
}
final bounds = new Rectangle<double>(
final bounds = Rectangle<double>(
pointElement.point.x - pointElement.radiusPx,
pointElement.point.y - pointElement.radiusPx,
pointElement.radiusPx * 2,
@ -531,7 +523,7 @@ class _DatumPoint<D> extends Point<double> {
: super(x, y);
factory _DatumPoint.from(_DatumPoint<D> other, [double x, double y]) {
return new _DatumPoint<D>(
return _DatumPoint<D>(
datum: other.datum,
domain: other.domain,
series: other.series,
@ -550,7 +542,7 @@ class _PointRendererElement<D> {
SymbolRenderer symbolRenderer;
_PointRendererElement<D> clone() {
return new _PointRendererElement<D>()
return _PointRendererElement<D>()
..point = this.point
..color = this.color
..fillColor = this.fillColor
@ -569,7 +561,7 @@ class _PointRendererElement<D> {
final y = _lerpDouble(previousPoint.y, targetPoint.y, animationPercent);
point = new _DatumPoint<D>.from(targetPoint, x, y);
point = _DatumPoint<D>.from(targetPoint, x, y);
color = getAnimatedColor(previous.color, target.color, animationPercent);
@ -625,7 +617,7 @@ class _AnimatedPoint<D> {
// Set the target measure value to the axis position for all points.
final targetPoint = newTarget.point;
final newPoint = new _DatumPoint<D>.from(targetPoint, targetPoint.x,
final newPoint = _DatumPoint<D>.from(targetPoint, targetPoint.x,
newTarget.measureAxisPosition.roundToDouble());
newTarget.point = newPoint;
@ -685,7 +677,7 @@ class LinePointHighlighterTester<D> {
bool isDatumSelected(D datum) {
var contains = false;
behavior._seriesPointMap.forEach((String key, _AnimatedPoint<D> point) {
behavior._seriesPointMap.forEach((key, point) {
if (point._currentPoint.point.datum == datum) {
contains = true;
return;

@ -54,7 +54,7 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
static const _defaultLabelPosition = AnnotationLabelPosition.auto;
static const _defaultLabelPadding = 5;
static final _defaultLabelStyle =
new TextStyleSpec(fontSize: 12, color: Color.black);
TextStyleSpec(fontSize: 12, color: Color.black);
static const _defaultStrokeWidthPx = 2.0;
/// List of annotations to render on the chart.
@ -121,20 +121,20 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
extendAxis = extendAxis ?? true,
labelPadding = labelPadding ?? _defaultLabelPadding,
defaultStrokeWidthPx = defaultStrokeWidthPx ?? _defaultStrokeWidthPx {
_lifecycleListener = new LifecycleListener<D>(
_lifecycleListener = LifecycleListener<D>(
onPostprocess: _updateAxisRange, onAxisConfigured: _updateViewData);
}
@override
void attachTo(BaseChart<D> chart) {
if (!(chart is CartesianChart)) {
throw new ArgumentError(
throw ArgumentError(
'RangeAnnotation can only be attached to a CartesianChart');
}
_chart = chart;
_view = new _RangeAnnotationLayoutView<D>(
_view = _RangeAnnotationLayoutView<D>(
defaultColor: defaultColor, labelPadding: labelPadding, chart: chart);
chart.addView(_view);
@ -155,7 +155,7 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
if (extendAxis) {
final domainAxis = _chart.domainAxis;
annotations.forEach((AnnotationSegment annotation) {
annotations.forEach((annotation) {
Axis axis;
switch (annotation.axisType) {
@ -182,7 +182,7 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
void _updateViewData() {
_currentKeys.clear();
annotations.forEach((AnnotationSegment annotation) {
annotations.forEach((annotation) {
Axis axis;
switch (annotation.axisType) {
@ -251,8 +251,8 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
animatingAnnotation = _annotationMap[key];
} else {
// Create a new annotation, positioned at the start and end values.
animatingAnnotation = new _AnimatedAnnotation<D>(key: key)
..setNewTarget(new _AnnotationElement<D>()
animatingAnnotation = _AnimatedAnnotation<D>(key: key)
..setNewTarget(_AnnotationElement<D>()
..annotation = annotationDatum
..color = color
..dashPattern = dashPattern
@ -272,7 +272,7 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
_currentKeys.add(key);
// Get the annotation element we are going to setup.
final annotationElement = new _AnnotationElement<D>()
final annotationElement = _AnnotationElement<D>()
..annotation = annotationDatum
..color = color
..dashPattern = dashPattern
@ -289,7 +289,7 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
});
// Animate out annotations that don't exist anymore.
_annotationMap.forEach((String key, _AnimatedAnnotation<D> annotation) {
_annotationMap.forEach((key, annotation) {
if (_currentKeys.contains(annotation.key) != true) {
annotation.animateOut();
}
@ -310,7 +310,7 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
final startPosition = (axis.getLocation(startValue) * 100).round() / 100;
final endPosition = (axis.getLocation(endValue) * 100).round() / 100;
return new _DatumAnnotation(
return _DatumAnnotation(
startPosition: startPosition,
endPosition: endPosition,
axisType: axisType);
@ -335,7 +335,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
Rectangle<int> get drawBounds => _drawAreaBounds;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
/// Store a map of series drawn on the chart, mapped by series name.
///
@ -347,7 +347,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
@required this.defaultColor,
@required this.labelPadding,
@required this.chart,
}) : this.layoutConfig = new LayoutViewConfig(
}) : this.layoutConfig = LayoutViewConfig(
paintOrder: LayoutViewPaintOrder.rangeAnnotation,
position: LayoutPosition.DrawArea,
positionOrder: LayoutViewPositionOrder.drawArea);
@ -356,14 +356,6 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
_annotationMap = value;
}
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
@override
ViewMeasuredSizes measure(int maxWidth, int maxHeight) {
return null;
@ -384,16 +376,16 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
if (animationPercent == 1.0) {
final keysToRemove = <String>[];
_annotationMap.forEach((String key, _AnimatedAnnotation<D> annotation) {
_annotationMap.forEach((key, annotation) {
if (annotation.animatingOut) {
keysToRemove.add(key);
}
});
keysToRemove.forEach((String key) => _annotationMap.remove(key));
keysToRemove.forEach((key) => _annotationMap.remove(key));
}
_annotationMap.forEach((String key, _AnimatedAnnotation<D> annotation) {
_annotationMap.forEach((key, annotation) {
final annotationElement =
annotation.getCurrentAnnotation(animationPercent);
@ -477,7 +469,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
switch (annotationElement.annotation.axisType) {
case RangeAnnotationAxisType.domain:
bounds = new Rectangle<num>(
bounds = Rectangle<num>(
annotationElement.annotation.startPosition,
_drawAreaBounds.top,
annotationElement.annotation.endPosition -
@ -486,7 +478,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
break;
case RangeAnnotationAxisType.measure:
bounds = new Rectangle<num>(
bounds = Rectangle<num>(
_drawAreaBounds.left,
annotationElement.annotation.endPosition,
_drawAreaBounds.width,
@ -505,16 +497,16 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
switch (annotationElement.annotation.axisType) {
case RangeAnnotationAxisType.domain:
points.add(new Point<num>(
points.add(Point<num>(
annotationElement.annotation.startPosition, _drawAreaBounds.top));
points.add(new Point<num>(
points.add(Point<num>(
annotationElement.annotation.endPosition, _drawAreaBounds.bottom));
break;
case RangeAnnotationAxisType.measure:
points.add(new Point<num>(
points.add(Point<num>(
_drawAreaBounds.left, annotationElement.annotation.startPosition));
points.add(new Point<num>(
points.add(Point<num>(
_drawAreaBounds.right, annotationElement.annotation.endPosition));
break;
}
@ -655,7 +647,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
switch (calculatedLabelPosition) {
case AnnotationLabelPosition.margin:
case AnnotationLabelPosition.auto:
throw new ArgumentError(_unresolvedAutoMessage);
throw ArgumentError(_unresolvedAutoMessage);
break;
case AnnotationLabelPosition.outside:
@ -685,7 +677,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
break;
}
return new Point<int>(labelX.round(), labelY.round());
return Point<int>(labelX.round(), labelY.round());
}
/// Gets the resolved location for a vertical domain annotation label element.
@ -734,7 +726,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
switch (calculatedLabelPosition) {
case AnnotationLabelPosition.margin:
case AnnotationLabelPosition.auto:
throw new ArgumentError(_unresolvedAutoMessage);
throw ArgumentError(_unresolvedAutoMessage);
break;
case AnnotationLabelPosition.outside:
@ -764,7 +756,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
break;
}
return new Point<int>(labelX.round(), labelY.round());
return Point<int>(labelX.round(), labelY.round());
}
/// Gets the resolved location for a measure annotation label element.
@ -834,7 +826,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
switch (calculatedLabelPosition) {
case AnnotationLabelPosition.margin:
case AnnotationLabelPosition.auto:
throw new ArgumentError(_unresolvedAutoMessage);
throw ArgumentError(_unresolvedAutoMessage);
break;
case AnnotationLabelPosition.outside:
@ -858,7 +850,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
break;
}
return new Point<int>(labelX.round(), labelY.round());
return Point<int>(labelX.round(), labelY.round());
}
/// Gets the resolved location for a vertical measure annotation label
@ -920,7 +912,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
switch (calculatedLabelPosition) {
case AnnotationLabelPosition.margin:
case AnnotationLabelPosition.auto:
throw new ArgumentError(_unresolvedAutoMessage);
throw ArgumentError(_unresolvedAutoMessage);
break;
case AnnotationLabelPosition.outside:
@ -944,7 +936,7 @@ class _RangeAnnotationLayoutView<D> extends LayoutView {
break;
}
return new Point<int>(labelX.round(), labelY.round());
return Point<int>(labelX.round(), labelY.round());
}
/// Resolves [AnnotationLabelPosition.auto] configuration for an annotation
@ -1014,7 +1006,7 @@ class _DatumAnnotation {
factory _DatumAnnotation.from(_DatumAnnotation other,
[double startPosition, double endPosition]) {
return new _DatumAnnotation(
return _DatumAnnotation(
startPosition: startPosition ?? other.startPosition,
endPosition: endPosition ?? other.endPosition,
axisType: other.axisType);
@ -1035,9 +1027,9 @@ class _AnnotationElement<D> {
double strokeWidthPx;
_AnnotationElement<D> clone() {
return new _AnnotationElement<D>()
..annotation = new _DatumAnnotation.from(annotation)
..color = color != null ? new Color.fromOther(color: color) : null
return _AnnotationElement<D>()
..annotation = _DatumAnnotation.from(annotation)
..color = color != null ? Color.fromOther(color: color) : null
..startLabel = this.startLabel
..endLabel = this.endLabel
..isRange = this.isRange
@ -1065,7 +1057,7 @@ class _AnnotationElement<D> {
previousAnnotation.endPosition;
annotation =
new _DatumAnnotation.from(targetAnnotation, startPosition, endPosition);
_DatumAnnotation.from(targetAnnotation, startPosition, endPosition);
color = getAnimatedColor(previous.color, target.color, animationPercent);
@ -1128,7 +1120,7 @@ class RangeAnnotationTester<D> {
RangeAnnotationTester(this.behavior);
set graphicsFactory(GraphicsFactory value) {
behavior._view._graphicsFactory = value;
behavior._view.graphicsFactory = value;
}
mockLayout(Rectangle<int> bounds) {
@ -1148,7 +1140,7 @@ class RangeAnnotationTester<D> {
AnnotationLabelPosition labelPosition}) {
var exists = false;
behavior._annotationMap.forEach((String key, _AnimatedAnnotation<D> a) {
behavior._annotationMap.forEach((key, a) {
final currentAnnotation = a._currentAnnotation;
final annotation = currentAnnotation.annotation;
@ -1222,7 +1214,7 @@ class RangeAnnotationSegment<D> extends AnnotationSegment<D> {
labelStyleSpec: labelStyleSpec);
@override
String get key => 'r::${axisType}::${axisId}::${startValue}::${endValue}';
String get key => 'r::$axisType::$axisId::$startValue::$endValue';
}
/// Data for a chart line annotation.
@ -1253,7 +1245,7 @@ class LineAnnotationSegment<D> extends AnnotationSegment<D> {
labelStyleSpec: labelStyleSpec);
@override
String get key => 'l::${axisType}::${axisId}::${value}';
String get key => 'l::$axisType::$axisId::$value';
}
/// Axis type for an annotation.

@ -47,11 +47,10 @@ class LockSelection<D> implements ChartBehavior<D> {
// Setup the appropriate gesture listening.
switch (this.eventTrigger) {
case SelectionTrigger.tap:
_listener =
new GestureListener(onTapTest: _onTapTest, onTap: _onSelect);
_listener = GestureListener(onTapTest: _onTapTest, onTap: _onSelect);
break;
default:
throw new ArgumentError('LockSelection does not support the event '
throw ArgumentError('LockSelection does not support the event '
'trigger "${this.eventTrigger}"');
break;
}

@ -107,11 +107,10 @@ class SelectNearest<D> implements ChartBehavior<D> {
// Setup the appropriate gesture listening.
switch (this.eventTrigger) {
case SelectionTrigger.tap:
_listener =
new GestureListener(onTapTest: _onTapTest, onTap: _onSelect);
_listener = GestureListener(onTapTest: _onTapTest, onTap: _onSelect);
break;
case SelectionTrigger.tapAndDrag:
_listener = new GestureListener(
_listener = GestureListener(
onTapTest: _onTapTest,
onTap: _onSelect,
onDragStart: _onSelect,
@ -119,7 +118,7 @@ class SelectNearest<D> implements ChartBehavior<D> {
);
break;
case SelectionTrigger.pressHold:
_listener = new GestureListener(
_listener = GestureListener(
onTapTest: _onTapTest,
onLongPress: _onSelect,
onDragStart: _onSelect,
@ -127,7 +126,7 @@ class SelectNearest<D> implements ChartBehavior<D> {
onDragEnd: _onDeselectAll);
break;
case SelectionTrigger.longPressHold:
_listener = new GestureListener(
_listener = GestureListener(
onTapTest: _onTapTest,
onLongPress: _onLongPressSelect,
onDragStart: _onSelect,
@ -136,7 +135,7 @@ class SelectNearest<D> implements ChartBehavior<D> {
break;
case SelectionTrigger.hover:
default:
_listener = new GestureListener(onHover: _onSelect);
_listener = GestureListener(onHover: _onSelect);
break;
}
}
@ -171,11 +170,10 @@ class SelectNearest<D> implements ChartBehavior<D> {
details[0].domainDistance <= maximumDomainDistancePx) {
seriesDatumList = expandToDomain
? _expandToDomain(details.first)
: [new SeriesDatum<D>(details.first.series, details.first.datum)];
: [SeriesDatum<D>(details.first.series, details.first.datum)];
// Filter out points from overlay series.
seriesDatumList
.removeWhere((SeriesDatum<D> datum) => datum.series.overlaySeries);
seriesDatumList.removeWhere((datum) => datum.series.overlaySeries);
if (selectClosestSeries && seriesList.isEmpty) {
if (details.first.series.overlaySeries) {
@ -184,7 +182,7 @@ class SelectNearest<D> implements ChartBehavior<D> {
// copy of the list by domain distance because we do not want to
// re-order the actual return values here.
final sortedSeriesDatumList =
new List<SeriesDatum<D>>.from(seriesDatumList);
List<SeriesDatum<D>>.from(seriesDatumList);
sortedSeriesDatumList.sort((a, b) =>
a.datum.domainDistance.compareTo(b.datum.domainDistance));
seriesList.add(sortedSeriesDatumList.first.series);
@ -215,7 +213,7 @@ class SelectNearest<D> implements ChartBehavior<D> {
List<SeriesDatum<D>> _expandToDomain(DatumDetails<D> nearestDetails) {
// Make sure that the "nearest" datum is at the top of the list.
final data = <SeriesDatum<D>>[
new SeriesDatum(nearestDetails.series, nearestDetails.datum)
SeriesDatum(nearestDetails.series, nearestDetails.datum)
];
final nearestDomain = nearestDetails.domain;
@ -236,7 +234,7 @@ class SelectNearest<D> implements ChartBehavior<D> {
}
if (domain == nearestDomain) {
data.add(new SeriesDatum(series, datum));
data.add(SeriesDatum(series, datum));
} else if (testBounds) {
final domainLowerBound = domainLowerBoundFn(i);
final domainUpperBound = domainUpperBoundFn(i);
@ -261,7 +259,7 @@ class SelectNearest<D> implements ChartBehavior<D> {
}
if (addDatum) {
data.add(new SeriesDatum(series, datum));
data.add(SeriesDatum(series, datum));
}
}
}

@ -153,9 +153,9 @@ class Slider<D> implements ChartBehavior<D> {
this.snapToDatum = false,
SliderStyle style,
this.layoutPaintOrder = LayoutViewPaintOrder.slider}) {
_handleRenderer = handleRenderer ?? new RectSymbolRenderer();
_handleRenderer = handleRenderer ?? RectSymbolRenderer();
_roleId = roleId ?? '';
_style = style ?? new SliderStyle();
_style = style ?? SliderStyle();
_domainValue = initialDomainValue;
if (_domainValue != null) {
@ -165,7 +165,7 @@ class Slider<D> implements ChartBehavior<D> {
// Setup the appropriate gesture listening.
switch (this.eventTrigger) {
case SelectionTrigger.tapAndDrag:
_gestureListener = new GestureListener(
_gestureListener = GestureListener(
onTapTest: _onTapTest,
onTap: _onSelect,
onDragStart: _onSelect,
@ -173,7 +173,7 @@ class Slider<D> implements ChartBehavior<D> {
onDragEnd: _onDragEnd);
break;
case SelectionTrigger.pressHold:
_gestureListener = new GestureListener(
_gestureListener = GestureListener(
onTapTest: _onTapTest,
onLongPress: _onSelect,
onDragStart: _onSelect,
@ -181,7 +181,7 @@ class Slider<D> implements ChartBehavior<D> {
onDragEnd: _onDragEnd);
break;
case SelectionTrigger.longPressHold:
_gestureListener = new GestureListener(
_gestureListener = GestureListener(
onTapTest: _onTapTest,
onLongPress: _onLongPressSelect,
onDragStart: _onSelect,
@ -189,21 +189,20 @@ class Slider<D> implements ChartBehavior<D> {
onDragEnd: _onDragEnd);
break;
default:
throw new ArgumentError('Slider does not support the event trigger '
throw ArgumentError('Slider does not support the event trigger '
'"${this.eventTrigger}"');
break;
}
// Set up chart draw cycle listeners.
_lifecycleListener = new LifecycleListener<D>(
_lifecycleListener = LifecycleListener<D>(
onData: _setInitialDragState,
onAxisConfigured: _updateViewData,
onPostrender: _fireChangeEvent,
);
// Set up slider event listeners.
_sliderEventListener =
new SliderEventListener<D>(onChange: onChangeCallback);
_sliderEventListener = SliderEventListener<D>(onChange: onChangeCallback);
}
bool _onTapTest(Point<double> chartPoint) {
@ -286,7 +285,7 @@ class Slider<D> implements ChartBehavior<D> {
}
void _updateViewData() {
_sliderHandle ??= new _AnimatedSlider();
_sliderHandle ??= _AnimatedSlider();
// If not set in the constructor, initial position for the handle is the
// center of the draw area.
@ -299,10 +298,10 @@ class Slider<D> implements ChartBehavior<D> {
_moveSliderToDomain(_domainValue);
// Move the handle to the current event position.
final element = new _SliderElement()
final element = _SliderElement()
..domainCenterPoint =
new Point<int>(_domainCenterPoint.x, _domainCenterPoint.y)
..buttonBounds = new Rectangle<int>(_handleBounds.left, _handleBounds.top,
Point<int>(_domainCenterPoint.x, _domainCenterPoint.y)
..buttonBounds = Rectangle<int>(_handleBounds.left, _handleBounds.top,
_handleBounds.width, _handleBounds.height)
..fill = _style.fillColor
..stroke = _style.strokeColor
@ -342,7 +341,7 @@ class Slider<D> implements ChartBehavior<D> {
// Fire the event.
_sliderEventListener.onChange(
new Point<int>(_domainCenterPoint.x, _domainCenterPoint.y),
Point<int>(_domainCenterPoint.x, _domainCenterPoint.y),
_domainValue,
_roleId,
dragState);
@ -378,10 +377,9 @@ class Slider<D> implements ChartBehavior<D> {
_domainValue = _chart.domainAxis.getDomain(position.toDouble());
if (_domainCenterPoint != null) {
_domainCenterPoint =
new Point<int>(position.round(), _domainCenterPoint.y);
_domainCenterPoint = Point<int>(position.round(), _domainCenterPoint.y);
} else {
_domainCenterPoint = new Point<int>(
_domainCenterPoint = Point<int>(
position.round(), (viewBounds.top + viewBounds.height / 2).round());
}
@ -394,12 +392,12 @@ class Slider<D> implements ChartBehavior<D> {
handleReferenceY = viewBounds.top;
break;
default:
throw new ArgumentError('Slider does not support the handle position '
throw ArgumentError('Slider does not support the handle position '
'"${_style.handlePosition}"');
}
// Move the slider handle along the domain axis.
_handleBounds = new Rectangle<int>(
_handleBounds = Rectangle<int>(
(_domainCenterPoint.x -
_style.handleSize.width / 2 +
_style.handleOffset.x)
@ -432,7 +430,7 @@ class Slider<D> implements ChartBehavior<D> {
bool _moveSliderToDomain(D domain) {
final x = _chart.domainAxis.getLocation(domain);
return _moveSliderToPoint(new Point<double>(x, 0.0));
return _moveSliderToPoint(Point<double>(x, 0.0));
}
/// Programmatically moves the slider to the location of [domain] on the
@ -470,8 +468,7 @@ class Slider<D> implements ChartBehavior<D> {
@override
void attachTo(BaseChart<D> chart) {
if (!(chart is CartesianChart)) {
throw new ArgumentError(
'Slider can only be attached to a cartesian chart.');
throw ArgumentError('Slider can only be attached to a cartesian chart.');
}
_chart = chart as CartesianChart;
@ -479,7 +476,7 @@ class Slider<D> implements ChartBehavior<D> {
// Only vertical rendering is supported by this behavior.
assert(_chart.vertical);
_view = new _SliderLayoutView<D>(
_view = _SliderLayoutView<D>(
layoutPaintOrder: layoutPaintOrder, handleRenderer: _handleRenderer);
chart.addView(_view);
@ -496,7 +493,7 @@ class Slider<D> implements ChartBehavior<D> {
}
@override
String get role => 'Slider-${eventTrigger.toString()}-${_roleId}';
String get role => 'Slider-${eventTrigger.toString()}-$_roleId';
}
/// Style configuration for a [Slider] behavior.
@ -572,7 +569,7 @@ class _SliderLayoutView<D> extends LayoutView {
Rectangle<int> get drawBounds => _drawAreaBounds;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
/// Renderer for the handle. Defaults to a rectangle.
SymbolRenderer _handleRenderer;
@ -582,7 +579,7 @@ class _SliderLayoutView<D> extends LayoutView {
_SliderLayoutView(
{@required int layoutPaintOrder, @required SymbolRenderer handleRenderer})
: this.layoutConfig = new LayoutViewConfig(
: this.layoutConfig = LayoutViewConfig(
paintOrder: layoutPaintOrder,
position: LayoutPosition.DrawArea,
positionOrder: LayoutViewPositionOrder.drawArea),
@ -592,14 +589,6 @@ class _SliderLayoutView<D> extends LayoutView {
_sliderHandle = value;
}
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
@override
ViewMeasuredSizes measure(int maxWidth, int maxHeight) {
return null;
@ -616,10 +605,8 @@ class _SliderLayoutView<D> extends LayoutView {
canvas.drawLine(
points: [
new Point<num>(
sliderElement.domainCenterPoint.x, _drawAreaBounds.top),
new Point<num>(
sliderElement.domainCenterPoint.x, _drawAreaBounds.bottom),
Point<num>(sliderElement.domainCenterPoint.x, _drawAreaBounds.top),
Point<num>(sliderElement.domainCenterPoint.x, _drawAreaBounds.bottom),
],
stroke: sliderElement.stroke,
strokeWidthPx: sliderElement.strokeWidthPx);
@ -646,7 +633,7 @@ class _SliderElement<D> {
double strokeWidthPx;
_SliderElement<D> clone() {
return new _SliderElement<D>()
return _SliderElement<D>()
..domainCenterPoint = this.domainCenterPoint
..buttonBounds = this.buttonBounds
..fill = this.fill
@ -668,7 +655,7 @@ class _SliderElement<D> {
final y = ((targetPoint.y - previousPoint.y) * animationPercent) +
previousPoint.y;
domainCenterPoint = new Point<int>(x.round(), y.round());
domainCenterPoint = Point<int>(x.round(), y.round());
final previousBounds = localPrevious.buttonBounds;
final targetBounds = localTarget.buttonBounds;
@ -685,7 +672,7 @@ class _SliderElement<D> {
((targetBounds.left - previousBounds.left) * animationPercent) +
previousBounds.left;
buttonBounds = new Rectangle<int>(left.round(), top.round(),
buttonBounds = Rectangle<int>(left.round(), top.round(),
(right - left).round(), (bottom - top).round());
fill = getAnimatedColor(previous.fill, target.fill, animationPercent);
@ -726,7 +713,7 @@ class _AnimatedSlider<D> {
final bottom = targetBounds.bottom;
final left = right;
newTarget.buttonBounds = new Rectangle<int>(left.round(), top.round(),
newTarget.buttonBounds = Rectangle<int>(left.round(), top.round(),
(right - left).round(), (bottom - top).round());
// Animate the stroke width to 0 so that we don't get a lingering line after
@ -775,8 +762,8 @@ class SliderEventListener<D> {
/// [domain] is the domain value at the slider position.
///
/// [dragState] indicates the current state of a drag event.
typedef SliderListenerCallback<D>(Point<int> point, D domain, String roleId,
SliderListenerDragState dragState);
typedef SliderListenerCallback<D> = Function(Point<int> point, D domain,
String roleId, SliderListenerDragState dragState);
/// Describes the current state of a slider change as a result of a drag event.
///

@ -43,7 +43,7 @@ abstract class InitialHintBehavior<D> implements ChartBehavior<D> {
@protected
CartesianChart<D> get chart => _chart;
Duration _hintDuration = new Duration(milliseconds: 3000);
Duration _hintDuration = Duration(milliseconds: 3000);
/// The amount of time to animate to the desired viewport.
///
@ -104,9 +104,9 @@ abstract class InitialHintBehavior<D> implements ChartBehavior<D> {
double _targetViewportScalingFactor;
InitialHintBehavior() {
_listener = new GestureListener(onTapTest: onTapTest);
_listener = GestureListener(onTapTest: onTapTest);
_lifecycleListener = new LifecycleListener<D>(
_lifecycleListener = LifecycleListener<D>(
onAxisConfigured: _onAxisConfigured,
onAnimationComplete: _onAnimationComplete);
}
@ -114,7 +114,7 @@ abstract class InitialHintBehavior<D> implements ChartBehavior<D> {
@override
attachTo(BaseChart<D> chart) {
if (!(chart is CartesianChart)) {
throw new ArgumentError(
throw ArgumentError(
'InitialHintBehavior can only be attached to a CartesianChart');
}
@ -127,7 +127,7 @@ abstract class InitialHintBehavior<D> implements ChartBehavior<D> {
@override
removeFrom(BaseChart<D> chart) {
if (!(chart is CartesianChart)) {
throw new ArgumentError(
throw ArgumentError(
'InitialHintBehavior can only be removed from a CartesianChart');
}

@ -68,7 +68,7 @@ class PanBehavior<D> implements ChartBehavior<D> {
}
PanBehavior() {
_listener = new GestureListener(
_listener = GestureListener(
onTapTest: onTapTest,
onDragStart: onDragStart,
onDragUpdate: onDragUpdate,
@ -79,7 +79,7 @@ class PanBehavior<D> implements ChartBehavior<D> {
@override
attachTo(BaseChart<D> chart) {
if (!(chart is CartesianChart)) {
throw new ArgumentError(
throw ArgumentError(
'PanBehavior can only be attached to a CartesianChart');
}
@ -91,7 +91,7 @@ class PanBehavior<D> implements ChartBehavior<D> {
// Wrap domain axis tick provider with the panning behavior one.
_domainAxisTickProvider =
new PanningTickProvider<D>(_chart.domainAxis.tickProvider);
PanningTickProvider<D>(_chart.domainAxis.tickProvider);
_chart.domainAxis.tickProvider = _domainAxisTickProvider;
}
@ -99,7 +99,7 @@ class PanBehavior<D> implements ChartBehavior<D> {
@override
removeFrom(BaseChart<D> chart) {
if (!(chart is CartesianChart)) {
throw new ArgumentError(
throw ArgumentError(
'PanBehavior can only be attached to a CartesianChart');
}
@ -218,4 +218,4 @@ class PanBehavior<D> implements ChartBehavior<D> {
}
/// Callback for when panning is completed.
typedef void PanningCompletedCallback();
typedef PanningCompletedCallback = void Function();

@ -64,7 +64,7 @@ class PanningTickProvider<D> implements TickProvider<D> {
TickHint<D> tickHint,
}) {
if (_mode == PanningTickProviderMode.stepSizeLocked) {
tickHint = new TickHint(
tickHint = TickHint(
_ticks.first.value,
_ticks.last.value,
tickCount: _ticks.length,

@ -72,9 +72,9 @@ class CanvasBarStack {
final width = right - left;
final height = bottom - top;
final fullStackRect = new Rectangle(left, top, width, height);
final fullStackRect = Rectangle(left, top, width, height);
return new CanvasBarStack._internal(
return CanvasBarStack._internal(
segments,
radius: radius,
stackedBarPadding: stackedBarPadding,

@ -151,7 +151,7 @@ Color getAnimatedColor(Color previous, Color target, double animationPercent) {
var b = (((target.b - previous.b) * animationPercent) + previous.b).round();
var a = (((target.a - previous.a) * animationPercent) + previous.a).round();
return new Color(a: a, r: r, g: g, b: b);
return Color(a: a, r: r, g: g, b: b);
}
/// Defines the pattern for a color fill.

@ -19,8 +19,8 @@ import '../../common/color.dart' show Color;
import '../../common/symbol_renderer.dart' show SymbolRenderer;
import 'processed_series.dart' show ImmutableSeries;
typedef String DomainFormatter<D>(D domain);
typedef String MeasureFormatter(num measure);
typedef DomainFormatter<D> = String Function(D domain);
typedef MeasureFormatter = String Function(num measure);
/// Represents processed rendering details for a data point from a series.
class DatumDetails<D> {
@ -183,7 +183,7 @@ class DatumDetails<D> {
double radiusPx,
SymbolRenderer symbolRenderer,
double strokeWidthPx}) {
return new DatumDetails<D>(
return DatumDetails<D>(
datum: datum ?? other.datum,
index: index ?? other.index,
domain: domain ?? other.domain,

@ -56,7 +56,7 @@ class MutableSeries<D> extends ImmutableSeries<D> {
AccessorFn<TextStyleSpec> insideLabelStyleAccessorFn;
AccessorFn<TextStyleSpec> outsideLabelStyleAccessorFn;
final _attrs = new SeriesAttributes();
final _attrs = SeriesAttributes();
Axis measureAxis;
Axis domainAxis;

@ -48,8 +48,8 @@ class SelectionModel<D> {
/// Create a deep copy of the selection model.
SelectionModel.fromOther(SelectionModel<D> other) {
_selectedDatum = new List.from(other._selectedDatum);
_selectedSeries = new List.from(other._selectedSeries);
_selectedDatum = List.from(other._selectedDatum);
_selectedSeries = List.from(other._selectedSeries);
}
/// Create selection model from configuration.
@ -64,8 +64,8 @@ class SelectionModel<D> {
}
// Add to list of selected series.
_selectedSeries.addAll(seriesList.where((ImmutableSeries<D> series) =>
selectedDataMap.keys.contains(series.id)));
_selectedSeries.addAll(seriesList
.where((series) => selectedDataMap.keys.contains(series.id)));
// Add to list of selected data.
for (ImmutableSeries<D> series in seriesList) {
@ -76,7 +76,7 @@ class SelectionModel<D> {
final datum = series.data[i];
if (selectedDataMap[series.id].contains(domainFn(i))) {
_selectedDatum.add(new SeriesDatum(series, datum));
_selectedDatum.add(SeriesDatum(series, datum));
}
}
}
@ -86,11 +86,11 @@ class SelectionModel<D> {
// Add to list of selected series, if it does not already exist.
if (selectedSeriesConfig != null) {
final remainingSeriesToAdd = selectedSeriesConfig
.where((String seriesId) => !selectedSeries.contains(seriesId))
.where((seriesId) => !selectedSeries.contains(seriesId))
.toList();
_selectedSeries.addAll(seriesList.where((ImmutableSeries<D> series) =>
remainingSeriesToAdd.contains(series.id)));
_selectedSeries.addAll(seriesList
.where((series) => remainingSeriesToAdd.contains(series.id)));
}
}
@ -99,14 +99,13 @@ class SelectionModel<D> {
bool isDatumSelected(ImmutableSeries<D> series, int index) {
final datum = index == null ? null : series.data[index];
return _selectedDatum.contains(new SeriesDatum(series, datum));
return _selectedDatum.contains(SeriesDatum(series, datum));
}
/// Returns the selected [SeriesDatum] for this [SelectionModel].
///
/// This is empty by default.
List<SeriesDatum<D>> get selectedDatum =>
new List.unmodifiable(_selectedDatum);
List<SeriesDatum<D>> get selectedDatum => List.unmodifiable(_selectedDatum);
/// Returns true if this [SelectionModel] has a selected series.
bool get hasSeriesSelection => _selectedSeries.isNotEmpty;
@ -115,7 +114,7 @@ class SelectionModel<D> {
///
/// This is empty by default.
List<ImmutableSeries<D>> get selectedSeries =>
new List.unmodifiable(_selectedSeries);
List.unmodifiable(_selectedSeries);
/// Returns true if this [SelectionModel] has a selected datum or series.
bool get hasAnySelection =>
@ -124,14 +123,14 @@ class SelectionModel<D> {
@override
bool operator ==(Object other) {
return other is SelectionModel &&
new ListEquality().equals(_selectedDatum, other.selectedDatum) &&
new ListEquality().equals(_selectedSeries, other.selectedSeries);
ListEquality().equals(_selectedDatum, other.selectedDatum) &&
ListEquality().equals(_selectedSeries, other.selectedSeries);
}
@override
int get hashCode {
int hashcode = new ListEquality().hash(_selectedDatum);
hashcode = hashcode * 37 + new ListEquality().hash(_selectedSeries);
int hashcode = ListEquality().hash(_selectedDatum);
hashcode = hashcode * 37 + ListEquality().hash(_selectedSeries);
return hashcode;
}
}
@ -168,12 +167,11 @@ class MutableSelectionModel<D> extends SelectionModel<D> {
_selectedSeries = seriesList;
// Provide a copy, so listeners get an immutable model.
final copyOfSelectionModel = new SelectionModel.fromOther(this);
final copyOfSelectionModel = SelectionModel.fromOther(this);
_updatedListeners.forEach((listener) => listener(copyOfSelectionModel));
final changed =
!new ListEquality().equals(origSelectedDatum, _selectedDatum) ||
!new ListEquality().equals(origSelectedSeries, _selectedSeries);
final changed = !ListEquality().equals(origSelectedDatum, _selectedDatum) ||
!ListEquality().equals(origSelectedSeries, _selectedSeries);
if (notifyListeners && changed) {
_changedListeners.forEach((listener) => listener(copyOfSelectionModel));
}
@ -220,7 +218,7 @@ class MutableSelectionModel<D> extends SelectionModel<D> {
/// Callback for SelectionModel. It is triggered when the selection state
/// changes.
typedef SelectionModelListener<D>(SelectionModel<D> model);
typedef SelectionModelListener<D> = Function(SelectionModel<D> model);
enum SelectionModelType {
/// Typical Hover or Details event for viewing the details of the selected

@ -41,10 +41,10 @@ import 'series_datum.dart' show SeriesDatum;
/// [rendererIdKey] can be added as an attribute to user-defined [Series]
/// objects.
const AttributeKey<String> rendererIdKey =
const AttributeKey<String>('SeriesRenderer.rendererId');
AttributeKey<String>('SeriesRenderer.rendererId');
const AttributeKey<SeriesRenderer> rendererKey =
const AttributeKey<SeriesRenderer>('SeriesRenderer.renderer');
AttributeKey<SeriesRenderer>('SeriesRenderer.renderer');
/// A series renderer draws one or more series of data onto a chart canvas.
abstract class SeriesRenderer<D> extends LayoutView {
@ -142,25 +142,17 @@ abstract class BaseSeriesRenderer<D> implements SeriesRenderer<D> {
Rectangle<int> get drawBounds => _drawAreaBounds;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
BaseSeriesRenderer({
@required this.rendererId,
@required int layoutPaintOrder,
this.symbolRenderer,
}) : this.layoutConfig = new LayoutViewConfig(
}) : this.layoutConfig = LayoutViewConfig(
paintOrder: layoutPaintOrder,
position: LayoutPosition.DrawArea,
positionOrder: LayoutViewPositionOrder.drawArea);
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
@override
void onAttach(BaseChart<D> chart) {}
@ -185,7 +177,7 @@ abstract class BaseSeriesRenderer<D> implements SeriesRenderer<D> {
int maxMissing = 0;
bool hasSpecifiedCategory = false;
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
if (series.colorFn == null) {
// If there is no category, give it a default category to match logic.
String category = series.seriesCategory;
@ -208,7 +200,7 @@ abstract class BaseSeriesRenderer<D> implements SeriesRenderer<D> {
if (!emptyCategoryUsesSinglePalette && !hasSpecifiedCategory) {
final palettes = StyleFactory.style.getOrderedPalettes(maxMissing);
int index = 0;
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
if (series.colorFn == null) {
final color = palettes[index % palettes.length].shadeDefault;
index++;
@ -227,7 +219,7 @@ abstract class BaseSeriesRenderer<D> implements SeriesRenderer<D> {
// the max for any category to ensure that the gradients look appropriate.
final colorsByCategory = <String, List<Color>>{};
int index = 0;
missingColorCountPerCategory.keys.forEach((String category) {
missingColorCountPerCategory.keys.forEach((category) {
colorsByCategory[category] =
colorPalettes[index % colorPalettes.length].makeShades(maxMissing);
index++;
@ -236,7 +228,7 @@ abstract class BaseSeriesRenderer<D> implements SeriesRenderer<D> {
missingColorCountPerCategory[category] = 0;
});
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
if (series.colorFn == null) {
final category = series.seriesCategory ?? defaultCategory;
@ -249,12 +241,12 @@ abstract class BaseSeriesRenderer<D> implements SeriesRenderer<D> {
}
// Fill color defaults to the series color if no accessor is provided.
series.fillColorFn ??= (int index) => series.colorFn(index);
series.fillColorFn ??= (index) => series.colorFn(index);
});
} else {
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
// Fill color defaults to the series color if no accessor is provided.
series.fillColorFn ??= (int index) => series.colorFn(index);
series.fillColorFn ??= (index) => series.colorFn(index);
});
}
}
@ -346,7 +338,7 @@ abstract class BaseSeriesRenderer<D> implements SeriesRenderer<D> {
var strokeWidthPx = strokeWidthPxFn != null ? strokeWidthPxFn(index) : null;
strokeWidthPx = strokeWidthPx?.toDouble();
final details = new DatumDetails<D>(
final details = DatumDetails<D>(
datum: seriesDatum.datum,
index: seriesDatum.index,
domain: domainValue,

@ -35,7 +35,7 @@ class LayoutConfig {
/// Specs that applies to one margin.
class MarginSpec {
/// [MarginSpec] that has max of 50 percent.
static const defaultSpec = const MarginSpec._internal(null, null, null, 50);
static const defaultSpec = MarginSpec._internal(null, null, null, 50);
final int _minPixel;
final int _maxPixel;
@ -64,7 +64,7 @@ class MarginSpec {
assert(minPixel <= maxPixel);
}
return new MarginSpec._internal(minPixel, maxPixel, null, null);
return MarginSpec._internal(minPixel, maxPixel, null, null);
}
/// Create [MarginSpec] with a fixed pixel size [pixels].
@ -74,7 +74,7 @@ class MarginSpec {
// Require require or higher setting if set
assert(pixels == null || pixels >= 0);
return new MarginSpec._internal(pixels, pixels, null, null);
return MarginSpec._internal(pixels, pixels, null, null);
}
/// Create [MarginSpec] that specifies min/max percentage.
@ -92,7 +92,7 @@ class MarginSpec {
assert(minPercent <= maxPercent);
}
return new MarginSpec._internal(null, null, minPercent, maxPercent);
return MarginSpec._internal(null, null, minPercent, maxPercent);
}
/// Get the min pixels, given the [totalPixels].

@ -53,7 +53,7 @@ class LayoutManagerImpl implements LayoutManager {
/// Create a new [LayoutManager].
LayoutManagerImpl({LayoutConfig config})
: this.config = config ?? new LayoutConfig();
: this.config = config ?? LayoutConfig();
/// Add one [LayoutView].
void addView(LayoutView view) {
@ -79,9 +79,9 @@ class LayoutManagerImpl implements LayoutManager {
@override
List<LayoutView> get paintOrderedViews {
if (_viewsNeedPaintSort) {
_paintOrderedViews = new List<LayoutView>.from(_views);
_paintOrderedViews = List<LayoutView>.from(_views);
_paintOrderedViews.sort((LayoutView v1, LayoutView v2) =>
_paintOrderedViews.sort((v1, v2) =>
v1.layoutConfig.paintOrder.compareTo(v2.layoutConfig.paintOrder));
_viewsNeedPaintSort = false;
@ -93,10 +93,9 @@ class LayoutManagerImpl implements LayoutManager {
@override
List<LayoutView> get positionOrderedViews {
if (_viewsNeedPositionSort) {
_positionOrderedViews = new List<LayoutView>.from(_views);
_positionOrderedViews = List<LayoutView>.from(_views);
_positionOrderedViews.sort((LayoutView v1, LayoutView v2) => v1
.layoutConfig.positionOrder
_positionOrderedViews.sort((v1, v2) => v1.layoutConfig.positionOrder
.compareTo(v2.layoutConfig.positionOrder));
_viewsNeedPositionSort = false;
@ -114,8 +113,7 @@ class LayoutManagerImpl implements LayoutManager {
Rectangle<int> get drawableLayoutAreaBounds {
assert(_drawAreaBoundsOutdated == false);
final drawableViews =
_views.where((LayoutView view) => view.isSeriesRenderer);
final drawableViews = _views.where((view) => view.isSeriesRenderer);
var componentBounds = drawableViews?.first?.componentBounds;
@ -126,7 +124,7 @@ class LayoutManagerImpl implements LayoutManager {
}
}
} else {
componentBounds = new Rectangle(0, 0, 0, 0);
componentBounds = Rectangle(0, 0, 0, 0);
}
return componentBounds;
@ -226,8 +224,8 @@ class LayoutManagerImpl implements LayoutManager {
);
// Bounds for the draw area.
_drawAreaBounds = new Rectangle(measurements.leftWidth,
measurements.topHeight, drawAreaWidth, drawAreaHeight);
_drawAreaBounds = Rectangle(measurements.leftWidth, measurements.topHeight,
drawAreaWidth, drawAreaHeight);
_drawAreaBoundsOutdated = false;
}
@ -243,26 +241,26 @@ class LayoutManagerImpl implements LayoutManager {
_viewsForPositions(LayoutPosition.Left, LayoutPosition.FullLeft);
var drawAreaViews = _viewsForPositions(LayoutPosition.DrawArea);
final fullBounds = new Rectangle(0, 0, width, height);
final fullBounds = Rectangle(0, 0, width, height);
// Layout the margins.
new LeftMarginLayoutStrategy()
LeftMarginLayoutStrategy()
.layout(leftViews, _measurements.leftSizes, fullBounds, drawAreaBounds);
new RightMarginLayoutStrategy().layout(
RightMarginLayoutStrategy().layout(
rightViews, _measurements.rightSizes, fullBounds, drawAreaBounds);
new BottomMarginLayoutStrategy().layout(
BottomMarginLayoutStrategy().layout(
bottomViews, _measurements.bottomSizes, fullBounds, drawAreaBounds);
new TopMarginLayoutStrategy()
TopMarginLayoutStrategy()
.layout(topViews, _measurements.topSizes, fullBounds, drawAreaBounds);
// Layout the drawArea.
drawAreaViews.forEach(
(LayoutView view) => view.layout(_drawAreaBounds, _drawAreaBounds));
drawAreaViews
.forEach((view) => view.layout(_drawAreaBounds, _drawAreaBounds));
}
Iterable<LayoutView> _viewsForPositions(LayoutPosition p1,
[LayoutPosition p2]) {
return positionOrderedViews.where((LayoutView view) =>
return positionOrderedViews.where((view) =>
(view.layoutConfig.position == p1 ||
(p2 != null && view.layoutConfig.position == p2)));
}
@ -297,14 +295,14 @@ class LayoutManagerImpl implements LayoutManager {
? height - bottomHeight - topHeight
: height;
var leftSizes = new LeftMarginLayoutStrategy().measure(leftViews,
var leftSizes = LeftMarginLayoutStrategy().measure(leftViews,
maxWidth: useMax ? maxLeftWidth : leftWidth,
height: adjustedHeight,
fullHeight: height);
leftWidth = max(leftSizes.total, config.leftSpec.getMinPixels(width));
var rightSizes = new RightMarginLayoutStrategy().measure(rightViews,
var rightSizes = RightMarginLayoutStrategy().measure(rightViews,
maxWidth: useMax ? maxRightWidth : rightWidth,
height: adjustedHeight,
fullHeight: height);
@ -312,20 +310,20 @@ class LayoutManagerImpl implements LayoutManager {
final adjustedWidth = width - leftWidth - rightWidth;
var bottomSizes = new BottomMarginLayoutStrategy().measure(bottomViews,
var bottomSizes = BottomMarginLayoutStrategy().measure(bottomViews,
maxHeight: useMax ? maxBottomHeight : bottomHeight,
width: adjustedWidth,
fullWidth: width);
bottomHeight =
max(bottomSizes.total, config.bottomSpec.getMinPixels(height));
var topSizes = new TopMarginLayoutStrategy().measure(topViews,
var topSizes = TopMarginLayoutStrategy().measure(topViews,
maxHeight: useMax ? maxTopHeight : topHeight,
width: adjustedWidth,
fullWidth: width);
topHeight = max(topSizes.total, config.topSpec.getMinPixels(height));
return new _MeasuredSizes(
return _MeasuredSizes(
leftWidth: leftWidth,
leftSizes: leftSizes,
rightWidth: rightWidth,

@ -39,8 +39,8 @@ class SizeList {
}
class _DesiredViewSizes {
final preferredSizes = new SizeList();
final minimumSizes = new SizeList();
final preferredSizes = SizeList();
final minimumSizes = SizeList();
void add(int preferred, int minimum) {
preferredSizes.add(preferred);
@ -74,10 +74,10 @@ abstract class VerticalMarginStrategy {
{@required int maxWidth,
@required int height,
@required int fullHeight}) {
final measuredWidths = new _DesiredViewSizes();
final measuredWidths = _DesiredViewSizes();
int remainingWidth = maxWidth;
views.forEach((LayoutView view) {
views.forEach((view) {
final params = view.layoutConfig;
final viewMargin = params.viewMargin;
@ -118,7 +118,7 @@ class LeftMarginLayoutStrategy extends VerticalMarginStrategy {
var prevBoundsRight = drawAreaBounds.left;
int i = 0;
views.forEach((LayoutView view) {
views.forEach((view) {
final params = view.layoutConfig;
final width = measuredSizes[i];
@ -133,7 +133,7 @@ class LeftMarginLayoutStrategy extends VerticalMarginStrategy {
prevBoundsRight = left - params.viewMargin.leftPx;
// Layout this component.
view.layout(new Rectangle(left, top, width, height), drawAreaBounds);
view.layout(Rectangle(left, top, width, height), drawAreaBounds);
i++;
});
@ -148,7 +148,7 @@ class RightMarginLayoutStrategy extends VerticalMarginStrategy {
var prevBoundsLeft = drawAreaBounds.right;
int i = 0;
views.forEach((LayoutView view) {
views.forEach((view) {
final params = view.layoutConfig;
final width = measuredSizes[i];
@ -163,7 +163,7 @@ class RightMarginLayoutStrategy extends VerticalMarginStrategy {
prevBoundsLeft = left + width + params.viewMargin.rightPx;
// Layout this component.
view.layout(new Rectangle(left, top, width, height), drawAreaBounds);
view.layout(Rectangle(left, top, width, height), drawAreaBounds);
i++;
});
@ -174,10 +174,10 @@ class RightMarginLayoutStrategy extends VerticalMarginStrategy {
abstract class HorizontalMarginStrategy {
SizeList measure(Iterable<LayoutView> views,
{@required int maxHeight, @required int width, @required int fullWidth}) {
final measuredHeights = new _DesiredViewSizes();
final measuredHeights = _DesiredViewSizes();
int remainingHeight = maxHeight;
views.forEach((LayoutView view) {
views.forEach((view) {
final params = view.layoutConfig;
final viewMargin = params.viewMargin;
@ -218,7 +218,7 @@ class TopMarginLayoutStrategy extends HorizontalMarginStrategy {
var prevBoundsBottom = drawAreaBounds.top;
int i = 0;
views.forEach((LayoutView view) {
views.forEach((view) {
final params = view.layoutConfig;
final height = measuredSizes[i];
@ -234,7 +234,7 @@ class TopMarginLayoutStrategy extends HorizontalMarginStrategy {
prevBoundsBottom = top - params.viewMargin.topPx;
// Layout this component.
view.layout(new Rectangle(left, top, width, height), drawAreaBounds);
view.layout(Rectangle(left, top, width, height), drawAreaBounds);
i++;
});
@ -249,7 +249,7 @@ class BottomMarginLayoutStrategy extends HorizontalMarginStrategy {
var prevBoundsTop = drawAreaBounds.bottom;
int i = 0;
views.forEach((LayoutView view) {
views.forEach((view) {
final params = view.layoutConfig;
final height = measuredSizes[i];
@ -265,7 +265,7 @@ class BottomMarginLayoutStrategy extends HorizontalMarginStrategy {
prevBoundsTop = top + height + params.viewMargin.bottomPx;
// Layout this component.
view.layout(new Rectangle(left, top, width, height), drawAreaBounds);
view.layout(Rectangle(left, top, width, height), drawAreaBounds);
i++;
});

@ -80,8 +80,7 @@ class LayoutViewPositionOrder {
/// A configuration for margin (empty space) around a layout child view.
class ViewMargin {
/// A [ViewMargin] with all zero px.
static const empty =
const ViewMargin(topPx: 0, bottomPx: 0, rightPx: 0, leftPx: 0);
static const empty = ViewMargin(topPx: 0, bottomPx: 0, rightPx: 0, leftPx: 0);
final int topPx;
final int bottomPx;
@ -152,7 +151,7 @@ class LayoutViewConfig {
/// The measurement is tight to the component, without adding [ComponentBuffer].
class ViewMeasuredSizes {
/// All zeroes component size.
static const zero = const ViewMeasuredSizes(
static const zero = ViewMeasuredSizes(
preferredWidth: 0, preferredHeight: 0, minWidth: 0, minHeight: 0);
final int preferredWidth;

@ -37,7 +37,6 @@ class LineChart extends NumericCartesianChart {
@override
SeriesRenderer<num> makeDefaultRenderer() {
return new LineRenderer<num>()
..rendererId = SeriesRenderer.defaultRendererId;
return LineRenderer<num>()..rendererId = SeriesRenderer.defaultRendererId;
}
}

@ -33,11 +33,10 @@ import '../scatter_plot/point_renderer.dart' show PointRenderer;
import '../scatter_plot/point_renderer_config.dart' show PointRendererConfig;
import 'line_renderer_config.dart' show LineRendererConfig;
const styleSegmentsKey = const AttributeKey<List<_LineRendererElement>>(
'LineRenderer.styleSegments');
const styleSegmentsKey =
AttributeKey<List<_LineRendererElement>>('LineRenderer.styleSegments');
const lineStackIndexKey =
const AttributeKey<int>('LineRenderer.lineStackIndex');
const lineStackIndexKey = AttributeKey<int>('LineRenderer.lineStackIndex');
class LineRenderer<D> extends BaseCartesianRenderer<D> {
// Configuration used to extend the clipping area to extend the draw bounds.
@ -69,9 +68,9 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final _currentKeys = <String>[];
factory LineRenderer({String rendererId, LineRendererConfig config}) {
return new LineRenderer._internal(
return LineRenderer._internal(
rendererId: rendererId ?? 'line',
config: config ?? new LineRendererConfig());
config: config ?? LineRendererConfig());
}
LineRenderer._internal({String rendererId, this.config})
@ -79,8 +78,8 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
rendererId: rendererId,
layoutPaintOrder: config.layoutPaintOrder,
symbolRenderer: config.symbolRenderer) {
_pointRenderer = new PointRenderer<D>(
config: new PointRendererConfig<D>(radiusPx: this.config.radiusPx));
_pointRenderer = PointRenderer<D>(
config: PointRendererConfig<D>(radiusPx: this.config.radiusPx));
}
@override
@ -96,13 +95,13 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
void configureSeries(List<MutableSeries<D>> seriesList) {
assignMissingColors(seriesList, emptyCategoryUsesSinglePalette: false);
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
// Add a default area color function which applies the configured
// areaOpacity value to the datum's current color.
series.areaColorFn ??= (int index) {
series.areaColorFn ??= (index) {
final color = series.colorFn(index);
return new Color(
return Color(
r: color.r,
g: color.g,
b: color.b,
@ -123,7 +122,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
series.measureUpperBoundFn != null &&
series.measureLowerBoundFn != null);
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
final colorFn = series.colorFn;
final areaColorFn = series.areaColorFn;
final domainFn = series.domainFn;
@ -136,7 +135,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final styleSegments = <_LineRendererElement<D>>[];
var styleSegmentsIndex = 0;
final usedKeys = new Set<String>();
final usedKeys = Set<String>();
// Configure style segments for each series.
String previousSegmentKey;
@ -163,8 +162,8 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
// Compare strokeWidthPx to 2 decimals of precision. Any less and you
// can't see any difference in the canvas anyways.
final strokeWidthPxRounded = (strokeWidthPx * 100).round() / 100;
var styleKey = '${series.id}__${styleSegmentsIndex}__${color}'
'__${dashPattern}__${strokeWidthPxRounded}';
var styleKey = '${series.id}__${styleSegmentsIndex}__$color'
'__${dashPattern}__$strokeWidthPxRounded';
if (styleKey != previousSegmentKey) {
// If we have a repeated style segment, update the repeat index and
@ -173,8 +172,8 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
if (usedKeys.isNotEmpty && usedKeys.contains(styleKey)) {
styleSegmentsIndex++;
styleKey = '${series.id}__${styleSegmentsIndex}__${color}'
'__${dashPattern}__${strokeWidthPxRounded}';
styleKey = '${series.id}__${styleSegmentsIndex}__$color'
'__${dashPattern}__$strokeWidthPxRounded';
}
// Make sure that the previous style segment extends to the current
@ -185,11 +184,11 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
}
// Create a new style segment.
currentDetails = new _LineRendererElement<D>()
currentDetails = _LineRendererElement<D>()
..color = color
..areaColor = areaColor
..dashPattern = dashPattern
..domainExtent = new _Range<D>(domain, domain)
..domainExtent = _Range<D>(domain, domain)
..strokeWidthPx = strokeWidthPx
..styleKey = styleKey
..roundEndCaps = config.roundEndCaps;
@ -273,7 +272,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
}
}
return (int i) => curOffsets[domainFn(i)];
return (i) => curOffsets[domainFn(i)];
}
/// Merge the line map and the new series so that the new elements are mixed
@ -285,7 +284,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
void _mergeIntoSeriesMap(List<ImmutableSeries<D>> seriesList) {
List<MapEntry<String, List<_AnimatedElements<D>>>> newLineMap = [];
seriesList.forEach((ImmutableSeries<D> series) {
seriesList.forEach((series) {
final key = series.id;
// First, add all the series from the old map that have been removed from
@ -332,7 +331,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
_mergeIntoSeriesMap(seriesList);
seriesList.forEach((ImmutableSeries<D> series) {
seriesList.forEach((series) {
final domainAxis = series.getAttr(domainAxisKey) as ImmutableAxis<D>;
final lineKey = series.id;
final stackIndex = series.getAttr(lineStackIndexKey);
@ -372,12 +371,12 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
// later to display only the relevant parts of data. This ensures that
// styles that visually depend on the start location, such as dash
// patterns, are not disrupted by other changes in style.
styleSegments.forEach((_LineRendererElement styleSegment) {
styleSegments.forEach((styleSegment) {
final styleKey = styleSegment.styleKey;
// If we already have an AnimatingPoint for that index, use it.
var animatingElements = elementsList.firstWhere(
(_AnimatedElements elements) => elements.styleKey == styleKey,
(elements) => elements.styleKey == styleKey,
orElse: () => null);
if (animatingElements != null) {
@ -398,7 +397,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final animatingLines = <_AnimatedLine<D>>[];
for (var index = 0; index < lineElementList.length; index++) {
animatingLines.add(new _AnimatedLine<D>(
animatingLines.add(_AnimatedLine<D>(
key: lineElementList[index].styleKey,
overlaySeries: series.overlaySeries)
..setNewTarget(lineElementList[index]));
@ -410,7 +409,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
animatingAreas = <_AnimatedArea<D>>[];
for (var index = 0; index < areaElementList.length; index++) {
animatingAreas.add(new _AnimatedArea<D>(
animatingAreas.add(_AnimatedArea<D>(
key: areaElementList[index].styleKey,
overlaySeries: series.overlaySeries)
..setNewTarget(areaElementList[index]));
@ -424,14 +423,14 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
animatingBounds ??= <_AnimatedArea<D>>[];
for (var index = 0; index < boundsElementList.length; index++) {
animatingBounds.add(new _AnimatedArea<D>(
animatingBounds.add(_AnimatedArea<D>(
key: boundsElementList[index].styleKey,
overlaySeries: series.overlaySeries)
..setNewTarget(boundsElementList[index]));
}
}
animatingElements = new _AnimatedElements<D>()
animatingElements = _AnimatedElements<D>()
..styleKey = styleSegment.styleKey
..allPoints = allPointList
..lines = animatingLines
@ -458,7 +457,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
// than we did in the previous chart draw cycle.
// TODO: Nicer animations for incoming segments.
if (index >= animatingElements.lines.length) {
animatingElements.lines.add(new _AnimatedLine<D>(
animatingElements.lines.add(_AnimatedLine<D>(
key: lineElement.styleKey,
overlaySeries: series.overlaySeries));
}
@ -473,7 +472,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
// cycle than we did in the previous chart draw cycle.
// TODO: Nicer animations for incoming segments.
if (index >= animatingElements.areas.length) {
animatingElements.areas.add(new _AnimatedArea<D>(
animatingElements.areas.add(_AnimatedArea<D>(
key: areaElement.styleKey,
overlaySeries: series.overlaySeries));
}
@ -489,7 +488,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
// cycle than we did in the previous chart draw cycle.
// TODO: Nicer animations for incoming segments.
if (index >= animatingElements.bounds.length) {
animatingElements.bounds.add(new _AnimatedArea<D>(
animatingElements.bounds.add(_AnimatedArea<D>(
key: boundElement.styleKey,
overlaySeries: series.overlaySeries));
}
@ -506,7 +505,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
});
// Animate out lines that don't exist anymore.
_seriesLineMap.forEach((String key, List<_AnimatedElements<D>> elements) {
_seriesLineMap.forEach((key, elements) {
for (var element in elements) {
if (element.lines != null) {
for (var line in element.lines) {
@ -599,10 +598,10 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final linePointList = lineSegments[index];
// Update the set of areas that still exist in the series data.
final lineStyleKey = '${styleKey}__line__${index}';
final lineStyleKey = '${styleKey}__line__$index';
_currentKeys.add(lineStyleKey);
lineElements.add(new _LineRendererElement<D>()
lineElements.add(_LineRendererElement<D>()
..points = linePointList
..color = color
..areaColor = areaColor
@ -622,10 +621,10 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final areaPointList = areaSegments[index];
// Update the set of areas that still exist in the series data.
final areaStyleKey = '${styleKey}__area_${index}';
final areaStyleKey = '${styleKey}__area_$index';
_currentKeys.add(areaStyleKey);
areaElements.add(new _AreaRendererElement<D>()
areaElements.add(_AreaRendererElement<D>()
..points = areaPointList
..color = color
..areaColor = areaColor
@ -643,10 +642,10 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
for (var index = 0; index < boundsSegment.length; index++) {
final boundsPointList = boundsSegment[index];
final boundsStyleKey = '${styleKey}__bounds_${index}';
final boundsStyleKey = '${styleKey}__bounds_$index';
_currentKeys.add(boundsStyleKey);
boundsElements.add(new _AreaRendererElement<D>()
boundsElements.add(_AreaRendererElement<D>()
..points = boundsPointList
..color = color
..areaColor = areaColor
@ -858,7 +857,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final areaPointList = <_DatumPoint<D>>[];
// Add all points for upper bounds.
areaPointList.addAll(pointList.map((datumPoint) => new _DatumPoint.from(
areaPointList.addAll(pointList.map((datumPoint) => _DatumPoint.from(
datumPoint,
datumPoint.x,
initializeFromZero
@ -869,7 +868,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
// Add all points for lower bounds, in reverse order.
areaPointList.addAll(pointList.reversed.map((datumPoint) =>
new _DatumPoint.from(
_DatumPoint.from(
datumPoint,
datumPoint.x,
initializeFromZero
@ -902,7 +901,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final endPosition = domainAxis.getLocation(details.domainExtent.end) ??
drawBounds.right.toDouble();
return new _Range<num>(startPosition, endPosition);
return _Range<num>(startPosition, endPosition);
}
@override
@ -919,9 +918,8 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
if (animationPercent == 1.0) {
final keysToRemove = <String>[];
_seriesLineMap.forEach((String key, List<_AnimatedElements<D>> elements) {
elements.removeWhere(
(_AnimatedElements<D> element) => element.animatingOut);
_seriesLineMap.forEach((key, elements) {
elements.removeWhere((element) => element.animatingOut);
if (elements.isEmpty) {
keysToRemove.add(key);
@ -931,16 +929,15 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
keysToRemove.forEach(_seriesLineMap.remove);
}
_seriesLineMap.forEach((String key, List<_AnimatedElements<D>> elements) {
_seriesLineMap.forEach((key, elements) {
if (config.includeArea) {
elements
.map<List<_AnimatedArea<D>>>(
(_AnimatedElements<D> animatingElement) =>
animatingElement.areas)
.expand<_AnimatedArea<D>>((List<_AnimatedArea<D>> areas) => areas)
.map<_AreaRendererElement<D>>((_AnimatedArea<D> animatingArea) =>
(animatingElement) => animatingElement.areas)
.expand<_AnimatedArea<D>>((areas) => areas)
.map<_AreaRendererElement<D>>((animatingArea) =>
animatingArea?.getCurrentArea(animationPercent))
.forEach((_AreaRendererElement area) {
.forEach((area) {
if (area != null) {
canvas.drawPolygon(
clipBounds: _getClipBoundsForExtent(area.positionExtent),
@ -953,12 +950,11 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
if (_hasMeasureBounds) {
elements
.map<List<_AnimatedArea<D>>>(
(_AnimatedElements<D> animatingElement) =>
animatingElement.bounds)
.expand<_AnimatedArea<D>>((List<_AnimatedArea<D>> bounds) => bounds)
.map<_AreaRendererElement<D>>((_AnimatedArea<D> animatingBounds) =>
(animatingElement) => animatingElement.bounds)
.expand<_AnimatedArea<D>>((bounds) => bounds)
.map<_AreaRendererElement<D>>((animatingBounds) =>
animatingBounds?.getCurrentArea(animationPercent))
.forEach((_AreaRendererElement bound) {
.forEach((bound) {
if (bound != null) {
canvas.drawPolygon(
clipBounds: _getClipBoundsForExtent(bound.positionExtent),
@ -971,12 +967,11 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
if (config.includeLine) {
elements
.map<List<_AnimatedLine<D>>>(
(_AnimatedElements<D> animatingElement) =>
animatingElement.lines)
.expand<_AnimatedLine<D>>((List<_AnimatedLine<D>> lines) => lines)
.map<_LineRendererElement<D>>((_AnimatedLine<D> animatingLine) =>
(animatingElement) => animatingElement.lines)
.expand<_AnimatedLine<D>>((lines) => lines)
.map<_LineRendererElement<D>>((animatingLine) =>
animatingLine?.getCurrentLine(animationPercent))
.forEach((_LineRendererElement line) {
.forEach((line) {
if (line != null) {
canvas.drawLine(
clipBounds: _getClipBoundsForExtent(line.positionExtent),
@ -1009,7 +1004,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
? clamp((extent.start), drawBounds.left, drawBounds.right)
: clamp((extent.end), drawBounds.left, drawBounds.right);
return new Rectangle<num>(
return Rectangle<num>(
left,
drawBounds.top - drawBoundTopExtensionPx,
right - left,
@ -1035,7 +1030,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
? measureAxis.getLocation(measureValue + measureOffsetValue)
: null;
return new _DatumPoint<D>(
return _DatumPoint<D>(
datum: datum,
domain: domainValue,
series: series,
@ -1054,18 +1049,18 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
return nearest;
}
_seriesLineMap.values.forEach((List<_AnimatedElements<D>> seriesSegments) {
_seriesLineMap.values.forEach((seriesSegments) {
_DatumPoint<D> nearestPoint;
double nearestDomainDistance = 10000.0;
double nearestMeasureDistance = 10000.0;
double nearestRelativeDistance = 10000.0;
seriesSegments.forEach((_AnimatedElements<D> segment) {
seriesSegments.forEach((segment) {
if (segment.overlaySeries) {
return;
}
segment.allPoints.forEach((Point p) {
segment.allPoints.forEach((p) {
// Don't look at points not in the drawArea.
if (p.x < componentBounds.left || p.x > componentBounds.right) {
return;
@ -1108,8 +1103,8 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
// Found a point, add it to the list.
if (nearestPoint != null) {
nearest.add(new DatumDetails<D>(
chartPosition: new Point<double>(nearestPoint.x, nearestPoint.y),
nearest.add(DatumDetails<D>(
chartPosition: Point<double>(nearestPoint.x, nearestPoint.y),
datum: nearestPoint.datum,
domain: nearestPoint.domain,
series: nearestPoint.series,
@ -1134,9 +1129,9 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
final point = _getPoint(seriesDatum.datum, details.domain, series,
domainAxis, details.measure, details.measureOffset, measureAxis);
final chartPosition = new Point<double>(point.x, point.y);
final chartPosition = Point<double>(point.x, point.y);
return new DatumDetails.from(details, chartPosition: chartPosition);
return DatumDetails.from(details, chartPosition: chartPosition);
}
}
@ -1151,7 +1146,7 @@ class _DatumPoint<D> extends Point<double> {
: super(x, y);
factory _DatumPoint.from(_DatumPoint<D> other, [double x, double y]) {
return new _DatumPoint<D>(
return _DatumPoint<D>(
datum: other.datum,
domain: other.domain,
series: other.series,
@ -1175,13 +1170,11 @@ class _LineRendererElement<D> {
bool roundEndCaps;
_LineRendererElement<D> clone() {
return new _LineRendererElement<D>()
..points = new List<_DatumPoint<D>>.from(points)
..color = color != null ? new Color.fromOther(color: color) : null
..areaColor =
areaColor != null ? new Color.fromOther(color: areaColor) : null
..dashPattern =
dashPattern != null ? new List<int>.from(dashPattern) : null
return _LineRendererElement<D>()
..points = List<_DatumPoint<D>>.from(points)
..color = color != null ? Color.fromOther(color: color) : null
..areaColor = areaColor != null ? Color.fromOther(color: areaColor) : null
..dashPattern = dashPattern != null ? List<int>.from(dashPattern) : null
..domainExtent = domainExtent
..measureAxisPosition = measureAxisPosition
..positionExtent = positionExtent
@ -1207,7 +1200,7 @@ class _LineRendererElement<D> {
lastPoint = previousPoint;
} else {
previousPoint =
new _DatumPoint<D>.from(targetPoint, targetPoint.x, lastPoint.y);
_DatumPoint<D>.from(targetPoint, targetPoint.x, lastPoint.y);
}
final x = ((targetPoint.x - previousPoint.x) * animationPercent) +
@ -1224,9 +1217,9 @@ class _LineRendererElement<D> {
}
if (points.length - 1 >= pointIndex) {
points[pointIndex] = new _DatumPoint<D>.from(targetPoint, x, y);
points[pointIndex] = _DatumPoint<D>.from(targetPoint, x, y);
} else {
points.add(new _DatumPoint<D>.from(targetPoint, x, y));
points.add(_DatumPoint<D>.from(targetPoint, x, y));
}
}
@ -1278,7 +1271,7 @@ class _AnimatedLine<D> {
for (var index = 0; index < newTarget.points.length; index++) {
var targetPoint = newTarget.points[index];
newPoints.add(new _DatumPoint<D>.from(targetPoint, targetPoint.x,
newPoints.add(_DatumPoint<D>.from(targetPoint, targetPoint.x,
newTarget.measureAxisPosition.roundToDouble()));
}
@ -1328,11 +1321,10 @@ class _AreaRendererElement<D> {
String styleKey;
_AreaRendererElement<D> clone() {
return new _AreaRendererElement<D>()
..points = new List<_DatumPoint<D>>.from(points)
..color = color != null ? new Color.fromOther(color: color) : null
..areaColor =
areaColor != null ? new Color.fromOther(color: areaColor) : null
return _AreaRendererElement<D>()
..points = List<_DatumPoint<D>>.from(points)
..color = color != null ? Color.fromOther(color: color) : null
..areaColor = areaColor != null ? Color.fromOther(color: areaColor) : null
..domainExtent = domainExtent
..measureAxisPosition = measureAxisPosition
..positionExtent = positionExtent
@ -1356,7 +1348,7 @@ class _AreaRendererElement<D> {
lastPoint = previousPoint;
} else {
previousPoint =
new _DatumPoint<D>.from(targetPoint, targetPoint.x, lastPoint.y);
_DatumPoint<D>.from(targetPoint, targetPoint.x, lastPoint.y);
}
final x = ((targetPoint.x - previousPoint.x) * animationPercent) +
@ -1373,9 +1365,9 @@ class _AreaRendererElement<D> {
}
if (points.length - 1 >= pointIndex) {
points[pointIndex] = new _DatumPoint<D>.from(targetPoint, x, y);
points[pointIndex] = _DatumPoint<D>.from(targetPoint, x, y);
} else {
points.add(new _DatumPoint<D>.from(targetPoint, x, y));
points.add(_DatumPoint<D>.from(targetPoint, x, y));
}
}
@ -1423,7 +1415,7 @@ class _AnimatedArea<D> {
for (var index = 0; index < newTarget.points.length; index++) {
var targetPoint = newTarget.points[index];
newPoints.add(new _DatumPoint<D>.from(targetPoint, targetPoint.x,
newPoints.add(_DatumPoint<D>.from(targetPoint, targetPoint.x,
newTarget.measureAxisPosition.roundToDouble()));
}

@ -26,7 +26,7 @@ class LineRendererConfig<D> extends LayoutViewConfig
final SymbolRenderer symbolRenderer;
final rendererAttributes = new RendererAttributes();
final rendererAttributes = RendererAttributes();
/// Radius of points on the line, if [includePoints] is enabled.
final double radiusPx;
@ -83,10 +83,10 @@ class LineRendererConfig<D> extends LayoutViewConfig
this.areaOpacity = 0.1,
this.roundEndCaps = false,
SymbolRenderer symbolRenderer})
: this.symbolRenderer = symbolRenderer ?? new LineSymbolRenderer();
: this.symbolRenderer = symbolRenderer ?? LineSymbolRenderer();
@override
LineRenderer<D> build() {
return new LineRenderer<D>(config: this, rendererId: customRendererId);
return LineRenderer<D>(config: this, rendererId: customRendererId);
}
}

@ -39,10 +39,10 @@ class ArcLabelDecorator<D> extends ArcRendererDecorator<D> {
static const _defaultLabelPosition = ArcLabelPosition.auto;
static const _defaultLabelPadding = 5;
static final _defaultInsideLabelStyle =
new TextStyleSpec(fontSize: 12, color: Color.white);
TextStyleSpec(fontSize: 12, color: Color.white);
static final _defaultOutsideLabelStyle =
new TextStyleSpec(fontSize: 12, color: Color.black);
static final _defaultLeaderLineStyle = new ArcLabelLeaderLineStyleSpec(
TextStyleSpec(fontSize: 12, color: Color.black);
static final _defaultLeaderLineStyle = ArcLabelLeaderLineStyleSpec(
length: 20.0,
thickness: 1.0,
color: StyleFactory.style.arcLabelOutsideLeaderLine);
@ -136,16 +136,16 @@ class ArcLabelDecorator<D> extends ArcRendererDecorator<D> {
final centerRadius = arcElements.innerRadius +
((arcElements.radius - arcElements.innerRadius) / 2);
final innerPoint = new Point<double>(
final innerPoint = Point<double>(
arcElements.center.x + arcElements.innerRadius * cos(centerAngle),
arcElements.center.y + arcElements.innerRadius * sin(centerAngle));
final outerPoint = new Point<double>(
final outerPoint = Point<double>(
arcElements.center.x + arcElements.radius * cos(centerAngle),
arcElements.center.y + arcElements.radius * sin(centerAngle));
//final bounds = element.bounds;
final bounds = new Rectangle<double>.fromPoints(innerPoint, outerPoint);
final bounds = Rectangle<double>.fromPoints(innerPoint, outerPoint);
// Get space available inside and outside the arc.
final totalPadding = labelPadding * 2;
@ -268,7 +268,7 @@ class ArcLabelDecorator<D> extends ArcRendererDecorator<D> {
bool previousLabelLeftOfChart) {
final labelRadius = arcElements.radius + leaderLineStyleSpec.length / 2;
final labelPoint = new Point<double>(
final labelPoint = Point<double>(
arcElements.center.x + labelRadius * cos(centerAngle),
arcElements.center.y + labelRadius * sin(centerAngle));
@ -347,10 +347,10 @@ class ArcLabelDecorator<D> extends ArcRendererDecorator<D> {
final tailX = (labelLeftOfChart ? -1 : 1) * leaderLineStyleSpec.length;
final leaderLineTailPoint =
new Point<double>(labelPoint.x + tailX, labelPoint.y);
Point<double>(labelPoint.x + tailX, labelPoint.y);
final centerRadius = radius - leaderLineStyleSpec.length / 2;
final leaderLineStartPoint = new Point<double>(
final leaderLineStartPoint = Point<double>(
arcCenterPoint.x + centerRadius * cos(centerAngle),
arcCenterPoint.y + centerRadius * sin(centerAngle));

@ -32,7 +32,7 @@ import 'arc_renderer_config.dart' show ArcRendererConfig;
import 'arc_renderer_decorator.dart' show ArcRendererDecorator;
const arcElementsKey =
const AttributeKey<List<ArcRendererElement>>('ArcRenderer.elements');
AttributeKey<List<ArcRendererElement>>('ArcRenderer.elements');
class ArcRenderer<D> extends BaseSeriesRenderer<D> {
// Constant used in the calculation of [centerContentBounds], calculated once
@ -49,7 +49,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
///
/// [LinkedHashMap] is used to render the series on the canvas in the same
/// order as the data was given to the chart.
final _seriesArcMap = new LinkedHashMap<String, _AnimatedArcList<D>>();
final _seriesArcMap = LinkedHashMap<String, _AnimatedArcList<D>>();
// Store a list of arcs that exist in the series data.
//
@ -59,9 +59,9 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
final _currentKeys = <String>[];
factory ArcRenderer({String rendererId, ArcRendererConfig config}) {
return new ArcRenderer._internal(
return ArcRenderer._internal(
rendererId: rendererId ?? 'line',
config: config ?? new ArcRendererConfig());
config: config ?? ArcRendererConfig());
}
ArcRenderer._internal({String rendererId, this.config})
@ -84,7 +84,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
@override
void preprocessSeries(List<MutableSeries<D>> seriesList) {
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
var elements = <ArcRendererElement<D>>[];
var domainFn = series.domainFn;
@ -110,7 +110,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
var angle = arcLength == 2 * pi ? arcLength * .999999 : arcLength;
var endAngle = startAngle + angle;
var details = new ArcRendererElement<D>();
var details = ArcRendererElement<D>();
details.startAngle = startAngle;
details.endAngle = endAngle;
details.index = 0;
@ -132,7 +132,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
var angle = arcLength * percentOfSeries;
var endAngle = startAngle + angle;
var details = new ArcRendererElement<D>();
var details = ArcRendererElement<D>();
details.startAngle = startAngle;
details.endAngle = endAngle;
details.index = arcIndex;
@ -158,8 +158,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
final bounds = _chart.drawAreaBounds;
final center = new Point<double>(
(bounds.left + bounds.width / 2).toDouble(),
final center = Point<double>((bounds.left + bounds.width / 2).toDouble(),
(bounds.top + bounds.height / 2).toDouble());
final radius = bounds.height < bounds.width
@ -168,18 +167,18 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
if (config.arcRatio != null) {
if (0 < config.arcRatio || config.arcRatio > 1) {
throw new ArgumentError('arcRatio must be between 0 and 1');
throw ArgumentError('arcRatio must be between 0 and 1');
}
}
final innerRadius = _calculateInnerRadius(radius);
seriesList.forEach((ImmutableSeries<D> series) {
seriesList.forEach((series) {
var colorFn = series.colorFn;
var arcListKey = series.id;
var arcList =
_seriesArcMap.putIfAbsent(arcListKey, () => new _AnimatedArcList());
_seriesArcMap.putIfAbsent(arcListKey, () => _AnimatedArcList());
var elementsList = series.getAttr(arcElementsKey);
@ -191,9 +190,8 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
var arcKey = '__no_data__';
// If we already have an AnimatingArc for that index, use it.
var animatingArc = arcList.arcs.firstWhere(
(_AnimatedArc arc) => arc.key == arcKey,
orElse: () => null);
var animatingArc = arcList.arcs
.firstWhere((arc) => arc.key == arcKey, orElse: () => null);
arcList.center = center;
arcList.radius = radius;
@ -205,7 +203,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
// If we don't have any existing arc element, create a new arc. Unlike
// real arcs, we should not animate the no data state in from 0.
if (animatingArc == null) {
animatingArc = new _AnimatedArc<D>(arcKey, null, null);
animatingArc = _AnimatedArc<D>(arcKey, null, null);
arcList.arcs.add(animatingArc);
} else {
animatingArc.datum = null;
@ -217,7 +215,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
// Get the arcElement we are going to setup.
// Optimization to prevent allocation in non-animating case.
final arcElement = new ArcRendererElement<D>()
final arcElement = ArcRendererElement<D>()
..color = config.noDataColor
..startAngle = details.startAngle
..endAngle = details.endAngle
@ -235,9 +233,8 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
var arcKey = domainValue.toString();
// If we already have an AnimatingArc for that index, use it.
var animatingArc = arcList.arcs.firstWhere(
(_AnimatedArc arc) => arc.key == arcKey,
orElse: () => null);
var animatingArc = arcList.arcs
.firstWhere((arc) => arc.key == arcKey, orElse: () => null);
arcList.center = center;
arcList.radius = radius;
@ -251,8 +248,8 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
// angle. If there were no previous arcs, then animate everything in
// from 0.
if (animatingArc == null) {
animatingArc = new _AnimatedArc<D>(arcKey, datum, domainValue)
..setNewTarget(new ArcRendererElement<D>()
animatingArc = _AnimatedArc<D>(arcKey, datum, domainValue)
..setNewTarget(ArcRendererElement<D>()
..color = colorFn(arcIndex)
..startAngle = previousEndAngle
..endAngle = previousEndAngle
@ -273,7 +270,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
// Get the arcElement we are going to setup.
// Optimization to prevent allocation in non-animating case.
final arcElement = new ArcRendererElement<D>()
final arcElement = ArcRendererElement<D>()
..color = colorFn(arcIndex)
..startAngle = details.startAngle
..endAngle = details.endAngle
@ -286,7 +283,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
});
// Animate out arcs that don't exist anymore.
_seriesArcMap.forEach((String key, _AnimatedArcList<D> arcList) {
_seriesArcMap.forEach((key, arcList) {
for (var arcIndex = 0; arcIndex < arcList.arcs.length; arcIndex++) {
final arc = arcList.arcs[arcIndex];
final arcStartAngle = arc.previousArcStartAngle;
@ -319,8 +316,8 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
if (animationPercent == 1.0) {
final keysToRemove = <String>[];
_seriesArcMap.forEach((String key, _AnimatedArcList<D> arcList) {
arcList.arcs.removeWhere((_AnimatedArc<D> arc) => arc.animatingOut);
_seriesArcMap.forEach((key, arcList) {
arcList.arcs.removeWhere((arc) => arc.animatingOut);
if (arcList.arcs.isEmpty) {
keysToRemove.add(key);
@ -330,9 +327,9 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
keysToRemove.forEach(_seriesArcMap.remove);
}
_seriesArcMap.forEach((String key, _AnimatedArcList<D> arcList) {
_seriesArcMap.forEach((key, arcList) {
final circleSectors = <CanvasPieSlice>[];
final arcElementsList = new ArcRendererElementList<D>()
final arcElementsList = ArcRendererElementList<D>()
..arcs = <ArcRendererElement<D>>[]
..center = arcList.center
..innerRadius = arcList.innerRadius
@ -342,11 +339,11 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
..strokeWidthPx = arcList.strokeWidthPx;
arcList.arcs
.map<ArcRendererElement<D>>((_AnimatedArc<D> animatingArc) =>
animatingArc.getCurrentArc(animationPercent))
.forEach((ArcRendererElement arc) {
circleSectors.add(
new CanvasPieSlice(arc.startAngle, arc.endAngle, fill: arc.color));
.map<ArcRendererElement<D>>(
(animatingArc) => animatingArc.getCurrentArc(animationPercent))
.forEach((arc) {
circleSectors
.add(CanvasPieSlice(arc.startAngle, arc.endAngle, fill: arc.color));
arcElementsList.arcs.add(arc);
});
@ -354,8 +351,8 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
// Decorate the arcs with decorators that should appear below the main
// series data.
arcRendererDecorators
.where((ArcRendererDecorator decorator) => !decorator.renderAbove)
.forEach((ArcRendererDecorator decorator) {
.where((decorator) => !decorator.renderAbove)
.forEach((decorator) {
decorator.decorate(arcElementsList, canvas, graphicsFactory,
drawBounds: drawBounds,
animationPercent: animationPercent,
@ -363,15 +360,15 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
});
// Draw the arcs.
canvas.drawPie(new CanvasPie(
canvas.drawPie(CanvasPie(
circleSectors, arcList.center, arcList.radius, arcList.innerRadius,
stroke: arcList.stroke, strokeWidthPx: arcList.strokeWidthPx));
// Decorate the arcs with decorators that should appear above the main
// series data. This is the typical place for labels.
arcRendererDecorators
.where((ArcRendererDecorator decorator) => decorator.renderAbove)
.forEach((ArcRendererDecorator decorator) {
.where((decorator) => decorator.renderAbove)
.forEach((decorator) {
decorator.decorate(arcElementsList, canvas, graphicsFactory,
drawBounds: drawBounds,
animationPercent: animationPercent,
@ -398,7 +395,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
arcList.innerRadius < config.minHoleWidthForCenterContent) {
// Return default bounds of 0 size.
final bounds = _chart.drawAreaBounds;
return new Rectangle<int>((bounds.left + bounds.width / 2).round(),
return Rectangle<int>((bounds.left + bounds.width / 2).round(),
(bounds.top + bounds.height / 2).round(), 0, 0);
}
@ -406,7 +403,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
// size that will fit within the pie's inner radius.
final width = (_cosPIOver4 * arcList.innerRadius).floor();
return new Rectangle<int>((arcList.center.x - width).round(),
return Rectangle<int>((arcList.center.x - width).round(),
(arcList.center.y - width).round(), width * 2, width * 2);
}
@ -422,7 +419,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
final chartPosition = _getChartPosition(series.id, domain.toString());
return new DatumDetails(
return DatumDetails(
datum: datum,
domain: domain,
measure: measure,
@ -457,7 +454,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
final centerPointRadius =
arcList.innerRadius + (arcList.radius - arcList.innerRadius) / 2;
chartPosition = new Point<double>(
chartPosition = Point<double>(
centerPointRadius * cos(centerAngle) + arcList.center.x,
centerPointRadius * sin(centerAngle) + arcList.center.y);
@ -478,7 +475,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
return nearest;
}
_seriesArcMap.forEach((String key, _AnimatedArcList<D> arcList) {
_seriesArcMap.forEach((key, arcList) {
if (arcList.series.overlaySeries) {
return;
}
@ -506,11 +503,11 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
chartPointAngle = 2 * pi + chartPointAngle;
}
arcList.arcs.forEach((_AnimatedArc<D> arc) {
arcList.arcs.forEach((arc) {
if (innerRadius <= distance && distance <= radius) {
if (arc.currentArcStartAngle <= chartPointAngle &&
chartPointAngle <= arc.currentArcEndAngle) {
nearest.add(new DatumDetails<D>(
nearest.add(DatumDetails<D>(
series: arcList.series,
datum: arc.datum,
domain: arc.domain,
@ -531,7 +528,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
final chartPosition =
_getChartPosition(details.series.id, details.domain.toString());
return new DatumDetails.from(details, chartPosition: chartPosition);
return DatumDetails.from(details, chartPosition: chartPosition);
}
/// Assigns colors to series that are missing their colorFn.
@ -540,7 +537,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
{@required bool emptyCategoryUsesSinglePalette}) {
int maxMissing = 0;
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
if (series.colorFn == null) {
maxMissing = max(maxMissing, series.data.length);
}
@ -550,7 +547,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
final colorPalettes = StyleFactory.style.getOrderedPalettes(1);
final colorPalette = colorPalettes[0].makeShades(maxMissing);
seriesList.forEach((MutableSeries series) {
seriesList.forEach((series) {
series.colorFn ??= (index) => colorPalette[index];
});
}
@ -593,10 +590,10 @@ class ArcRendererElement<D> {
ImmutableSeries<D> series;
ArcRendererElement<D> clone() {
return new ArcRendererElement<D>()
return ArcRendererElement<D>()
..startAngle = startAngle
..endAngle = endAngle
..color = new Color.fromOther(color: color)
..color = Color.fromOther(color: color)
..index = index
..key = key
..series = series;

@ -34,7 +34,7 @@ class ArcRendererConfig<D> extends LayoutViewConfig
final SymbolRenderer symbolRenderer;
final rendererAttributes = new RendererAttributes();
final rendererAttributes = RendererAttributes();
/// Total arc length, in radians.
///
@ -85,10 +85,10 @@ class ArcRendererConfig<D> extends LayoutViewConfig
SymbolRenderer symbolRenderer})
: this.noDataColor = StyleFactory.style.noDataColor,
this.stroke = StyleFactory.style.white,
this.symbolRenderer = symbolRenderer ?? new CircleSymbolRenderer();
this.symbolRenderer = symbolRenderer ?? CircleSymbolRenderer();
@override
ArcRenderer<D> build() {
return new ArcRenderer<D>(config: this, rendererId: customRendererId);
return ArcRenderer<D>(config: this, rendererId: customRendererId);
}
}

@ -24,11 +24,11 @@ import '../layout/layout_config.dart' show LayoutConfig, MarginSpec;
import 'arc_renderer.dart' show ArcRenderer;
class PieChart<D> extends BaseChart<D> {
static final _defaultLayoutConfig = new LayoutConfig(
topSpec: new MarginSpec.fromPixel(minPixel: 20),
bottomSpec: new MarginSpec.fromPixel(minPixel: 20),
leftSpec: new MarginSpec.fromPixel(minPixel: 20),
rightSpec: new MarginSpec.fromPixel(minPixel: 20),
static final _defaultLayoutConfig = LayoutConfig(
topSpec: MarginSpec.fromPixel(minPixel: 20),
bottomSpec: MarginSpec.fromPixel(minPixel: 20),
leftSpec: MarginSpec.fromPixel(minPixel: 20),
rightSpec: MarginSpec.fromPixel(minPixel: 20),
);
PieChart({LayoutConfig layoutConfig})
@ -38,7 +38,7 @@ class PieChart<D> extends BaseChart<D> {
void drawInternal(List<MutableSeries<D>> seriesList,
{bool skipAnimation, bool skipLayout}) {
if (seriesList.length > 1) {
throw new ArgumentError('PieChart can only render a single series');
throw ArgumentError('PieChart can only render a single series');
}
super.drawInternal(seriesList,
skipAnimation: skipAnimation, skipLayout: skipLayout);
@ -46,7 +46,7 @@ class PieChart<D> extends BaseChart<D> {
@override
SeriesRenderer<D> makeDefaultRenderer() {
return new ArcRenderer<D>()..rendererId = SeriesRenderer.defaultRendererId;
return ArcRenderer<D>()..rendererId = SeriesRenderer.defaultRendererId;
}
/// Returns a list of datum details from selection model of [type].

@ -37,7 +37,7 @@ class ComparisonPointsDecorator<D> extends PointRendererDecorator<D> {
final bool renderAbove = false;
ComparisonPointsDecorator({PointSymbolRenderer symbolRenderer})
: this.symbolRenderer = symbolRenderer ?? new CylinderSymbolRenderer();
: this.symbolRenderer = symbolRenderer ?? CylinderSymbolRenderer();
@override
void decorate(PointRendererElement<D> pointElement, ChartCanvas canvas,
@ -79,19 +79,19 @@ class ComparisonPointsDecorator<D> extends PointRendererDecorator<D> {
// Construct the points that describe our line p1p2.
var p1 =
new Point<double>(pointElement.point.xLower, pointElement.point.yLower);
Point<double>(pointElement.point.xLower, pointElement.point.yLower);
var p2 =
new Point<double>(pointElement.point.xUpper, pointElement.point.yUpper);
Point<double>(pointElement.point.xUpper, pointElement.point.yUpper);
// First check to see if there is no intersection at all between the line
// p1p2 and [drawBounds].
final dataBoundsRect = new Rectangle<num>.fromPoints(p1, p2);
final dataBoundsRect = Rectangle<num>.fromPoints(p1, p2);
if (!drawBounds.intersects(dataBoundsRect)) {
return null;
}
// Line with end points [p1] and [p2].
final p1p2 = new _Line.fromPoints(p1, p2);
final p1p2 = _Line.fromPoints(p1, p2);
// Next, slide p1 along the line p1p2 towards the edge of the draw area if
// the point is located outside of it.
@ -125,14 +125,14 @@ class ComparisonPointsDecorator<D> extends PointRendererDecorator<D> {
// with equations y = bounds.top and y = bounds.bottom. We can pass these
// into a standard line interception method to find our point.
if (p1.y < bounds.top) {
final p = line.intersection(new _Line(0.0, bounds.top.toDouble()));
final p = line.intersection(_Line(0.0, bounds.top.toDouble()));
if (p != null && bounds.containsPoint(p)) {
return p;
}
}
if (p1.y > bounds.bottom) {
final p = line.intersection(new _Line(0.0, bounds.bottom.toDouble()));
final p = line.intersection(_Line(0.0, bounds.bottom.toDouble()));
if (p != null && bounds.containsPoint(p)) {
return p;
}
@ -145,16 +145,14 @@ class ComparisonPointsDecorator<D> extends PointRendererDecorator<D> {
//
// y = slope * x + yIntercept
if (p1.x < bounds.left) {
final p =
line.intersection(new _Line.fromVertical(bounds.left.toDouble()));
final p = line.intersection(_Line.fromVertical(bounds.left.toDouble()));
if (p != null && bounds.containsPoint(p)) {
return p;
}
}
if (p1.x > bounds.right) {
final p =
line.intersection(new _Line.fromVertical(bounds.right.toDouble()));
final p = line.intersection(_Line.fromVertical(bounds.right.toDouble()));
if (p != null && bounds.containsPoint(p)) {
return p;
}
@ -187,7 +185,7 @@ class _Line {
factory _Line.fromPoints(Point<num> p1, Point<num> p2) {
// Handle vertical lines.
if (p1.x == p2.x) {
return new _Line.fromVertical(p1.x);
return _Line.fromVertical(p1.x);
}
// Slope of the line p1p2.
@ -196,12 +194,12 @@ class _Line {
// y-intercept of the line p1p2.
double b = (p1.y - (m * p1.x)).toDouble();
return new _Line(m, b);
return _Line(m, b);
}
/// Creates a vertical line, with the question x = [xIntercept].
factory _Line.fromVertical(num xIntercept) {
return new _Line(null, null, xIntercept.toDouble());
return _Line(null, null, xIntercept.toDouble());
}
/// Computes the intersection of `this` and [other].
@ -218,14 +216,14 @@ class _Line {
// just plug its xIntercept value into the line equation as x and solve for
// y.
if (other.vertical) {
return new Point<double>(
return Point<double>(
other.xIntercept, slope * other.xIntercept + yIntercept);
}
// If this line is a vertical line (has undefined slope), then we can just
// plug its xIntercept value into the line equation as x and solve for y.
if (vertical) {
return new Point<double>(
return Point<double>(
xIntercept, other.slope * xIntercept + other.yIntercept);
}
@ -236,6 +234,6 @@ class _Line {
final y = slope * (other.yIntercept - yIntercept) / (slope - other.slope) +
yIntercept;
return new Point<double>(x, y);
return Point<double>(x, y);
}
}

@ -38,22 +38,22 @@ import 'point_renderer_config.dart' show PointRendererConfig;
import 'point_renderer_decorator.dart' show PointRendererDecorator;
const pointElementsKey =
const AttributeKey<List<PointRendererElement>>('PointRenderer.elements');
AttributeKey<List<PointRendererElement>>('PointRenderer.elements');
const pointSymbolRendererFnKey =
const AttributeKey<AccessorFn<String>>('PointRenderer.symbolRendererFn');
AttributeKey<AccessorFn<String>>('PointRenderer.symbolRendererFn');
const pointSymbolRendererIdKey =
const AttributeKey<String>('PointRenderer.symbolRendererId');
AttributeKey<String>('PointRenderer.symbolRendererId');
/// Defines a fixed radius for data bounds lines (typically drawn by attaching a
/// [ComparisonPointsDecorator] to the renderer.
const boundsLineRadiusPxKey =
const AttributeKey<double>('SymbolAnnotationRenderer.boundsLineRadiusPx');
AttributeKey<double>('SymbolAnnotationRenderer.boundsLineRadiusPx');
/// Defines an [AccessorFn] for the radius for data bounds lines (typically
/// drawn by attaching a [ComparisonPointsDecorator] to the renderer.
const boundsLineRadiusPxFnKey = const AttributeKey<AccessorFn<double>>(
const boundsLineRadiusPxFnKey = AttributeKey<AccessorFn<double>>(
'SymbolAnnotationRenderer.boundsLineRadiusPxFn');
const defaultSymbolRendererId = '__default__';
@ -75,7 +75,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
/// [LinkedHashMap] is used to render the series on the canvas in the same
/// order as the data was given to the chart.
@protected
var seriesPointMap = new LinkedHashMap<String, List<AnimatedPoint<D>>>();
var seriesPointMap = LinkedHashMap<String, List<AnimatedPoint<D>>>();
// Store a list of lines that exist in the series data.
//
@ -85,14 +85,13 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
final _currentKeys = <String>[];
PointRenderer({String rendererId, PointRendererConfig config})
: this.config = config ?? new PointRendererConfig(),
: this.config = config ?? PointRendererConfig(),
pointRendererDecorators = config?.pointRendererDecorators ?? [],
super(
rendererId: rendererId ?? 'point',
layoutPaintOrder:
config?.layoutPaintOrder ?? LayoutViewPaintOrder.point,
symbolRenderer:
config?.symbolRenderer ?? new CircleSymbolRenderer());
symbolRenderer: config?.symbolRenderer ?? CircleSymbolRenderer());
@override
void configureSeries(List<MutableSeries<D>> seriesList) {
@ -101,7 +100,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
@override
void preprocessSeries(List<MutableSeries<D>> seriesList) {
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
final elements = <PointRendererElement<D>>[];
// Default to the configured radius if none was defined by the series.
@ -132,9 +131,8 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
// series data between chart draw cycles. Ideally we should require the
// user to provide a key function, but this at least provides some
// smoothing when adding/removing data.
series.keyFn ??=
(int index) => '${series.id}__${series.domainFn(index)}__'
'${series.measureFn(index)}';
series.keyFn ??= (index) => '${series.id}__${series.domainFn(index)}__'
'${series.measureFn(index)}';
for (var index = 0; index < series.data.length; index++) {
// Default to the configured radius if none was returned by the
@ -181,7 +179,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
var fillColor = fillColorFn(index);
fillColor ??= color;
final details = new PointRendererElement<D>()
final details = PointRendererElement<D>()
..color = color
..fillColor = fillColor
..radiusPx = radiusPx.toDouble()
@ -203,7 +201,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
// later for sorting.
final sortedSeriesIds = [];
seriesList.forEach((ImmutableSeries<D> series) {
seriesList.forEach((series) {
sortedSeriesIds.add(series.id);
final domainAxis = series.getAttr(domainAxisKey) as ImmutableAxis<D>;
@ -256,9 +254,8 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
final pointKey = keyFn(index);
// If we already have an AnimatingPoint for that index, use it.
var animatingPoint = pointList.firstWhere(
(AnimatedPoint point) => point.key == pointKey,
orElse: () => null);
var animatingPoint = pointList
.firstWhere((point) => point.key == pointKey, orElse: () => null);
// If we don't have any existing arc element, create a new arc and
// have it animate in from the position of the previous arc's end
@ -279,9 +276,9 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
0.0,
measureAxis);
animatingPoint = new AnimatedPoint<D>(
animatingPoint = AnimatedPoint<D>(
key: pointKey, overlaySeries: series.overlaySeries)
..setNewTarget(new PointRendererElement<D>()
..setNewTarget(PointRendererElement<D>()
..color = details.color
..fillColor = details.fillColor
..measureAxisPosition = measureAxis.getLocation(0.0)
@ -298,7 +295,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
_currentKeys.add(pointKey);
// Get the pointElement we are going to setup.
final pointElement = new PointRendererElement<D>()
final pointElement = PointRendererElement<D>()
..color = details.color
..fillColor = details.fillColor
..measureAxisPosition = measureAxis.getLocation(0.0)
@ -315,11 +312,11 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
// Sort the renderer elements to be in the same order as the series list.
// They may get disordered between chart draw cycles if a behavior adds or
// removes series from the list (e.g. click to hide on legends).
seriesPointMap = new LinkedHashMap.fromIterable(sortedSeriesIds,
seriesPointMap = LinkedHashMap.fromIterable(sortedSeriesIds,
key: (k) => k, value: (k) => seriesPointMap[k]);
// Animate out points that don't exist anymore.
seriesPointMap.forEach((String key, List<AnimatedPoint<D>> points) {
seriesPointMap.forEach((key, points) {
for (var point in points) {
if (_currentKeys.contains(point.key) != true) {
point.animateOut();
@ -342,27 +339,27 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
if (animationPercent == 1.0) {
final keysToRemove = <String>[];
seriesPointMap.forEach((String key, List<AnimatedPoint<D>> points) {
points.removeWhere((AnimatedPoint<D> point) => point.animatingOut);
seriesPointMap.forEach((key, points) {
points.removeWhere((point) => point.animatingOut);
if (points.isEmpty) {
keysToRemove.add(key);
}
});
keysToRemove.forEach((String key) => seriesPointMap.remove(key));
keysToRemove.forEach((key) => seriesPointMap.remove(key));
}
seriesPointMap.forEach((String key, List<AnimatedPoint<D>> points) {
seriesPointMap.forEach((key, points) {
points
.map<PointRendererElement<D>>((AnimatedPoint<D> animatingPoint) =>
.map<PointRendererElement<D>>((animatingPoint) =>
animatingPoint.getCurrentPoint(animationPercent))
.forEach((PointRendererElement point) {
.forEach((point) {
// Decorate the points with decorators that should appear below the main
// series data.
pointRendererDecorators
.where((PointRendererDecorator decorator) => !decorator.renderAbove)
.forEach((PointRendererDecorator decorator) {
.where((decorator) => !decorator.renderAbove)
.forEach((decorator) {
decorator.decorate(point, canvas, graphicsFactory,
drawBounds: componentBounds,
animationPercent: animationPercent,
@ -374,7 +371,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
// prevents harshly clipping off half of the shape.
if (point.point.y != null &&
componentBounds.containsPoint(point.point)) {
final bounds = new Rectangle<double>(
final bounds = Rectangle<double>(
point.point.x - point.radiusPx,
point.point.y - point.radiusPx,
point.radiusPx * 2,
@ -388,8 +385,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
} else {
final id = point.symbolRendererId;
if (!config.customSymbolRenderers.containsKey(id)) {
throw new ArgumentError(
'Invalid custom symbol renderer id "${id}"');
throw ArgumentError('Invalid custom symbol renderer id "$id"');
}
final customRenderer = config.customSymbolRenderers[id];
@ -403,8 +399,8 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
// Decorate the points with decorators that should appear above the main
// series data. This is the typical place for labels.
pointRendererDecorators
.where((PointRendererDecorator decorator) => decorator.renderAbove)
.forEach((PointRendererDecorator decorator) {
.where((decorator) => decorator.renderAbove)
.forEach((decorator) {
decorator.decorate(point, canvas, graphicsFactory,
drawBounds: componentBounds,
animationPercent: animationPercent,
@ -450,7 +446,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
? measureAxis.getLocation(measureUpperBoundValue + measureOffsetValue)
: null;
return new DatumPoint<D>(
return DatumPoint<D>(
datum: datum,
domain: domainValue,
series: series,
@ -472,13 +468,13 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
return nearest;
}
seriesPointMap.values.forEach((List<AnimatedPoint<D>> points) {
seriesPointMap.values.forEach((points) {
PointRendererElement<D> nearestPoint;
double nearestDomainDistance = _maxInitialDistance;
double nearestMeasureDistance = _maxInitialDistance;
double nearestRelativeDistance = _maxInitialDistance;
points.forEach((AnimatedPoint<D> point) {
points.forEach((point) {
if (point.overlaySeries) {
return;
}
@ -519,14 +515,13 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
} else {
final id = nearestPoint.symbolRendererId;
if (!config.customSymbolRenderers.containsKey(id)) {
throw new ArgumentError(
'Invalid custom symbol renderer id "${id}"');
throw ArgumentError('Invalid custom symbol renderer id "$id"');
}
nearestSymbolRenderer = config.customSymbolRenderers[id];
}
nearest.add(new DatumDetails<D>(
nearest.add(DatumDetails<D>(
datum: nearestPoint.point.datum,
domain: nearestPoint.point.domain,
series: nearestPoint.point.series,
@ -573,9 +568,9 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
// use the smaller of this distance and the distance from the primary
// point as the relativeDistance from this datum.
final num relativeDistanceBounds = distanceBetweenPointAndLineSegment(
new Vector2(chartPoint.x, chartPoint.y),
new Vector2(datumPoint.xLower, datumPoint.yLower),
new Vector2(datumPoint.xUpper, datumPoint.yUpper));
Vector2(chartPoint.x, chartPoint.y),
Vector2(datumPoint.xLower, datumPoint.yLower),
Vector2(datumPoint.xUpper, datumPoint.yUpper));
insidePoint = (relativeDistance < radiusPx) ||
(boundsLineRadiusPx != null &&
@ -589,7 +584,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
insidePoint = (relativeDistance < radiusPx);
}
return new _Distances(
return _Distances(
domainDistance: domainDistance,
measureDistance: measureDistance,
relativeDistance: relativeDistance,
@ -636,16 +631,16 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
} else {
final id = symbolRendererId;
if (!config.customSymbolRenderers.containsKey(id)) {
throw new ArgumentError('Invalid custom symbol renderer id "${id}"');
throw ArgumentError('Invalid custom symbol renderer id "$id"');
}
nearestSymbolRenderer = config.customSymbolRenderers[id];
}
return new DatumDetails.from(details,
chartPosition: new Point<double>(point.x, point.y),
chartPositionLower: new Point<double>(point.xLower, point.yLower),
chartPositionUpper: new Point<double>(point.xUpper, point.yUpper),
return DatumDetails.from(details,
chartPosition: Point<double>(point.x, point.y),
chartPositionLower: Point<double>(point.xLower, point.yLower),
chartPositionUpper: Point<double>(point.xUpper, point.yUpper),
symbolRenderer: nearestSymbolRenderer);
}
}
@ -682,7 +677,7 @@ class DatumPoint<D> extends Point<double> {
double y,
double yLower,
double yUpper}) {
return new DatumPoint<D>(
return DatumPoint<D>(
datum: other.datum,
domain: other.domain,
series: other.series,
@ -706,11 +701,10 @@ class PointRendererElement<D> {
String symbolRendererId;
PointRendererElement<D> clone() {
return new PointRendererElement<D>()
..point = new DatumPoint<D>.from(point)
..color = color != null ? new Color.fromOther(color: color) : null
..fillColor =
fillColor != null ? new Color.fromOther(color: fillColor) : null
return PointRendererElement<D>()
..point = DatumPoint<D>.from(point)
..color = color != null ? Color.fromOther(color: color) : null
..fillColor = fillColor != null ? Color.fromOther(color: fillColor) : null
..measureAxisPosition = measureAxisPosition
..radiusPx = radiusPx
..boundsLineRadiusPx = boundsLineRadiusPx
@ -756,7 +750,7 @@ class PointRendererElement<D> {
previousPoint.yUpper
: null;
point = new DatumPoint<D>.from(targetPoint,
point = DatumPoint<D>.from(targetPoint,
x: x,
xLower: xLower,
xUpper: xUpper,
@ -808,7 +802,7 @@ class AnimatedPoint<D> {
// Set the target measure value to the axis position.
var targetPoint = newTarget.point;
newTarget.point = new DatumPoint<D>.from(targetPoint,
newTarget.point = DatumPoint<D>.from(targetPoint,
x: targetPoint.x,
y: newTarget.measureAxisPosition.roundToDouble(),
yLower: newTarget.measureAxisPosition.roundToDouble(),

@ -42,7 +42,7 @@ class PointRendererConfig<D> extends LayoutViewConfig
/// [symbolRenderer].
final Map<String, SymbolRenderer> customSymbolRenderers;
final rendererAttributes = new RendererAttributes();
final rendererAttributes = RendererAttributes();
/// Default radius of the points, used if a series does not define a radiusPx
/// accessor function.
@ -75,6 +75,6 @@ class PointRendererConfig<D> extends LayoutViewConfig
@override
PointRenderer<D> build() {
return new PointRenderer<D>(config: this, rendererId: customRendererId);
return PointRenderer<D>(config: this, rendererId: customRendererId);
}
}

@ -55,13 +55,12 @@ class ScatterPlotChart extends NumericCartesianChart {
@override
SeriesRenderer<num> makeDefaultRenderer() {
return new PointRenderer<num>()
..rendererId = SeriesRenderer.defaultRendererId;
return PointRenderer<num>()..rendererId = SeriesRenderer.defaultRendererId;
}
@override
void initDomainAxis() {
domainAxis.tickDrawStrategy = new GridlineRendererSpec<num>()
domainAxis.tickDrawStrategy = GridlineRendererSpec<num>()
.createDrawStrategy(context, graphicsFactory);
}
}

@ -32,7 +32,7 @@ import '../layout/layout_view.dart'
LayoutViewPaintOrder,
LayoutViewPositionOrder,
ViewMeasuredSizes;
import 'point_renderer.dart' show AnimatedPoint, DatumPoint, PointRenderer;
import 'point_renderer.dart' show DatumPoint, PointRenderer;
import 'symbol_annotation_renderer_config.dart'
show SymbolAnnotationRendererConfig;
@ -51,13 +51,13 @@ import 'symbol_annotation_renderer_config.dart'
class SymbolAnnotationRenderer<D> extends PointRenderer<D>
implements LayoutView {
Rectangle<int> _componentBounds;
GraphicsFactory _graphicsFactory;
GraphicsFactory graphicsFactory;
CartesianChart<D> _chart;
var _currentHeight = 0;
final _seriesInfo = new LinkedHashMap<String, _SeriesInfo<D>>();
final _seriesInfo = LinkedHashMap<String, _SeriesInfo<D>>();
SymbolAnnotationRenderer(
{String rendererId, SymbolAnnotationRendererConfig config})
@ -79,7 +79,7 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
double offset = 0.0;
seriesList.forEach((MutableSeries<D> series) {
seriesList.forEach((series) {
final seriesKey = series.id;
// Default to the configured radius if none was defined by the series.
@ -105,19 +105,18 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
localConfig.verticalSymbolTopPaddingPx +
(rowInnerHeight / 2);
series.measureFn = (int index) => 0;
series.measureOffsetFn = (int index) => 0;
series.measureFn = (index) => 0;
series.measureOffsetFn = (index) => 0;
// Override the key function to allow for range annotations that start at
// the same point. This is a necessary hack because every annotation has a
// measure value of 0, so the key generated in [PointRenderer] is not
// unique enough.
series.keyFn ??=
(int index) => '${series.id}__${series.domainFn(index)}__'
'${series.domainLowerBoundFn(index)}__'
'${series.domainUpperBoundFn(index)}';
series.keyFn ??= (index) => '${series.id}__${series.domainFn(index)}__'
'${series.domainLowerBoundFn(index)}__'
'${series.domainUpperBoundFn(index)}';
_seriesInfo[seriesKey] = new _SeriesInfo<D>(
_seriesInfo[seriesKey] = _SeriesInfo<D>(
rowHeight: rowHeight,
rowStart: offset,
symbolCenter: symbolCenter,
@ -165,7 +164,7 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
final measureUpperBoundPosition =
domainUpperBoundPosition != null ? measurePosition : null;
return new DatumPoint<D>(
return DatumPoint<D>(
datum: datum,
domain: domainValue,
series: series,
@ -180,7 +179,7 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
@override
void onAttach(BaseChart<D> chart) {
if (!(chart is CartesianChart)) {
throw new ArgumentError(
throw ArgumentError(
'SymbolAnnotationRenderer can only be attached to a CartesianChart');
}
@ -205,13 +204,13 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
// Use the domain axis of the attached chart to render the separator lines
// to keep the same overall style.
if ((config as SymbolAnnotationRendererConfig).showSeparatorLines) {
seriesPointMap.forEach((String key, List<AnimatedPoint<D>> points) {
seriesPointMap.forEach((key, points) {
final seriesInfo = _seriesInfo[key];
final y = componentBounds.top + seriesInfo.rowStart;
final domainAxis = _chart.domainAxis;
final bounds = new Rectangle<int>(
final bounds = Rectangle<int>(
componentBounds.left, y.round(), componentBounds.width, 0);
domainAxis.tickDrawStrategy
.drawAxisLine(canvas, domainAxis.axisOrientation, bounds);
@ -219,21 +218,13 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
}
}
@override
GraphicsFactory get graphicsFactory => _graphicsFactory;
@override
set graphicsFactory(GraphicsFactory value) {
_graphicsFactory = value;
}
//
// Layout methods
//
@override
LayoutViewConfig get layoutConfig {
return new LayoutViewConfig(
return LayoutViewConfig(
paintOrder: LayoutViewPaintOrder.point,
position: LayoutPosition.Bottom,
positionOrder: LayoutViewPositionOrder.symbolAnnotation);
@ -244,7 +235,7 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
// The sizing of component is not flexible. It's height is always a multiple
// of the number of series rendered, even if that ends up taking all of the
// available margin space.
return new ViewMeasuredSizes(
return ViewMeasuredSizes(
preferredWidth: maxWidth, preferredHeight: _currentHeight);
}

@ -57,8 +57,8 @@ class SymbolAnnotationRendererConfig<D> extends PointRendererConfig<D> {
customRendererId: customRendererId,
pointRendererDecorators: pointRendererDecorators ??
[
new ComparisonPointsDecorator(
symbolRenderer: new RectangleRangeSymbolRenderer())
ComparisonPointsDecorator(
symbolRenderer: RectangleRangeSymbolRenderer())
],
radiusPx: radiusPx,
symbolRenderer: symbolRenderer,
@ -66,7 +66,7 @@ class SymbolAnnotationRendererConfig<D> extends PointRendererConfig<D> {
@override
SymbolAnnotationRenderer<D> build() {
return new SymbolAnnotationRenderer<D>(
return SymbolAnnotationRenderer<D>(
config: this, rendererId: customRendererId);
}
}

@ -41,20 +41,20 @@ class TimeSeriesChart extends CartesianChart<DateTime> {
: super(
vertical: vertical,
layoutConfig: layoutConfig,
domainAxis: new DateTimeAxis(dateTimeFactory),
domainAxis: DateTimeAxis(dateTimeFactory),
primaryMeasureAxis: primaryMeasureAxis,
secondaryMeasureAxis: secondaryMeasureAxis,
disjointMeasureAxes: disjointMeasureAxes);
@override
void initDomainAxis() {
domainAxis.tickDrawStrategy = new SmallTickRendererSpec<DateTime>()
domainAxis.tickDrawStrategy = SmallTickRendererSpec<DateTime>()
.createDrawStrategy(context, graphicsFactory);
}
@override
SeriesRenderer<DateTime> makeDefaultRenderer() {
return new LineRenderer<DateTime>()
return LineRenderer<DateTime>()
..rendererId = SeriesRenderer.defaultRendererId;
}

@ -17,9 +17,9 @@ import 'package:meta/meta.dart' show immutable;
@immutable
class Color {
static const black = const Color(r: 0, g: 0, b: 0);
static const white = const Color(r: 255, g: 255, b: 255);
static const transparent = const Color(r: 0, g: 0, b: 0, a: 0);
static const black = Color(r: 0, g: 0, b: 0);
static const white = Color(r: 255, g: 255, b: 255);
static const transparent = Color(r: 0, g: 0, b: 0, a: 0);
static const _darkerPercentOfOrig = 0.7;
static const _lighterPercentOfOrig = 0.1;
@ -53,12 +53,12 @@ class Color {
final g = (bigint >> 8) & 255;
final b = bigint & 255;
final a = 255;
return new Color(r: r, g: g, b: b, a: a);
return Color(r: r, g: g, b: b, a: a);
}
Color get darker =>
_darker ??
new Color(
Color(
r: (r * _darkerPercentOfOrig).round(),
g: (g * _darkerPercentOfOrig).round(),
b: (b * _darkerPercentOfOrig).round(),
@ -66,7 +66,7 @@ class Color {
Color get lighter =>
_lighter ??
new Color(
Color(
r: r + ((255 - r) * _lighterPercentOfOrig).round(),
g: g + ((255 - g) * _lighterPercentOfOrig).round(),
b: b + ((255 - b) * _lighterPercentOfOrig).round(),

@ -48,7 +48,7 @@ class LocalDateTimeFactory implements DateTimeFactory {
DateTime createDateTimeFromMilliSecondsSinceEpoch(
int millisecondsSinceEpoch) {
return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
return DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
}
DateTime createDateTime(int year,
@ -59,13 +59,13 @@ class LocalDateTimeFactory implements DateTimeFactory {
int second = 0,
int millisecond = 0,
int microsecond = 0]) {
return new DateTime(
return DateTime(
year, month, day, hour, minute, second, millisecond, microsecond);
}
/// Returns a [DateFormat].
DateFormat createDateFormat(String pattern) {
return new DateFormat(pattern);
return DateFormat(pattern);
}
}
@ -75,7 +75,7 @@ class UTCDateTimeFactory implements DateTimeFactory {
DateTime createDateTimeFromMilliSecondsSinceEpoch(
int millisecondsSinceEpoch) {
return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch,
return DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch,
isUtc: true);
}
@ -87,12 +87,12 @@ class UTCDateTimeFactory implements DateTimeFactory {
int second = 0,
int millisecond = 0,
int microsecond = 0]) {
return new DateTime.utc(
return DateTime.utc(
year, month, day, hour, minute, second, millisecond, microsecond);
}
/// Returns a [DateFormat].
DateFormat createDateFormat(String pattern) {
return new DateFormat(pattern);
return DateFormat(pattern);
}
}

@ -95,10 +95,11 @@ class GestureListener {
this.onTapCancel = onTapCancel ?? defaultTapCancel;
}
typedef GestureCancelCallback();
typedef bool GestureSinglePointCallback(Point<double> localPosition);
typedef GestureCancelCallback = Function();
typedef GestureSinglePointCallback = bool Function(Point<double> localPosition);
typedef bool GestureDragStartCallback(Point<double> localPosition);
typedef GestureDragUpdateCallback(Point<double> localPosition, double scale);
typedef GestureDragEndCallback(
typedef GestureDragStartCallback = bool Function(Point<double> localPosition);
typedef GestureDragUpdateCallback = Function(
Point<double> localPosition, double scale);
typedef GestureDragEndCallback = Function(
Point<double> localPosition, double scale, double pixelsPerSec);

@ -20,9 +20,9 @@ import 'palette.dart' show Palette;
///
/// @link https://material.io/guidelines/style/color.html#color-color-palette
class MaterialPalette {
static const black = const Color(r: 0, g: 0, b: 0);
static const transparent = const Color(r: 0, g: 0, b: 0, a: 0);
static const white = const Color(r: 255, g: 255, b: 255);
static const black = Color(r: 0, g: 0, b: 0);
static const transparent = Color(r: 0, g: 0, b: 0, a: 0);
static const white = Color(r: 255, g: 255, b: 255);
static Palette get blue => const MaterialBlue();
static Palette get red => const MaterialRed();
@ -77,10 +77,10 @@ class MaterialPalette {
}
class MaterialBlue extends Palette {
static const _shade200 = const Color(r: 0x90, g: 0xCA, b: 0xF9); //#90CAF9
static const _shade500 = const Color(
r: 0x21, g: 0x96, b: 0xF3, darker: _shade700, lighter: _shade200);
static const _shade700 = const Color(r: 0x19, g: 0x76, b: 0xD2); //#1976D2
static const _shade200 = Color(r: 0x90, g: 0xCA, b: 0xF9); //#90CAF9
static const _shade500 =
Color(r: 0x21, g: 0x96, b: 0xF3, darker: _shade700, lighter: _shade200);
static const _shade700 = Color(r: 0x19, g: 0x76, b: 0xD2); //#1976D2
const MaterialBlue();
@ -89,10 +89,10 @@ class MaterialBlue extends Palette {
}
class MaterialRed extends Palette {
static const _shade200 = const Color(r: 0xEF, g: 0x9A, b: 0x9A); //#EF9A9A
static const _shade700 = const Color(r: 0xD3, g: 0x2F, b: 0x2F); //#D32F2F
static const _shade500 = const Color(
r: 0xF4, g: 0x43, b: 0x36, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xEF, g: 0x9A, b: 0x9A); //#EF9A9A
static const _shade700 = Color(r: 0xD3, g: 0x2F, b: 0x2F); //#D32F2F
static const _shade500 =
Color(r: 0xF4, g: 0x43, b: 0x36, darker: _shade700, lighter: _shade200);
const MaterialRed();
@ -101,10 +101,10 @@ class MaterialRed extends Palette {
}
class MaterialYellow extends Palette {
static const _shade200 = const Color(r: 0xFF, g: 0xF5, b: 0x9D); //#FFF59D
static const _shade700 = const Color(r: 0xFB, g: 0xC0, b: 0x2D); //#FBC02D
static const _shade500 = const Color(
r: 0xFF, g: 0xEB, b: 0x3B, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xFF, g: 0xF5, b: 0x9D); //#FFF59D
static const _shade700 = Color(r: 0xFB, g: 0xC0, b: 0x2D); //#FBC02D
static const _shade500 =
Color(r: 0xFF, g: 0xEB, b: 0x3B, darker: _shade700, lighter: _shade200);
const MaterialYellow();
@ -113,10 +113,10 @@ class MaterialYellow extends Palette {
}
class MaterialGreen extends Palette {
static const _shade200 = const Color(r: 0xA5, g: 0xD6, b: 0xA7); //#A5D6A7
static const _shade700 = const Color(r: 0x38, g: 0x8E, b: 0x3C); //#388E3C;
static const _shade500 = const Color(
r: 0x4C, g: 0xAF, b: 0x50, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xA5, g: 0xD6, b: 0xA7); //#A5D6A7
static const _shade700 = Color(r: 0x38, g: 0x8E, b: 0x3C); //#388E3C;
static const _shade500 =
Color(r: 0x4C, g: 0xAF, b: 0x50, darker: _shade700, lighter: _shade200);
const MaterialGreen();
@ -125,10 +125,10 @@ class MaterialGreen extends Palette {
}
class MaterialPurple extends Palette {
static const _shade200 = const Color(r: 0xCE, g: 0x93, b: 0xD8); //#CE93D8
static const _shade700 = const Color(r: 0x7B, g: 0x1F, b: 0xA2); //#7B1FA2
static const _shade500 = const Color(
r: 0x9C, g: 0x27, b: 0xB0, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xCE, g: 0x93, b: 0xD8); //#CE93D8
static const _shade700 = Color(r: 0x7B, g: 0x1F, b: 0xA2); //#7B1FA2
static const _shade500 =
Color(r: 0x9C, g: 0x27, b: 0xB0, darker: _shade700, lighter: _shade200);
const MaterialPurple();
@ -137,10 +137,10 @@ class MaterialPurple extends Palette {
}
class MaterialCyan extends Palette {
static const _shade200 = const Color(r: 0x80, g: 0xDE, b: 0xEA); //#80DEEA
static const _shade700 = const Color(r: 0x00, g: 0x97, b: 0xA7); //#0097A7
static const _shade500 = const Color(
r: 0x00, g: 0xBC, b: 0xD4, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0x80, g: 0xDE, b: 0xEA); //#80DEEA
static const _shade700 = Color(r: 0x00, g: 0x97, b: 0xA7); //#0097A7
static const _shade500 =
Color(r: 0x00, g: 0xBC, b: 0xD4, darker: _shade700, lighter: _shade200);
const MaterialCyan();
@ -149,10 +149,10 @@ class MaterialCyan extends Palette {
}
class MaterialDeepOrange extends Palette {
static const _shade200 = const Color(r: 0xFF, g: 0xAB, b: 0x91); //#FFAB91
static const _shade700 = const Color(r: 0xE6, g: 0x4A, b: 0x19); //#E64A19
static const _shade500 = const Color(
r: 0xFF, g: 0x57, b: 0x22, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xFF, g: 0xAB, b: 0x91); //#FFAB91
static const _shade700 = Color(r: 0xE6, g: 0x4A, b: 0x19); //#E64A19
static const _shade500 =
Color(r: 0xFF, g: 0x57, b: 0x22, darker: _shade700, lighter: _shade200);
const MaterialDeepOrange();
@ -161,10 +161,10 @@ class MaterialDeepOrange extends Palette {
}
class MaterialLime extends Palette {
static const _shade200 = const Color(r: 0xE6, g: 0xEE, b: 0x9C); //#E6EE9C
static const _shade700 = const Color(r: 0xAF, g: 0xB4, b: 0x2B); //#AFB42B
static const _shade500 = const Color(
r: 0xCD, g: 0xDC, b: 0x39, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xE6, g: 0xEE, b: 0x9C); //#E6EE9C
static const _shade700 = Color(r: 0xAF, g: 0xB4, b: 0x2B); //#AFB42B
static const _shade500 =
Color(r: 0xCD, g: 0xDC, b: 0x39, darker: _shade700, lighter: _shade200);
const MaterialLime();
@ -173,10 +173,10 @@ class MaterialLime extends Palette {
}
class MaterialIndigo extends Palette {
static const _shade200 = const Color(r: 0x9F, g: 0xA8, b: 0xDA); //#9FA8DA
static const _shade700 = const Color(r: 0x30, g: 0x3F, b: 0x9F); //#303F9F
static const _shade500 = const Color(
r: 0x3F, g: 0x51, b: 0xB5, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0x9F, g: 0xA8, b: 0xDA); //#9FA8DA
static const _shade700 = Color(r: 0x30, g: 0x3F, b: 0x9F); //#303F9F
static const _shade500 =
Color(r: 0x3F, g: 0x51, b: 0xB5, darker: _shade700, lighter: _shade200);
const MaterialIndigo();
@ -185,10 +185,10 @@ class MaterialIndigo extends Palette {
}
class MaterialPink extends Palette {
static const _shade200 = const Color(r: 0xF4, g: 0x8F, b: 0xB1); //#F48FB1
static const _shade700 = const Color(r: 0xC2, g: 0x18, b: 0x5B); //#C2185B
static const _shade500 = const Color(
r: 0xE9, g: 0x1E, b: 0x63, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xF4, g: 0x8F, b: 0xB1); //#F48FB1
static const _shade700 = Color(r: 0xC2, g: 0x18, b: 0x5B); //#C2185B
static const _shade500 =
Color(r: 0xE9, g: 0x1E, b: 0x63, darker: _shade700, lighter: _shade200);
const MaterialPink();
@ -197,10 +197,10 @@ class MaterialPink extends Palette {
}
class MaterialTeal extends Palette {
static const _shade200 = const Color(r: 0x80, g: 0xCB, b: 0xC4); //#80CBC4
static const _shade700 = const Color(r: 0x00, g: 0x79, b: 0x6B); //#00796B
static const _shade500 = const Color(
r: 0x00, g: 0x96, b: 0x88, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0x80, g: 0xCB, b: 0xC4); //#80CBC4
static const _shade700 = Color(r: 0x00, g: 0x79, b: 0x6B); //#00796B
static const _shade500 =
Color(r: 0x00, g: 0x96, b: 0x88, darker: _shade700, lighter: _shade200);
const MaterialTeal();
@ -209,10 +209,10 @@ class MaterialTeal extends Palette {
}
class MaterialGray extends Palette {
static const _shade200 = const Color(r: 0xEE, g: 0xEE, b: 0xEE); //#EEEEEE
static const _shade700 = const Color(r: 0x61, g: 0x61, b: 0x61); //#616161
static const _shade500 = const Color(
r: 0x9E, g: 0x9E, b: 0x9E, darker: _shade700, lighter: _shade200);
static const _shade200 = Color(r: 0xEE, g: 0xEE, b: 0xEE); //#EEEEEE
static const _shade700 = Color(r: 0x61, g: 0x61, b: 0x61); //#616161
static const _shade500 =
Color(r: 0x9E, g: 0x9E, b: 0x9E, darker: _shade700, lighter: _shade200);
const MaterialGray();

@ -39,14 +39,14 @@ abstract class Palette {
darker: shadeDefault.darker, lighter: lighterColor));
}
colors.add(new Color.fromOther(color: shadeDefault, lighter: lighterColor));
colors.add(Color.fromOther(color: shadeDefault, lighter: lighterColor));
return colors;
}
Color _getSteppedColor(Color color, int index, int steps,
{Color darker, Color lighter}) {
final fraction = index / steps;
return new Color(
return Color(
r: color.r + ((255 - color.r) * fraction).round(),
g: color.g + ((255 - color.g) * fraction).round(),
b: color.b + ((255 - color.b) * fraction).round(),

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save