mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Web charts common update (#111)
This commit is contained in:
@@ -43,13 +43,13 @@ class MockCanvas extends Mock implements ChartCanvas {}
|
||||
/// A fake [GraphicsFactory] that returns [FakeTextStyle] and [FakeTextElement].
|
||||
class FakeGraphicsFactory extends GraphicsFactory {
|
||||
@override
|
||||
TextStyle createTextPaint() => new FakeTextStyle();
|
||||
TextStyle createTextPaint() => FakeTextStyle();
|
||||
|
||||
@override
|
||||
TextElement createTextElement(String text) => new FakeTextElement(text);
|
||||
TextElement createTextElement(String text) => FakeTextElement(text);
|
||||
|
||||
@override
|
||||
LineStyle createLinePaint() => new MockLinePaint();
|
||||
LineStyle createLinePaint() => MockLinePaint();
|
||||
}
|
||||
|
||||
/// Stores [TextStyle] properties for test to verify.
|
||||
@@ -72,7 +72,7 @@ class FakeTextElement implements TextElement {
|
||||
|
||||
FakeTextElement(this.text);
|
||||
|
||||
TextMeasurement get measurement => new TextMeasurement(
|
||||
TextMeasurement get measurement => TextMeasurement(
|
||||
horizontalSliceWidth: text.length.toDouble(),
|
||||
verticalSliceWidth: textStyle.fontSize.toDouble(),
|
||||
baseline: textStyle.fontSize.toDouble());
|
||||
@@ -81,7 +81,7 @@ class FakeTextElement implements TextElement {
|
||||
class MockLinePaint extends Mock implements LineStyle {}
|
||||
|
||||
class FakeBarRendererElement implements ImmutableBarRendererElement<String> {
|
||||
final _series = new MockImmutableSeries<String>();
|
||||
final _series = MockImmutableSeries<String>();
|
||||
final AccessorFn<String> labelAccessor;
|
||||
final String datum;
|
||||
final Rectangle<int> bounds;
|
||||
@@ -106,9 +106,9 @@ void main() {
|
||||
Rectangle<int> drawBounds;
|
||||
|
||||
setUpAll(() {
|
||||
canvas = new MockCanvas();
|
||||
graphicsFactory = new FakeGraphicsFactory();
|
||||
drawBounds = new Rectangle(0, 0, 200, 100);
|
||||
canvas = MockCanvas();
|
||||
graphicsFactory = FakeGraphicsFactory();
|
||||
drawBounds = Rectangle(0, 0, 200, 100);
|
||||
});
|
||||
|
||||
group('horizontal bar chart', () {
|
||||
@@ -118,12 +118,12 @@ void main() {
|
||||
// 'LabelA' and 'LabelB' both have lengths of 6.
|
||||
// 'LabelB' would not fit inside the bar in auto setting because it has
|
||||
// width of 5.
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 20, 50, 20), (_) => 'LabelA', data),
|
||||
new FakeBarRendererElement(
|
||||
'B', new Rectangle(0, 70, 5, 20), (_) => 'LabelB', data)
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 20, 50, 20), (_) => 'LabelA', data),
|
||||
FakeBarRendererElement(
|
||||
'B', Rectangle(0, 70, 5, 20), (_) => 'LabelB', data)
|
||||
];
|
||||
final decorator = new BarLabelDecorator();
|
||||
final decorator = BarLabelDecorator();
|
||||
|
||||
decorator.decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
@@ -155,15 +155,15 @@ void main() {
|
||||
final barElements = [
|
||||
// 'LabelABC' would not fit inside the bar in auto setting because it
|
||||
// has a width of 8.
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 6, 20), (_) => 'LabelABC', ['A']),
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 0, 6, 20), (_) => 'LabelABC', ['A']),
|
||||
];
|
||||
// Draw bounds with width of 10 means that space inside the bar is larger.
|
||||
final smallDrawBounds = new Rectangle(0, 0, 10, 20);
|
||||
final smallDrawBounds = Rectangle(0, 0, 10, 20);
|
||||
|
||||
new BarLabelDecorator(
|
||||
BarLabelDecorator(
|
||||
labelPadding: 0, // Turn off label padding for testing.
|
||||
insideLabelStyleSpec: new TextStyleSpec(fontSize: 10))
|
||||
insideLabelStyleSpec: TextStyleSpec(fontSize: 10))
|
||||
.decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: smallDrawBounds,
|
||||
animationPercent: 1.0,
|
||||
@@ -182,14 +182,14 @@ void main() {
|
||||
final barElements = [
|
||||
// 'LabelABC' would not fit inside the bar in auto setting because it
|
||||
// has a width of 8.
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 6, 20), (_) => 'LabelABC', ['A']),
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 0, 6, 20), (_) => 'LabelABC', ['A']),
|
||||
];
|
||||
|
||||
new BarLabelDecorator(
|
||||
BarLabelDecorator(
|
||||
labelPosition: BarLabelPosition.inside,
|
||||
labelPadding: 0, // Turn off label padding for testing.
|
||||
insideLabelStyleSpec: new TextStyleSpec(fontSize: 10))
|
||||
insideLabelStyleSpec: TextStyleSpec(fontSize: 10))
|
||||
.decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
animationPercent: 1.0,
|
||||
@@ -206,14 +206,14 @@ void main() {
|
||||
|
||||
test('LabelPosition.outside always paints outside the bar', () {
|
||||
final barElements = [
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 10, 20), (_) => 'Label', ['A']),
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 0, 10, 20), (_) => 'Label', ['A']),
|
||||
];
|
||||
|
||||
new BarLabelDecorator(
|
||||
BarLabelDecorator(
|
||||
labelPosition: BarLabelPosition.outside,
|
||||
labelPadding: 0, // Turn off label padding for testing.
|
||||
outsideLabelStyleSpec: new TextStyleSpec(fontSize: 10))
|
||||
outsideLabelStyleSpec: TextStyleSpec(fontSize: 10))
|
||||
.decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
animationPercent: 1.0,
|
||||
@@ -234,18 +234,18 @@ void main() {
|
||||
// 'LabelA' and 'LabelB' both have lengths of 6.
|
||||
// 'LabelB' would not fit inside the bar in auto setting because it has
|
||||
// width of 5.
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 20, 50, 20), (_) => 'LabelA', data),
|
||||
new FakeBarRendererElement(
|
||||
'B', new Rectangle(0, 70, 5, 20), (_) => 'LabelB', data)
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 20, 50, 20), (_) => 'LabelA', data),
|
||||
FakeBarRendererElement(
|
||||
'B', Rectangle(0, 70, 5, 20), (_) => 'LabelB', data)
|
||||
];
|
||||
final insideColor = new Color(r: 0, g: 0, b: 0);
|
||||
final outsideColor = new Color(r: 255, g: 255, b: 255);
|
||||
final decorator = new BarLabelDecorator(
|
||||
final insideColor = Color(r: 0, g: 0, b: 0);
|
||||
final outsideColor = Color(r: 255, g: 255, b: 255);
|
||||
final decorator = BarLabelDecorator(
|
||||
labelPadding: 0,
|
||||
insideLabelStyleSpec: new TextStyleSpec(
|
||||
insideLabelStyleSpec: TextStyleSpec(
|
||||
fontSize: 10, fontFamily: 'insideFont', color: insideColor),
|
||||
outsideLabelStyleSpec: new TextStyleSpec(
|
||||
outsideLabelStyleSpec: TextStyleSpec(
|
||||
fontSize: 8, fontFamily: 'outsideFont', color: outsideColor));
|
||||
|
||||
decorator.decorate(barElements, canvas, graphicsFactory,
|
||||
@@ -276,15 +276,15 @@ void main() {
|
||||
|
||||
test('TextAnchor.end starts on the right most of bar', () {
|
||||
final barElements = [
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 10, 20), (_) => 'LabelA', ['A'])
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 0, 10, 20), (_) => 'LabelA', ['A'])
|
||||
];
|
||||
|
||||
new BarLabelDecorator(
|
||||
BarLabelDecorator(
|
||||
labelAnchor: BarLabelAnchor.end,
|
||||
labelPosition: BarLabelPosition.inside,
|
||||
labelPadding: 0, // Turn off label padding for testing.
|
||||
insideLabelStyleSpec: new TextStyleSpec(fontSize: 10))
|
||||
insideLabelStyleSpec: TextStyleSpec(fontSize: 10))
|
||||
.decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
animationPercent: 1.0,
|
||||
@@ -301,15 +301,15 @@ void main() {
|
||||
|
||||
test('RTL TextAnchor.start starts on the right', () {
|
||||
final barElements = [
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 10, 20), (_) => 'LabelA', ['A'])
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 0, 10, 20), (_) => 'LabelA', ['A'])
|
||||
];
|
||||
|
||||
new BarLabelDecorator(
|
||||
BarLabelDecorator(
|
||||
labelAnchor: BarLabelAnchor.start,
|
||||
labelPosition: BarLabelPosition.inside,
|
||||
labelPadding: 0, // Turn off label padding for testing.
|
||||
insideLabelStyleSpec: new TextStyleSpec(fontSize: 10))
|
||||
insideLabelStyleSpec: TextStyleSpec(fontSize: 10))
|
||||
.decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
animationPercent: 1.0,
|
||||
@@ -327,15 +327,15 @@ void main() {
|
||||
|
||||
test('RTL TextAnchor.end starts on the left', () {
|
||||
final barElements = [
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 10, 20), (_) => 'LabelA', ['A'])
|
||||
FakeBarRendererElement(
|
||||
'A', Rectangle(0, 0, 10, 20), (_) => 'LabelA', ['A'])
|
||||
];
|
||||
|
||||
new BarLabelDecorator(
|
||||
BarLabelDecorator(
|
||||
labelAnchor: BarLabelAnchor.end,
|
||||
labelPosition: BarLabelPosition.inside,
|
||||
labelPadding: 0, // Turn off label padding for testing.
|
||||
insideLabelStyleSpec: new TextStyleSpec(fontSize: 10))
|
||||
insideLabelStyleSpec: TextStyleSpec(fontSize: 10))
|
||||
.decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
animationPercent: 1.0,
|
||||
@@ -355,11 +355,10 @@ void main() {
|
||||
group('Null and empty label scenarios', () {
|
||||
test('Skip label if label accessor does not exist', () {
|
||||
final barElements = [
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 10, 20), null, ['A'])
|
||||
FakeBarRendererElement('A', Rectangle(0, 0, 10, 20), null, ['A'])
|
||||
];
|
||||
|
||||
new BarLabelDecorator().decorate(barElements, canvas, graphicsFactory,
|
||||
BarLabelDecorator().decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
animationPercent: 1.0,
|
||||
renderingVertically: false);
|
||||
@@ -370,13 +369,11 @@ void main() {
|
||||
test('Skip label if label is null or empty', () {
|
||||
final data = ['A', 'B'];
|
||||
final barElements = [
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 10, 20), null, data),
|
||||
new FakeBarRendererElement(
|
||||
'B', new Rectangle(0, 50, 10, 20), (_) => '', data),
|
||||
FakeBarRendererElement('A', Rectangle(0, 0, 10, 20), null, data),
|
||||
FakeBarRendererElement('B', Rectangle(0, 50, 10, 20), (_) => '', data),
|
||||
];
|
||||
|
||||
new BarLabelDecorator().decorate(barElements, canvas, graphicsFactory,
|
||||
BarLabelDecorator().decorate(barElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds,
|
||||
animationPercent: 1.0,
|
||||
renderingVertically: false);
|
||||
@@ -386,11 +383,10 @@ void main() {
|
||||
|
||||
test('Skip label if no width available', () {
|
||||
final barElements = [
|
||||
new FakeBarRendererElement(
|
||||
'A', new Rectangle(0, 0, 200, 20), (_) => 'a', ['A'])
|
||||
FakeBarRendererElement('A', Rectangle(0, 0, 200, 20), (_) => 'a', ['A'])
|
||||
];
|
||||
|
||||
new BarLabelDecorator(
|
||||
BarLabelDecorator(
|
||||
labelPadding: 0,
|
||||
labelPosition: BarLabelPosition.outside,
|
||||
).decorate(barElements, canvas, graphicsFactory,
|
||||
|
||||
@@ -50,8 +50,7 @@ class FakeBarRenderer<D> extends BarRenderer<D> {
|
||||
int paintBarCallCount = 0;
|
||||
|
||||
factory FakeBarRenderer({BarRendererConfig config, String rendererId}) {
|
||||
return new FakeBarRenderer._internal(
|
||||
config: config, rendererId: rendererId);
|
||||
return FakeBarRenderer._internal(config: config, rendererId: rendererId);
|
||||
}
|
||||
|
||||
FakeBarRenderer._internal({BarRendererConfig config, String rendererId})
|
||||
@@ -73,10 +72,10 @@ void main() {
|
||||
// Convenience methods for creating mocks.
|
||||
/////////////////////////////////////////
|
||||
_configureBaseRenderer(BaseBarRenderer renderer, bool vertical) {
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
final verticalChart = new MockChart();
|
||||
final verticalChart = MockChart();
|
||||
when(verticalChart.vertical).thenReturn(vertical);
|
||||
when(verticalChart.context).thenReturn(context);
|
||||
renderer.onAttach(verticalChart);
|
||||
@@ -85,132 +84,132 @@ void main() {
|
||||
}
|
||||
|
||||
BarRenderer makeRenderer({BarRendererConfig config}) {
|
||||
final renderer = new BarRenderer(config: config);
|
||||
final renderer = BarRenderer(config: config);
|
||||
_configureBaseRenderer(renderer, true);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
FakeBarRenderer makeFakeRenderer({BarRendererConfig config}) {
|
||||
final renderer = new FakeBarRenderer(config: config);
|
||||
final renderer = FakeBarRenderer(config: config);
|
||||
_configureBaseRenderer(renderer, true);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
var myFakeDesktopAData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
var myFakeTabletAData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
var myFakeMobileAData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
var myFakeDesktopBData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
var myFakeTabletBData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
var myFakeMobileBData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
seriesList = [
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop',
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeDesktopAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Tablet',
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeTabletAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Mobile',
|
||||
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeMobileAData))
|
||||
];
|
||||
|
||||
groupedStackedSeriesList = [
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop A',
|
||||
seriesCategory: 'A',
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeDesktopAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Tablet A',
|
||||
seriesCategory: 'A',
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeTabletAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Mobile A',
|
||||
seriesCategory: 'A',
|
||||
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeMobileAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop B',
|
||||
seriesCategory: 'B',
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeDesktopBData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Tablet B',
|
||||
seriesCategory: 'B',
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeTabletBData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Mobile B',
|
||||
seriesCategory: 'B',
|
||||
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeMobileBData))
|
||||
];
|
||||
});
|
||||
@@ -218,7 +217,7 @@ void main() {
|
||||
group('preprocess', () {
|
||||
test('with grouped bars', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarRendererConfig(groupingType: BarGroupingType.grouped));
|
||||
config: BarRendererConfig(groupingType: BarGroupingType.grouped));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
|
||||
@@ -278,8 +277,8 @@ void main() {
|
||||
|
||||
test('with grouped stacked bars', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarRendererConfig(
|
||||
groupingType: BarGroupingType.groupedStacked));
|
||||
config:
|
||||
BarRendererConfig(groupingType: BarGroupingType.groupedStacked));
|
||||
|
||||
renderer.preprocessSeries(groupedStackedSeriesList);
|
||||
|
||||
@@ -390,7 +389,7 @@ void main() {
|
||||
|
||||
test('with stacked bars', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarRendererConfig(groupingType: BarGroupingType.stacked));
|
||||
config: BarRendererConfig(groupingType: BarGroupingType.stacked));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
|
||||
@@ -450,16 +449,16 @@ void main() {
|
||||
|
||||
test('with stacked bars containing zero and null', () {
|
||||
// Set up some nulls and zeros in the data.
|
||||
seriesList[2].data[0] = new MyRow('MyCampaign1', null);
|
||||
seriesList[2].data[2] = new MyRow('MyCampaign3', 0);
|
||||
seriesList[2].data[0] = MyRow('MyCampaign1', null);
|
||||
seriesList[2].data[2] = MyRow('MyCampaign3', 0);
|
||||
|
||||
seriesList[1].data[1] = new MyRow('MyCampaign2', null);
|
||||
seriesList[1].data[3] = new MyRow('MyOtherCampaign', 0);
|
||||
seriesList[1].data[1] = MyRow('MyCampaign2', null);
|
||||
seriesList[1].data[3] = MyRow('MyOtherCampaign', 0);
|
||||
|
||||
seriesList[0].data[2] = new MyRow('MyCampaign3', 0);
|
||||
seriesList[0].data[2] = MyRow('MyCampaign3', 0);
|
||||
|
||||
renderer = makeRenderer(
|
||||
config: new BarRendererConfig(groupingType: BarGroupingType.stacked));
|
||||
config: BarRendererConfig(groupingType: BarGroupingType.stacked));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
|
||||
@@ -547,7 +546,7 @@ void main() {
|
||||
group('preprocess weight pattern', () {
|
||||
test('with grouped bars', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarRendererConfig(
|
||||
config: BarRendererConfig(
|
||||
groupingType: BarGroupingType.grouped, weightPattern: [3, 2, 1]));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -612,7 +611,7 @@ void main() {
|
||||
|
||||
test('with grouped stacked bars', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarRendererConfig(
|
||||
config: BarRendererConfig(
|
||||
groupingType: BarGroupingType.groupedStacked,
|
||||
weightPattern: [2, 1]));
|
||||
|
||||
@@ -729,7 +728,7 @@ void main() {
|
||||
|
||||
test('with stacked bars - weightPattern not used', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarRendererConfig(
|
||||
config: BarRendererConfig(
|
||||
groupingType: BarGroupingType.stacked, weightPattern: [2, 1]));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -796,24 +795,24 @@ void main() {
|
||||
test('only include null in draw if animating from a non null measure', () {
|
||||
// Helper to create series list for this test only.
|
||||
List<MutableSeries<String>> _createSeriesList(List<MyRow> data) {
|
||||
final domainAxis = new MockAxis<dynamic>();
|
||||
final domainAxis = MockAxis<dynamic>();
|
||||
when(domainAxis.rangeBand).thenReturn(100.0);
|
||||
when(domainAxis.getLocation('MyCampaign1')).thenReturn(20.0);
|
||||
when(domainAxis.getLocation('MyCampaign2')).thenReturn(40.0);
|
||||
when(domainAxis.getLocation('MyCampaign3')).thenReturn(60.0);
|
||||
when(domainAxis.getLocation('MyOtherCampaign')).thenReturn(80.0);
|
||||
final measureAxis = new MockAxis<num>();
|
||||
final measureAxis = MockAxis<num>();
|
||||
when(measureAxis.getLocation(0)).thenReturn(0.0);
|
||||
when(measureAxis.getLocation(5)).thenReturn(5.0);
|
||||
when(measureAxis.getLocation(75)).thenReturn(75.0);
|
||||
when(measureAxis.getLocation(100)).thenReturn(100.0);
|
||||
|
||||
final color = new Color.fromHex(code: '#000000');
|
||||
final color = Color.fromHex(code: '#000000');
|
||||
|
||||
final series = new MutableSeries<String>(new Series<MyRow, String>(
|
||||
final series = MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
colorFn: (_, __) => color,
|
||||
fillColorFn: (_, __) => color,
|
||||
@@ -825,26 +824,26 @@ void main() {
|
||||
return [series];
|
||||
}
|
||||
|
||||
final canvas = new MockCanvas();
|
||||
final canvas = MockCanvas();
|
||||
|
||||
final myDataWithNull = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', null),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', null),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
final seriesListWithNull = _createSeriesList(myDataWithNull);
|
||||
|
||||
final myDataWithMeasures = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 0),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 0),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
final seriesListWithMeasures = _createSeriesList(myDataWithMeasures);
|
||||
|
||||
final renderer = makeFakeRenderer(
|
||||
config: new BarRendererConfig(groupingType: BarGroupingType.grouped));
|
||||
config: BarRendererConfig(groupingType: BarGroupingType.grouped));
|
||||
|
||||
// Verify that only 3 bars are drawn for an initial draw with null data.
|
||||
renderer.preprocessSeries(seriesListWithNull);
|
||||
|
||||
@@ -66,10 +66,10 @@ void main() {
|
||||
// Convenience methods for creating mocks.
|
||||
/////////////////////////////////////////
|
||||
_configureBaseRenderer(BaseBarRenderer renderer, bool vertical) {
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
final verticalChart = new MockChart();
|
||||
final verticalChart = MockChart();
|
||||
when(verticalChart.vertical).thenReturn(vertical);
|
||||
when(verticalChart.context).thenReturn(context);
|
||||
renderer.onAttach(verticalChart);
|
||||
@@ -78,51 +78,51 @@ void main() {
|
||||
}
|
||||
|
||||
BarTargetLineRenderer makeRenderer({BarTargetLineRendererConfig config}) {
|
||||
final renderer = new BarTargetLineRenderer(config: config);
|
||||
final renderer = BarTargetLineRenderer(config: config);
|
||||
_configureBaseRenderer(renderer, true);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
var myFakeDesktopData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
var myFakeTabletData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
var myFakeMobileData = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 25),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 25),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
|
||||
seriesList = [
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeDesktopData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Tablet',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeTabletData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Mobile',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeMobileData))
|
||||
];
|
||||
});
|
||||
@@ -130,7 +130,7 @@ void main() {
|
||||
group('preprocess', () {
|
||||
test('with grouped bar target lines', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarTargetLineRendererConfig(
|
||||
config: BarTargetLineRendererConfig(
|
||||
groupingType: BarGroupingType.grouped));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -194,7 +194,7 @@ void main() {
|
||||
|
||||
test('with stacked bar target lines', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarTargetLineRendererConfig(
|
||||
config: BarTargetLineRendererConfig(
|
||||
groupingType: BarGroupingType.stacked));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -258,16 +258,16 @@ void main() {
|
||||
|
||||
test('with stacked bar target lines containing zero and null', () {
|
||||
// Set up some nulls and zeros in the data.
|
||||
seriesList[2].data[0] = new MyRow('MyCampaign1', null);
|
||||
seriesList[2].data[2] = new MyRow('MyCampaign3', 0);
|
||||
seriesList[2].data[0] = MyRow('MyCampaign1', null);
|
||||
seriesList[2].data[2] = MyRow('MyCampaign3', 0);
|
||||
|
||||
seriesList[1].data[1] = new MyRow('MyCampaign2', null);
|
||||
seriesList[1].data[3] = new MyRow('MyOtherCampaign', 0);
|
||||
seriesList[1].data[1] = MyRow('MyCampaign2', null);
|
||||
seriesList[1].data[3] = MyRow('MyOtherCampaign', 0);
|
||||
|
||||
seriesList[0].data[2] = new MyRow('MyCampaign3', 0);
|
||||
seriesList[0].data[2] = MyRow('MyCampaign3', 0);
|
||||
|
||||
renderer = makeRenderer(
|
||||
config: new BarTargetLineRendererConfig(
|
||||
config: BarTargetLineRendererConfig(
|
||||
groupingType: BarGroupingType.stacked));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -367,7 +367,7 @@ void main() {
|
||||
|
||||
test('with stroke width target lines', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarTargetLineRendererConfig(
|
||||
config: BarTargetLineRendererConfig(
|
||||
groupingType: BarGroupingType.grouped, strokeWidthPx: 5.0));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -428,7 +428,7 @@ void main() {
|
||||
group('preprocess with weight pattern', () {
|
||||
test('with grouped bar target lines', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarTargetLineRendererConfig(
|
||||
config: BarTargetLineRendererConfig(
|
||||
groupingType: BarGroupingType.grouped, weightPattern: [3, 2, 1]));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -496,7 +496,7 @@ void main() {
|
||||
|
||||
test('with stacked bar target lines - weightPattern not used', () {
|
||||
renderer = makeRenderer(
|
||||
config: new BarTargetLineRendererConfig(
|
||||
config: BarTargetLineRendererConfig(
|
||||
groupingType: BarGroupingType.stacked, weightPattern: [2, 1]));
|
||||
|
||||
renderer.preprocessSeries(seriesList);
|
||||
@@ -566,24 +566,24 @@ void main() {
|
||||
test('only include null in draw if animating from a non null measure', () {
|
||||
// Helper to create series list for this test only.
|
||||
List<MutableSeries<String>> _createSeriesList(List<MyRow> data) {
|
||||
final domainAxis = new MockAxis<dynamic>();
|
||||
final domainAxis = MockAxis<dynamic>();
|
||||
when(domainAxis.rangeBand).thenReturn(100.0);
|
||||
when(domainAxis.getLocation('MyCampaign1')).thenReturn(20.0);
|
||||
when(domainAxis.getLocation('MyCampaign2')).thenReturn(40.0);
|
||||
when(domainAxis.getLocation('MyCampaign3')).thenReturn(60.0);
|
||||
when(domainAxis.getLocation('MyOtherCampaign')).thenReturn(80.0);
|
||||
final measureAxis = new MockAxis<num>();
|
||||
final measureAxis = MockAxis<num>();
|
||||
when(measureAxis.getLocation(0)).thenReturn(0.0);
|
||||
when(measureAxis.getLocation(5)).thenReturn(5.0);
|
||||
when(measureAxis.getLocation(75)).thenReturn(75.0);
|
||||
when(measureAxis.getLocation(100)).thenReturn(100.0);
|
||||
|
||||
final color = new Color.fromHex(code: '#000000');
|
||||
final color = Color.fromHex(code: '#000000');
|
||||
|
||||
final series = new MutableSeries<String>(new Series<MyRow, String>(
|
||||
final series = MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
colorFn: (_, __) => color,
|
||||
fillColorFn: (_, __) => color,
|
||||
@@ -595,26 +595,26 @@ void main() {
|
||||
return [series];
|
||||
}
|
||||
|
||||
final canvas = new MockCanvas();
|
||||
final canvas = MockCanvas();
|
||||
|
||||
final myDataWithNull = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', null),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', null),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
final seriesListWithNull = _createSeriesList(myDataWithNull);
|
||||
|
||||
final myDataWithMeasures = [
|
||||
new MyRow('MyCampaign1', 5),
|
||||
new MyRow('MyCampaign2', 0),
|
||||
new MyRow('MyCampaign3', 100),
|
||||
new MyRow('MyOtherCampaign', 75),
|
||||
MyRow('MyCampaign1', 5),
|
||||
MyRow('MyCampaign2', 0),
|
||||
MyRow('MyCampaign3', 100),
|
||||
MyRow('MyOtherCampaign', 75),
|
||||
];
|
||||
final seriesListWithMeasures = _createSeriesList(myDataWithMeasures);
|
||||
|
||||
renderer = makeRenderer(
|
||||
config: new BarTargetLineRendererConfig(
|
||||
config: BarTargetLineRendererConfig(
|
||||
groupingType: BarGroupingType.grouped));
|
||||
|
||||
// Verify that only 3 lines are drawn for an initial draw with null data.
|
||||
|
||||
@@ -61,40 +61,40 @@ class MockDateTimeAxis extends Mock implements Axis<DateTime> {}
|
||||
class MockCanvas extends Mock implements ChartCanvas {}
|
||||
|
||||
void main() {
|
||||
final date0 = new DateTime(2018, 2, 1);
|
||||
final date1 = new DateTime(2018, 2, 7);
|
||||
final dateOutsideViewport = new DateTime(2018, 1, 1);
|
||||
final date0 = DateTime(2018, 2, 1);
|
||||
final date1 = DateTime(2018, 2, 7);
|
||||
final dateOutsideViewport = DateTime(2018, 1, 1);
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Convenience methods for creating mocks.
|
||||
/////////////////////////////////////////
|
||||
_configureBaseRenderer(BaseBarRenderer renderer, bool vertical) {
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
final verticalChart = new MockChart();
|
||||
final verticalChart = MockChart();
|
||||
when(verticalChart.vertical).thenReturn(vertical);
|
||||
when(verticalChart.context).thenReturn(context);
|
||||
renderer.onAttach(verticalChart);
|
||||
|
||||
final layoutBounds = vertical
|
||||
? new Rectangle<int>(70, 20, 230, 100)
|
||||
: new Rectangle<int>(70, 20, 100, 230);
|
||||
? Rectangle<int>(70, 20, 230, 100)
|
||||
: Rectangle<int>(70, 20, 100, 230);
|
||||
renderer.layout(layoutBounds, layoutBounds);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
BaseBarRenderer _makeBarRenderer({bool vertical, BarGroupingType groupType}) {
|
||||
final renderer =
|
||||
new BarRenderer(config: new BarRendererConfig(groupingType: groupType));
|
||||
BarRenderer(config: BarRendererConfig(groupingType: groupType));
|
||||
_configureBaseRenderer(renderer, vertical);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
BaseBarRenderer _makeBarTargetRenderer(
|
||||
{bool vertical, BarGroupingType groupType}) {
|
||||
final renderer = new BarTargetLineRenderer(
|
||||
config: new BarTargetLineRendererConfig(groupingType: groupType));
|
||||
final renderer = BarTargetLineRenderer(
|
||||
config: BarTargetLineRendererConfig(groupingType: groupType));
|
||||
_configureBaseRenderer(renderer, vertical);
|
||||
return renderer;
|
||||
}
|
||||
@@ -102,11 +102,11 @@ void main() {
|
||||
MutableSeries _makeSeries(
|
||||
{String id, String seriesCategory, bool vertical = true}) {
|
||||
final data = <MyRow>[
|
||||
new MyRow('camp0', 10),
|
||||
new MyRow('camp1', 10),
|
||||
MyRow('camp0', 10),
|
||||
MyRow('camp1', 10),
|
||||
];
|
||||
|
||||
final series = new MutableSeries<String>(new Series(
|
||||
final series = MutableSeries<String>(Series(
|
||||
id: id,
|
||||
data: data,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
@@ -115,10 +115,10 @@ void main() {
|
||||
));
|
||||
|
||||
series.measureOffsetFn = (_) => 0.0;
|
||||
series.colorFn = (_) => new Color.fromHex(code: '#000000');
|
||||
series.colorFn = (_) => Color.fromHex(code: '#000000');
|
||||
|
||||
// Mock the Domain axis results.
|
||||
final domainAxis = new MockOrdinalAxis();
|
||||
final domainAxis = MockOrdinalAxis();
|
||||
when(domainAxis.rangeBand).thenReturn(100.0);
|
||||
final domainOffset = vertical ? 70.0 : 20.0;
|
||||
when(domainAxis.getLocation('camp0'))
|
||||
@@ -140,7 +140,7 @@ void main() {
|
||||
series.setAttr(domainAxisKey, domainAxis);
|
||||
|
||||
// Mock the Measure axis results.
|
||||
final measureAxis = new MockNumericAxis();
|
||||
final measureAxis = MockNumericAxis();
|
||||
if (vertical) {
|
||||
when(measureAxis.getLocation(0.0)).thenReturn(20.0 + 100.0);
|
||||
when(measureAxis.getLocation(10.0)).thenReturn(20.0 + 100.0 - 10.0);
|
||||
@@ -158,11 +158,11 @@ void main() {
|
||||
MutableSeries _makeDateTimeSeries(
|
||||
{String id, String seriesCategory, bool vertical = true}) {
|
||||
final data = <MyDateTimeRow>[
|
||||
new MyDateTimeRow(date0, 10),
|
||||
new MyDateTimeRow(date1, 10),
|
||||
MyDateTimeRow(date0, 10),
|
||||
MyDateTimeRow(date1, 10),
|
||||
];
|
||||
|
||||
final series = new MutableSeries<DateTime>(new Series(
|
||||
final series = MutableSeries<DateTime>(Series(
|
||||
id: id,
|
||||
data: data,
|
||||
domainFn: (dynamic row, _) => row.time,
|
||||
@@ -171,10 +171,10 @@ void main() {
|
||||
));
|
||||
|
||||
series.measureOffsetFn = (_) => 0.0;
|
||||
series.colorFn = (_) => new Color.fromHex(code: '#000000');
|
||||
series.colorFn = (_) => Color.fromHex(code: '#000000');
|
||||
|
||||
// Mock the Domain axis results.
|
||||
final domainAxis = new MockDateTimeAxis();
|
||||
final domainAxis = MockDateTimeAxis();
|
||||
when(domainAxis.rangeBand).thenReturn(100.0);
|
||||
final domainOffset = vertical ? 70.0 : 20.0;
|
||||
when(domainAxis.getLocation(date0)).thenReturn(domainOffset + 10.0 + 50.0);
|
||||
@@ -185,7 +185,7 @@ void main() {
|
||||
series.setAttr(domainAxisKey, domainAxis);
|
||||
|
||||
// Mock the Measure axis results.
|
||||
final measureAxis = new MockNumericAxis();
|
||||
final measureAxis = MockNumericAxis();
|
||||
if (vertical) {
|
||||
when(measureAxis.getLocation(0.0)).thenReturn(20.0 + 100.0);
|
||||
when(measureAxis.getLocation(10.0)).thenReturn(20.0 + 100.0 - 10.0);
|
||||
@@ -221,11 +221,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -251,11 +251,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -274,11 +274,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -304,11 +304,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -329,11 +329,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -358,11 +358,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -395,11 +395,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -435,11 +435,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -484,13 +484,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 13.0, 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
Point<double>(70.0 + 10.0 + 13.0, 20.0), selectNearestByDomain, null);
|
||||
|
||||
// Verify
|
||||
expect(details.length, equals(1));
|
||||
@@ -513,11 +511,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 50.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 50.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -544,19 +542,17 @@ void main() {
|
||||
final renderer =
|
||||
_makeBarRenderer(vertical: true, groupType: BarGroupingType.grouped);
|
||||
final seriesList = <MutableSeries>[
|
||||
_makeSeries(id: 'foo')..data.add(new MyRow('outsideViewport', 20))
|
||||
_makeSeries(id: 'foo')..data.add(MyRow('outsideViewport', 20))
|
||||
];
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
// Note: point is in the axis, over a bar outside of the viewport.
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(65.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
Point<double>(65.0, 20.0 + 100.0 - 5.0), selectNearestByDomain, null);
|
||||
|
||||
// Verify
|
||||
expect(details.length, equals(0));
|
||||
@@ -577,11 +573,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 13.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 13.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -606,11 +602,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -643,11 +639,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -682,11 +678,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -732,11 +728,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 100.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 100.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -761,11 +757,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 50.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 50.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -800,13 +796,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 13.0, 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
Point<double>(70.0 + 10.0 + 13.0, 20.0), selectNearestByDomain, null);
|
||||
|
||||
// Verify
|
||||
expect(details.length, equals(1));
|
||||
@@ -829,11 +823,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -866,11 +860,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -906,11 +900,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -958,11 +952,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 50.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 50.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -989,19 +983,17 @@ void main() {
|
||||
final renderer = _makeBarTargetRenderer(
|
||||
vertical: true, groupType: BarGroupingType.grouped);
|
||||
final seriesList = <MutableSeries>[
|
||||
_makeSeries(id: 'foo')..data.add(new MyRow('outsideViewport', 20))
|
||||
_makeSeries(id: 'foo')..data.add(MyRow('outsideViewport', 20))
|
||||
];
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
// Note: point is in the axis, over a bar outside of the viewport.
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(65.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
Point<double>(65.0, 20.0 + 100.0 - 5.0), selectNearestByDomain, null);
|
||||
|
||||
// Verify
|
||||
expect(details.length, equals(0));
|
||||
@@ -1022,11 +1014,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 100.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 100.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1051,11 +1043,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1088,11 +1080,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1127,11 +1119,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 20.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1178,11 +1170,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 5.0, 20.0 + 10.0 + 50.0),
|
||||
Point<double>(70.0 + 5.0, 20.0 + 10.0 + 50.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1217,11 +1209,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1246,11 +1238,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1283,11 +1275,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 13.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1323,11 +1315,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 20.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1375,11 +1367,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0 + 50.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0 + 50.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -1407,19 +1399,17 @@ void main() {
|
||||
vertical: true, groupType: BarGroupingType.grouped);
|
||||
final seriesList = <MutableSeries>[
|
||||
_makeDateTimeSeries(id: 'foo')
|
||||
..data.add(new MyDateTimeRow(dateOutsideViewport, 20))
|
||||
..data.add(MyDateTimeRow(dateOutsideViewport, 20))
|
||||
];
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
// Note: point is in the axis, over a bar outside of the viewport.
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(65.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
Point<double>(65.0, 20.0 + 100.0 - 5.0), selectNearestByDomain, null);
|
||||
|
||||
// Verify
|
||||
expect(details.length, equals(0));
|
||||
|
||||
@@ -46,7 +46,7 @@ void main() {
|
||||
var tester = AxisTester(axis);
|
||||
axis.tickDrawStrategy = MockTickDrawStrategy();
|
||||
axis.graphicsFactory = MockGraphicsFactory();
|
||||
tester.scale.range = new ScaleOutputExtent(0, 300);
|
||||
tester.scale.range = ScaleOutputExtent(0, 300);
|
||||
|
||||
axis.updateTicks();
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ class FakeTextElement implements TextElement {
|
||||
|
||||
/// Helper to create a tick for testing.
|
||||
Tick<String> _createTestTick(String value, double locationPx) {
|
||||
return new Tick(
|
||||
return Tick(
|
||||
value: value,
|
||||
textElement: new FakeTextElement(value),
|
||||
textElement: FakeTextElement(value),
|
||||
locationPx: locationPx);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ void _verify(Tick<String> tick, {double location, double opacity}) {
|
||||
void main() {
|
||||
// Tick first render.
|
||||
test('tick created for the first time', () {
|
||||
final tick = new AxisTicks(_createTestTick('a', 100.0));
|
||||
final tick = AxisTicks(_createTestTick('a', 100.0));
|
||||
|
||||
// Animate in the tick, there was no previous position to animated in from
|
||||
// so the tick appears in the target immediately.
|
||||
@@ -69,8 +69,7 @@ void main() {
|
||||
|
||||
// Tick that is animated in.
|
||||
test('tick created with a previous location', () {
|
||||
final tick = new AxisTicks(_createTestTick('a', 200.0))
|
||||
..animateInFrom(100.0);
|
||||
final tick = AxisTicks(_createTestTick('a', 200.0))..animateInFrom(100.0);
|
||||
|
||||
tick.setCurrentTick(0.0);
|
||||
_verify(tick, location: 100.0, opacity: 0.0);
|
||||
@@ -87,7 +86,7 @@ void main() {
|
||||
|
||||
// Tick that is being animated out.
|
||||
test('tick is animated in and then out', () {
|
||||
final tick = new AxisTicks(_createTestTick('a', 100.0));
|
||||
final tick = AxisTicks(_createTestTick('a', 100.0));
|
||||
|
||||
// Animate in the tick, there was no previous position to animated in from
|
||||
// so the tick appears in the target immediately.
|
||||
@@ -113,7 +112,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('tick target change after reaching target', () {
|
||||
final tick = new AxisTicks(_createTestTick('a', 100.0));
|
||||
final tick = AxisTicks(_createTestTick('a', 100.0));
|
||||
|
||||
// Animate in the tick.
|
||||
tick.setCurrentTick(1.0);
|
||||
@@ -137,7 +136,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('tick target change before reaching initial target', () {
|
||||
final tick = new AxisTicks(_createTestTick('a', 400.0))..animateInFrom(0.0);
|
||||
final tick = AxisTicks(_createTestTick('a', 400.0))..animateInFrom(0.0);
|
||||
|
||||
// Animate in the tick.
|
||||
tick.setCurrentTick(0.25);
|
||||
@@ -161,7 +160,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('tick target animate out before reaching initial target', () {
|
||||
final tick = new AxisTicks(_createTestTick('a', 400.0))..animateInFrom(0.0);
|
||||
final tick = AxisTicks(_createTestTick('a', 400.0))..animateInFrom(0.0);
|
||||
|
||||
// Animate in the tick.
|
||||
tick.setCurrentTick(0.25);
|
||||
|
||||
@@ -48,14 +48,14 @@ class FakeDrawStrategy extends BaseTickDrawStrategy<num> {
|
||||
|
||||
FakeDrawStrategy(
|
||||
this.collidesAfterTickCount, this.alternateRenderingAfterTickCount)
|
||||
: super(null, new FakeGraphicsFactory());
|
||||
: super(null, FakeGraphicsFactory());
|
||||
|
||||
@override
|
||||
CollisionReport collides(List<Tick<num>> ticks, _) {
|
||||
final ticksCollide = ticks.length >= collidesAfterTickCount;
|
||||
final alternateTicksUsed = ticks.length >= alternateRenderingAfterTickCount;
|
||||
|
||||
return new CollisionReport(
|
||||
return CollisionReport(
|
||||
ticksCollide: ticksCollide,
|
||||
ticks: ticks,
|
||||
alternateTicksUsed: alternateTicksUsed);
|
||||
@@ -73,13 +73,13 @@ class FakeDrawStrategy extends BaseTickDrawStrategy<num> {
|
||||
/// A fake [GraphicsFactory] that returns [MockTextStyle] and [MockTextElement].
|
||||
class FakeGraphicsFactory extends GraphicsFactory {
|
||||
@override
|
||||
TextStyle createTextPaint() => new MockTextStyle();
|
||||
TextStyle createTextPaint() => MockTextStyle();
|
||||
|
||||
@override
|
||||
TextElement createTextElement(String text) => new MockTextElement(text);
|
||||
TextElement createTextElement(String text) => MockTextElement(text);
|
||||
|
||||
@override
|
||||
LineStyle createLinePaint() => new MockLinePaint();
|
||||
LineStyle createLinePaint() => MockLinePaint();
|
||||
}
|
||||
|
||||
class MockTextStyle extends Mock implements TextStyle {}
|
||||
@@ -113,11 +113,11 @@ void main() {
|
||||
ChartContext context;
|
||||
|
||||
setUp(() {
|
||||
graphicsFactory = new FakeGraphicsFactory();
|
||||
scale = new MockNumericScale();
|
||||
tickProvider = new BucketingNumericTickProvider();
|
||||
formatter = new NumericTickFormatter();
|
||||
context = new MockChartContext();
|
||||
graphicsFactory = FakeGraphicsFactory();
|
||||
scale = MockNumericScale();
|
||||
tickProvider = BucketingNumericTickProvider();
|
||||
formatter = NumericTickFormatter();
|
||||
context = MockChartContext();
|
||||
});
|
||||
|
||||
group('threshold', () {
|
||||
@@ -128,8 +128,8 @@ void main() {
|
||||
..showBucket = true
|
||||
..setFixedTickCount(21)
|
||||
..allowedSteps = [1.0, 2.5, 5.0];
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(0.1, 0.7));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(0.1, 0.7));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
when(scale[0.1]).thenReturn(90.0);
|
||||
when(scale[0]).thenReturn(100.0);
|
||||
@@ -163,17 +163,16 @@ void main() {
|
||||
// Verify that the rest of the ticks are all above the threshold in value
|
||||
// and have normal labels.
|
||||
var aboveThresholdTicks = ticks.sublist(2);
|
||||
aboveThresholdTicks.retainWhere((Tick tick) => tick.value > 0.1);
|
||||
aboveThresholdTicks.retainWhere((tick) => tick.value > 0.1);
|
||||
expect(aboveThresholdTicks, hasLength(18));
|
||||
|
||||
aboveThresholdTicks = ticks.sublist(2);
|
||||
aboveThresholdTicks.retainWhere((Tick tick) =>
|
||||
aboveThresholdTicks.retainWhere((tick) =>
|
||||
tick.textElement.text != '' && !tick.textElement.text.contains('<'));
|
||||
expect(aboveThresholdTicks, hasLength(18));
|
||||
|
||||
aboveThresholdTicks = ticks.sublist(2);
|
||||
aboveThresholdTicks
|
||||
.retainWhere((Tick tick) => tick.labelOffsetPx == null);
|
||||
aboveThresholdTicks.retainWhere((tick) => tick.labelOffsetPx == null);
|
||||
expect(aboveThresholdTicks, hasLength(18));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ class FakeTextElement implements TextElement {
|
||||
this.textDirection,
|
||||
double horizontalSliceWidth,
|
||||
double verticalSliceWidth,
|
||||
) : measurement = new TextMeasurement(
|
||||
) : measurement = TextMeasurement(
|
||||
horizontalSliceWidth: horizontalSliceWidth,
|
||||
verticalSliceWidth: verticalSliceWidth);
|
||||
}
|
||||
@@ -91,10 +91,10 @@ Tick<String> createTick(String value, double locationPx,
|
||||
{double horizontalWidth,
|
||||
double verticalWidth,
|
||||
TextDirection textDirection}) {
|
||||
return new Tick<String>(
|
||||
return Tick<String>(
|
||||
value: value,
|
||||
locationPx: locationPx,
|
||||
textElement: new FakeTextElement(
|
||||
textElement: FakeTextElement(
|
||||
value, textDirection, horizontalWidth, verticalWidth));
|
||||
}
|
||||
|
||||
@@ -103,18 +103,18 @@ void main() {
|
||||
ChartContext chartContext;
|
||||
|
||||
setUpAll(() {
|
||||
graphicsFactory = new MockGraphicsFactory();
|
||||
when(graphicsFactory.createLinePaint()).thenReturn(new MockLineStyle());
|
||||
when(graphicsFactory.createTextPaint()).thenReturn(new MockTextStyle());
|
||||
graphicsFactory = MockGraphicsFactory();
|
||||
when(graphicsFactory.createLinePaint()).thenReturn(MockLineStyle());
|
||||
when(graphicsFactory.createTextPaint()).thenReturn(MockTextStyle());
|
||||
|
||||
chartContext = new MockContext();
|
||||
chartContext = MockContext();
|
||||
when(chartContext.chartContainerIsRtl).thenReturn(false);
|
||||
when(chartContext.isRtl).thenReturn(false);
|
||||
});
|
||||
|
||||
group('collision detection - vertically drawn axis', () {
|
||||
test('ticks do not collide', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 2);
|
||||
|
||||
@@ -130,7 +130,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide because it does not have minimum padding', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 2);
|
||||
|
||||
@@ -146,7 +146,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('first tick causes collision', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0);
|
||||
|
||||
@@ -162,7 +162,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('last tick causes collision', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0);
|
||||
|
||||
@@ -178,7 +178,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks do not collide for inside tick label anchor', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 2,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -195,7 +195,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide for inside anchor - first tick too large', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 2,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -212,7 +212,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide for inside anchor - center tick too large', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 2,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -229,7 +229,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide for inside anchor - last tick too large', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 2,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -248,7 +248,7 @@ void main() {
|
||||
|
||||
group('collision detection - horizontally drawn axis', () {
|
||||
test('ticks do not collide for TickLabelAnchor.before', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 2,
|
||||
labelAnchor: TickLabelAnchor.before);
|
||||
@@ -265,7 +265,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks do not collide for TickLabelAnchor.inside', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -288,7 +288,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide - first tick too large', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -305,7 +305,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide - middle tick too large', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -322,7 +322,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide - last tick too large', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -341,7 +341,7 @@ void main() {
|
||||
|
||||
group('collision detection - unsorted ticks', () {
|
||||
test('ticks do not collide', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -358,7 +358,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('ticks collide - tick B is too large', () {
|
||||
final drawStrategy = new BaseTickDrawStrategyImpl(
|
||||
final drawStrategy = BaseTickDrawStrategyImpl(
|
||||
chartContext, graphicsFactory,
|
||||
minimumPaddingBetweenLabelsPx: 0,
|
||||
labelAnchor: TickLabelAnchor.inside);
|
||||
@@ -378,7 +378,7 @@ void main() {
|
||||
group('collision detection - corner cases', () {
|
||||
test('null ticks do not collide', () {
|
||||
final drawStrategy =
|
||||
new BaseTickDrawStrategyImpl(chartContext, graphicsFactory);
|
||||
BaseTickDrawStrategyImpl(chartContext, graphicsFactory);
|
||||
|
||||
final report = drawStrategy.collides(null, AxisOrientation.left);
|
||||
|
||||
@@ -387,7 +387,7 @@ void main() {
|
||||
|
||||
test('empty tick list do not collide', () {
|
||||
final drawStrategy =
|
||||
new BaseTickDrawStrategyImpl(chartContext, graphicsFactory);
|
||||
BaseTickDrawStrategyImpl(chartContext, graphicsFactory);
|
||||
|
||||
final report = drawStrategy.collides([], AxisOrientation.left);
|
||||
|
||||
@@ -396,7 +396,7 @@ void main() {
|
||||
|
||||
test('single tick does not collide', () {
|
||||
final drawStrategy =
|
||||
new BaseTickDrawStrategyImpl(chartContext, graphicsFactory);
|
||||
BaseTickDrawStrategyImpl(chartContext, graphicsFactory);
|
||||
|
||||
final report = drawStrategy.collides(
|
||||
[createTick('A', 10.0, horizontalWidth: 10.0)],
|
||||
|
||||
@@ -57,14 +57,14 @@ class FakeDrawStrategy<D> extends BaseTickDrawStrategy<D> {
|
||||
|
||||
FakeDrawStrategy(
|
||||
this.collidesAfterTickCount, this.alternateRenderingAfterTickCount)
|
||||
: super(null, new FakeGraphicsFactory());
|
||||
: super(null, FakeGraphicsFactory());
|
||||
|
||||
@override
|
||||
CollisionReport collides(List<Tick<D>> ticks, _) {
|
||||
final ticksCollide = ticks.length >= collidesAfterTickCount;
|
||||
final alternateTicksUsed = ticks.length >= alternateRenderingAfterTickCount;
|
||||
|
||||
return new CollisionReport(
|
||||
return CollisionReport(
|
||||
ticksCollide: ticksCollide,
|
||||
ticks: ticks,
|
||||
alternateTicksUsed: alternateTicksUsed);
|
||||
@@ -82,13 +82,13 @@ class FakeDrawStrategy<D> extends BaseTickDrawStrategy<D> {
|
||||
/// A fake [GraphicsFactory] that returns [MockTextStyle] and [MockTextElement].
|
||||
class FakeGraphicsFactory extends GraphicsFactory {
|
||||
@override
|
||||
TextStyle createTextPaint() => new MockTextStyle();
|
||||
TextStyle createTextPaint() => MockTextStyle();
|
||||
|
||||
@override
|
||||
TextElement createTextElement(String text) => new MockTextElement();
|
||||
TextElement createTextElement(String text) => MockTextElement();
|
||||
|
||||
@override
|
||||
LineStyle createLinePaint() => new MockLinePaint();
|
||||
LineStyle createLinePaint() => MockLinePaint();
|
||||
}
|
||||
|
||||
class MockTextStyle extends Mock implements TextStyle {}
|
||||
@@ -100,24 +100,24 @@ class MockLinePaint extends Mock implements LineStyle {}
|
||||
class MockChartContext extends Mock implements ChartContext {}
|
||||
|
||||
void main() {
|
||||
const dateTimeFactory = const SimpleDateTimeFactory();
|
||||
const dateTimeFactory = SimpleDateTimeFactory();
|
||||
FakeGraphicsFactory graphicsFactory;
|
||||
EndPointsTickProvider tickProvider;
|
||||
ChartContext context;
|
||||
|
||||
setUp(() {
|
||||
graphicsFactory = new FakeGraphicsFactory();
|
||||
context = new MockChartContext();
|
||||
graphicsFactory = FakeGraphicsFactory();
|
||||
context = MockChartContext();
|
||||
});
|
||||
|
||||
test('dateTime_choosesEndPointTicks', () {
|
||||
final formatter = new DateTimeTickFormatter(dateTimeFactory);
|
||||
final scale = new MockDateTimeScale();
|
||||
tickProvider = new EndPointsTickProvider<DateTime>();
|
||||
final formatter = DateTimeTickFormatter(dateTimeFactory);
|
||||
final scale = MockDateTimeScale();
|
||||
tickProvider = EndPointsTickProvider<DateTime>();
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy<DateTime>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new DateTimeExtents(
|
||||
start: new DateTime(2018, 8, 1), end: new DateTime(2018, 8, 11)));
|
||||
final drawStrategy = FakeDrawStrategy<DateTime>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(DateTimeExtents(
|
||||
start: DateTime(2018, 8, 1), end: DateTime(2018, 8, 11)));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
when(scale.domainStepSize).thenReturn(1000.0);
|
||||
|
||||
@@ -131,17 +131,17 @@ void main() {
|
||||
orientation: null);
|
||||
|
||||
expect(ticks, hasLength(2));
|
||||
expect(ticks[0].value, equals(new DateTime(2018, 8, 1)));
|
||||
expect(ticks[1].value, equals(new DateTime(2018, 8, 11)));
|
||||
expect(ticks[0].value, equals(DateTime(2018, 8, 1)));
|
||||
expect(ticks[1].value, equals(DateTime(2018, 8, 11)));
|
||||
});
|
||||
|
||||
test('numeric_choosesEndPointTicks', () {
|
||||
final formatter = new NumericTickFormatter();
|
||||
final scale = new MockNumericScale();
|
||||
tickProvider = new EndPointsTickProvider<num>();
|
||||
final formatter = NumericTickFormatter();
|
||||
final scale = MockNumericScale();
|
||||
tickProvider = EndPointsTickProvider<num>();
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy<num>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(10.0, 70.0));
|
||||
final drawStrategy = FakeDrawStrategy<num>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(10.0, 70.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
when(scale.domainStepSize).thenReturn(1000.0);
|
||||
|
||||
@@ -160,15 +160,15 @@ void main() {
|
||||
});
|
||||
|
||||
test('ordinal_choosesEndPointTicks', () {
|
||||
final formatter = new OrdinalTickFormatter();
|
||||
final scale = new SimpleOrdinalScale();
|
||||
final formatter = OrdinalTickFormatter();
|
||||
final scale = SimpleOrdinalScale();
|
||||
scale.addDomain('A');
|
||||
scale.addDomain('B');
|
||||
scale.addDomain('C');
|
||||
scale.addDomain('D');
|
||||
tickProvider = new EndPointsTickProvider<String>();
|
||||
tickProvider = EndPointsTickProvider<String>();
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy<String>(10, 10);
|
||||
final drawStrategy = FakeDrawStrategy<String>(10, 10);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
context: context,
|
||||
@@ -185,13 +185,13 @@ void main() {
|
||||
});
|
||||
|
||||
test('dateTime_emptySeriesChoosesNoTicks', () {
|
||||
final formatter = new DateTimeTickFormatter(dateTimeFactory);
|
||||
final scale = new MockDateTimeScale();
|
||||
tickProvider = new EndPointsTickProvider<DateTime>();
|
||||
final formatter = DateTimeTickFormatter(dateTimeFactory);
|
||||
final scale = MockDateTimeScale();
|
||||
tickProvider = EndPointsTickProvider<DateTime>();
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy<DateTime>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new DateTimeExtents(
|
||||
start: new DateTime(2018, 8, 1), end: new DateTime(2018, 8, 11)));
|
||||
final drawStrategy = FakeDrawStrategy<DateTime>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(DateTimeExtents(
|
||||
start: DateTime(2018, 8, 1), end: DateTime(2018, 8, 11)));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
// An un-configured axis has no domain step size, and its scale defaults to
|
||||
@@ -211,12 +211,12 @@ void main() {
|
||||
});
|
||||
|
||||
test('numeric_emptySeriesChoosesNoTicks', () {
|
||||
final formatter = new NumericTickFormatter();
|
||||
final scale = new MockNumericScale();
|
||||
tickProvider = new EndPointsTickProvider<num>();
|
||||
final formatter = NumericTickFormatter();
|
||||
final scale = MockNumericScale();
|
||||
tickProvider = EndPointsTickProvider<num>();
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy<num>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(10.0, 70.0));
|
||||
final drawStrategy = FakeDrawStrategy<num>(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(10.0, 70.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
// An un-configured axis has no domain step size, and its scale defaults to
|
||||
|
||||
@@ -26,12 +26,12 @@ const EPSILON = 0.001;
|
||||
void main() {
|
||||
group('Stacking bars', () {
|
||||
test('basic apply survives copy and reset', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
LinearScale scale = LinearScale();
|
||||
scale.addDomain(100.0);
|
||||
scale.addDomain(130.0);
|
||||
scale.addDomain(200.0);
|
||||
scale.addDomain(170.0);
|
||||
scale.range = new ScaleOutputExtent(2000, 1000);
|
||||
scale.range = ScaleOutputExtent(2000, 1000);
|
||||
|
||||
expect(scale.range.start, equals(2000));
|
||||
expect(scale.range.end, equals(1000));
|
||||
@@ -71,11 +71,11 @@ void main() {
|
||||
});
|
||||
|
||||
test('viewport assigned domain extent applies to scale', () {
|
||||
LinearScale scale = new LinearScale()..keepViewportWithinData = false;
|
||||
LinearScale scale = LinearScale()..keepViewportWithinData = false;
|
||||
scale.addDomain(50.0);
|
||||
scale.addDomain(70.0);
|
||||
scale.viewportDomain = new NumericExtents(100.0, 200.0);
|
||||
scale.range = new ScaleOutputExtent(0, 200);
|
||||
scale.viewportDomain = NumericExtents(100.0, 200.0);
|
||||
scale.range = ScaleOutputExtent(0, 200);
|
||||
|
||||
expect(scale[200.0], closeTo(200, EPSILON));
|
||||
expect(scale[100.0], closeTo(0, EPSILON));
|
||||
@@ -86,8 +86,8 @@ void main() {
|
||||
scale.resetViewportSettings();
|
||||
scale.addDomain(50.0);
|
||||
scale.addDomain(100.0);
|
||||
scale.viewportDomain = new NumericExtents(0.0, 100.0);
|
||||
scale.range = new ScaleOutputExtent(0, 200);
|
||||
scale.viewportDomain = NumericExtents(0.0, 100.0);
|
||||
scale.range = ScaleOutputExtent(0, 200);
|
||||
|
||||
expect(scale[0.0], closeTo(0, EPSILON));
|
||||
expect(scale[100.0], closeTo(200, EPSILON));
|
||||
@@ -96,12 +96,12 @@ void main() {
|
||||
});
|
||||
|
||||
test('comparing domain and range to viewport handles extent edges', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.range = new ScaleOutputExtent(1000, 1400);
|
||||
scale.domainOverride = new NumericExtents(100.0, 300.0);
|
||||
scale.viewportDomain = new NumericExtents(200.0, 300.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.range = ScaleOutputExtent(1000, 1400);
|
||||
scale.domainOverride = NumericExtents(100.0, 300.0);
|
||||
scale.viewportDomain = NumericExtents(200.0, 300.0);
|
||||
|
||||
expect(scale.viewportDomain, equals(new NumericExtents(200.0, 300.0)));
|
||||
expect(scale.viewportDomain, equals(NumericExtents(200.0, 300.0)));
|
||||
|
||||
expect(scale[210.0], closeTo(1040, EPSILON));
|
||||
expect(scale[400.0], closeTo(1800, EPSILON));
|
||||
@@ -120,10 +120,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('scale applies in reverse', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.range = new ScaleOutputExtent(1000, 1400);
|
||||
scale.domainOverride = new NumericExtents(100.0, 300.0);
|
||||
scale.viewportDomain = new NumericExtents(200.0, 300.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.range = ScaleOutputExtent(1000, 1400);
|
||||
scale.domainOverride = NumericExtents(100.0, 300.0);
|
||||
scale.viewportDomain = NumericExtents(200.0, 300.0);
|
||||
|
||||
expect(scale.reverse(1040.0), closeTo(210.0, EPSILON));
|
||||
expect(scale.reverse(1800.0), closeTo(400.0, EPSILON));
|
||||
@@ -131,10 +131,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('scale works with a range from larger to smaller', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.range = new ScaleOutputExtent(1400, 1000);
|
||||
scale.domainOverride = new NumericExtents(100.0, 300.0);
|
||||
scale.viewportDomain = new NumericExtents(200.0, 300.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.range = ScaleOutputExtent(1400, 1000);
|
||||
scale.domainOverride = NumericExtents(100.0, 300.0);
|
||||
scale.viewportDomain = NumericExtents(200.0, 300.0);
|
||||
|
||||
expect(scale[200.0], closeTo(1400.0, EPSILON));
|
||||
expect(scale[250.0], closeTo(1200.0, EPSILON));
|
||||
@@ -142,9 +142,9 @@ void main() {
|
||||
});
|
||||
|
||||
test('scaleFactor and translate applies to scale', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.range = new ScaleOutputExtent(1000, 1200);
|
||||
scale.domainOverride = new NumericExtents(100.0, 200.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.range = ScaleOutputExtent(1000, 1200);
|
||||
scale.domainOverride = NumericExtents(100.0, 200.0);
|
||||
scale.setViewportSettings(4.0, -50.0);
|
||||
|
||||
expect(scale[100.0], closeTo(950.0, EPSILON));
|
||||
@@ -167,8 +167,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('scale handles single point', () {
|
||||
LinearScale domainScale = new LinearScale();
|
||||
domainScale.range = new ScaleOutputExtent(1000, 1200);
|
||||
LinearScale domainScale = LinearScale();
|
||||
domainScale.range = ScaleOutputExtent(1000, 1200);
|
||||
domainScale.addDomain(50.0);
|
||||
|
||||
// A single point should render in the middle of the scale.
|
||||
@@ -176,125 +176,125 @@ void main() {
|
||||
});
|
||||
|
||||
test('testAllZeros', () {
|
||||
LinearScale measureScale = new LinearScale();
|
||||
measureScale.range = new ScaleOutputExtent(1000, 1200);
|
||||
LinearScale measureScale = LinearScale();
|
||||
measureScale.range = ScaleOutputExtent(1000, 1200);
|
||||
measureScale.addDomain(0.0);
|
||||
|
||||
expect(measureScale[0.0], closeTo(1100.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale calculates step size', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(3.0);
|
||||
scale.addDomain(11.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
|
||||
// 1 - 11 has 6 steps of size 2, 0 - 12
|
||||
expect(scale.rangeBand, closeTo(100.0 / 6.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale applies rangeBand to detected step size', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(0.5);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(0.5);
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(2.0);
|
||||
scale.addDomain(10.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
|
||||
// 100 range / 10 steps * 0.5percentStep = 5
|
||||
expect(scale.rangeBand, closeTo(5.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale stepSize calculation survives copy', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.stepSizeConfig = new StepSizeConfig.fixedDomain(1.0);
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.stepSizeConfig = StepSizeConfig.fixedDomain(1.0);
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(3.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
expect(scale.copy().rangeBand, closeTo(100.0 / 3.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale rangeBand calculation survives copy', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.rangeBandConfig = new RangeBandConfig.fixedPixel(123.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.rangeBandConfig = RangeBandConfig.fixedPixel(123.0);
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(3.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
|
||||
expect(scale.copy().rangeBand, closeTo(123, EPSILON));
|
||||
});
|
||||
|
||||
test('scale rangeBand works for single domain value', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
scale.addDomain(1.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
|
||||
expect(scale.rangeBand, closeTo(100, EPSILON));
|
||||
});
|
||||
|
||||
test('scale rangeBand works for multiple domains of the same value', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(1.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
|
||||
expect(scale.rangeBand, closeTo(100.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale rangeBand is zero when no domains are added', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
|
||||
expect(scale.rangeBand, closeTo(0.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale domain info reset on resetDomain', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
LinearScale scale = LinearScale();
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(3.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
scale.setViewportSettings(1000.0, 2000.0);
|
||||
|
||||
scale.resetDomain();
|
||||
scale.resetViewportSettings();
|
||||
expect(scale.viewportScalingFactor, closeTo(1.0, EPSILON));
|
||||
expect(scale.viewportTranslatePx, closeTo(0, EPSILON));
|
||||
expect(scale.range, equals(new ScaleOutputExtent(100, 200)));
|
||||
expect(scale.range, equals(ScaleOutputExtent(100, 200)));
|
||||
});
|
||||
|
||||
test('scale handles null domain values', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
LinearScale scale = LinearScale();
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(null);
|
||||
scale.addDomain(3.0);
|
||||
scale.addDomain(11.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
|
||||
expect(scale.rangeBand, closeTo(100.0 / 6.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale domainOverride survives copy', () {
|
||||
LinearScale scale = new LinearScale()..keepViewportWithinData = false;
|
||||
LinearScale scale = LinearScale()..keepViewportWithinData = false;
|
||||
scale.addDomain(1.0);
|
||||
scale.addDomain(3.0);
|
||||
scale.range = new ScaleOutputExtent(100, 200);
|
||||
scale.range = ScaleOutputExtent(100, 200);
|
||||
scale.setViewportSettings(2.0, 10.0);
|
||||
scale.domainOverride = new NumericExtents(0.0, 100.0);
|
||||
scale.domainOverride = NumericExtents(0.0, 100.0);
|
||||
|
||||
LinearScale other = scale.copy();
|
||||
|
||||
expect(other.domainOverride, equals(new NumericExtents(0.0, 100.0)));
|
||||
expect(other.domainOverride, equals(NumericExtents(0.0, 100.0)));
|
||||
expect(other[5.0], closeTo(120.0, EPSILON));
|
||||
});
|
||||
|
||||
test('scale calculates a scaleFactor given a domain window', () {
|
||||
LinearScale scale = new LinearScale();
|
||||
LinearScale scale = LinearScale();
|
||||
scale.addDomain(100.0);
|
||||
scale.addDomain(130.0);
|
||||
scale.addDomain(200.0);
|
||||
|
||||
@@ -49,14 +49,14 @@ class FakeDrawStrategy extends BaseTickDrawStrategy<num> {
|
||||
|
||||
FakeDrawStrategy(
|
||||
this.collidesAfterTickCount, this.alternateRenderingAfterTickCount)
|
||||
: super(null, new FakeGraphicsFactory());
|
||||
: super(null, FakeGraphicsFactory());
|
||||
|
||||
@override
|
||||
CollisionReport collides(List<Tick<num>> ticks, _) {
|
||||
final ticksCollide = ticks.length >= collidesAfterTickCount;
|
||||
final alternateTicksUsed = ticks.length >= alternateRenderingAfterTickCount;
|
||||
|
||||
return new CollisionReport(
|
||||
return CollisionReport(
|
||||
ticksCollide: ticksCollide,
|
||||
ticks: ticks,
|
||||
alternateTicksUsed: alternateTicksUsed);
|
||||
@@ -74,13 +74,13 @@ class FakeDrawStrategy extends BaseTickDrawStrategy<num> {
|
||||
/// A fake [GraphicsFactory] that returns [MockTextStyle] and [MockTextElement].
|
||||
class FakeGraphicsFactory extends GraphicsFactory {
|
||||
@override
|
||||
TextStyle createTextPaint() => new MockTextStyle();
|
||||
TextStyle createTextPaint() => MockTextStyle();
|
||||
|
||||
@override
|
||||
TextElement createTextElement(String text) => new MockTextElement();
|
||||
TextElement createTextElement(String text) => MockTextElement();
|
||||
|
||||
@override
|
||||
LineStyle createLinePaint() => new MockLinePaint();
|
||||
LineStyle createLinePaint() => MockLinePaint();
|
||||
}
|
||||
|
||||
class MockTextStyle extends Mock implements TextStyle {}
|
||||
@@ -110,11 +110,11 @@ void main() {
|
||||
ChartContext context;
|
||||
|
||||
setUp(() {
|
||||
graphicsFactory = new FakeGraphicsFactory();
|
||||
scale = new MockNumericScale();
|
||||
tickProvider = new NumericTickProvider();
|
||||
formatter = new NumericTickFormatter();
|
||||
context = new MockChartContext();
|
||||
graphicsFactory = FakeGraphicsFactory();
|
||||
scale = MockNumericScale();
|
||||
tickProvider = NumericTickProvider();
|
||||
formatter = NumericTickFormatter();
|
||||
context = MockChartContext();
|
||||
});
|
||||
|
||||
test('singleTickCount_choosesTicksWithSmallestStepCoveringDomain', () {
|
||||
@@ -123,8 +123,8 @@ void main() {
|
||||
..dataIsInWholeNumbers = false
|
||||
..setFixedTickCount(4)
|
||||
..allowedSteps = [1.0, 2.5, 5.0];
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(10.0, 70.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(10.0, 70.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -151,8 +151,8 @@ void main() {
|
||||
..dataIsInWholeNumbers = false
|
||||
..setTickCount(5, 3)
|
||||
..allowedSteps = [1.0, 2.5, 5.0];
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(10.0, 80.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(10.0, 80.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -178,8 +178,8 @@ void main() {
|
||||
..dataIsInWholeNumbers = false
|
||||
..setTickCount(5, 3)
|
||||
..allowedSteps = [1.0, 2.5, 6.0];
|
||||
final drawStrategy = new FakeDrawStrategy(10, 5);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(10.0, 80.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 5);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(10.0, 80.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -203,8 +203,8 @@ void main() {
|
||||
..dataIsInWholeNumbers = false
|
||||
..setTickCount(5, 3)
|
||||
..allowedSteps = [1.0, 2.5, 6.0];
|
||||
final drawStrategy = new FakeDrawStrategy(5, 5);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(10.0, 80.0));
|
||||
final drawStrategy = FakeDrawStrategy(5, 5);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(10.0, 80.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -228,8 +228,8 @@ void main() {
|
||||
..dataIsInWholeNumbers = false
|
||||
..setFixedTickCount(3)
|
||||
..allowedSteps = [1.0, 2.5, 5.0];
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(55.0, 135.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(55.0, 135.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -252,8 +252,8 @@ void main() {
|
||||
..dataIsInWholeNumbers = false
|
||||
..setFixedTickCount(3)
|
||||
..allowedSteps = [1.0, 2.5, 5.0];
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(-55.0, 135.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(-55.0, 135.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -271,8 +271,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('boundsCrossOrigin_returnsValidTickRange', () {
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(-55.0, 135.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(-55.0, 135.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -297,9 +297,9 @@ void main() {
|
||||
..dataIsInWholeNumbers = true
|
||||
..setFixedTickCount(3)
|
||||
..allowedSteps = [1.0, 2.5, 5.0];
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(0.25, 0.75));
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(0.25, 0.75));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -324,9 +324,9 @@ void main() {
|
||||
..allowedSteps = [5.0]
|
||||
..dataToAxisUnitConverter = const CelsiusToFahrenheitConverter();
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(0.0, 20.0));
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(0.0, 20.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -349,10 +349,9 @@ void main() {
|
||||
..dataIsInWholeNumbers = false
|
||||
..setFixedTickCount(5);
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
|
||||
when(scale.viewportDomain)
|
||||
.thenReturn(new NumericExtents(0.000001, 0.000002));
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(0.000001, 0.000002));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -378,10 +377,9 @@ void main() {
|
||||
..dataIsInWholeNumbers = true
|
||||
..setFixedTickCount(5);
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
|
||||
when(scale.viewportDomain)
|
||||
.thenReturn(new NumericExtents(0.000001, 0.000002));
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(0.000001, 0.000002));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -407,10 +405,10 @@ void main() {
|
||||
..dataIsInWholeNumbers = true
|
||||
..setFixedTickCount(5);
|
||||
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
|
||||
when(scale.viewportDomain)
|
||||
.thenReturn(new NumericExtents(101.000001, 101.000002));
|
||||
.thenReturn(NumericExtents(101.000001, 101.000002));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
@@ -431,15 +429,15 @@ void main() {
|
||||
});
|
||||
|
||||
test('handles tick hint for non zero ticks', () {
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(20.0, 35.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(20.0, 35.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
// Step Size: 3,
|
||||
// Previous start tick: 10
|
||||
// Previous window: 10 - 25
|
||||
// Previous ticks: 10, 13, 16, 19, 22, 25
|
||||
final tickHint = new TickHint(10, 25, tickCount: 6);
|
||||
final tickHint = TickHint(10, 25, tickCount: 6);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
context: context,
|
||||
@@ -464,15 +462,15 @@ void main() {
|
||||
});
|
||||
|
||||
test('handles tick hint for negative starting ticks', () {
|
||||
final drawStrategy = new FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(new NumericExtents(-35.0, -20.0));
|
||||
final drawStrategy = FakeDrawStrategy(10, 10);
|
||||
when(scale.viewportDomain).thenReturn(NumericExtents(-35.0, -20.0));
|
||||
when(scale.rangeWidth).thenReturn(1000);
|
||||
|
||||
// Step Size: 3,
|
||||
// Previous start tick: -25
|
||||
// Previous window: -25 to -10
|
||||
// Previous ticks: -25, -22, -19, -16, -13, -10
|
||||
final tickHint = new TickHint(-25, -10, tickCount: 6);
|
||||
final tickHint = TickHint(-25, -10, tickCount: 6);
|
||||
|
||||
final ticks = tickProvider.getTicks(
|
||||
context: context,
|
||||
|
||||
@@ -24,13 +24,13 @@ void main() {
|
||||
SimpleOrdinalScale scale;
|
||||
|
||||
setUp(() {
|
||||
scale = new SimpleOrdinalScale();
|
||||
scale = SimpleOrdinalScale();
|
||||
scale.addDomain('a');
|
||||
scale.addDomain('b');
|
||||
scale.addDomain('c');
|
||||
scale.addDomain('d');
|
||||
|
||||
scale.range = new ScaleOutputExtent(2000, 1000);
|
||||
scale.range = ScaleOutputExtent(2000, 1000);
|
||||
});
|
||||
|
||||
group('conversion', () {
|
||||
@@ -81,7 +81,7 @@ void main() {
|
||||
|
||||
group('set RangeBandConfig', () {
|
||||
test('fixed pixel range band changes range band', () {
|
||||
scale.rangeBandConfig = new RangeBandConfig.fixedPixel(123.0);
|
||||
scale.rangeBandConfig = RangeBandConfig.fixedPixel(123.0);
|
||||
|
||||
expect(scale.rangeBand, closeTo(123.0, EPSILON));
|
||||
|
||||
@@ -91,25 +91,24 @@ void main() {
|
||||
});
|
||||
|
||||
test('percent range band changes range band', () {
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(0.5);
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(0.5);
|
||||
// 125 = 0.5f * 1000pixels / 4domains
|
||||
expect(scale.rangeBand, closeTo(125.0, EPSILON));
|
||||
});
|
||||
|
||||
test('space from step changes range band', () {
|
||||
scale.rangeBandConfig =
|
||||
new RangeBandConfig.fixedPixelSpaceBetweenStep(50.0);
|
||||
scale.rangeBandConfig = RangeBandConfig.fixedPixelSpaceBetweenStep(50.0);
|
||||
// 200 = 1000pixels / 4domains) - 50
|
||||
expect(scale.rangeBand, closeTo(200.0, EPSILON));
|
||||
});
|
||||
|
||||
test('fixed domain throws argument exception', () {
|
||||
expect(() => scale.rangeBandConfig = new RangeBandConfig.fixedDomain(5.0),
|
||||
expect(() => scale.rangeBandConfig = RangeBandConfig.fixedDomain(5.0),
|
||||
throwsArgumentError);
|
||||
});
|
||||
|
||||
test('type of none throws argument exception', () {
|
||||
expect(() => scale.rangeBandConfig = new RangeBandConfig.none(),
|
||||
expect(() => scale.rangeBandConfig = RangeBandConfig.none(),
|
||||
throwsArgumentError);
|
||||
});
|
||||
|
||||
@@ -124,16 +123,16 @@ void main() {
|
||||
});
|
||||
|
||||
test('to auto does not throw', () {
|
||||
scale.stepSizeConfig = new StepSizeConfig.auto();
|
||||
scale.stepSizeConfig = StepSizeConfig.auto();
|
||||
});
|
||||
|
||||
test('to fixed domain throw arugment exception', () {
|
||||
expect(() => scale.stepSizeConfig = new StepSizeConfig.fixedDomain(1.0),
|
||||
expect(() => scale.stepSizeConfig = StepSizeConfig.fixedDomain(1.0),
|
||||
throwsArgumentError);
|
||||
});
|
||||
|
||||
test('to fixed pixel throw arugment exception', () {
|
||||
expect(() => scale.stepSizeConfig = new StepSizeConfig.fixedPixels(1.0),
|
||||
expect(() => scale.stepSizeConfig = StepSizeConfig.fixedPixels(1.0),
|
||||
throwsArgumentError);
|
||||
});
|
||||
});
|
||||
@@ -165,15 +164,15 @@ void main() {
|
||||
|
||||
test('rangeband is scaled', () {
|
||||
scale.setViewportSettings(2.0, -700.0);
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
|
||||
expect(scale.rangeBand, closeTo(500.0, EPSILON));
|
||||
});
|
||||
|
||||
test('translate to pixels is scaled', () {
|
||||
scale.setViewportSettings(2.0, -700.0);
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
scale.range = new ScaleOutputExtent(1000, 2000);
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
scale.range = ScaleOutputExtent(1000, 2000);
|
||||
|
||||
final scaledStepWidth = 500.0;
|
||||
final scaledInitialShift = 250.0;
|
||||
@@ -186,8 +185,8 @@ void main() {
|
||||
|
||||
test('only b and c should be within the viewport', () {
|
||||
scale.setViewportSettings(2.0, -700.0);
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(1.0);
|
||||
scale.range = new ScaleOutputExtent(1000, 2000);
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(1.0);
|
||||
scale.range = ScaleOutputExtent(1000, 2000);
|
||||
|
||||
expect(scale.compareDomainValueToViewport('a'), equals(-1));
|
||||
expect(scale.compareDomainValueToViewport('c'), equals(0));
|
||||
@@ -198,8 +197,8 @@ void main() {
|
||||
|
||||
group('viewport', () {
|
||||
test('set adjust scale to show viewport', () {
|
||||
scale.range = new ScaleOutputExtent(1000, 2000);
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(0.5);
|
||||
scale.range = ScaleOutputExtent(1000, 2000);
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(0.5);
|
||||
scale.setViewport(2, 'b');
|
||||
|
||||
expect(scale['a'], closeTo(750, EPSILON));
|
||||
@@ -217,8 +216,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('set starting value if starting domain is not in domain list', () {
|
||||
scale.range = new ScaleOutputExtent(1000, 2000);
|
||||
scale.rangeBandConfig = new RangeBandConfig.percentOfStep(0.5);
|
||||
scale.range = ScaleOutputExtent(1000, 2000);
|
||||
scale.rangeBandConfig = RangeBandConfig.percentOfStep(0.5);
|
||||
scale.setViewport(2, 'f');
|
||||
|
||||
expect(scale['a'], closeTo(1250, EPSILON));
|
||||
@@ -228,7 +227,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('get size returns number of full steps that fit scale range', () {
|
||||
scale.range = new ScaleOutputExtent(1000, 2000);
|
||||
scale.range = ScaleOutputExtent(1000, 2000);
|
||||
|
||||
scale.setViewportSettings(2.0, 0.0);
|
||||
expect(scale.viewportDataSize, equals(2));
|
||||
@@ -238,7 +237,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('get starting viewport gets first fully visible domain', () {
|
||||
scale.range = new ScaleOutputExtent(1000, 2000);
|
||||
scale.range = ScaleOutputExtent(1000, 2000);
|
||||
|
||||
scale.setViewportSettings(2.0, -500.0);
|
||||
expect(scale.viewportStartingDomain, equals('b'));
|
||||
|
||||
@@ -52,19 +52,19 @@ void main() {
|
||||
LinearScale scale;
|
||||
|
||||
setUp(() {
|
||||
context = new MockChartContext();
|
||||
graphicsFactory = new MockGraphicsFactory();
|
||||
formatter = new MockNumericTickFormatter();
|
||||
drawStrategy = new MockDrawStrategy();
|
||||
scale = new LinearScale()..range = new ScaleOutputExtent(0, 300);
|
||||
context = MockChartContext();
|
||||
graphicsFactory = MockGraphicsFactory();
|
||||
formatter = MockNumericTickFormatter();
|
||||
drawStrategy = MockDrawStrategy();
|
||||
scale = LinearScale()..range = ScaleOutputExtent(0, 300);
|
||||
});
|
||||
|
||||
group('scale is extended with static tick values', () {
|
||||
test('values extend existing domain values', () {
|
||||
final tickProvider = new StaticTickProvider<num>([
|
||||
new TickSpec<num>(50, label: '50'),
|
||||
new TickSpec<num>(75, label: '75'),
|
||||
new TickSpec<num>(100, label: '100'),
|
||||
final tickProvider = StaticTickProvider<num>([
|
||||
TickSpec<num>(50, label: '50'),
|
||||
TickSpec<num>(75, label: '75'),
|
||||
TickSpec<num>(100, label: '100'),
|
||||
]);
|
||||
|
||||
scale.addDomain(60);
|
||||
@@ -87,10 +87,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('values within data extent', () {
|
||||
final tickProvider = new StaticTickProvider<num>([
|
||||
new TickSpec<num>(50, label: '50'),
|
||||
new TickSpec<num>(75, label: '75'),
|
||||
new TickSpec<num>(100, label: '100'),
|
||||
final tickProvider = StaticTickProvider<num>([
|
||||
TickSpec<num>(50, label: '50'),
|
||||
TickSpec<num>(75, label: '75'),
|
||||
TickSpec<num>(100, label: '100'),
|
||||
]);
|
||||
|
||||
scale.addDomain(0);
|
||||
@@ -115,13 +115,13 @@ void main() {
|
||||
|
||||
group('formatter', () {
|
||||
test('is not called when all ticks have labels', () {
|
||||
final tickProvider = new StaticTickProvider<num>([
|
||||
new TickSpec<num>(50, label: '50'),
|
||||
new TickSpec<num>(75, label: '75'),
|
||||
new TickSpec<num>(100, label: '100'),
|
||||
final tickProvider = StaticTickProvider<num>([
|
||||
TickSpec<num>(50, label: '50'),
|
||||
TickSpec<num>(75, label: '75'),
|
||||
TickSpec<num>(100, label: '100'),
|
||||
]);
|
||||
|
||||
final fakeFormatter = new FakeNumericTickFormatter();
|
||||
final fakeFormatter = FakeNumericTickFormatter();
|
||||
|
||||
tickProvider.getTicks(
|
||||
context: context,
|
||||
@@ -136,13 +136,13 @@ void main() {
|
||||
});
|
||||
|
||||
test('is called when one ticks does not have label', () {
|
||||
final tickProvider = new StaticTickProvider<num>([
|
||||
new TickSpec<num>(50, label: '50'),
|
||||
new TickSpec<num>(75),
|
||||
new TickSpec<num>(100, label: '100'),
|
||||
final tickProvider = StaticTickProvider<num>([
|
||||
TickSpec<num>(50, label: '50'),
|
||||
TickSpec<num>(75),
|
||||
TickSpec<num>(100, label: '100'),
|
||||
]);
|
||||
|
||||
final fakeFormatter = new FakeNumericTickFormatter();
|
||||
final fakeFormatter = FakeNumericTickFormatter();
|
||||
|
||||
tickProvider.getTicks(
|
||||
context: context,
|
||||
@@ -157,13 +157,13 @@ void main() {
|
||||
});
|
||||
|
||||
test('is called when all ticks do not have labels', () {
|
||||
final tickProvider = new StaticTickProvider<num>([
|
||||
new TickSpec<num>(50),
|
||||
new TickSpec<num>(75),
|
||||
new TickSpec<num>(100),
|
||||
final tickProvider = StaticTickProvider<num>([
|
||||
TickSpec<num>(50),
|
||||
TickSpec<num>(75),
|
||||
TickSpec<num>(100),
|
||||
]);
|
||||
|
||||
final fakeFormatter = new FakeNumericTickFormatter();
|
||||
final fakeFormatter = FakeNumericTickFormatter();
|
||||
|
||||
tickProvider.getTicks(
|
||||
context: context,
|
||||
|
||||
@@ -19,7 +19,8 @@ import 'package:test/test.dart';
|
||||
|
||||
const EPSILON = 0.001;
|
||||
|
||||
typedef bool IsTransitionFunction(DateTime tickValue, DateTime prevTickValue);
|
||||
typedef IsTransitionFunction = bool Function(
|
||||
DateTime tickValue, DateTime prevTickValue);
|
||||
|
||||
class FakeTimeTickFormatter implements TimeTickFormatter {
|
||||
static const firstTick = '-firstTick-';
|
||||
@@ -56,41 +57,41 @@ void main() {
|
||||
TimeTickFormatter timeFormatter3;
|
||||
|
||||
setUp(() {
|
||||
timeFormatter1 = new FakeTimeTickFormatter('fake1');
|
||||
timeFormatter2 = new FakeTimeTickFormatter('fake2');
|
||||
timeFormatter3 = new FakeTimeTickFormatter('fake3');
|
||||
timeFormatter1 = FakeTimeTickFormatter('fake1');
|
||||
timeFormatter2 = FakeTimeTickFormatter('fake2');
|
||||
timeFormatter3 = FakeTimeTickFormatter('fake3');
|
||||
});
|
||||
|
||||
group('Uses formatter', () {
|
||||
test('with largest interval less than diff between tickValues', () {
|
||||
final formatter = new DateTimeTickFormatter.withFormatters(
|
||||
final formatter = DateTimeTickFormatter.withFormatters(
|
||||
{10: timeFormatter1, 100: timeFormatter2, 1000: timeFormatter3});
|
||||
final formatterCache = <DateTime, String>{};
|
||||
|
||||
final ticksWith10Diff = [
|
||||
new DateTime.fromMillisecondsSinceEpoch(0),
|
||||
new DateTime.fromMillisecondsSinceEpoch(10),
|
||||
new DateTime.fromMillisecondsSinceEpoch(20)
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
DateTime.fromMillisecondsSinceEpoch(10),
|
||||
DateTime.fromMillisecondsSinceEpoch(20)
|
||||
];
|
||||
final ticksWith20Diff = [
|
||||
new DateTime.fromMillisecondsSinceEpoch(0),
|
||||
new DateTime.fromMillisecondsSinceEpoch(20),
|
||||
new DateTime.fromMillisecondsSinceEpoch(40)
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
DateTime.fromMillisecondsSinceEpoch(20),
|
||||
DateTime.fromMillisecondsSinceEpoch(40)
|
||||
];
|
||||
final ticksWith100Diff = [
|
||||
new DateTime.fromMillisecondsSinceEpoch(0),
|
||||
new DateTime.fromMillisecondsSinceEpoch(100),
|
||||
new DateTime.fromMillisecondsSinceEpoch(200)
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
DateTime.fromMillisecondsSinceEpoch(100),
|
||||
DateTime.fromMillisecondsSinceEpoch(200)
|
||||
];
|
||||
final ticksWith200Diff = [
|
||||
new DateTime.fromMillisecondsSinceEpoch(0),
|
||||
new DateTime.fromMillisecondsSinceEpoch(200),
|
||||
new DateTime.fromMillisecondsSinceEpoch(400)
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
DateTime.fromMillisecondsSinceEpoch(200),
|
||||
DateTime.fromMillisecondsSinceEpoch(400)
|
||||
];
|
||||
final ticksWith1000Diff = [
|
||||
new DateTime.fromMillisecondsSinceEpoch(0),
|
||||
new DateTime.fromMillisecondsSinceEpoch(1000),
|
||||
new DateTime.fromMillisecondsSinceEpoch(2000)
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
DateTime.fromMillisecondsSinceEpoch(1000),
|
||||
DateTime.fromMillisecondsSinceEpoch(2000)
|
||||
];
|
||||
|
||||
final expectedLabels10Diff = [
|
||||
@@ -139,14 +140,14 @@ void main() {
|
||||
});
|
||||
|
||||
test('with smallest interval when no smaller one exists', () {
|
||||
final formatter = new DateTimeTickFormatter.withFormatters(
|
||||
final formatter = DateTimeTickFormatter.withFormatters(
|
||||
{10: timeFormatter1, 100: timeFormatter2});
|
||||
final formatterCache = <DateTime, String>{};
|
||||
|
||||
final ticks = [
|
||||
new DateTime.fromMillisecondsSinceEpoch(0),
|
||||
new DateTime.fromMillisecondsSinceEpoch(1),
|
||||
new DateTime.fromMillisecondsSinceEpoch(2)
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
DateTime.fromMillisecondsSinceEpoch(1),
|
||||
DateTime.fromMillisecondsSinceEpoch(2)
|
||||
];
|
||||
final expectedLabels = [
|
||||
'fake1-firstTick-0',
|
||||
@@ -159,11 +160,11 @@ void main() {
|
||||
});
|
||||
|
||||
test('with smallest interval for single tick input', () {
|
||||
final formatter = new DateTimeTickFormatter.withFormatters(
|
||||
final formatter = DateTimeTickFormatter.withFormatters(
|
||||
{10: timeFormatter1, 100: timeFormatter2});
|
||||
final formatterCache = <DateTime, String>{};
|
||||
|
||||
final ticks = [new DateTime.fromMillisecondsSinceEpoch(5000)];
|
||||
final ticks = [DateTime.fromMillisecondsSinceEpoch(5000)];
|
||||
final expectedLabels = ['fake1-firstTick-5000'];
|
||||
final actualLabels = formatter.format(ticks, formatterCache, stepSize: 0);
|
||||
expect(actualLabels, equals(expectedLabels));
|
||||
@@ -171,7 +172,7 @@ void main() {
|
||||
|
||||
test('on empty input doesnt break', () {
|
||||
final formatter =
|
||||
new DateTimeTickFormatter.withFormatters({10: timeFormatter1});
|
||||
DateTimeTickFormatter.withFormatters({10: timeFormatter1});
|
||||
final formatterCache = <DateTime, String>{};
|
||||
|
||||
final actualLabels =
|
||||
@@ -180,19 +181,19 @@ void main() {
|
||||
});
|
||||
|
||||
test('that formats transition tick with transition format', () {
|
||||
final timeFormatter = new FakeTimeTickFormatter('fake',
|
||||
isTransitionFunction: (DateTime tickValue, _) =>
|
||||
final timeFormatter = FakeTimeTickFormatter('fake',
|
||||
isTransitionFunction: (tickValue, _) =>
|
||||
tickValue.millisecondsSinceEpoch == 20);
|
||||
final formatterCache = <DateTime, String>{};
|
||||
|
||||
final formatter =
|
||||
new DateTimeTickFormatter.withFormatters({10: timeFormatter});
|
||||
DateTimeTickFormatter.withFormatters({10: timeFormatter});
|
||||
|
||||
final ticks = [
|
||||
new DateTime.fromMillisecondsSinceEpoch(0),
|
||||
new DateTime.fromMillisecondsSinceEpoch(10),
|
||||
new DateTime.fromMillisecondsSinceEpoch(20),
|
||||
new DateTime.fromMillisecondsSinceEpoch(30)
|
||||
DateTime.fromMillisecondsSinceEpoch(0),
|
||||
DateTime.fromMillisecondsSinceEpoch(10),
|
||||
DateTime.fromMillisecondsSinceEpoch(20),
|
||||
DateTime.fromMillisecondsSinceEpoch(30)
|
||||
];
|
||||
|
||||
final expectedLabels = [
|
||||
@@ -212,21 +213,21 @@ void main() {
|
||||
test('throws arugment error if time resolution key is not positive', () {
|
||||
// -1 is reserved for any, if there is only one formatter, -1 is allowed.
|
||||
expect(
|
||||
() => new DateTimeTickFormatter.withFormatters(
|
||||
() => DateTimeTickFormatter.withFormatters(
|
||||
{-1: timeFormatter1, 2: timeFormatter2}),
|
||||
throwsArgumentError);
|
||||
});
|
||||
|
||||
test('throws argument error if formatters is null or empty', () {
|
||||
expect(() => new DateTimeTickFormatter.withFormatters(null),
|
||||
throwsArgumentError);
|
||||
expect(() => new DateTimeTickFormatter.withFormatters({}),
|
||||
expect(() => DateTimeTickFormatter.withFormatters(null),
|
||||
throwsArgumentError);
|
||||
expect(
|
||||
() => DateTimeTickFormatter.withFormatters({}), throwsArgumentError);
|
||||
});
|
||||
|
||||
test('throws arugment error if formatters are not sorted', () {
|
||||
expect(
|
||||
() => new DateTimeTickFormatter.withFormatters({
|
||||
() => DateTimeTickFormatter.withFormatters({
|
||||
3: timeFormatter1,
|
||||
1: timeFormatter2,
|
||||
2: timeFormatter3,
|
||||
@@ -234,7 +235,7 @@ void main() {
|
||||
throwsArgumentError);
|
||||
|
||||
expect(
|
||||
() => new DateTimeTickFormatter.withFormatters({
|
||||
() => DateTimeTickFormatter.withFormatters({
|
||||
1: timeFormatter1,
|
||||
3: timeFormatter2,
|
||||
2: timeFormatter3,
|
||||
@@ -242,7 +243,7 @@ void main() {
|
||||
throwsArgumentError);
|
||||
|
||||
expect(
|
||||
() => new DateTimeTickFormatter.withFormatters({
|
||||
() => DateTimeTickFormatter.withFormatters({
|
||||
2: timeFormatter1,
|
||||
3: timeFormatter2,
|
||||
1: timeFormatter3,
|
||||
|
||||
@@ -23,7 +23,7 @@ class SimpleDateTimeFactory implements DateTimeFactory {
|
||||
@override
|
||||
DateTime createDateTimeFromMilliSecondsSinceEpoch(
|
||||
int millisecondsSinceEpoch) =>
|
||||
new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
|
||||
DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
|
||||
|
||||
@override
|
||||
DateTime createDateTime(int year,
|
||||
@@ -34,9 +34,9 @@ class SimpleDateTimeFactory implements DateTimeFactory {
|
||||
int second = 0,
|
||||
int millisecond = 0,
|
||||
int microsecond = 0]) =>
|
||||
new DateTime(
|
||||
DateTime(
|
||||
year, month, day, hour, minute, second, millisecond, microsecond);
|
||||
|
||||
@override
|
||||
DateFormat createDateFormat(String pattern) => new DateFormat(pattern);
|
||||
DateFormat createDateFormat(String pattern) => DateFormat(pattern);
|
||||
}
|
||||
|
||||
@@ -25,16 +25,16 @@ import 'simple_date_time_factory.dart' show SimpleDateTimeFactory;
|
||||
const EPSILON = 0.001;
|
||||
|
||||
void main() {
|
||||
const dateTimeFactory = const SimpleDateTimeFactory();
|
||||
const dateTimeFactory = SimpleDateTimeFactory();
|
||||
const millisecondsInHour = 3600 * 1000;
|
||||
|
||||
setUp(() {});
|
||||
|
||||
group('Day time stepper', () {
|
||||
test('get steps with 1 day increments', () {
|
||||
final stepper = new DayTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 8, 20), end: new DateTime(2017, 8, 25));
|
||||
final stepper = DayTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 8, 20), end: DateTime(2017, 8, 25));
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(1);
|
||||
final steps = stepIterable.toList();
|
||||
|
||||
@@ -42,20 +42,20 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 8, 20),
|
||||
new DateTime(2017, 8, 21),
|
||||
new DateTime(2017, 8, 22),
|
||||
new DateTime(2017, 8, 23),
|
||||
new DateTime(2017, 8, 24),
|
||||
new DateTime(2017, 8, 25),
|
||||
DateTime(2017, 8, 20),
|
||||
DateTime(2017, 8, 21),
|
||||
DateTime(2017, 8, 22),
|
||||
DateTime(2017, 8, 23),
|
||||
DateTime(2017, 8, 24),
|
||||
DateTime(2017, 8, 25),
|
||||
]));
|
||||
});
|
||||
|
||||
test('get steps with 5 day increments', () {
|
||||
final stepper = new DayTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 8, 10),
|
||||
end: new DateTime(2017, 8, 26),
|
||||
final stepper = DayTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 8, 10),
|
||||
end: DateTime(2017, 8, 26),
|
||||
);
|
||||
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(5);
|
||||
@@ -66,19 +66,19 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 8, 11),
|
||||
new DateTime(2017, 8, 16),
|
||||
new DateTime(2017, 8, 21),
|
||||
new DateTime(2017, 8, 26),
|
||||
DateTime(2017, 8, 11),
|
||||
DateTime(2017, 8, 16),
|
||||
DateTime(2017, 8, 21),
|
||||
DateTime(2017, 8, 26),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving forward change', () {
|
||||
final stepper = new DayTimeStepper(dateTimeFactory);
|
||||
final stepper = DayTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 begin on March 12
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 3, 11),
|
||||
end: new DateTime(2017, 3, 13),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 3, 11),
|
||||
end: DateTime(2017, 3, 13),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(1);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -87,18 +87,18 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 3, 11),
|
||||
new DateTime(2017, 3, 12),
|
||||
new DateTime(2017, 3, 13),
|
||||
DateTime(2017, 3, 11),
|
||||
DateTime(2017, 3, 12),
|
||||
DateTime(2017, 3, 13),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving backward change', () {
|
||||
final stepper = new DayTimeStepper(dateTimeFactory);
|
||||
final stepper = DayTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 end on November 5
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 11, 4),
|
||||
end: new DateTime(2017, 11, 6),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 11, 4),
|
||||
end: DateTime(2017, 11, 6),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(1);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -107,19 +107,19 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 11, 4),
|
||||
new DateTime(2017, 11, 5),
|
||||
new DateTime(2017, 11, 6),
|
||||
DateTime(2017, 11, 4),
|
||||
DateTime(2017, 11, 5),
|
||||
DateTime(2017, 11, 6),
|
||||
]));
|
||||
});
|
||||
});
|
||||
|
||||
group('Hour time stepper', () {
|
||||
test('gets steps in 1 hour increments', () {
|
||||
final stepper = new HourTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 8, 20, 10),
|
||||
end: new DateTime(2017, 8, 20, 15),
|
||||
final stepper = HourTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 8, 20, 10),
|
||||
end: DateTime(2017, 8, 20, 15),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(1);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -128,20 +128,20 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 8, 20, 10),
|
||||
new DateTime(2017, 8, 20, 11),
|
||||
new DateTime(2017, 8, 20, 12),
|
||||
new DateTime(2017, 8, 20, 13),
|
||||
new DateTime(2017, 8, 20, 14),
|
||||
new DateTime(2017, 8, 20, 15),
|
||||
DateTime(2017, 8, 20, 10),
|
||||
DateTime(2017, 8, 20, 11),
|
||||
DateTime(2017, 8, 20, 12),
|
||||
DateTime(2017, 8, 20, 13),
|
||||
DateTime(2017, 8, 20, 14),
|
||||
DateTime(2017, 8, 20, 15),
|
||||
]));
|
||||
});
|
||||
|
||||
test('gets steps in 4 hour increments', () {
|
||||
final stepper = new HourTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 8, 20, 10),
|
||||
end: new DateTime(2017, 8, 21, 10),
|
||||
final stepper = HourTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 8, 20, 10),
|
||||
end: DateTime(2017, 8, 21, 10),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(4);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -150,22 +150,22 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 8, 20, 12),
|
||||
new DateTime(2017, 8, 20, 16),
|
||||
new DateTime(2017, 8, 20, 20),
|
||||
new DateTime(2017, 8, 21, 0),
|
||||
new DateTime(2017, 8, 21, 4),
|
||||
new DateTime(2017, 8, 21, 8),
|
||||
DateTime(2017, 8, 20, 12),
|
||||
DateTime(2017, 8, 20, 16),
|
||||
DateTime(2017, 8, 20, 20),
|
||||
DateTime(2017, 8, 21, 0),
|
||||
DateTime(2017, 8, 21, 4),
|
||||
DateTime(2017, 8, 21, 8),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving forward change in 1 hour increments',
|
||||
() {
|
||||
final stepper = new HourTimeStepper(dateTimeFactory);
|
||||
final stepper = HourTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 begin on March 12. At 2am clocks are turned to 3am.
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 3, 12, 0),
|
||||
end: new DateTime(2017, 3, 12, 5),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 3, 12, 0),
|
||||
end: DateTime(2017, 3, 12, 5),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(1);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -174,21 +174,21 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 3, 12, 0),
|
||||
new DateTime(2017, 3, 12, 1),
|
||||
new DateTime(2017, 3, 12, 3),
|
||||
new DateTime(2017, 3, 12, 4),
|
||||
new DateTime(2017, 3, 12, 5),
|
||||
DateTime(2017, 3, 12, 0),
|
||||
DateTime(2017, 3, 12, 1),
|
||||
DateTime(2017, 3, 12, 3),
|
||||
DateTime(2017, 3, 12, 4),
|
||||
DateTime(2017, 3, 12, 5),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving backward change in 1 hour increments',
|
||||
() {
|
||||
final stepper = new HourTimeStepper(dateTimeFactory);
|
||||
final stepper = HourTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 end on November 5. At 2am, clocks are turned to 1am.
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 11, 5, 0),
|
||||
end: new DateTime(2017, 11, 5, 4),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 11, 5, 0),
|
||||
end: DateTime(2017, 11, 5, 4),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(1);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -197,24 +197,24 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 11, 5, 0),
|
||||
new DateTime(2017, 11, 5, 0)
|
||||
.add(new Duration(milliseconds: millisecondsInHour)),
|
||||
new DateTime(2017, 11, 5, 0)
|
||||
.add(new Duration(milliseconds: millisecondsInHour * 2)),
|
||||
new DateTime(2017, 11, 5, 2),
|
||||
new DateTime(2017, 11, 5, 3),
|
||||
new DateTime(2017, 11, 5, 4),
|
||||
DateTime(2017, 11, 5, 0),
|
||||
DateTime(2017, 11, 5, 0)
|
||||
.add(Duration(milliseconds: millisecondsInHour)),
|
||||
DateTime(2017, 11, 5, 0)
|
||||
.add(Duration(milliseconds: millisecondsInHour * 2)),
|
||||
DateTime(2017, 11, 5, 2),
|
||||
DateTime(2017, 11, 5, 3),
|
||||
DateTime(2017, 11, 5, 4),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving forward change in 4 hour increments',
|
||||
() {
|
||||
final stepper = new HourTimeStepper(dateTimeFactory);
|
||||
final stepper = HourTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 begin on March 12. At 2am clocks are turned to 3am.
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 3, 12, 0),
|
||||
end: new DateTime(2017, 3, 13, 0),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 3, 12, 0),
|
||||
end: DateTime(2017, 3, 13, 0),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(4);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -223,23 +223,23 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 3, 12, 4),
|
||||
new DateTime(2017, 3, 12, 8),
|
||||
new DateTime(2017, 3, 12, 12),
|
||||
new DateTime(2017, 3, 12, 16),
|
||||
new DateTime(2017, 3, 12, 20),
|
||||
new DateTime(2017, 3, 13, 0),
|
||||
DateTime(2017, 3, 12, 4),
|
||||
DateTime(2017, 3, 12, 8),
|
||||
DateTime(2017, 3, 12, 12),
|
||||
DateTime(2017, 3, 12, 16),
|
||||
DateTime(2017, 3, 12, 20),
|
||||
DateTime(2017, 3, 13, 0),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving backward change in 4 hour increments',
|
||||
() {
|
||||
final stepper = new HourTimeStepper(dateTimeFactory);
|
||||
final stepper = HourTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 end on November 5.
|
||||
// At 2am, clocks are turned to 1am.
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 11, 5, 0),
|
||||
end: new DateTime(2017, 11, 6, 0),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 11, 5, 0),
|
||||
end: DateTime(2017, 11, 6, 0),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(4);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -248,24 +248,24 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 11, 5, 0)
|
||||
.add(new Duration(milliseconds: millisecondsInHour)),
|
||||
new DateTime(2017, 11, 5, 4),
|
||||
new DateTime(2017, 11, 5, 8),
|
||||
new DateTime(2017, 11, 5, 12),
|
||||
new DateTime(2017, 11, 5, 16),
|
||||
new DateTime(2017, 11, 5, 20),
|
||||
new DateTime(2017, 11, 6, 0),
|
||||
DateTime(2017, 11, 5, 0)
|
||||
.add(Duration(milliseconds: millisecondsInHour)),
|
||||
DateTime(2017, 11, 5, 4),
|
||||
DateTime(2017, 11, 5, 8),
|
||||
DateTime(2017, 11, 5, 12),
|
||||
DateTime(2017, 11, 5, 16),
|
||||
DateTime(2017, 11, 5, 20),
|
||||
DateTime(2017, 11, 6, 0),
|
||||
]));
|
||||
});
|
||||
});
|
||||
|
||||
group('Minute time stepper', () {
|
||||
test('gets steps with 5 minute increments', () {
|
||||
final stepper = new MinuteTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 8, 20, 3, 46),
|
||||
end: new DateTime(2017, 8, 20, 4, 02),
|
||||
final stepper = MinuteTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 8, 20, 3, 46),
|
||||
end: DateTime(2017, 8, 20, 4, 02),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(5);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -274,18 +274,18 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 8, 20, 3, 50),
|
||||
new DateTime(2017, 8, 20, 3, 55),
|
||||
new DateTime(2017, 8, 20, 4),
|
||||
DateTime(2017, 8, 20, 3, 50),
|
||||
DateTime(2017, 8, 20, 3, 55),
|
||||
DateTime(2017, 8, 20, 4),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving forward change', () {
|
||||
final stepper = new MinuteTimeStepper(dateTimeFactory);
|
||||
final stepper = MinuteTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 begin on March 12. At 2am clocks are turned to 3am.
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 3, 12, 1, 40),
|
||||
end: new DateTime(2017, 3, 12, 4, 02),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 3, 12, 1, 40),
|
||||
end: DateTime(2017, 3, 12, 4, 02),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(15);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -294,21 +294,21 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 3, 12, 1, 45),
|
||||
new DateTime(2017, 3, 12, 3),
|
||||
new DateTime(2017, 3, 12, 3, 15),
|
||||
new DateTime(2017, 3, 12, 3, 30),
|
||||
new DateTime(2017, 3, 12, 3, 45),
|
||||
new DateTime(2017, 3, 12, 4),
|
||||
DateTime(2017, 3, 12, 1, 45),
|
||||
DateTime(2017, 3, 12, 3),
|
||||
DateTime(2017, 3, 12, 3, 15),
|
||||
DateTime(2017, 3, 12, 3, 30),
|
||||
DateTime(2017, 3, 12, 3, 45),
|
||||
DateTime(2017, 3, 12, 4),
|
||||
]));
|
||||
});
|
||||
|
||||
test('steps correctly after daylight saving forward change', () {
|
||||
final stepper = new MinuteTimeStepper(dateTimeFactory);
|
||||
final stepper = MinuteTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 begin on March 12. At 2am clocks are turned to 3am.
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 3, 12, 3, 02),
|
||||
end: new DateTime(2017, 3, 12, 4, 02),
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 3, 12, 3, 02),
|
||||
end: DateTime(2017, 3, 12, 4, 02),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(30);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -317,19 +317,18 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 3, 12, 3, 30),
|
||||
new DateTime(2017, 3, 12, 4),
|
||||
DateTime(2017, 3, 12, 3, 30),
|
||||
DateTime(2017, 3, 12, 4),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step through daylight saving backward change', () {
|
||||
final stepper = new MinuteTimeStepper(dateTimeFactory);
|
||||
final stepper = MinuteTimeStepper(dateTimeFactory);
|
||||
// DST for PST 2017 end on November 5.
|
||||
// At 2am, clocks are turned to 1am.
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 11, 5)
|
||||
.add(new Duration(hours: 1, minutes: 29)),
|
||||
end: new DateTime(2017, 11, 5, 3, 02));
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 11, 5).add(Duration(hours: 1, minutes: 29)),
|
||||
end: DateTime(2017, 11, 5, 3, 02));
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(30);
|
||||
final steps = stepIterable.toList();
|
||||
|
||||
@@ -338,27 +337,27 @@ void main() {
|
||||
steps,
|
||||
equals([
|
||||
// The first 1:30am
|
||||
new DateTime(2017, 11, 5).add(new Duration(hours: 1, minutes: 30)),
|
||||
DateTime(2017, 11, 5).add(Duration(hours: 1, minutes: 30)),
|
||||
// The 2nd 1am.
|
||||
new DateTime(2017, 11, 5).add(new Duration(hours: 2)),
|
||||
DateTime(2017, 11, 5).add(Duration(hours: 2)),
|
||||
// The 2nd 1:30am
|
||||
new DateTime(2017, 11, 5).add(new Duration(hours: 2, minutes: 30)),
|
||||
DateTime(2017, 11, 5).add(Duration(hours: 2, minutes: 30)),
|
||||
// 2am
|
||||
new DateTime(2017, 11, 5).add(new Duration(hours: 3)),
|
||||
DateTime(2017, 11, 5).add(Duration(hours: 3)),
|
||||
// 2:30am
|
||||
new DateTime(2017, 11, 5).add(new Duration(hours: 3, minutes: 30)),
|
||||
DateTime(2017, 11, 5).add(Duration(hours: 3, minutes: 30)),
|
||||
// 3am
|
||||
new DateTime(2017, 11, 5, 3)
|
||||
DateTime(2017, 11, 5, 3)
|
||||
]));
|
||||
});
|
||||
});
|
||||
|
||||
group('Month time stepper', () {
|
||||
test('steps crosses the year', () {
|
||||
final stepper = new MonthTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 5),
|
||||
end: new DateTime(2018, 9),
|
||||
final stepper = MonthTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 5),
|
||||
end: DateTime(2018, 9),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(4);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -367,18 +366,18 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 8),
|
||||
new DateTime(2017, 12),
|
||||
new DateTime(2018, 4),
|
||||
new DateTime(2018, 8),
|
||||
DateTime(2017, 8),
|
||||
DateTime(2017, 12),
|
||||
DateTime(2018, 4),
|
||||
DateTime(2018, 8),
|
||||
]));
|
||||
});
|
||||
|
||||
test('steps within one year', () {
|
||||
final stepper = new MonthTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017, 1),
|
||||
end: new DateTime(2017, 5),
|
||||
final stepper = MonthTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017, 1),
|
||||
end: DateTime(2017, 5),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(2);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -387,66 +386,66 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2017, 2),
|
||||
new DateTime(2017, 4),
|
||||
DateTime(2017, 2),
|
||||
DateTime(2017, 4),
|
||||
]));
|
||||
});
|
||||
|
||||
test('step before would allow ticks to include last month of the year', () {
|
||||
final stepper = new MonthTimeStepper(dateTimeFactory);
|
||||
final time = new DateTime(2017, 10);
|
||||
final stepper = MonthTimeStepper(dateTimeFactory);
|
||||
final time = DateTime(2017, 10);
|
||||
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 1),
|
||||
equals(new DateTime(2017, 10)));
|
||||
equals(DateTime(2017, 10)));
|
||||
|
||||
// Months - 3, 6, 9, 12
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 3),
|
||||
equals(new DateTime(2017, 9)));
|
||||
equals(DateTime(2017, 9)));
|
||||
|
||||
// Months - 6, 12
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 6),
|
||||
equals(new DateTime(2017, 6)));
|
||||
equals(DateTime(2017, 6)));
|
||||
});
|
||||
|
||||
test('step before for January', () {
|
||||
final stepper = new MonthTimeStepper(dateTimeFactory);
|
||||
final time = new DateTime(2017, 1);
|
||||
final stepper = MonthTimeStepper(dateTimeFactory);
|
||||
final time = DateTime(2017, 1);
|
||||
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 1),
|
||||
equals(new DateTime(2017, 1)));
|
||||
equals(DateTime(2017, 1)));
|
||||
|
||||
// Months - 3, 6, 9, 12
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 3),
|
||||
equals(new DateTime(2016, 12)));
|
||||
equals(DateTime(2016, 12)));
|
||||
|
||||
// Months - 6, 12
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 6),
|
||||
equals(new DateTime(2016, 12)));
|
||||
equals(DateTime(2016, 12)));
|
||||
});
|
||||
|
||||
test('step before for December', () {
|
||||
final stepper = new MonthTimeStepper(dateTimeFactory);
|
||||
final time = new DateTime(2017, 12);
|
||||
final stepper = MonthTimeStepper(dateTimeFactory);
|
||||
final time = DateTime(2017, 12);
|
||||
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 1),
|
||||
equals(new DateTime(2017, 12)));
|
||||
equals(DateTime(2017, 12)));
|
||||
|
||||
// Months - 3, 6, 9, 12
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 3),
|
||||
equals(new DateTime(2017, 12)));
|
||||
equals(DateTime(2017, 12)));
|
||||
|
||||
// Months - 6, 12
|
||||
expect(stepper.getStepTimeBeforeInclusive(time, 6),
|
||||
equals(new DateTime(2017, 12)));
|
||||
equals(DateTime(2017, 12)));
|
||||
});
|
||||
});
|
||||
|
||||
group('Year stepper', () {
|
||||
test('steps in 10 year increments', () {
|
||||
final stepper = new YearTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(2017),
|
||||
end: new DateTime(2042),
|
||||
final stepper = YearTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(2017),
|
||||
end: DateTime(2042),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(10);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -455,17 +454,17 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(2020),
|
||||
new DateTime(2030),
|
||||
new DateTime(2040),
|
||||
DateTime(2020),
|
||||
DateTime(2030),
|
||||
DateTime(2040),
|
||||
]));
|
||||
});
|
||||
|
||||
test('steps through negative year', () {
|
||||
final stepper = new YearTimeStepper(dateTimeFactory);
|
||||
final extent = new DateTimeExtents(
|
||||
start: new DateTime(-420),
|
||||
end: new DateTime(240),
|
||||
final stepper = YearTimeStepper(dateTimeFactory);
|
||||
final extent = DateTimeExtents(
|
||||
start: DateTime(-420),
|
||||
end: DateTime(240),
|
||||
);
|
||||
final stepIterable = stepper.getSteps(extent)..iterator.reset(200);
|
||||
final steps = stepIterable.toList();
|
||||
@@ -474,10 +473,10 @@ void main() {
|
||||
expect(
|
||||
steps,
|
||||
equals([
|
||||
new DateTime(-400),
|
||||
new DateTime(-200),
|
||||
new DateTime(0),
|
||||
new DateTime(200),
|
||||
DateTime(-400),
|
||||
DateTime(-200),
|
||||
DateTime(0),
|
||||
DateTime(200),
|
||||
]));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,13 +20,13 @@ import 'simple_date_time_factory.dart' show SimpleDateTimeFactory;
|
||||
const EPSILON = 0.001;
|
||||
|
||||
void main() {
|
||||
const dateTimeFactory = const SimpleDateTimeFactory();
|
||||
const dateTimeFactory = SimpleDateTimeFactory();
|
||||
|
||||
group('Find closest step size from stepper', () {
|
||||
test('from exactly matching step size', () {
|
||||
final stepper = AutoAdjustingDateTimeTickProvider.createHourTickProvider(
|
||||
dateTimeFactory);
|
||||
final oneHourMs = (new Duration(hours: 1)).inMilliseconds;
|
||||
final oneHourMs = (Duration(hours: 1)).inMilliseconds;
|
||||
final closestStepSize = stepper.getClosestStepSize(oneHourMs);
|
||||
|
||||
expect(closestStepSize, equals(oneHourMs));
|
||||
@@ -36,9 +36,9 @@ void main() {
|
||||
() {
|
||||
final stepper = AutoAdjustingDateTimeTickProvider.createHourTickProvider(
|
||||
dateTimeFactory);
|
||||
final oneHourMs = (new Duration(hours: 1)).inMilliseconds;
|
||||
final closestStepSize = stepper
|
||||
.getClosestStepSize((new Duration(minutes: 56)).inMilliseconds);
|
||||
final oneHourMs = (Duration(hours: 1)).inMilliseconds;
|
||||
final closestStepSize =
|
||||
stepper.getClosestStepSize((Duration(minutes: 56)).inMilliseconds);
|
||||
|
||||
expect(closestStepSize, equals(oneHourMs));
|
||||
});
|
||||
@@ -47,9 +47,9 @@ void main() {
|
||||
() {
|
||||
final stepper = AutoAdjustingDateTimeTickProvider.createHourTickProvider(
|
||||
dateTimeFactory);
|
||||
final oneDayMs = (new Duration(hours: 24)).inMilliseconds;
|
||||
final oneDayMs = (Duration(hours: 24)).inMilliseconds;
|
||||
final closestStepSize =
|
||||
stepper.getClosestStepSize((new Duration(hours: 25)).inMilliseconds);
|
||||
stepper.getClosestStepSize((Duration(hours: 25)).inMilliseconds);
|
||||
|
||||
expect(closestStepSize, equals(oneDayMs));
|
||||
});
|
||||
@@ -57,9 +57,9 @@ void main() {
|
||||
test('choose closest increment if exact not found', () {
|
||||
final stepper = AutoAdjustingDateTimeTickProvider.createHourTickProvider(
|
||||
dateTimeFactory);
|
||||
final threeHoursMs = (new Duration(hours: 3)).inMilliseconds;
|
||||
final closestStepSize = stepper.getClosestStepSize(
|
||||
(new Duration(hours: 3, minutes: 28)).inMilliseconds);
|
||||
final threeHoursMs = (Duration(hours: 3)).inMilliseconds;
|
||||
final closestStepSize = stepper
|
||||
.getClosestStepSize((Duration(hours: 3, minutes: 28)).inMilliseconds);
|
||||
|
||||
expect(closestStepSize, equals(threeHoursMs));
|
||||
});
|
||||
|
||||
@@ -30,8 +30,8 @@ class MockGraphicsFactory extends Mock implements GraphicsFactory {}
|
||||
|
||||
class FakeNumericChart extends NumericCartesianChart {
|
||||
FakeNumericChart() {
|
||||
context = new MockContext();
|
||||
graphicsFactory = new MockGraphicsFactory();
|
||||
context = MockContext();
|
||||
graphicsFactory = MockGraphicsFactory();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -42,8 +42,8 @@ class FakeNumericChart extends NumericCartesianChart {
|
||||
|
||||
class FakeOrdinalChart extends OrdinalCartesianChart {
|
||||
FakeOrdinalChart() {
|
||||
context = new MockContext();
|
||||
graphicsFactory = new MockGraphicsFactory();
|
||||
context = MockContext();
|
||||
graphicsFactory = MockGraphicsFactory();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -54,8 +54,8 @@ class FakeOrdinalChart extends OrdinalCartesianChart {
|
||||
|
||||
class FakeTimeSeries extends TimeSeriesChart {
|
||||
FakeTimeSeries() {
|
||||
context = new MockContext();
|
||||
graphicsFactory = new MockGraphicsFactory();
|
||||
context = MockContext();
|
||||
graphicsFactory = MockGraphicsFactory();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -67,36 +67,36 @@ class FakeTimeSeries extends TimeSeriesChart {
|
||||
void main() {
|
||||
group('Axis reset with new axis spec', () {
|
||||
test('for ordinal chart', () {
|
||||
final chart = new FakeOrdinalChart();
|
||||
final chart = FakeOrdinalChart();
|
||||
chart.configurationChanged();
|
||||
final domainAxis = chart.domainAxis;
|
||||
expect(domainAxis, isNotNull);
|
||||
|
||||
chart.domainAxisSpec = new OrdinalAxisSpec();
|
||||
chart.domainAxisSpec = OrdinalAxisSpec();
|
||||
chart.configurationChanged();
|
||||
|
||||
expect(domainAxis, isNot(chart.domainAxis));
|
||||
});
|
||||
|
||||
test('for numeric chart', () {
|
||||
final chart = new FakeNumericChart();
|
||||
final chart = FakeNumericChart();
|
||||
chart.configurationChanged();
|
||||
final domainAxis = chart.domainAxis;
|
||||
expect(domainAxis, isNotNull);
|
||||
|
||||
chart.domainAxisSpec = new NumericAxisSpec();
|
||||
chart.domainAxisSpec = NumericAxisSpec();
|
||||
chart.configurationChanged();
|
||||
|
||||
expect(domainAxis, isNot(chart.domainAxis));
|
||||
});
|
||||
|
||||
test('for time series chart', () {
|
||||
final chart = new FakeTimeSeries();
|
||||
final chart = FakeTimeSeries();
|
||||
chart.configurationChanged();
|
||||
final domainAxis = chart.domainAxis;
|
||||
expect(domainAxis, isNotNull);
|
||||
|
||||
chart.domainAxisSpec = new DateTimeAxisSpec();
|
||||
chart.domainAxisSpec = DateTimeAxisSpec();
|
||||
chart.configurationChanged();
|
||||
|
||||
expect(domainAxis, isNot(chart.domainAxis));
|
||||
|
||||
@@ -54,14 +54,14 @@ void main() {
|
||||
BaseCartesianRenderer renderer;
|
||||
|
||||
setUp(() {
|
||||
renderer = new FakeCartesianRenderer();
|
||||
renderer = FakeCartesianRenderer();
|
||||
});
|
||||
|
||||
group('find viewport start', () {
|
||||
test('several domains are in the viewport', () {
|
||||
final data = [0, 1, 2, 3, 4, 5, 6];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(0);
|
||||
@@ -78,8 +78,8 @@ void main() {
|
||||
test('extents are all in the viewport, use the first domain', () {
|
||||
// Start of viewport is the same as the start of the domain.
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(any)).thenReturn(0);
|
||||
|
||||
final start = renderer.findNearestViewportStart(axis, domainFn, data);
|
||||
@@ -89,8 +89,8 @@ void main() {
|
||||
|
||||
test('is the first domain', () {
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(0);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(1);
|
||||
@@ -103,8 +103,8 @@ void main() {
|
||||
|
||||
test('is the last domain', () {
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(-1);
|
||||
@@ -117,8 +117,8 @@ void main() {
|
||||
|
||||
test('is the middle', () {
|
||||
final data = [0, 1, 2, 3, 4, 5, 6];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(-1);
|
||||
@@ -134,8 +134,8 @@ void main() {
|
||||
|
||||
test('viewport is between data', () {
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(1);
|
||||
@@ -151,8 +151,8 @@ void main() {
|
||||
test('all extents greater than viewport ', () {
|
||||
// Return the right most value as start of viewport.
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(any)).thenReturn(1);
|
||||
|
||||
final start = renderer.findNearestViewportStart(axis, domainFn, data);
|
||||
@@ -165,8 +165,8 @@ void main() {
|
||||
test('all extents less than viewport ', () {
|
||||
// Return the left most value as the start of the viewport.
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(any)).thenReturn(-1);
|
||||
|
||||
final start = renderer.findNearestViewportStart(axis, domainFn, data);
|
||||
@@ -178,8 +178,8 @@ void main() {
|
||||
group('find viewport end', () {
|
||||
test('several domains are in the viewport', () {
|
||||
final data = [0, 1, 2, 3, 4, 5, 6];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(0);
|
||||
@@ -196,8 +196,8 @@ void main() {
|
||||
test('extents are all in the viewport, use the last domain', () {
|
||||
// Start of viewport is the same as the end of the domain.
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(any)).thenReturn(0);
|
||||
|
||||
final start = renderer.findNearestViewportEnd(axis, domainFn, data);
|
||||
@@ -207,8 +207,8 @@ void main() {
|
||||
|
||||
test('is the first domain', () {
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(0);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(1);
|
||||
@@ -221,8 +221,8 @@ void main() {
|
||||
|
||||
test('is the last domain', () {
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(-1);
|
||||
@@ -235,8 +235,8 @@ void main() {
|
||||
|
||||
test('is the middle', () {
|
||||
final data = [0, 1, 2, 3, 4, 5, 6];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(-1);
|
||||
@@ -252,8 +252,8 @@ void main() {
|
||||
|
||||
test('viewport is between data', () {
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(0)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(1)).thenReturn(-1);
|
||||
when(axis.compareDomainValueToViewport(2)).thenReturn(1);
|
||||
@@ -269,8 +269,8 @@ void main() {
|
||||
test('all extents greater than viewport ', () {
|
||||
// Return the right most value as start of viewport.
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(any)).thenReturn(1);
|
||||
|
||||
final start = renderer.findNearestViewportEnd(axis, domainFn, data);
|
||||
@@ -283,8 +283,8 @@ void main() {
|
||||
test('all extents less than viewport ', () {
|
||||
// Return the left most value as the start of the viewport.
|
||||
final data = [0, 1, 2, 3];
|
||||
final domainFn = (int index) => data[index];
|
||||
final axis = new MockAxis();
|
||||
final domainFn = (index) => data[index];
|
||||
final axis = MockAxis();
|
||||
when(axis.compareDomainValueToViewport(any)).thenReturn(-1);
|
||||
|
||||
final start = renderer.findNearestViewportEnd(axis, domainFn, data);
|
||||
|
||||
@@ -45,31 +45,30 @@ void main() {
|
||||
MockAxis domainAxis;
|
||||
|
||||
MutableSeries<String> _series1;
|
||||
final _s1D1 = new MyRow('s1d1', 11, 'a11yd1');
|
||||
final _s1D2 = new MyRow('s1d2', 12, 'a11yd2');
|
||||
final _s1D3 = new MyRow('s1d3', 13, 'a11yd3');
|
||||
final _s1D1 = MyRow('s1d1', 11, 'a11yd1');
|
||||
final _s1D2 = MyRow('s1d2', 12, 'a11yd2');
|
||||
final _s1D3 = MyRow('s1d3', 13, 'a11yd3');
|
||||
|
||||
setUp(() {
|
||||
chart = new FakeCartesianChart()
|
||||
..drawAreaBounds = new Rectangle(50, 20, 150, 80);
|
||||
chart = FakeCartesianChart()..drawAreaBounds = Rectangle(50, 20, 150, 80);
|
||||
|
||||
behavior = new DomainA11yExploreBehavior<String>(
|
||||
behavior = DomainA11yExploreBehavior<String>(
|
||||
vocalizationCallback: domainVocalization);
|
||||
behavior.attachTo(chart);
|
||||
|
||||
domainAxis = new MockAxis();
|
||||
_series1 = new MutableSeries(new Series<MyRow, String>(
|
||||
domainAxis = MockAxis();
|
||||
_series1 = MutableSeries(Series<MyRow, String>(
|
||||
id: 's1',
|
||||
data: [_s1D1, _s1D2, _s1D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
))
|
||||
..setAttr(domainAxisKey, domainAxis);
|
||||
});
|
||||
|
||||
test('creates nodes for vertically drawn charts', () {
|
||||
// A LTR chart
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
chart.context = context;
|
||||
@@ -87,16 +86,16 @@ void main() {
|
||||
|
||||
expect(nodes, hasLength(3));
|
||||
expect(nodes[0].label, equals('s1d1'));
|
||||
expect(nodes[0].boundingBox, equals(new Rectangle(50, 20, 50, 80)));
|
||||
expect(nodes[0].boundingBox, equals(Rectangle(50, 20, 50, 80)));
|
||||
expect(nodes[1].label, equals('s1d2'));
|
||||
expect(nodes[1].boundingBox, equals(new Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[1].boundingBox, equals(Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[2].label, equals('s1d3'));
|
||||
expect(nodes[2].boundingBox, equals(new Rectangle(150, 20, 50, 80)));
|
||||
expect(nodes[2].boundingBox, equals(Rectangle(150, 20, 50, 80)));
|
||||
});
|
||||
|
||||
test('creates nodes for vertically drawn RTL charts', () {
|
||||
// A RTL chart
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(true);
|
||||
when(context.isRtl).thenReturn(true);
|
||||
chart.context = context;
|
||||
@@ -114,16 +113,16 @@ void main() {
|
||||
|
||||
expect(nodes, hasLength(3));
|
||||
expect(nodes[0].label, equals('s1d1'));
|
||||
expect(nodes[0].boundingBox, equals(new Rectangle(150, 20, 50, 80)));
|
||||
expect(nodes[0].boundingBox, equals(Rectangle(150, 20, 50, 80)));
|
||||
expect(nodes[1].label, equals('s1d2'));
|
||||
expect(nodes[1].boundingBox, equals(new Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[1].boundingBox, equals(Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[2].label, equals('s1d3'));
|
||||
expect(nodes[2].boundingBox, equals(new Rectangle(50, 20, 50, 80)));
|
||||
expect(nodes[2].boundingBox, equals(Rectangle(50, 20, 50, 80)));
|
||||
});
|
||||
|
||||
test('creates nodes for horizontally drawn charts', () {
|
||||
// A LTR chart
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
chart.context = context;
|
||||
@@ -141,16 +140,16 @@ void main() {
|
||||
|
||||
expect(nodes, hasLength(3));
|
||||
expect(nodes[0].label, equals('s1d1'));
|
||||
expect(nodes[0].boundingBox, equals(new Rectangle(50, 20, 150, 20)));
|
||||
expect(nodes[0].boundingBox, equals(Rectangle(50, 20, 150, 20)));
|
||||
expect(nodes[1].label, equals('s1d2'));
|
||||
expect(nodes[1].boundingBox, equals(new Rectangle(50, 40, 150, 20)));
|
||||
expect(nodes[1].boundingBox, equals(Rectangle(50, 40, 150, 20)));
|
||||
expect(nodes[2].label, equals('s1d3'));
|
||||
expect(nodes[2].boundingBox, equals(new Rectangle(50, 60, 150, 20)));
|
||||
expect(nodes[2].boundingBox, equals(Rectangle(50, 60, 150, 20)));
|
||||
});
|
||||
|
||||
test('creates nodes for horizontally drawn RTL charts', () {
|
||||
// A LTR chart
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(true);
|
||||
when(context.isRtl).thenReturn(true);
|
||||
chart.context = context;
|
||||
@@ -168,16 +167,16 @@ void main() {
|
||||
|
||||
expect(nodes, hasLength(3));
|
||||
expect(nodes[0].label, equals('s1d1'));
|
||||
expect(nodes[0].boundingBox, equals(new Rectangle(50, 20, 150, 20)));
|
||||
expect(nodes[0].boundingBox, equals(Rectangle(50, 20, 150, 20)));
|
||||
expect(nodes[1].label, equals('s1d2'));
|
||||
expect(nodes[1].boundingBox, equals(new Rectangle(50, 40, 150, 20)));
|
||||
expect(nodes[1].boundingBox, equals(Rectangle(50, 40, 150, 20)));
|
||||
expect(nodes[2].label, equals('s1d3'));
|
||||
expect(nodes[2].boundingBox, equals(new Rectangle(50, 60, 150, 20)));
|
||||
expect(nodes[2].boundingBox, equals(Rectangle(50, 60, 150, 20)));
|
||||
});
|
||||
|
||||
test('nodes ordered correctly with a series missing a domain', () {
|
||||
// A LTR chart
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
chart.context = context;
|
||||
@@ -189,11 +188,11 @@ void main() {
|
||||
when(domainAxis.getLocation('s1d2')).thenReturn(125.0);
|
||||
when(domainAxis.getLocation('s1d3')).thenReturn(175.0);
|
||||
// Create a series with a missing domain
|
||||
final seriesWithMissingDomain = new MutableSeries(new Series<MyRow, String>(
|
||||
final seriesWithMissingDomain = MutableSeries(Series<MyRow, String>(
|
||||
id: 'm1',
|
||||
data: [_s1D1, _s1D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
))
|
||||
..setAttr(domainAxisKey, domainAxis);
|
||||
|
||||
@@ -204,21 +203,21 @@ void main() {
|
||||
|
||||
expect(nodes, hasLength(3));
|
||||
expect(nodes[0].label, equals('s1d1'));
|
||||
expect(nodes[0].boundingBox, equals(new Rectangle(50, 20, 50, 80)));
|
||||
expect(nodes[0].boundingBox, equals(Rectangle(50, 20, 50, 80)));
|
||||
expect(nodes[1].label, equals('s1d2'));
|
||||
expect(nodes[1].boundingBox, equals(new Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[1].boundingBox, equals(Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[2].label, equals('s1d3'));
|
||||
expect(nodes[2].boundingBox, equals(new Rectangle(150, 20, 50, 80)));
|
||||
expect(nodes[2].boundingBox, equals(Rectangle(150, 20, 50, 80)));
|
||||
});
|
||||
|
||||
test('creates nodes with minimum width', () {
|
||||
// A behavior with minimum width of 50
|
||||
final behaviorWithMinWidth =
|
||||
new DomainA11yExploreBehavior<String>(minimumWidth: 50.0);
|
||||
DomainA11yExploreBehavior<String>(minimumWidth: 50.0);
|
||||
behaviorWithMinWidth.attachTo(chart);
|
||||
|
||||
// A LTR chart
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
chart.context = context;
|
||||
@@ -237,11 +236,11 @@ void main() {
|
||||
|
||||
expect(nodes, hasLength(3));
|
||||
expect(nodes[0].label, equals('s1d1'));
|
||||
expect(nodes[0].boundingBox, equals(new Rectangle(50, 20, 50, 80)));
|
||||
expect(nodes[0].boundingBox, equals(Rectangle(50, 20, 50, 80)));
|
||||
expect(nodes[1].label, equals('s1d2'));
|
||||
expect(nodes[1].boundingBox, equals(new Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[1].boundingBox, equals(Rectangle(100, 20, 50, 80)));
|
||||
expect(nodes[2].label, equals('s1d3'));
|
||||
expect(nodes[2].boundingBox, equals(new Rectangle(150, 20, 50, 80)));
|
||||
expect(nodes[2].boundingBox, equals(Rectangle(150, 20, 50, 80)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ void main() {
|
||||
|
||||
PercentInjector _makeBehavior(
|
||||
{PercentInjectorTotalType totalType = PercentInjectorTotalType.domain}) {
|
||||
final behavior = new PercentInjector(totalType: totalType);
|
||||
final behavior = PercentInjector(totalType: totalType);
|
||||
|
||||
behavior.attachTo(_chart);
|
||||
|
||||
@@ -64,92 +64,92 @@ void main() {
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
_chart = new MockChart();
|
||||
_chart = MockChart();
|
||||
|
||||
final myFakeDesktopAData = [
|
||||
new MyRow('MyCampaign1', 1, 1, 1),
|
||||
new MyRow('MyCampaign2', 2, 2, 2),
|
||||
new MyRow('MyCampaign3', 3, 3, 3),
|
||||
MyRow('MyCampaign1', 1, 1, 1),
|
||||
MyRow('MyCampaign2', 2, 2, 2),
|
||||
MyRow('MyCampaign3', 3, 3, 3),
|
||||
];
|
||||
|
||||
final myFakeTabletAData = [
|
||||
new MyRow('MyCampaign1', 2, 2, 2),
|
||||
new MyRow('MyCampaign2', 3, 3, 3),
|
||||
new MyRow('MyCampaign3', 4, 4, 4),
|
||||
MyRow('MyCampaign1', 2, 2, 2),
|
||||
MyRow('MyCampaign2', 3, 3, 3),
|
||||
MyRow('MyCampaign3', 4, 4, 4),
|
||||
];
|
||||
|
||||
final myFakeMobileAData = [
|
||||
new MyRow('MyCampaign1', 3, 3, 3),
|
||||
new MyRow('MyCampaign2', 4, 4, 4),
|
||||
new MyRow('MyCampaign3', 5, 5, 5),
|
||||
MyRow('MyCampaign1', 3, 3, 3),
|
||||
MyRow('MyCampaign2', 4, 4, 4),
|
||||
MyRow('MyCampaign3', 5, 5, 5),
|
||||
];
|
||||
|
||||
final myFakeDesktopBData = [
|
||||
new MyRow('MyCampaign1', 10, 8, 12),
|
||||
new MyRow('MyCampaign2', 20, 18, 22),
|
||||
new MyRow('MyCampaign3', 30, 28, 32),
|
||||
MyRow('MyCampaign1', 10, 8, 12),
|
||||
MyRow('MyCampaign2', 20, 18, 22),
|
||||
MyRow('MyCampaign3', 30, 28, 32),
|
||||
];
|
||||
|
||||
final myFakeTabletBData = [
|
||||
new MyRow('MyCampaign1', 20, 18, 22),
|
||||
new MyRow('MyCampaign2', 30, 28, 32),
|
||||
new MyRow('MyCampaign3', 40, 38, 42),
|
||||
MyRow('MyCampaign1', 20, 18, 22),
|
||||
MyRow('MyCampaign2', 30, 28, 32),
|
||||
MyRow('MyCampaign3', 40, 38, 42),
|
||||
];
|
||||
|
||||
final myFakeMobileBData = [
|
||||
new MyRow('MyCampaign1', 30, 28, 32),
|
||||
new MyRow('MyCampaign2', 40, 38, 42),
|
||||
new MyRow('MyCampaign3', 50, 48, 52),
|
||||
MyRow('MyCampaign1', 30, 28, 32),
|
||||
MyRow('MyCampaign2', 40, 38, 42),
|
||||
MyRow('MyCampaign3', 50, 48, 52),
|
||||
];
|
||||
|
||||
seriesList = [
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop A',
|
||||
seriesCategory: 'A',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeDesktopAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Tablet A',
|
||||
seriesCategory: 'A',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeTabletAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Mobile A',
|
||||
seriesCategory: 'A',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeMobileAData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop B',
|
||||
seriesCategory: 'B',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureLowerBoundFn: (MyRow row, _) => row.clickCountLower,
|
||||
measureUpperBoundFn: (MyRow row, _) => row.clickCountUpper,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureLowerBoundFn: (row, _) => row.clickCountLower,
|
||||
measureUpperBoundFn: (row, _) => row.clickCountUpper,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeDesktopBData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Tablet B',
|
||||
seriesCategory: 'B',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureLowerBoundFn: (MyRow row, _) => row.clickCountLower,
|
||||
measureUpperBoundFn: (MyRow row, _) => row.clickCountUpper,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureLowerBoundFn: (row, _) => row.clickCountLower,
|
||||
measureUpperBoundFn: (row, _) => row.clickCountUpper,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeTabletBData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Mobile B',
|
||||
seriesCategory: 'B',
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureLowerBoundFn: (MyRow row, _) => row.clickCountLower,
|
||||
measureUpperBoundFn: (MyRow row, _) => row.clickCountUpper,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureLowerBoundFn: (row, _) => row.clickCountLower,
|
||||
measureUpperBoundFn: (row, _) => row.clickCountUpper,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
data: myFakeMobileBData))
|
||||
];
|
||||
});
|
||||
|
||||
@@ -57,12 +57,12 @@ void main() {
|
||||
MockBehavior unnamedBehavior;
|
||||
|
||||
setUp(() {
|
||||
chart = new ConcreteChart();
|
||||
chart = ConcreteChart();
|
||||
|
||||
namedBehavior = new MockBehavior();
|
||||
namedBehavior = MockBehavior();
|
||||
when(namedBehavior.role).thenReturn('foo');
|
||||
|
||||
unnamedBehavior = new MockBehavior();
|
||||
unnamedBehavior = MockBehavior();
|
||||
when(unnamedBehavior.role).thenReturn(null);
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('detach is called when name is reused', () {
|
||||
final otherBehavior = new MockBehavior();
|
||||
final otherBehavior = MockBehavior();
|
||||
when(otherBehavior.role).thenReturn('foo');
|
||||
|
||||
chart.addBehavior(namedBehavior);
|
||||
@@ -117,7 +117,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('detach is not called when name is different', () {
|
||||
final otherBehavior = new MockBehavior();
|
||||
final otherBehavior = MockBehavior();
|
||||
when(otherBehavior.role).thenReturn('bar');
|
||||
|
||||
chart.addBehavior(namedBehavior);
|
||||
@@ -133,7 +133,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('behaviors are removed when chart is destroyed', () {
|
||||
final parentBehavior = new ParentBehavior(unnamedBehavior);
|
||||
final parentBehavior = ParentBehavior(unnamedBehavior);
|
||||
|
||||
chart.addBehavior(parentBehavior);
|
||||
// The parent should add the child behavoir.
|
||||
|
||||
@@ -55,14 +55,14 @@ void main() {
|
||||
MockSelectionModel _selectionModel;
|
||||
|
||||
MutableSeries<String> _series1;
|
||||
final _s1D1 = new MyRow('s1d1', 11);
|
||||
final _s1D2 = new MyRow('s1d2', 12);
|
||||
final _s1D3 = new MyRow('s1d3', 13);
|
||||
final _s1D1 = MyRow('s1d1', 11);
|
||||
final _s1D2 = MyRow('s1d2', 12);
|
||||
final _s1D3 = MyRow('s1d3', 13);
|
||||
|
||||
MutableSeries<String> _series2;
|
||||
final _s2D1 = new MyRow('s2d1', 21);
|
||||
final _s2D2 = new MyRow('s2d2', 22);
|
||||
final _s2D3 = new MyRow('s2d3', 23);
|
||||
final _s2D1 = MyRow('s2d1', 21);
|
||||
final _s2D2 = MyRow('s2d2', 22);
|
||||
final _s2D3 = MyRow('s2d3', 23);
|
||||
|
||||
_setupSelection(List<MyRow> selected) {
|
||||
for (var i = 0; i < _series1.data.length; i++) {
|
||||
@@ -76,25 +76,25 @@ void main() {
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
_chart = new MockChart();
|
||||
_chart = MockChart();
|
||||
|
||||
_selectionModel = new MockSelectionModel();
|
||||
_selectionModel = MockSelectionModel();
|
||||
when(_chart.getSelectionModel(SelectionModelType.info))
|
||||
.thenReturn(_selectionModel);
|
||||
|
||||
_series1 = new MutableSeries(new Series<MyRow, String>(
|
||||
_series1 = MutableSeries(Series<MyRow, String>(
|
||||
id: 's1',
|
||||
data: [_s1D1, _s1D2, _s1D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault))
|
||||
..measureFn = (_) => 0.0;
|
||||
|
||||
_series2 = new MutableSeries(new Series<MyRow, String>(
|
||||
_series2 = MutableSeries(Series<MyRow, String>(
|
||||
id: 's2',
|
||||
data: [_s2D1, _s2D2, _s2D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault))
|
||||
..measureFn = (_) => 0.0;
|
||||
});
|
||||
@@ -102,7 +102,7 @@ void main() {
|
||||
group('DomainHighligher', () {
|
||||
test('darkens the selected bars', () {
|
||||
// Setup
|
||||
final behavior = new DomainHighlighter(SelectionModelType.info);
|
||||
final behavior = DomainHighlighter(SelectionModelType.info);
|
||||
behavior.attachTo(_chart);
|
||||
_setupSelection([_s1D2, _s2D2]);
|
||||
final seriesList = [_series1, _series2];
|
||||
@@ -126,7 +126,7 @@ void main() {
|
||||
|
||||
test('listens to other selection models', () {
|
||||
// Setup
|
||||
final behavior = new DomainHighlighter(SelectionModelType.action);
|
||||
final behavior = DomainHighlighter(SelectionModelType.action);
|
||||
when(_chart.getSelectionModel(SelectionModelType.action))
|
||||
.thenReturn(_selectionModel);
|
||||
|
||||
@@ -140,7 +140,7 @@ void main() {
|
||||
|
||||
test('leaves everything alone with no selection', () {
|
||||
// Setup
|
||||
final behavior = new DomainHighlighter(SelectionModelType.info);
|
||||
final behavior = DomainHighlighter(SelectionModelType.info);
|
||||
behavior.attachTo(_chart);
|
||||
_setupSelection([]);
|
||||
final seriesList = [_series1, _series2];
|
||||
@@ -164,7 +164,7 @@ void main() {
|
||||
|
||||
test('cleans up', () {
|
||||
// Setup
|
||||
final behavior = new DomainHighlighter(SelectionModelType.info);
|
||||
final behavior = DomainHighlighter(SelectionModelType.info);
|
||||
behavior.attachTo(_chart);
|
||||
_setupSelection([_s1D2, _s2D2]);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class FakeChart extends BaseChart {
|
||||
List<DatumDetails> getDatumDetails(SelectionModelType type) => [];
|
||||
|
||||
@override
|
||||
SeriesRenderer makeDefaultRenderer() => new FakeRenderer();
|
||||
SeriesRenderer makeDefaultRenderer() => FakeRenderer();
|
||||
|
||||
void requestOnDraw(List<MutableSeries> seriesList) {
|
||||
fireOnDraw(seriesList);
|
||||
@@ -68,7 +68,7 @@ void main() {
|
||||
|
||||
InitialSelection _makeBehavior(SelectionModelType selectionModelType,
|
||||
{List<String> selectedSeries, List<SeriesDatumConfig> selectedData}) {
|
||||
InitialSelection behavior = new InitialSelection(
|
||||
InitialSelection behavior = InitialSelection(
|
||||
selectionModelType: selectionModelType,
|
||||
selectedSeriesConfig: selectedSeries,
|
||||
selectedDataConfig: selectedData);
|
||||
@@ -79,27 +79,27 @@ void main() {
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
_chart = new FakeChart();
|
||||
_chart = FakeChart();
|
||||
|
||||
_series1 = new MutableSeries(new Series(
|
||||
_series1 = MutableSeries(Series(
|
||||
id: 'mySeries1',
|
||||
data: ['A', 'B', 'C', 'D'],
|
||||
domainFn: (dynamic datum, __) => datum,
|
||||
measureFn: (_, __) => 0));
|
||||
|
||||
_series2 = new MutableSeries(new Series(
|
||||
_series2 = MutableSeries(Series(
|
||||
id: 'mySeries2',
|
||||
data: ['W', 'X', 'Y', 'Z'],
|
||||
domainFn: (dynamic datum, __) => datum,
|
||||
measureFn: (_, __) => 0));
|
||||
|
||||
_series3 = new MutableSeries(new Series(
|
||||
_series3 = MutableSeries(Series(
|
||||
id: 'mySeries3',
|
||||
data: ['W', 'X', 'Y', 'Z'],
|
||||
domainFn: (dynamic datum, __) => datum,
|
||||
measureFn: (_, __) => 0));
|
||||
|
||||
_series4 = new MutableSeries(new Series(
|
||||
_series4 = MutableSeries(Series(
|
||||
id: 'mySeries4',
|
||||
data: ['W', 'X', 'Y', 'Z'],
|
||||
domainFn: (dynamic datum, __) => datum,
|
||||
@@ -108,7 +108,7 @@ void main() {
|
||||
|
||||
test('selects initial datum', () {
|
||||
_makeBehavior(infoSelectionType,
|
||||
selectedData: [new SeriesDatumConfig('mySeries1', 'C')]);
|
||||
selectedData: [SeriesDatumConfig('mySeries1', 'C')]);
|
||||
|
||||
_chart.requestOnDraw([_series1, _series2]);
|
||||
|
||||
@@ -123,8 +123,8 @@ void main() {
|
||||
|
||||
test('selects multiple initial data', () {
|
||||
_makeBehavior(infoSelectionType, selectedData: [
|
||||
new SeriesDatumConfig('mySeries1', 'C'),
|
||||
new SeriesDatumConfig('mySeries1', 'D')
|
||||
SeriesDatumConfig('mySeries1', 'C'),
|
||||
SeriesDatumConfig('mySeries1', 'D')
|
||||
]);
|
||||
|
||||
_chart.requestOnDraw([_series1, _series2]);
|
||||
@@ -168,7 +168,7 @@ void main() {
|
||||
|
||||
test('selects series and datum', () {
|
||||
_makeBehavior(infoSelectionType,
|
||||
selectedData: [new SeriesDatumConfig('mySeries1', 'C')],
|
||||
selectedData: [SeriesDatumConfig('mySeries1', 'C')],
|
||||
selectedSeries: ['mySeries4']);
|
||||
|
||||
_chart.requestOnDraw([_series1, _series2, _series3, _series4]);
|
||||
@@ -197,7 +197,7 @@ void main() {
|
||||
// Request a draw with a new series list.
|
||||
_chart.draw(
|
||||
[
|
||||
new Series(
|
||||
Series(
|
||||
id: 'mySeries2',
|
||||
data: ['W', 'X', 'Y', 'Z'],
|
||||
domainFn: (dynamic datum, __) => datum,
|
||||
|
||||
@@ -81,8 +81,7 @@ class MockSeriesRenderer extends BaseSeriesRenderer {
|
||||
|
||||
DatumDetails addPositionToDetailsForSeriesDatum(
|
||||
DatumDetails details, SeriesDatum seriesDatum) {
|
||||
return new DatumDetails.from(details,
|
||||
chartPosition: new Point<double>(0.0, 0.0));
|
||||
return DatumDetails.from(details, chartPosition: Point<double>(0.0, 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,14 +91,14 @@ void main() {
|
||||
MockSeriesRenderer _seriesRenderer;
|
||||
|
||||
MutableSeries<int> _series1;
|
||||
final _s1D1 = new MyRow(1, 11);
|
||||
final _s1D2 = new MyRow(2, 12);
|
||||
final _s1D3 = new MyRow(3, 13);
|
||||
final _s1D1 = MyRow(1, 11);
|
||||
final _s1D2 = MyRow(2, 12);
|
||||
final _s1D3 = MyRow(3, 13);
|
||||
|
||||
MutableSeries<int> _series2;
|
||||
final _s2D1 = new MyRow(4, 21);
|
||||
final _s2D2 = new MyRow(5, 22);
|
||||
final _s2D3 = new MyRow(6, 23);
|
||||
final _s2D1 = MyRow(4, 21);
|
||||
final _s2D2 = MyRow(5, 22);
|
||||
final _s2D3 = MyRow(6, 23);
|
||||
|
||||
List<DatumDetails> _mockGetSelectedDatumDetails(List<SeriesDatum> selection) {
|
||||
final details = <DatumDetails>[];
|
||||
@@ -136,27 +135,27 @@ void main() {
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
_chart = new MockChart();
|
||||
_chart = MockChart();
|
||||
|
||||
_seriesRenderer = new MockSeriesRenderer();
|
||||
_seriesRenderer = MockSeriesRenderer();
|
||||
|
||||
_selectionModel = new MockSelectionModel();
|
||||
_selectionModel = MockSelectionModel();
|
||||
when(_chart.getSelectionModel(SelectionModelType.info))
|
||||
.thenReturn(_selectionModel);
|
||||
|
||||
_series1 = new MutableSeries(new Series<MyRow, int>(
|
||||
_series1 = MutableSeries(Series<MyRow, int>(
|
||||
id: 's1',
|
||||
data: [_s1D1, _s1D2, _s1D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault))
|
||||
..measureFn = (_) => 0.0;
|
||||
|
||||
_series2 = new MutableSeries(new Series<MyRow, int>(
|
||||
_series2 = MutableSeries(Series<MyRow, int>(
|
||||
id: 's2',
|
||||
data: [_s2D1, _s2D2, _s2D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault))
|
||||
..measureFn = (_) => 0.0;
|
||||
});
|
||||
@@ -165,17 +164,17 @@ void main() {
|
||||
test('highlights the selected points', () {
|
||||
// Setup
|
||||
final behavior =
|
||||
new LinePointHighlighter(selectionModelType: SelectionModelType.info);
|
||||
final tester = new LinePointHighlighterTester(behavior);
|
||||
LinePointHighlighter(selectionModelType: SelectionModelType.info);
|
||||
final tester = LinePointHighlighterTester(behavior);
|
||||
behavior.attachTo(_chart);
|
||||
_setupSelection([
|
||||
new SeriesDatum(_series1, _s1D2),
|
||||
new SeriesDatum(_series2, _s2D2),
|
||||
SeriesDatum(_series1, _s1D2),
|
||||
SeriesDatum(_series2, _s2D2),
|
||||
]);
|
||||
|
||||
// Mock axes for returning fake domain locations.
|
||||
Axis domainAxis = new MockNumericAxis();
|
||||
Axis primaryMeasureAxis = new MockNumericAxis();
|
||||
Axis domainAxis = MockNumericAxis();
|
||||
Axis primaryMeasureAxis = MockNumericAxis();
|
||||
|
||||
_series1.setAttr(domainAxisKey, domainAxis);
|
||||
_series1.setAttr(measureAxisKey, primaryMeasureAxis);
|
||||
@@ -205,8 +204,8 @@ void main() {
|
||||
|
||||
test('listens to other selection models', () {
|
||||
// Setup
|
||||
final behavior = new LinePointHighlighter(
|
||||
selectionModelType: SelectionModelType.action);
|
||||
final behavior =
|
||||
LinePointHighlighter(selectionModelType: SelectionModelType.action);
|
||||
when(_chart.getSelectionModel(SelectionModelType.action))
|
||||
.thenReturn(_selectionModel);
|
||||
|
||||
@@ -221,8 +220,8 @@ void main() {
|
||||
test('leaves everything alone with no selection', () {
|
||||
// Setup
|
||||
final behavior =
|
||||
new LinePointHighlighter(selectionModelType: SelectionModelType.info);
|
||||
final tester = new LinePointHighlighterTester(behavior);
|
||||
LinePointHighlighter(selectionModelType: SelectionModelType.info);
|
||||
final tester = LinePointHighlighterTester(behavior);
|
||||
behavior.attachTo(_chart);
|
||||
_setupSelection([]);
|
||||
|
||||
@@ -246,11 +245,11 @@ void main() {
|
||||
test('cleans up', () {
|
||||
// Setup
|
||||
final behavior =
|
||||
new LinePointHighlighter(selectionModelType: SelectionModelType.info);
|
||||
LinePointHighlighter(selectionModelType: SelectionModelType.info);
|
||||
behavior.attachTo(_chart);
|
||||
_setupSelection([
|
||||
new SeriesDatum(_series1, _s1D2),
|
||||
new SeriesDatum(_series2, _s2D2),
|
||||
SeriesDatum(_series1, _s1D2),
|
||||
SeriesDatum(_series2, _s2D2),
|
||||
]);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -33,9 +33,9 @@ class MockContext extends Mock implements ChartContext {}
|
||||
class ConcreteChart extends LineChart {
|
||||
LifecycleListener<num> lastListener;
|
||||
|
||||
final _domainAxis = new ConcreteNumericAxis();
|
||||
final _domainAxis = ConcreteNumericAxis();
|
||||
|
||||
final _primaryMeasureAxis = new ConcreteNumericAxis();
|
||||
final _primaryMeasureAxis = ConcreteNumericAxis();
|
||||
|
||||
@override
|
||||
addLifecycleListener(LifecycleListener listener) {
|
||||
@@ -60,9 +60,9 @@ class ConcreteChart extends LineChart {
|
||||
class ConcreteNumericAxis extends Axis<num> {
|
||||
ConcreteNumericAxis()
|
||||
: super(
|
||||
tickProvider: new MockTickProvider(),
|
||||
tickFormatter: new NumericTickFormatter(),
|
||||
scale: new LinearScale(),
|
||||
tickProvider: MockTickProvider(),
|
||||
tickFormatter: NumericTickFormatter(),
|
||||
scale: LinearScale(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,16 +76,16 @@ void main() {
|
||||
ConcreteChart _chart;
|
||||
|
||||
Series<MyRow, int> _series1;
|
||||
final _s1D1 = new MyRow(0, 11);
|
||||
final _s1D2 = new MyRow(1, 12);
|
||||
final _s1D3 = new MyRow(2, 13);
|
||||
final _s1D1 = MyRow(0, 11);
|
||||
final _s1D2 = MyRow(1, 12);
|
||||
final _s1D3 = MyRow(2, 13);
|
||||
|
||||
Series<MyRow, int> _series2;
|
||||
final _s2D1 = new MyRow(3, 21);
|
||||
final _s2D2 = new MyRow(4, 22);
|
||||
final _s2D3 = new MyRow(5, 23);
|
||||
final _s2D1 = MyRow(3, 21);
|
||||
final _s2D2 = MyRow(4, 22);
|
||||
final _s2D3 = MyRow(5, 23);
|
||||
|
||||
const _dashPattern = const <int>[2, 3];
|
||||
const _dashPattern = <int>[2, 3];
|
||||
|
||||
List<RangeAnnotationSegment<num>> _annotations1;
|
||||
|
||||
@@ -94,9 +94,9 @@ void main() {
|
||||
List<LineAnnotationSegment<num>> _annotations3;
|
||||
|
||||
ConcreteChart _makeChart() {
|
||||
final chart = new ConcreteChart();
|
||||
final chart = ConcreteChart();
|
||||
|
||||
final context = new MockContext();
|
||||
final context = MockContext();
|
||||
when(context.chartContainerIsRtl).thenReturn(false);
|
||||
when(context.isRtl).thenReturn(false);
|
||||
chart.context = context;
|
||||
@@ -123,22 +123,22 @@ void main() {
|
||||
}
|
||||
|
||||
setUpAll(() {
|
||||
drawBounds = new Rectangle<int>(0, 0, 100, 100);
|
||||
domainAxisBounds = new Rectangle<int>(0, 0, 100, 100);
|
||||
measureAxisBounds = new Rectangle<int>(0, 0, 100, 100);
|
||||
drawBounds = Rectangle<int>(0, 0, 100, 100);
|
||||
domainAxisBounds = Rectangle<int>(0, 0, 100, 100);
|
||||
measureAxisBounds = Rectangle<int>(0, 0, 100, 100);
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
_chart = _makeChart();
|
||||
|
||||
_series1 = new Series<MyRow, int>(
|
||||
_series1 = Series<MyRow, int>(
|
||||
id: 's1',
|
||||
data: [_s1D1, _s1D2, _s1D3],
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
measureFn: (dynamic row, _) => row.count,
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault);
|
||||
|
||||
_series2 = new Series<MyRow, int>(
|
||||
_series2 = Series<MyRow, int>(
|
||||
id: 's2',
|
||||
data: [_s2D1, _s2D2, _s2D3],
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
@@ -146,31 +146,31 @@ void main() {
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault);
|
||||
|
||||
_annotations1 = [
|
||||
new RangeAnnotationSegment(1, 2, RangeAnnotationAxisType.domain,
|
||||
RangeAnnotationSegment(1, 2, RangeAnnotationAxisType.domain,
|
||||
startLabel: 'Ann 1'),
|
||||
new RangeAnnotationSegment(4, 5, RangeAnnotationAxisType.domain,
|
||||
RangeAnnotationSegment(4, 5, RangeAnnotationAxisType.domain,
|
||||
color: MaterialPalette.gray.shade200, endLabel: 'Ann 2'),
|
||||
new RangeAnnotationSegment(5, 5.5, RangeAnnotationAxisType.measure,
|
||||
RangeAnnotationSegment(5, 5.5, RangeAnnotationAxisType.measure,
|
||||
startLabel: 'Really long tick start label',
|
||||
endLabel: 'Really long tick end label'),
|
||||
new RangeAnnotationSegment(10, 15, RangeAnnotationAxisType.measure,
|
||||
RangeAnnotationSegment(10, 15, RangeAnnotationAxisType.measure,
|
||||
startLabel: 'Ann 4 Start', endLabel: 'Ann 4 End'),
|
||||
new RangeAnnotationSegment(16, 22, RangeAnnotationAxisType.measure,
|
||||
RangeAnnotationSegment(16, 22, RangeAnnotationAxisType.measure,
|
||||
startLabel: 'Ann 5 Start', endLabel: 'Ann 5 End'),
|
||||
];
|
||||
|
||||
_annotations2 = [
|
||||
new RangeAnnotationSegment(1, 2, RangeAnnotationAxisType.domain),
|
||||
new RangeAnnotationSegment(4, 5, RangeAnnotationAxisType.domain,
|
||||
RangeAnnotationSegment(1, 2, RangeAnnotationAxisType.domain),
|
||||
RangeAnnotationSegment(4, 5, RangeAnnotationAxisType.domain,
|
||||
color: MaterialPalette.gray.shade200),
|
||||
new RangeAnnotationSegment(8, 10, RangeAnnotationAxisType.domain,
|
||||
RangeAnnotationSegment(8, 10, RangeAnnotationAxisType.domain,
|
||||
color: MaterialPalette.gray.shade300),
|
||||
];
|
||||
|
||||
_annotations3 = [
|
||||
new LineAnnotationSegment(1, RangeAnnotationAxisType.measure,
|
||||
LineAnnotationSegment(1, RangeAnnotationAxisType.measure,
|
||||
startLabel: 'Ann 1 Start', endLabel: 'Ann 1 End'),
|
||||
new LineAnnotationSegment(4, RangeAnnotationAxisType.measure,
|
||||
LineAnnotationSegment(4, RangeAnnotationAxisType.measure,
|
||||
startLabel: 'Ann 2 Start',
|
||||
endLabel: 'Ann 2 End',
|
||||
color: MaterialPalette.gray.shade200,
|
||||
@@ -181,8 +181,8 @@ void main() {
|
||||
group('RangeAnnotation', () {
|
||||
test('renders the annotations', () {
|
||||
// Setup
|
||||
final behavior = new RangeAnnotation<num>(_annotations1);
|
||||
final tester = new RangeAnnotationTester(behavior);
|
||||
final behavior = RangeAnnotation<num>(_annotations1);
|
||||
final tester = RangeAnnotationTester(behavior);
|
||||
behavior.attachTo(_chart);
|
||||
|
||||
final seriesList = [_series1, _series2];
|
||||
@@ -252,8 +252,8 @@ void main() {
|
||||
|
||||
test('extends the domain axis when annotations fall outside the range', () {
|
||||
// Setup
|
||||
final behavior = new RangeAnnotation<num>(_annotations2);
|
||||
final tester = new RangeAnnotationTester(behavior);
|
||||
final behavior = RangeAnnotation<num>(_annotations2);
|
||||
final tester = RangeAnnotationTester(behavior);
|
||||
behavior.attachTo(_chart);
|
||||
|
||||
final seriesList = [_series1, _series2];
|
||||
@@ -294,8 +294,8 @@ void main() {
|
||||
|
||||
test('test dash pattern equality', () {
|
||||
// Setup
|
||||
final behavior = new RangeAnnotation<num>(_annotations3);
|
||||
final tester = new RangeAnnotationTester(behavior);
|
||||
final behavior = RangeAnnotation<num>(_annotations3);
|
||||
final tester = RangeAnnotationTester(behavior);
|
||||
behavior.attachTo(_chart);
|
||||
|
||||
final seriesList = [_series1, _series2];
|
||||
@@ -332,7 +332,7 @@ void main() {
|
||||
|
||||
test('cleans up', () {
|
||||
// Setup
|
||||
final behavior = new RangeAnnotation<num>(_annotations2);
|
||||
final behavior = RangeAnnotation<num>(_annotations2);
|
||||
behavior.attachTo(_chart);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -51,7 +51,7 @@ void main() {
|
||||
LockSelection _makeLockSelectionBehavior(
|
||||
SelectionModelType selectionModelType) {
|
||||
LockSelection behavior =
|
||||
new LockSelection(selectionModelType: selectionModelType);
|
||||
LockSelection(selectionModelType: selectionModelType);
|
||||
|
||||
behavior.attachTo(_chart);
|
||||
|
||||
@@ -65,10 +65,10 @@ void main() {
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
_hoverSelectionModel = new MockSelectionModel();
|
||||
_clickSelectionModel = new MockSelectionModel();
|
||||
_hoverSelectionModel = MockSelectionModel();
|
||||
_clickSelectionModel = MockSelectionModel();
|
||||
|
||||
_chart = new MockChart();
|
||||
_chart = MockChart();
|
||||
when(_chart.getSelectionModel(SelectionModelType.info))
|
||||
.thenReturn(_hoverSelectionModel);
|
||||
when(_chart.getSelectionModel(SelectionModelType.action))
|
||||
@@ -79,7 +79,7 @@ void main() {
|
||||
test('can lock model with a selection', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeLockSelectionBehavior(SelectionModelType.info);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true);
|
||||
|
||||
when(_hoverSelectionModel.hasAnySelection).thenReturn(true);
|
||||
@@ -98,7 +98,7 @@ void main() {
|
||||
test('can lock and unlock model', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeLockSelectionBehavior(SelectionModelType.info);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true);
|
||||
|
||||
when(_hoverSelectionModel.hasAnySelection).thenReturn(true);
|
||||
@@ -125,7 +125,7 @@ void main() {
|
||||
test('does not lock model with empty selection', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeLockSelectionBehavior(SelectionModelType.info);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true);
|
||||
|
||||
when(_hoverSelectionModel.hasAnySelection).thenReturn(false);
|
||||
@@ -146,7 +146,7 @@ void main() {
|
||||
test('detach removes listener', () {
|
||||
// Setup
|
||||
final behavior = _makeLockSelectionBehavior(SelectionModelType.info);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true);
|
||||
expect(_chart.lastListener, isNotNull);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
{bool expandToDomain,
|
||||
bool selectClosestSeries,
|
||||
int maximumDomainDistancePx}) {
|
||||
SelectNearest<String> behavior = new SelectNearest<String>(
|
||||
SelectNearest<String> behavior = SelectNearest<String>(
|
||||
selectionModelType: selectionModelType,
|
||||
expandToDomain: expandToDomain,
|
||||
selectClosestSeries: selectClosestSeries,
|
||||
@@ -95,10 +95,10 @@ void main() {
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
_hoverSelectionModel = new MockSelectionModel();
|
||||
_clickSelectionModel = new MockSelectionModel();
|
||||
_hoverSelectionModel = MockSelectionModel();
|
||||
_clickSelectionModel = MockSelectionModel();
|
||||
|
||||
_chart = new MockChart();
|
||||
_chart = MockChart();
|
||||
when(_chart.getSelectionModel(SelectionModelType.info))
|
||||
.thenReturn(_hoverSelectionModel);
|
||||
when(_chart.getSelectionModel(SelectionModelType.action))
|
||||
@@ -106,25 +106,25 @@ void main() {
|
||||
|
||||
_series1Data = ['myDomain1', 'myDomain2', 'myDomain3'];
|
||||
|
||||
_series1 = new MutableSeries<String>(new Series(
|
||||
_series1 = MutableSeries<String>(Series(
|
||||
id: 'mySeries1',
|
||||
data: ['myDatum1', 'myDatum2', 'myDatum3'],
|
||||
domainFn: (_, int i) => _series1Data[i],
|
||||
domainFn: (_, i) => _series1Data[i],
|
||||
measureFn: (_, __) => 0));
|
||||
|
||||
_details1 = new DatumDetails(
|
||||
_details1 = DatumDetails(
|
||||
datum: 'myDatum1',
|
||||
domain: 'myDomain1',
|
||||
series: _series1,
|
||||
domainDistance: 10.0,
|
||||
measureDistance: 20.0);
|
||||
_details2 = new DatumDetails(
|
||||
_details2 = DatumDetails(
|
||||
datum: 'myDatum2',
|
||||
domain: 'myDomain2',
|
||||
series: _series1,
|
||||
domainDistance: 10.0,
|
||||
measureDistance: 20.0);
|
||||
_details3 = new DatumDetails(
|
||||
_details3 = DatumDetails(
|
||||
datum: 'myDatum3',
|
||||
domain: 'myDomain3',
|
||||
series: _series1,
|
||||
@@ -133,13 +133,13 @@ void main() {
|
||||
|
||||
_series2Data = ['myDomain1'];
|
||||
|
||||
_series2 = new MutableSeries<String>(new Series(
|
||||
_series2 = MutableSeries<String>(Series(
|
||||
id: 'mySeries2',
|
||||
data: ['myDatum1s2'],
|
||||
domainFn: (_, int i) => _series2Data[i],
|
||||
domainFn: (_, i) => _series2Data[i],
|
||||
measureFn: (_, __) => 0));
|
||||
|
||||
_details1Series2 = new DatumDetails(
|
||||
_details1Series2 = DatumDetails(
|
||||
datum: 'myDatum1s2',
|
||||
domain: 'myDomain1',
|
||||
series: _series2,
|
||||
@@ -154,7 +154,7 @@ void main() {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.hover,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: point,
|
||||
isWithinRenderer: true,
|
||||
@@ -166,7 +166,7 @@ void main() {
|
||||
|
||||
// Validate
|
||||
verify(_hoverSelectionModel.updateSelection(
|
||||
[new SeriesDatum(_series1, _details1.datum)], [_series1]));
|
||||
[SeriesDatum(_series1, _details1.datum)], [_series1]));
|
||||
verifyNoMoreInteractions(_hoverSelectionModel);
|
||||
verifyNoMoreInteractions(_clickSelectionModel);
|
||||
// Shouldn't be listening to anything else.
|
||||
@@ -178,7 +178,7 @@ void main() {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionModelType.action, SelectionTrigger.tap,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: point,
|
||||
isWithinRenderer: true,
|
||||
@@ -191,7 +191,7 @@ void main() {
|
||||
|
||||
// Validate
|
||||
verify(_clickSelectionModel.updateSelection(
|
||||
[new SeriesDatum(_series1, _details1.datum)], [_series1]));
|
||||
[SeriesDatum(_series1, _details1.datum)], [_series1]));
|
||||
verifyNoMoreInteractions(_hoverSelectionModel);
|
||||
verifyNoMoreInteractions(_clickSelectionModel);
|
||||
});
|
||||
@@ -201,28 +201,28 @@ void main() {
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.pressHold,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1],
|
||||
seriesList: [_series1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(200.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(200.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1],
|
||||
seriesList: [_series1]);
|
||||
|
||||
Point<double> updatePoint2 = new Point(300.0, 100.0);
|
||||
Point<double> updatePoint2 = Point(300.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint2,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2],
|
||||
seriesList: [_series1]);
|
||||
|
||||
Point<double> endPoint = new Point(400.0, 100.0);
|
||||
Point<double> endPoint = Point(400.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -239,10 +239,10 @@ void main() {
|
||||
// Validate
|
||||
// details1 was tripped 2 times (startPoint & updatePoint1)
|
||||
verify(_hoverSelectionModel.updateSelection(
|
||||
[new SeriesDatum(_series1, _details1.datum)], [_series1])).called(2);
|
||||
[SeriesDatum(_series1, _details1.datum)], [_series1])).called(2);
|
||||
// details2 was tripped for updatePoint2
|
||||
verify(_hoverSelectionModel.updateSelection(
|
||||
[new SeriesDatum(_series1, _details2.datum)], [_series1]));
|
||||
[SeriesDatum(_series1, _details2.datum)], [_series1]));
|
||||
// dragEnd deselects even though we are over details3.
|
||||
verify(_hoverSelectionModel.updateSelection([], []));
|
||||
verifyNoMoreInteractions(_hoverSelectionModel);
|
||||
@@ -254,21 +254,21 @@ void main() {
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.longPressHold,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1],
|
||||
seriesList: [_series1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(200.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(200.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2],
|
||||
seriesList: [_series1]);
|
||||
|
||||
Point<double> endPoint = new Point(400.0, 100.0);
|
||||
Point<double> endPoint = Point(400.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -290,9 +290,9 @@ void main() {
|
||||
// Validate
|
||||
// details1 was tripped 2 times (longPress & dragStart)
|
||||
verify(_hoverSelectionModel.updateSelection(
|
||||
[new SeriesDatum(_series1, _details1.datum)], [_series1])).called(2);
|
||||
[SeriesDatum(_series1, _details1.datum)], [_series1])).called(2);
|
||||
verify(_hoverSelectionModel.updateSelection(
|
||||
[new SeriesDatum(_series1, _details2.datum)], [_series1]));
|
||||
[SeriesDatum(_series1, _details2.datum)], [_series1]));
|
||||
// dragEnd deselects even though we are over details3.
|
||||
verify(_hoverSelectionModel.updateSelection([], []));
|
||||
verifyNoMoreInteractions(_hoverSelectionModel);
|
||||
@@ -304,21 +304,21 @@ void main() {
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.longPressHold,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1],
|
||||
seriesList: [_series1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(200.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(200.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2],
|
||||
seriesList: [_series1]);
|
||||
|
||||
Point<double> endPoint = new Point(400.0, 100.0);
|
||||
Point<double> endPoint = Point(400.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -343,7 +343,7 @@ void main() {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.hover,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true, respondWithDetails: [
|
||||
_details1,
|
||||
_details1Series2,
|
||||
@@ -357,8 +357,8 @@ void main() {
|
||||
|
||||
// Validate
|
||||
verify(_hoverSelectionModel.updateSelection([
|
||||
new SeriesDatum(_series1, _details1.datum),
|
||||
new SeriesDatum(_series2, _details1Series2.datum)
|
||||
SeriesDatum(_series1, _details1.datum),
|
||||
SeriesDatum(_series2, _details1Series2.datum)
|
||||
], [
|
||||
_series1
|
||||
]));
|
||||
@@ -370,7 +370,7 @@ void main() {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.hover,
|
||||
expandToDomain: false, selectClosestSeries: true);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true, respondWithDetails: [
|
||||
_details1,
|
||||
_details1Series2,
|
||||
@@ -384,7 +384,7 @@ void main() {
|
||||
|
||||
// Validate
|
||||
verify(_hoverSelectionModel.updateSelection(
|
||||
[new SeriesDatum(_series1, _details1.datum)], [_series1]));
|
||||
[SeriesDatum(_series1, _details1.datum)], [_series1]));
|
||||
verifyNoMoreInteractions(_hoverSelectionModel);
|
||||
verifyNoMoreInteractions(_clickSelectionModel);
|
||||
});
|
||||
@@ -393,7 +393,7 @@ void main() {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.hover,
|
||||
expandToDomain: true, selectClosestSeries: false);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true, respondWithDetails: [
|
||||
_details1,
|
||||
_details1Series2,
|
||||
@@ -407,8 +407,8 @@ void main() {
|
||||
|
||||
// Validate
|
||||
verify(_hoverSelectionModel.updateSelection([
|
||||
new SeriesDatum(_series1, _details1.datum),
|
||||
new SeriesDatum(_series2, _details1Series2.datum)
|
||||
SeriesDatum(_series1, _details1.datum),
|
||||
SeriesDatum(_series2, _details1Series2.datum)
|
||||
], []));
|
||||
verifyNoMoreInteractions(_hoverSelectionModel);
|
||||
verifyNoMoreInteractions(_clickSelectionModel);
|
||||
@@ -420,7 +420,7 @@ void main() {
|
||||
|
||||
_makeBehavior(SelectionModelType.info, SelectionTrigger.hover,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true, respondWithDetails: [
|
||||
_details1,
|
||||
_details1Series2,
|
||||
@@ -434,7 +434,7 @@ void main() {
|
||||
|
||||
// Validate
|
||||
verify(_hoverSelectionModel.updateSelection([
|
||||
new SeriesDatum(_series1, _details1.datum),
|
||||
SeriesDatum(_series1, _details1.datum),
|
||||
], [
|
||||
_series1
|
||||
]));
|
||||
@@ -448,7 +448,7 @@ void main() {
|
||||
expandToDomain: true,
|
||||
selectClosestSeries: true,
|
||||
maximumDomainDistancePx: 1);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(forPoint: point, isWithinRenderer: true, respondWithDetails: [
|
||||
_details1,
|
||||
_details1Series2,
|
||||
@@ -473,7 +473,7 @@ void main() {
|
||||
SelectNearest behavior = _makeBehavior(
|
||||
SelectionModelType.info, SelectionTrigger.hover,
|
||||
expandToDomain: true, selectClosestSeries: true);
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: point,
|
||||
isWithinRenderer: true,
|
||||
|
||||
@@ -86,42 +86,42 @@ class ConcreteSeriesLegend<D> extends SeriesLegend<D> {
|
||||
|
||||
void main() {
|
||||
MutableSeries<String> series1;
|
||||
final s1D1 = new MyRow('s1d1', 11);
|
||||
final s1D2 = new MyRow('s1d2', 12);
|
||||
final s1D3 = new MyRow('s1d3', 13);
|
||||
final s1D1 = MyRow('s1d1', 11);
|
||||
final s1D2 = MyRow('s1d2', 12);
|
||||
final s1D3 = MyRow('s1d3', 13);
|
||||
|
||||
MutableSeries<String> series2;
|
||||
final s2D1 = new MyRow('s2d1', 21);
|
||||
final s2D2 = new MyRow('s2d2', 22);
|
||||
final s2D3 = new MyRow('s2d3', 23);
|
||||
final s2D1 = MyRow('s2d1', 21);
|
||||
final s2D2 = MyRow('s2d2', 22);
|
||||
final s2D3 = MyRow('s2d3', 23);
|
||||
|
||||
final blue = new Color(r: 0x21, g: 0x96, b: 0xF3);
|
||||
final red = new Color(r: 0xF4, g: 0x43, b: 0x36);
|
||||
final blue = Color(r: 0x21, g: 0x96, b: 0xF3);
|
||||
final red = Color(r: 0xF4, g: 0x43, b: 0x36);
|
||||
|
||||
ConcreteChart chart;
|
||||
|
||||
setUp(() {
|
||||
series1 = new MutableSeries(new Series<MyRow, String>(
|
||||
series1 = MutableSeries(Series<MyRow, String>(
|
||||
id: 's1',
|
||||
data: [s1D1, s1D2, s1D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
colorFn: (_, __) => blue));
|
||||
|
||||
series2 = new MutableSeries(new Series<MyRow, String>(
|
||||
series2 = MutableSeries(Series<MyRow, String>(
|
||||
id: 's2',
|
||||
data: [s2D1, s2D2, s2D3],
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.count,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.count,
|
||||
colorFn: (_, __) => red));
|
||||
});
|
||||
|
||||
test('Legend entries created on chart post process', () {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final legend = new SeriesLegend<String>(selectionModelType: selectionType);
|
||||
final legend = SeriesLegend<String>(selectionModelType: selectionType);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
@@ -144,11 +144,11 @@ void main() {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final legend =
|
||||
new ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
|
||||
legend.defaultHiddenSeries = ['s2'];
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
@@ -164,9 +164,9 @@ void main() {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final legend =
|
||||
new ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
legend.hideSeries('s1');
|
||||
chart.callOnDraw();
|
||||
@@ -184,9 +184,9 @@ void main() {
|
||||
final seriesList2 = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final legend =
|
||||
new ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
|
||||
// First hide the series.
|
||||
@@ -219,9 +219,9 @@ void main() {
|
||||
test('selected series legend entry is updated', () {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final legend = new SeriesLegend<String>(selectionModelType: selectionType);
|
||||
final legend = SeriesLegend<String>(selectionModelType: selectionType);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
@@ -245,9 +245,9 @@ void main() {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final legend =
|
||||
new ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
ConcreteSeriesLegend<String>(selectionModelType: selectionType);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
|
||||
// First hide the series.
|
||||
@@ -304,23 +304,22 @@ void main() {
|
||||
test('generated legend entries use provided formatters', () {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final measureFormatter =
|
||||
(num value) => 'measure ${value?.toStringAsFixed(0)}';
|
||||
final measureFormatter = (value) => 'measure ${value?.toStringAsFixed(0)}';
|
||||
final secondaryMeasureFormatter =
|
||||
(num value) => 'secondary ${value?.toStringAsFixed(0)}';
|
||||
final legend = new SeriesLegend<String>(
|
||||
(value) => 'secondary ${value?.toStringAsFixed(0)}';
|
||||
final legend = SeriesLegend<String>(
|
||||
selectionModelType: selectionType,
|
||||
measureFormatter: measureFormatter,
|
||||
secondaryMeasureFormatter: secondaryMeasureFormatter);
|
||||
|
||||
series2.setAttr(measureAxisIdKey, 'secondaryMeasureAxisId');
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
chart.callOnPostProcess();
|
||||
chart.getSelectionModel(selectionType).updateSelection(
|
||||
[new SeriesDatum(series1, s1D1), new SeriesDatum(series2, s2D1)],
|
||||
[SeriesDatum(series1, s1D1), SeriesDatum(series2, s2D1)],
|
||||
[series1, series2]);
|
||||
|
||||
final legendEntries = legend.legendState.legendEntries;
|
||||
@@ -341,13 +340,13 @@ void main() {
|
||||
test('series legend - show measure sum when there is no selection', () {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final measureFormatter = (num value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = new SeriesLegend<String>(
|
||||
final measureFormatter = (value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = SeriesLegend<String>(
|
||||
selectionModelType: selectionType,
|
||||
legendDefaultMeasure: LegendDefaultMeasure.sum,
|
||||
measureFormatter: measureFormatter);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
@@ -373,13 +372,13 @@ void main() {
|
||||
test('series legend - show measure average when there is no selection', () {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final measureFormatter = (num value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = new SeriesLegend<String>(
|
||||
final measureFormatter = (value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = SeriesLegend<String>(
|
||||
selectionModelType: selectionType,
|
||||
legendDefaultMeasure: LegendDefaultMeasure.average,
|
||||
measureFormatter: measureFormatter);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
@@ -405,13 +404,13 @@ void main() {
|
||||
test('series legend - show first measure when there is no selection', () {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final measureFormatter = (num value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = new SeriesLegend<String>(
|
||||
final measureFormatter = (value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = SeriesLegend<String>(
|
||||
selectionModelType: selectionType,
|
||||
legendDefaultMeasure: LegendDefaultMeasure.firstValue,
|
||||
measureFormatter: measureFormatter);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
@@ -437,13 +436,13 @@ void main() {
|
||||
test('series legend - show last measure when there is no selection', () {
|
||||
final seriesList = [series1, series2];
|
||||
final selectionType = SelectionModelType.info;
|
||||
final measureFormatter = (num value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = new SeriesLegend<String>(
|
||||
final measureFormatter = (value) => '${value?.toStringAsFixed(0)}';
|
||||
final legend = SeriesLegend<String>(
|
||||
selectionModelType: selectionType,
|
||||
legendDefaultMeasure: LegendDefaultMeasure.lastValue,
|
||||
measureFormatter: measureFormatter);
|
||||
|
||||
chart = new ConcreteChart(seriesList);
|
||||
chart = ConcreteChart(seriesList);
|
||||
legend.attachTo(chart);
|
||||
chart.callOnDraw();
|
||||
chart.callOnPreProcess();
|
||||
|
||||
@@ -88,21 +88,21 @@ void main() {
|
||||
SliderListenerCallback onChangeCallback,
|
||||
bool snapToDatum = false,
|
||||
SliderHandlePosition handlePosition = SliderHandlePosition.middle}) {
|
||||
Slider behavior = new Slider(
|
||||
Slider behavior = Slider(
|
||||
eventTrigger: eventTrigger,
|
||||
initialDomainValue: initialDomainValue,
|
||||
onChangeCallback: onChangeCallback,
|
||||
snapToDatum: snapToDatum,
|
||||
style: new SliderStyle(
|
||||
style: SliderStyle(
|
||||
handleOffset: handleOffset, handlePosition: handlePosition));
|
||||
|
||||
behavior.attachTo(_chart);
|
||||
|
||||
tester = new SliderTester(behavior);
|
||||
tester = SliderTester(behavior);
|
||||
|
||||
// Mock out chart layout by assigning bounds to the layout view.
|
||||
tester.layout(
|
||||
new Rectangle<int>(0, 0, 200, 200), new Rectangle<int>(0, 0, 200, 200));
|
||||
Rectangle<int>(0, 0, 200, 200), Rectangle<int>(0, 0, 200, 200));
|
||||
|
||||
return behavior;
|
||||
}
|
||||
@@ -123,32 +123,32 @@ void main() {
|
||||
}
|
||||
|
||||
setUp(() {
|
||||
_chart = new MockChart();
|
||||
_chart = MockChart();
|
||||
|
||||
_domainAxis = new MockDomainAxis();
|
||||
_domainAxis = MockDomainAxis();
|
||||
|
||||
_series1 = new MutableSeries(new Series(
|
||||
_series1 = MutableSeries(Series(
|
||||
id: 'mySeries1',
|
||||
data: [],
|
||||
domainFn: (_, __) {},
|
||||
measureFn: (_, __) => 0));
|
||||
|
||||
_details1 = new DatumDetails(
|
||||
chartPosition: new Point(20.0, 80.0),
|
||||
_details1 = DatumDetails(
|
||||
chartPosition: Point(20.0, 80.0),
|
||||
datum: 'myDatum1',
|
||||
domain: 1.0,
|
||||
series: _series1,
|
||||
domainDistance: 10.0,
|
||||
measureDistance: 20.0);
|
||||
_details2 = new DatumDetails(
|
||||
chartPosition: new Point(40.0, 80.0),
|
||||
_details2 = DatumDetails(
|
||||
chartPosition: Point(40.0, 80.0),
|
||||
datum: 'myDatum2',
|
||||
domain: 2.0,
|
||||
series: _series1,
|
||||
domainDistance: 10.0,
|
||||
measureDistance: 20.0);
|
||||
_details3 = new DatumDetails(
|
||||
chartPosition: new Point(90.0, 80.0),
|
||||
_details3 = DatumDetails(
|
||||
chartPosition: Point(90.0, 80.0),
|
||||
datum: 'myDatum3',
|
||||
domain: 4.5,
|
||||
series: _series1,
|
||||
@@ -160,28 +160,28 @@ void main() {
|
||||
test('can listen to tap and drag', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionTrigger.tapAndDrag,
|
||||
handleOffset: new Point<double>(0.0, 0.0),
|
||||
handleSize: new Rectangle<int>(0, 0, 10, 20));
|
||||
handleOffset: Point<double>(0.0, 0.0),
|
||||
handleSize: Rectangle<int>(0, 0, 10, 20));
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(50.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(50.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2]);
|
||||
|
||||
Point<double> updatePoint2 = new Point(100.0, 100.0);
|
||||
Point<double> updatePoint2 = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint2,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details3]);
|
||||
|
||||
Point<double> endPoint = new Point(120.0, 100.0);
|
||||
Point<double> endPoint = Point(120.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -197,60 +197,60 @@ void main() {
|
||||
_chart.lastGestureListener.onDragStart(startPoint);
|
||||
expect(tester.domainCenterPoint, equals(startPoint));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint1, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint1));
|
||||
expect(tester.domainValue, equals(2.5));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(45, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(45, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint2, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint2));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag the point to the end point.
|
||||
_chart.lastGestureListener.onDragUpdate(endPoint, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(endPoint));
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, 90, 10, 20)));
|
||||
|
||||
// Simulate onDragEnd.
|
||||
_chart.lastGestureListener.onDragEnd(endPoint, 1.0, 1.0);
|
||||
|
||||
expect(tester.domainCenterPoint, equals(endPoint));
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, 90, 10, 20)));
|
||||
});
|
||||
|
||||
test('slider handle can render at top', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionTrigger.tapAndDrag,
|
||||
handleOffset: new Point<double>(0.0, 0.0),
|
||||
handleSize: new Rectangle<int>(0, 0, 10, 20),
|
||||
handleOffset: Point<double>(0.0, 0.0),
|
||||
handleSize: Rectangle<int>(0, 0, 10, 20),
|
||||
handlePosition: SliderHandlePosition.top);
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 0.0);
|
||||
Point<double> startPoint = Point(100.0, 0.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(50.0, 0.0);
|
||||
Point<double> updatePoint1 = Point(50.0, 0.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2]);
|
||||
|
||||
Point<double> updatePoint2 = new Point(100.0, 0.0);
|
||||
Point<double> updatePoint2 = Point(100.0, 0.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint2,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details3]);
|
||||
|
||||
Point<double> endPoint = new Point(120.0, 0.0);
|
||||
Point<double> endPoint = Point(120.0, 0.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -265,55 +265,55 @@ void main() {
|
||||
// Start the drag.
|
||||
_chart.lastGestureListener.onDragStart(startPoint);
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, -10, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, -10, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint1, 1.0);
|
||||
expect(tester.domainValue, equals(2.5));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(45, -10, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(45, -10, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint2, 1.0);
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, -10, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, -10, 10, 20)));
|
||||
|
||||
// Drag the point to the end point.
|
||||
_chart.lastGestureListener.onDragUpdate(endPoint, 1.0);
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, -10, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, -10, 10, 20)));
|
||||
|
||||
// Simulate onDragEnd.
|
||||
_chart.lastGestureListener.onDragEnd(endPoint, 1.0, 1.0);
|
||||
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, -10, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, -10, 10, 20)));
|
||||
});
|
||||
|
||||
test('can listen to press hold', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionTrigger.pressHold,
|
||||
handleOffset: new Point<double>(0.0, 0.0),
|
||||
handleSize: new Rectangle<int>(0, 0, 10, 20));
|
||||
handleOffset: Point<double>(0.0, 0.0),
|
||||
handleSize: Rectangle<int>(0, 0, 10, 20));
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(50.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(50.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2]);
|
||||
|
||||
Point<double> updatePoint2 = new Point(100.0, 100.0);
|
||||
Point<double> updatePoint2 = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint2,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details3]);
|
||||
|
||||
Point<double> endPoint = new Point(120.0, 100.0);
|
||||
Point<double> endPoint = Point(120.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -329,59 +329,59 @@ void main() {
|
||||
_chart.lastGestureListener.onDragStart(startPoint);
|
||||
expect(tester.domainCenterPoint, equals(startPoint));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint1, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint1));
|
||||
expect(tester.domainValue, equals(2.5));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(45, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(45, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint2, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint2));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag the point to the end point.
|
||||
_chart.lastGestureListener.onDragUpdate(endPoint, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(endPoint));
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, 90, 10, 20)));
|
||||
|
||||
// Simulate onDragEnd.
|
||||
_chart.lastGestureListener.onDragEnd(endPoint, 1.0, 1.0);
|
||||
|
||||
expect(tester.domainCenterPoint, equals(endPoint));
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, 90, 10, 20)));
|
||||
});
|
||||
|
||||
test('can listen to long press hold', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionTrigger.longPressHold,
|
||||
handleOffset: new Point<double>(0.0, 0.0),
|
||||
handleSize: new Rectangle<int>(0, 0, 10, 20));
|
||||
handleOffset: Point<double>(0.0, 0.0),
|
||||
handleSize: Rectangle<int>(0, 0, 10, 20));
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(50.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(50.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2]);
|
||||
|
||||
Point<double> updatePoint2 = new Point(100.0, 100.0);
|
||||
Point<double> updatePoint2 = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint2,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details3]);
|
||||
|
||||
Point<double> endPoint = new Point(120.0, 100.0);
|
||||
Point<double> endPoint = Point(120.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -397,59 +397,59 @@ void main() {
|
||||
_chart.lastGestureListener.onDragStart(startPoint);
|
||||
expect(tester.domainCenterPoint, equals(startPoint));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint1, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint1));
|
||||
expect(tester.domainValue, equals(2.5));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(45, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(45, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint2, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint2));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag the point to the end point.
|
||||
_chart.lastGestureListener.onDragUpdate(endPoint, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(endPoint));
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, 90, 10, 20)));
|
||||
|
||||
// Simulate onDragEnd.
|
||||
_chart.lastGestureListener.onDragEnd(endPoint, 1.0, 1.0);
|
||||
|
||||
expect(tester.domainCenterPoint, equals(endPoint));
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, 90, 10, 20)));
|
||||
});
|
||||
|
||||
test('no position update before long press', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionTrigger.longPressHold,
|
||||
handleOffset: new Point<double>(0.0, 0.0),
|
||||
handleSize: new Rectangle<int>(0, 0, 10, 20));
|
||||
handleOffset: Point<double>(0.0, 0.0),
|
||||
handleSize: Rectangle<int>(0, 0, 10, 20));
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(50.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(50.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2]);
|
||||
|
||||
Point<double> updatePoint2 = new Point(100.0, 100.0);
|
||||
Point<double> updatePoint2 = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint2,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details3]);
|
||||
|
||||
Point<double> endPoint = new Point(120.0, 100.0);
|
||||
Point<double> endPoint = Point(120.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -464,48 +464,48 @@ void main() {
|
||||
_chart.lastGestureListener.onDragStart(startPoint);
|
||||
expect(tester.domainCenterPoint, equals(startPoint));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag the point to the end point.
|
||||
_chart.lastGestureListener.onDragUpdate(endPoint, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(startPoint));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Simulate onDragEnd.
|
||||
_chart.lastGestureListener.onDragEnd(endPoint, 1.0, 1.0);
|
||||
|
||||
expect(tester.domainCenterPoint, equals(startPoint));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
});
|
||||
|
||||
test('can snap to datum', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
_makeBehavior(SelectionTrigger.tapAndDrag,
|
||||
handleOffset: new Point<double>(0.0, 0.0),
|
||||
handleSize: new Rectangle<int>(0, 0, 10, 20),
|
||||
handleOffset: Point<double>(0.0, 0.0),
|
||||
handleSize: Rectangle<int>(0, 0, 10, 20),
|
||||
snapToDatum: true);
|
||||
|
||||
Point<double> startPoint = new Point(100.0, 100.0);
|
||||
Point<double> startPoint = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: startPoint,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details1]);
|
||||
|
||||
Point<double> updatePoint1 = new Point(50.0, 100.0);
|
||||
Point<double> updatePoint1 = Point(50.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint1,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details2]);
|
||||
|
||||
Point<double> updatePoint2 = new Point(100.0, 100.0);
|
||||
Point<double> updatePoint2 = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: updatePoint2,
|
||||
isWithinRenderer: true,
|
||||
respondWithDetails: [_details3]);
|
||||
|
||||
Point<double> endPoint = new Point(120.0, 100.0);
|
||||
Point<double> endPoint = Point(120.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: endPoint,
|
||||
isWithinRenderer: true,
|
||||
@@ -521,33 +521,33 @@ void main() {
|
||||
_chart.lastGestureListener.onDragStart(startPoint);
|
||||
expect(tester.domainCenterPoint, equals(startPoint));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point. The slider should follow the mouse during
|
||||
// each drag update.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint1, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint1));
|
||||
expect(tester.domainValue, equals(2.5));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(45, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(45, 90, 10, 20)));
|
||||
|
||||
// Drag to first update point.
|
||||
_chart.lastGestureListener.onDragUpdate(updatePoint2, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(updatePoint2));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Drag the point to the end point.
|
||||
_chart.lastGestureListener.onDragUpdate(endPoint, 1.0);
|
||||
expect(tester.domainCenterPoint, equals(endPoint));
|
||||
expect(tester.domainValue, equals(6.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(115, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(115, 90, 10, 20)));
|
||||
|
||||
// Simulate onDragEnd. This is where we expect the snap to occur.
|
||||
_chart.lastGestureListener.onDragEnd(endPoint, 1.0, 1.0);
|
||||
|
||||
expect(tester.domainCenterPoint, equals(new Point<int>(90, 100)));
|
||||
expect(tester.domainCenterPoint, equals(Point<int>(90, 100)));
|
||||
expect(tester.domainValue, equals(4.5));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(85, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(85, 90, 10, 20)));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -555,8 +555,8 @@ void main() {
|
||||
test('can set domain position', () {
|
||||
// Setup chart matches point with single domain single series.
|
||||
final slider = _makeBehavior(SelectionTrigger.tapAndDrag,
|
||||
handleOffset: new Point<double>(0.0, 0.0),
|
||||
handleSize: new Rectangle<int>(0, 0, 10, 20),
|
||||
handleOffset: Point<double>(0.0, 0.0),
|
||||
handleSize: Rectangle<int>(0, 0, 10, 20),
|
||||
initialDomainValue: 1.0);
|
||||
|
||||
_setupChart();
|
||||
@@ -565,27 +565,27 @@ void main() {
|
||||
_chart.lastLifecycleListener.onAxisConfigured();
|
||||
|
||||
// Verify initial position.
|
||||
expect(tester.domainCenterPoint, equals(new Point(20.0, 100.0)));
|
||||
expect(tester.domainCenterPoint, equals(Point(20.0, 100.0)));
|
||||
expect(tester.domainValue, equals(1.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(15, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(15, 90, 10, 20)));
|
||||
|
||||
// Move to first domain value.
|
||||
slider.moveSliderToDomain(2);
|
||||
expect(tester.domainCenterPoint, equals(new Point(40.0, 100.0)));
|
||||
expect(tester.domainCenterPoint, equals(Point(40.0, 100.0)));
|
||||
expect(tester.domainValue, equals(2.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(35, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(35, 90, 10, 20)));
|
||||
|
||||
// Move to second domain value.
|
||||
slider.moveSliderToDomain(5);
|
||||
expect(tester.domainCenterPoint, equals(new Point(100.0, 100.0)));
|
||||
expect(tester.domainCenterPoint, equals(Point(100.0, 100.0)));
|
||||
expect(tester.domainValue, equals(5.0));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(95, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(95, 90, 10, 20)));
|
||||
|
||||
// Move to second domain value.
|
||||
slider.moveSliderToDomain(7.5);
|
||||
expect(tester.domainCenterPoint, equals(new Point(150.0, 100.0)));
|
||||
expect(tester.domainCenterPoint, equals(Point(150.0, 100.0)));
|
||||
expect(tester.domainValue, equals(7.5));
|
||||
expect(tester.handleBounds, equals(new Rectangle<int>(145, 90, 10, 20)));
|
||||
expect(tester.handleBounds, equals(Rectangle<int>(145, 90, 10, 20)));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -594,7 +594,7 @@ void main() {
|
||||
// Setup
|
||||
Slider behavior = _makeBehavior(SelectionTrigger.tapAndDrag);
|
||||
|
||||
Point<double> point = new Point(100.0, 100.0);
|
||||
Point<double> point = Point(100.0, 100.0);
|
||||
_setupChart(
|
||||
forPoint: point,
|
||||
isWithinRenderer: true,
|
||||
|
||||
@@ -22,15 +22,15 @@ void main() {
|
||||
ProxyGestureListener _proxy;
|
||||
Point<double> _point;
|
||||
setUp(() {
|
||||
_proxy = new ProxyGestureListener();
|
||||
_point = new Point<double>(10.0, 12.0);
|
||||
_proxy = ProxyGestureListener();
|
||||
_point = Point<double>(10.0, 12.0);
|
||||
});
|
||||
|
||||
group('Tap gesture', () {
|
||||
test('notified for simple case', () {
|
||||
// Setup
|
||||
final tapListener = new MockListener(consumeEvent: true);
|
||||
_proxy.add(new GestureListener(onTap: tapListener.callback));
|
||||
final tapListener = MockListener(consumeEvent: true);
|
||||
_proxy.add(GestureListener(onTap: tapListener.callback));
|
||||
|
||||
// Act
|
||||
_proxy.onTapTest(_point);
|
||||
@@ -42,8 +42,8 @@ void main() {
|
||||
|
||||
test('notifies new listener for second event', () {
|
||||
// Setup
|
||||
final tapListener1 = new MockListener();
|
||||
_proxy.add(new GestureListener(
|
||||
final tapListener1 = MockListener();
|
||||
_proxy.add(GestureListener(
|
||||
onTap: tapListener1.callback,
|
||||
));
|
||||
|
||||
@@ -55,8 +55,8 @@ void main() {
|
||||
tapListener1.verify(arg1: _point);
|
||||
|
||||
// Setup Another
|
||||
final tapListener2 = new MockListener();
|
||||
_proxy.add(new GestureListener(
|
||||
final tapListener2 = MockListener();
|
||||
_proxy.add(GestureListener(
|
||||
onTap: tapListener2.callback,
|
||||
));
|
||||
|
||||
@@ -71,18 +71,18 @@ void main() {
|
||||
|
||||
test('notifies claiming listener registered first', () {
|
||||
// Setup
|
||||
final claimingTapDownListener = new MockListener(consumeEvent: true);
|
||||
final claimingTapListener = new MockListener(consumeEvent: true);
|
||||
final claimingTapDownListener = MockListener(consumeEvent: true);
|
||||
final claimingTapListener = MockListener(consumeEvent: true);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: claimingTapDownListener.callback,
|
||||
onTap: claimingTapListener.callback,
|
||||
));
|
||||
|
||||
final nonclaimingTapDownListener = new MockListener(consumeEvent: false);
|
||||
final nonclaimingTapListener = new MockListener(consumeEvent: false);
|
||||
final nonclaimingTapDownListener = MockListener(consumeEvent: false);
|
||||
final nonclaimingTapListener = MockListener(consumeEvent: false);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: nonclaimingTapDownListener.callback,
|
||||
onTap: nonclaimingTapListener.callback,
|
||||
));
|
||||
@@ -100,18 +100,18 @@ void main() {
|
||||
|
||||
test('notifies claiming listener registered second', () {
|
||||
// Setup
|
||||
final nonclaimingTapDownListener = new MockListener(consumeEvent: false);
|
||||
final nonclaimingTapListener = new MockListener(consumeEvent: false);
|
||||
final nonclaimingTapDownListener = MockListener(consumeEvent: false);
|
||||
final nonclaimingTapListener = MockListener(consumeEvent: false);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: nonclaimingTapDownListener.callback,
|
||||
onTap: nonclaimingTapListener.callback,
|
||||
));
|
||||
|
||||
final claimingTapDownListener = new MockListener(consumeEvent: true);
|
||||
final claimingTapListener = new MockListener(consumeEvent: true);
|
||||
final claimingTapDownListener = MockListener(consumeEvent: true);
|
||||
final claimingTapListener = MockListener(consumeEvent: true);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: claimingTapDownListener.callback,
|
||||
onTap: claimingTapListener.callback,
|
||||
));
|
||||
@@ -131,21 +131,21 @@ void main() {
|
||||
group('LongPress gesture', () {
|
||||
test('notifies with tap', () {
|
||||
// Setup
|
||||
final tapDown = new MockListener(consumeEvent: true);
|
||||
final tap = new MockListener(consumeEvent: true);
|
||||
final tapCancel = new MockListener(consumeEvent: true);
|
||||
final tapDown = MockListener(consumeEvent: true);
|
||||
final tap = MockListener(consumeEvent: true);
|
||||
final tapCancel = MockListener(consumeEvent: true);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: tapDown.callback,
|
||||
onTap: tap.callback,
|
||||
onTapCancel: tapCancel.callback,
|
||||
));
|
||||
|
||||
final pressTapDown = new MockListener(consumeEvent: true);
|
||||
final longPress = new MockListener(consumeEvent: true);
|
||||
final pressCancel = new MockListener(consumeEvent: true);
|
||||
final pressTapDown = MockListener(consumeEvent: true);
|
||||
final longPress = MockListener(consumeEvent: true);
|
||||
final pressCancel = MockListener(consumeEvent: true);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: pressTapDown.callback,
|
||||
onLongPress: longPress.callback,
|
||||
onTapCancel: pressCancel.callback,
|
||||
@@ -170,23 +170,23 @@ void main() {
|
||||
group('Drag gesture', () {
|
||||
test('wins over tap', () {
|
||||
// Setup
|
||||
final tapDown = new MockListener(consumeEvent: true);
|
||||
final tap = new MockListener(consumeEvent: true);
|
||||
final tapCancel = new MockListener(consumeEvent: true);
|
||||
final tapDown = MockListener(consumeEvent: true);
|
||||
final tap = MockListener(consumeEvent: true);
|
||||
final tapCancel = MockListener(consumeEvent: true);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: tapDown.callback,
|
||||
onTap: tap.callback,
|
||||
onTapCancel: tapCancel.callback,
|
||||
));
|
||||
|
||||
final dragTapDown = new MockListener(consumeEvent: true);
|
||||
final dragStart = new MockListener(consumeEvent: true);
|
||||
final dragUpdate = new MockListener(consumeEvent: true);
|
||||
final dragEnd = new MockListener(consumeEvent: true);
|
||||
final dragCancel = new MockListener(consumeEvent: true);
|
||||
final dragTapDown = MockListener(consumeEvent: true);
|
||||
final dragStart = MockListener(consumeEvent: true);
|
||||
final dragUpdate = MockListener(consumeEvent: true);
|
||||
final dragEnd = MockListener(consumeEvent: true);
|
||||
final dragCancel = MockListener(consumeEvent: true);
|
||||
|
||||
_proxy.add(new GestureListener(
|
||||
_proxy.add(GestureListener(
|
||||
onTapTest: dragTapDown.callback,
|
||||
onDragStart: dragStart.callback,
|
||||
onDragUpdate: dragUpdate.callback,
|
||||
|
||||
@@ -35,31 +35,31 @@ void main() {
|
||||
SeriesDatum<String> _otherDatumOtherSeriesPair;
|
||||
|
||||
setUp(() {
|
||||
_selectionModel = new MutableSelectionModel<String>();
|
||||
_selectionModel = MutableSelectionModel<String>();
|
||||
|
||||
_closestDatumClosestSeries = new MyDatum('cDcS');
|
||||
_otherDatumClosestSeries = new MyDatum('oDcS');
|
||||
_closestSeries = new MutableSeries<String>(new Series<MyDatum, String>(
|
||||
_closestDatumClosestSeries = MyDatum('cDcS');
|
||||
_otherDatumClosestSeries = MyDatum('oDcS');
|
||||
_closestSeries = MutableSeries<String>(Series<MyDatum, String>(
|
||||
id: 'closest',
|
||||
data: [_closestDatumClosestSeries, _otherDatumClosestSeries],
|
||||
domainFn: (dynamic d, _) => d.id,
|
||||
measureFn: (_, __) => 0));
|
||||
_closestDatumClosestSeriesPair =
|
||||
new SeriesDatum<String>(_closestSeries, _closestDatumClosestSeries);
|
||||
SeriesDatum<String>(_closestSeries, _closestDatumClosestSeries);
|
||||
_otherDatumClosestSeriesPair =
|
||||
new SeriesDatum<String>(_closestSeries, _otherDatumClosestSeries);
|
||||
SeriesDatum<String>(_closestSeries, _otherDatumClosestSeries);
|
||||
|
||||
_closestDatumOtherSeries = new MyDatum('cDoS');
|
||||
_otherDatumOtherSeries = new MyDatum('oDoS');
|
||||
_otherSeries = new MutableSeries<String>(new Series<MyDatum, String>(
|
||||
_closestDatumOtherSeries = MyDatum('cDoS');
|
||||
_otherDatumOtherSeries = MyDatum('oDoS');
|
||||
_otherSeries = MutableSeries<String>(Series<MyDatum, String>(
|
||||
id: 'other',
|
||||
data: [_closestDatumOtherSeries, _otherDatumOtherSeries],
|
||||
domainFn: (dynamic d, _) => d.id,
|
||||
measureFn: (_, __) => 0));
|
||||
_closestDatumOtherSeriesPair =
|
||||
new SeriesDatum<String>(_otherSeries, _closestDatumOtherSeries);
|
||||
SeriesDatum<String>(_otherSeries, _closestDatumOtherSeries);
|
||||
_otherDatumOtherSeriesPair =
|
||||
new SeriesDatum<String>(_otherSeries, _otherDatumOtherSeries);
|
||||
SeriesDatum<String>(_otherSeries, _otherDatumOtherSeries);
|
||||
});
|
||||
|
||||
group('SelectionModel persists values', () {
|
||||
@@ -71,8 +71,8 @@ void main() {
|
||||
test('all datum are selected but only the first Series is', () {
|
||||
// Select the 'closest' datum for each Series.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
new SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -98,15 +98,15 @@ void main() {
|
||||
test('selection can change', () {
|
||||
// Select the 'closest' datum for each Series.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
new SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
|
||||
// Change selection to just the other datum on the other series.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_otherSeries, _otherDatumOtherSeries),
|
||||
SeriesDatum(_otherSeries, _otherDatumOtherSeries),
|
||||
], [
|
||||
_otherSeries
|
||||
]);
|
||||
@@ -137,8 +137,8 @@ void main() {
|
||||
|
||||
// Try to the 'closest' datum for each Series.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
new SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -151,8 +151,8 @@ void main() {
|
||||
|
||||
// Try to the 'closest' datum for each Series.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
new SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_otherSeries, _closestDatumOtherSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -165,7 +165,7 @@ void main() {
|
||||
|
||||
// Attempt to change selection
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_otherSeries, _otherDatumOtherSeries),
|
||||
SeriesDatum(_otherSeries, _otherDatumOtherSeries),
|
||||
], [
|
||||
_otherSeries
|
||||
]);
|
||||
@@ -186,14 +186,13 @@ void main() {
|
||||
test('listener triggered for change', () {
|
||||
SelectionModel<String> triggeredModel;
|
||||
// Listen
|
||||
_selectionModel
|
||||
.addSelectionChangedListener((SelectionModel<String> model) {
|
||||
_selectionModel.addSelectionChangedListener((model) {
|
||||
triggeredModel = model;
|
||||
});
|
||||
|
||||
// Set the selection to closest datum.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -206,20 +205,19 @@ void main() {
|
||||
SelectionModel<String> triggeredModel;
|
||||
// Set the selection to closest datum.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
|
||||
// Listen
|
||||
_selectionModel
|
||||
.addSelectionChangedListener((SelectionModel<String> model) {
|
||||
_selectionModel.addSelectionChangedListener((model) {
|
||||
triggeredModel = model;
|
||||
});
|
||||
|
||||
// Try to update the model with the same value.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -231,7 +229,7 @@ void main() {
|
||||
test('removed listener not triggered for change', () {
|
||||
SelectionModel<String> triggeredModel;
|
||||
|
||||
Function cb = (SelectionModel<String> model) {
|
||||
Function cb = (model) {
|
||||
triggeredModel = model;
|
||||
};
|
||||
|
||||
@@ -243,7 +241,7 @@ void main() {
|
||||
|
||||
// Set the selection to closest datum.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -257,14 +255,13 @@ void main() {
|
||||
test('listener triggered for change', () {
|
||||
SelectionModel<String> triggeredModel;
|
||||
// Listen
|
||||
_selectionModel
|
||||
.addSelectionUpdatedListener((SelectionModel<String> model) {
|
||||
_selectionModel.addSelectionUpdatedListener((model) {
|
||||
triggeredModel = model;
|
||||
});
|
||||
|
||||
// Set the selection to closest datum.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -277,20 +274,19 @@ void main() {
|
||||
SelectionModel<String> triggeredModel;
|
||||
// Set the selection to closest datum.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
|
||||
// Listen
|
||||
_selectionModel
|
||||
.addSelectionUpdatedListener((SelectionModel<String> model) {
|
||||
_selectionModel.addSelectionUpdatedListener((model) {
|
||||
triggeredModel = model;
|
||||
});
|
||||
|
||||
// Try to update the model with the same value.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
@@ -302,7 +298,7 @@ void main() {
|
||||
test('removed listener not triggered for change', () {
|
||||
SelectionModel<String> triggeredModel;
|
||||
|
||||
Function cb = (SelectionModel<String> model) {
|
||||
Function cb = (model) {
|
||||
triggeredModel = model;
|
||||
};
|
||||
|
||||
@@ -314,7 +310,7 @@ void main() {
|
||||
|
||||
// Set the selection to closest datum.
|
||||
_selectionModel.updateSelection([
|
||||
new SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
SeriesDatum(_closestSeries, _closestDatumClosestSeries),
|
||||
], [
|
||||
_closestSeries
|
||||
]);
|
||||
|
||||
@@ -56,47 +56,43 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
myFakeDesktopData = [
|
||||
new MyRow(
|
||||
'MyCampaign1', 1, 5, MaterialPalette.blue.shadeDefault, null, 2.0),
|
||||
new MyRow(
|
||||
MyRow('MyCampaign1', 1, 5, MaterialPalette.blue.shadeDefault, null, 2.0),
|
||||
MyRow(
|
||||
'MyCampaign2', 2, 25, MaterialPalette.green.shadeDefault, null, 2.0),
|
||||
new MyRow(
|
||||
'MyCampaign3', 3, 100, MaterialPalette.red.shadeDefault, null, 2.0),
|
||||
new MyRow('MyOtherCampaign', 4, 75, MaterialPalette.red.shadeDefault,
|
||||
null, 2.0),
|
||||
MyRow('MyCampaign3', 3, 100, MaterialPalette.red.shadeDefault, null, 2.0),
|
||||
MyRow('MyOtherCampaign', 4, 75, MaterialPalette.red.shadeDefault, null,
|
||||
2.0),
|
||||
];
|
||||
|
||||
myFakeTabletData = [
|
||||
new MyRow(
|
||||
MyRow(
|
||||
'MyCampaign1', 1, 5, MaterialPalette.blue.shadeDefault, [2, 2], 2.0),
|
||||
new MyRow(
|
||||
MyRow(
|
||||
'MyCampaign2', 2, 25, MaterialPalette.blue.shadeDefault, [3, 3], 2.0),
|
||||
new MyRow('MyCampaign3', 3, 100, MaterialPalette.blue.shadeDefault,
|
||||
[4, 4], 2.0),
|
||||
new MyRow('MyOtherCampaign', 4, 75, MaterialPalette.blue.shadeDefault,
|
||||
[4, 4], 2.0),
|
||||
MyRow('MyCampaign3', 3, 100, MaterialPalette.blue.shadeDefault, [4, 4],
|
||||
2.0),
|
||||
MyRow('MyOtherCampaign', 4, 75, MaterialPalette.blue.shadeDefault, [4, 4],
|
||||
2.0),
|
||||
];
|
||||
|
||||
myFakeMobileData = [
|
||||
new MyRow(
|
||||
'MyCampaign1', 1, 5, MaterialPalette.blue.shadeDefault, null, 2.0),
|
||||
new MyRow(
|
||||
'MyCampaign2', 2, 25, MaterialPalette.blue.shadeDefault, null, 3.0),
|
||||
new MyRow(
|
||||
MyRow('MyCampaign1', 1, 5, MaterialPalette.blue.shadeDefault, null, 2.0),
|
||||
MyRow('MyCampaign2', 2, 25, MaterialPalette.blue.shadeDefault, null, 3.0),
|
||||
MyRow(
|
||||
'MyCampaign3', 3, 100, MaterialPalette.blue.shadeDefault, null, 4.0),
|
||||
new MyRow('MyOtherCampaign', 4, 75, MaterialPalette.blue.shadeDefault,
|
||||
null, 4.0),
|
||||
MyRow('MyOtherCampaign', 4, 75, MaterialPalette.blue.shadeDefault, null,
|
||||
4.0),
|
||||
];
|
||||
|
||||
numericSeriesList = [
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Desktop',
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
measureFn: (dynamic row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
data: myFakeDesktopData)),
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Tablet',
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
@@ -104,7 +100,7 @@ void main() {
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
strokeWidthPxFn: (_, __) => 1.25,
|
||||
data: myFakeTabletData)),
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Mobile',
|
||||
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
@@ -115,14 +111,14 @@ void main() {
|
||||
];
|
||||
|
||||
ordinalSeriesList = [
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Desktop',
|
||||
colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
|
||||
domainFn: (dynamic row, _) => row.campaignString,
|
||||
measureFn: (dynamic row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
data: myFakeDesktopData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Tablet',
|
||||
colorFn: (_, __) => MaterialPalette.red.shadeDefault,
|
||||
domainFn: (dynamic row, _) => row.campaignString,
|
||||
@@ -130,7 +126,7 @@ void main() {
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
strokeWidthPxFn: (_, __) => 1.25,
|
||||
data: myFakeTabletData)),
|
||||
new MutableSeries<String>(new Series<MyRow, String>(
|
||||
MutableSeries<String>(Series<MyRow, String>(
|
||||
id: 'Mobile',
|
||||
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
|
||||
domainFn: (dynamic row, _) => row.campaignString,
|
||||
@@ -143,8 +139,8 @@ void main() {
|
||||
|
||||
group('preprocess', () {
|
||||
test('with numeric data and simple lines', () {
|
||||
renderer = new LineRenderer<num>(
|
||||
config: new LineRendererConfig(strokeWidthPx: 2.0));
|
||||
renderer =
|
||||
LineRenderer<num>(config: LineRendererConfig(strokeWidthPx: 2.0));
|
||||
|
||||
renderer.configureSeries(numericSeriesList);
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
@@ -207,8 +203,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with numeric data and stacked lines', () {
|
||||
renderer = new LineRenderer<num>(
|
||||
config: new LineRendererConfig(stacked: true, strokeWidthPx: 2.0));
|
||||
renderer = LineRenderer<num>(
|
||||
config: LineRendererConfig(stacked: true, strokeWidthPx: 2.0));
|
||||
|
||||
renderer.configureSeries(numericSeriesList);
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
@@ -272,37 +268,37 @@ void main() {
|
||||
|
||||
test('with numeric data and changes in style', () {
|
||||
numericSeriesList = [
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Desktop',
|
||||
colorFn: (MyRow row, _) => row.color,
|
||||
dashPatternFn: (MyRow row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (MyRow row, _) => row.strokeWidthPx,
|
||||
colorFn: (row, _) => row.color,
|
||||
dashPatternFn: (row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (row, _) => row.strokeWidthPx,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
measureFn: (dynamic row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
data: myFakeDesktopData)),
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Tablet',
|
||||
colorFn: (MyRow row, _) => row.color,
|
||||
dashPatternFn: (MyRow row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (MyRow row, _) => row.strokeWidthPx,
|
||||
colorFn: (row, _) => row.color,
|
||||
dashPatternFn: (row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (row, _) => row.strokeWidthPx,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
measureFn: (dynamic row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
data: myFakeTabletData)),
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Mobile',
|
||||
colorFn: (MyRow row, _) => row.color,
|
||||
dashPatternFn: (MyRow row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (MyRow row, _) => row.strokeWidthPx,
|
||||
colorFn: (row, _) => row.color,
|
||||
dashPatternFn: (row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (row, _) => row.strokeWidthPx,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
measureFn: (dynamic row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
data: myFakeMobileData))
|
||||
];
|
||||
|
||||
renderer = new LineRenderer<num>(
|
||||
config: new LineRendererConfig(strokeWidthPx: 2.0));
|
||||
renderer =
|
||||
LineRenderer<num>(config: LineRendererConfig(strokeWidthPx: 2.0));
|
||||
|
||||
renderer.configureSeries(numericSeriesList);
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
@@ -408,38 +404,38 @@ void main() {
|
||||
|
||||
test('with numeric data and repeats in style', () {
|
||||
var myFakeData = [
|
||||
new MyRow(
|
||||
MyRow(
|
||||
'MyCampaign1', 1, 5, MaterialPalette.blue.shadeDefault, null, 2.0),
|
||||
new MyRow('MyCampaign2', 2, 25, MaterialPalette.green.shadeDefault,
|
||||
null, 2.0),
|
||||
new MyRow('MyCampaign3', 3, 100, MaterialPalette.blue.shadeDefault,
|
||||
null, 2.0),
|
||||
new MyRow('MyCampaign4', 4, 75, MaterialPalette.green.shadeDefault,
|
||||
null, 2.0),
|
||||
new MyRow(
|
||||
MyRow('MyCampaign2', 2, 25, MaterialPalette.green.shadeDefault, null,
|
||||
2.0),
|
||||
MyRow('MyCampaign3', 3, 100, MaterialPalette.blue.shadeDefault, null,
|
||||
2.0),
|
||||
MyRow('MyCampaign4', 4, 75, MaterialPalette.green.shadeDefault, null,
|
||||
2.0),
|
||||
MyRow(
|
||||
'MyCampaign1', 5, 5, MaterialPalette.blue.shadeDefault, null, 2.0),
|
||||
new MyRow('MyCampaign2', 6, 25, MaterialPalette.green.shadeDefault,
|
||||
null, 2.0),
|
||||
new MyRow('MyCampaign3', 7, 100, MaterialPalette.blue.shadeDefault,
|
||||
null, 2.0),
|
||||
new MyRow('MyCampaign4', 8, 75, MaterialPalette.green.shadeDefault,
|
||||
null, 2.0),
|
||||
MyRow('MyCampaign2', 6, 25, MaterialPalette.green.shadeDefault, null,
|
||||
2.0),
|
||||
MyRow('MyCampaign3', 7, 100, MaterialPalette.blue.shadeDefault, null,
|
||||
2.0),
|
||||
MyRow('MyCampaign4', 8, 75, MaterialPalette.green.shadeDefault, null,
|
||||
2.0),
|
||||
];
|
||||
|
||||
numericSeriesList = [
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Desktop',
|
||||
colorFn: (MyRow row, _) => row.color,
|
||||
dashPatternFn: (MyRow row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (MyRow row, _) => row.strokeWidthPx,
|
||||
domainFn: (dynamic row, _) => row.campaign,
|
||||
measureFn: (dynamic row, _) => row.clickCount,
|
||||
colorFn: (row, _) => row.color,
|
||||
dashPatternFn: (row, _) => row.dashPattern,
|
||||
strokeWidthPxFn: (row, _) => row.strokeWidthPx,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (_, __) => 0,
|
||||
data: myFakeData)),
|
||||
];
|
||||
|
||||
renderer = new LineRenderer<num>(
|
||||
config: new LineRendererConfig(strokeWidthPx: 2.0));
|
||||
renderer =
|
||||
LineRenderer<num>(config: LineRendererConfig(strokeWidthPx: 2.0));
|
||||
|
||||
renderer.configureSeries(numericSeriesList);
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
@@ -494,8 +490,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with ordinal data and simple lines', () {
|
||||
renderer = new LineRenderer<String>(
|
||||
config: new LineRendererConfig(strokeWidthPx: 2.0));
|
||||
renderer =
|
||||
LineRenderer<String>(config: LineRendererConfig(strokeWidthPx: 2.0));
|
||||
|
||||
renderer.configureSeries(ordinalSeriesList);
|
||||
renderer.preprocessSeries(ordinalSeriesList);
|
||||
|
||||
@@ -50,23 +50,23 @@ void main() {
|
||||
/////////////////////////////////////////
|
||||
MutableSeries<int> _makeSeries({String id, int measureOffset = 0}) {
|
||||
final data = <MyRow>[
|
||||
new MyRow(1000, measureOffset + 10),
|
||||
new MyRow(2000, measureOffset + 20),
|
||||
new MyRow(3000, measureOffset + 30),
|
||||
MyRow(1000, measureOffset + 10),
|
||||
MyRow(2000, measureOffset + 20),
|
||||
MyRow(3000, measureOffset + 30),
|
||||
];
|
||||
|
||||
final series = new MutableSeries<int>(new Series<MyRow, int>(
|
||||
final series = MutableSeries<int>(Series<MyRow, int>(
|
||||
id: id,
|
||||
data: data,
|
||||
domainFn: (MyRow row, _) => row.timestamp,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
domainFn: (row, _) => row.timestamp,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
));
|
||||
|
||||
series.measureOffsetFn = (_) => 0.0;
|
||||
series.colorFn = (_) => new Color.fromHex(code: '#000000');
|
||||
series.colorFn = (_) => Color.fromHex(code: '#000000');
|
||||
|
||||
// Mock the Domain axis results.
|
||||
final domainAxis = new MockDomainAxis();
|
||||
final domainAxis = MockDomainAxis();
|
||||
when(domainAxis.rangeBand).thenReturn(100.0);
|
||||
when(domainAxis.getLocation(1000)).thenReturn(70.0);
|
||||
when(domainAxis.getLocation(2000)).thenReturn(70.0 + 100);
|
||||
@@ -74,7 +74,7 @@ void main() {
|
||||
series.setAttr(domainAxisKey, domainAxis);
|
||||
|
||||
// Mock the Measure axis results.
|
||||
final measureAxis = new MockMeasureAxis();
|
||||
final measureAxis = MockMeasureAxis();
|
||||
for (var i = 0; i <= 100; i++) {
|
||||
when(measureAxis.getLocation(i.toDouble()))
|
||||
.thenReturn(20.0 + 100.0 - i.toDouble());
|
||||
@@ -94,9 +94,9 @@ void main() {
|
||||
setUp(() {
|
||||
selectNearestByDomain = true;
|
||||
|
||||
renderer = new LineRenderer<int>(
|
||||
config: new LineRendererConfig(strokeWidthPx: 1.0));
|
||||
final layoutBounds = new Rectangle<int>(70, 20, 200, 100);
|
||||
renderer =
|
||||
LineRenderer<int>(config: LineRendererConfig(strokeWidthPx: 1.0));
|
||||
final layoutBounds = Rectangle<int>(70, 20, 200, 100);
|
||||
renderer.layout(layoutBounds, layoutBounds);
|
||||
return renderer;
|
||||
});
|
||||
@@ -114,11 +114,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act Point just below barSeries.data[0]
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -142,11 +142,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -163,11 +163,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -191,11 +191,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -214,11 +214,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -241,11 +241,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -277,11 +277,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 100.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
Point<double>(70.0 + 100.0 + 10.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -312,11 +312,11 @@ void main() {
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(70.0 + 100.0 + 10.0, 20.0 + 10.0),
|
||||
Point<double>(70.0 + 100.0 + 10.0, 20.0 + 10.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
|
||||
@@ -333,19 +333,17 @@ void main() {
|
||||
test('no selection for points outside of viewport', () {
|
||||
// Setup
|
||||
final seriesList = <MutableSeries<int>>[
|
||||
_makeSeries(id: 'foo')..data.add(new MyRow(-1000, 20))
|
||||
_makeSeries(id: 'foo')..data.add(MyRow(-1000, 20))
|
||||
];
|
||||
renderer.configureSeries(seriesList);
|
||||
renderer.preprocessSeries(seriesList);
|
||||
renderer.update(seriesList, false);
|
||||
renderer.paint(new MockCanvas(), 1.0);
|
||||
renderer.paint(MockCanvas(), 1.0);
|
||||
|
||||
// Act
|
||||
// Note: point is in the axis, over a bar outside of the viewport.
|
||||
final details = renderer.getNearestDatumDetailPerSeries(
|
||||
new Point<double>(-0.0, 20.0 + 100.0 - 5.0),
|
||||
selectNearestByDomain,
|
||||
null);
|
||||
Point<double>(-0.0, 20.0 + 100.0 - 5.0), selectNearestByDomain, null);
|
||||
|
||||
// Verify
|
||||
expect(details.length, equals(0));
|
||||
|
||||
@@ -43,13 +43,13 @@ class MockCanvas extends Mock implements ChartCanvas {}
|
||||
/// A fake [GraphicsFactory] that returns [FakeTextStyle] and [FakeTextElement].
|
||||
class FakeGraphicsFactory extends GraphicsFactory {
|
||||
@override
|
||||
TextStyle createTextPaint() => new FakeTextStyle();
|
||||
TextStyle createTextPaint() => FakeTextStyle();
|
||||
|
||||
@override
|
||||
TextElement createTextElement(String text) => new FakeTextElement(text);
|
||||
TextElement createTextElement(String text) => FakeTextElement(text);
|
||||
|
||||
@override
|
||||
LineStyle createLinePaint() => new MockLinePaint();
|
||||
LineStyle createLinePaint() => MockLinePaint();
|
||||
}
|
||||
|
||||
/// Stores [TextStyle] properties for test to verify.
|
||||
@@ -72,7 +72,7 @@ class FakeTextElement implements TextElement {
|
||||
|
||||
FakeTextElement(this.text);
|
||||
|
||||
TextMeasurement get measurement => new TextMeasurement(
|
||||
TextMeasurement get measurement => TextMeasurement(
|
||||
horizontalSliceWidth: text.length.toDouble(),
|
||||
verticalSliceWidth: textStyle.fontSize.toDouble(),
|
||||
baseline: textStyle.fontSize.toDouble());
|
||||
@@ -81,7 +81,7 @@ class FakeTextElement implements TextElement {
|
||||
class MockLinePaint extends Mock implements LineStyle {}
|
||||
|
||||
class FakeArcRendererElement extends ArcRendererElement<String> {
|
||||
final _series = new MockImmutableSeries<String>();
|
||||
final _series = MockImmutableSeries<String>();
|
||||
final AccessorFn<String> labelAccessor;
|
||||
final List<String> data;
|
||||
|
||||
@@ -101,32 +101,32 @@ void main() {
|
||||
Rectangle<int> drawBounds;
|
||||
|
||||
setUpAll(() {
|
||||
canvas = new MockCanvas();
|
||||
graphicsFactory = new FakeGraphicsFactory();
|
||||
drawBounds = new Rectangle(0, 0, 200, 200);
|
||||
canvas = MockCanvas();
|
||||
graphicsFactory = FakeGraphicsFactory();
|
||||
drawBounds = Rectangle(0, 0, 200, 200);
|
||||
});
|
||||
|
||||
group('pie chart', () {
|
||||
test('Paint labels with default settings', () {
|
||||
final data = ['A', 'B'];
|
||||
final arcElements = new ArcRendererElementList()
|
||||
final arcElements = ArcRendererElementList()
|
||||
..arcs = [
|
||||
// 'A' is small enough to fit inside the arc.
|
||||
// 'LongLabelB' should not fit inside the arc because it has length
|
||||
// greater than 10.
|
||||
new FakeArcRendererElement((_) => 'A', data)
|
||||
FakeArcRendererElement((_) => 'A', data)
|
||||
..startAngle = -pi / 2
|
||||
..endAngle = pi / 2,
|
||||
new FakeArcRendererElement((_) => 'LongLabelB', data)
|
||||
FakeArcRendererElement((_) => 'LongLabelB', data)
|
||||
..startAngle = pi / 2
|
||||
..endAngle = 3 * pi / 2,
|
||||
]
|
||||
..center = new Point(100.0, 100.0)
|
||||
..center = Point(100.0, 100.0)
|
||||
..innerRadius = 30.0
|
||||
..radius = 40.0
|
||||
..startAngle = -pi / 2;
|
||||
|
||||
final decorator = new ArcLabelDecorator();
|
||||
final decorator = ArcLabelDecorator();
|
||||
|
||||
decorator.decorate(arcElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds, animationPercent: 1.0);
|
||||
@@ -155,22 +155,22 @@ void main() {
|
||||
});
|
||||
|
||||
test('LabelPosition.inside always paints inside the arc', () {
|
||||
final arcElements = new ArcRendererElementList()
|
||||
final arcElements = ArcRendererElementList()
|
||||
..arcs = [
|
||||
// 'LongLabelABC' would not fit inside the arc because it has length
|
||||
// greater than 10. [ArcLabelPosition.inside] should override this.
|
||||
new FakeArcRendererElement((_) => 'LongLabelABC', ['A'])
|
||||
FakeArcRendererElement((_) => 'LongLabelABC', ['A'])
|
||||
..startAngle = -pi / 2
|
||||
..endAngle = pi / 2,
|
||||
]
|
||||
..center = new Point(100.0, 100.0)
|
||||
..center = Point(100.0, 100.0)
|
||||
..innerRadius = 30.0
|
||||
..radius = 40.0
|
||||
..startAngle = -pi / 2;
|
||||
|
||||
final decorator = new ArcLabelDecorator(
|
||||
final decorator = ArcLabelDecorator(
|
||||
labelPosition: ArcLabelPosition.inside,
|
||||
insideLabelStyleSpec: new TextStyleSpec(fontSize: 10));
|
||||
insideLabelStyleSpec: TextStyleSpec(fontSize: 10));
|
||||
|
||||
decorator.decorate(arcElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds, animationPercent: 1.0);
|
||||
@@ -186,22 +186,22 @@ void main() {
|
||||
});
|
||||
|
||||
test('LabelPosition.outside always paints outside the arc', () {
|
||||
final arcElements = new ArcRendererElementList()
|
||||
final arcElements = ArcRendererElementList()
|
||||
..arcs = [
|
||||
// 'A' will fit inside the arc because it has length less than 10.
|
||||
// [ArcLabelPosition.outside] should override this.
|
||||
new FakeArcRendererElement((_) => 'A', ['A'])
|
||||
FakeArcRendererElement((_) => 'A', ['A'])
|
||||
..startAngle = -pi / 2
|
||||
..endAngle = pi / 2,
|
||||
]
|
||||
..center = new Point(100.0, 100.0)
|
||||
..center = Point(100.0, 100.0)
|
||||
..innerRadius = 30.0
|
||||
..radius = 40.0
|
||||
..startAngle = -pi / 2;
|
||||
|
||||
final decorator = new ArcLabelDecorator(
|
||||
final decorator = ArcLabelDecorator(
|
||||
labelPosition: ArcLabelPosition.outside,
|
||||
outsideLabelStyleSpec: new TextStyleSpec(fontSize: 10));
|
||||
outsideLabelStyleSpec: TextStyleSpec(fontSize: 10));
|
||||
|
||||
decorator.decorate(arcElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds, animationPercent: 1.0);
|
||||
@@ -222,30 +222,30 @@ void main() {
|
||||
|
||||
test('Inside and outside label styles are applied', () {
|
||||
final data = ['A', 'B'];
|
||||
final arcElements = new ArcRendererElementList()
|
||||
final arcElements = ArcRendererElementList()
|
||||
..arcs = [
|
||||
// 'A' is small enough to fit inside the arc.
|
||||
// 'LongLabelB' should not fit inside the arc because it has length
|
||||
// greater than 10.
|
||||
new FakeArcRendererElement((_) => 'A', data)
|
||||
FakeArcRendererElement((_) => 'A', data)
|
||||
..startAngle = -pi / 2
|
||||
..endAngle = pi / 2,
|
||||
new FakeArcRendererElement((_) => 'LongLabelB', data)
|
||||
FakeArcRendererElement((_) => 'LongLabelB', data)
|
||||
..startAngle = pi / 2
|
||||
..endAngle = 3 * pi / 2,
|
||||
]
|
||||
..center = new Point(100.0, 100.0)
|
||||
..center = Point(100.0, 100.0)
|
||||
..innerRadius = 30.0
|
||||
..radius = 40.0
|
||||
..startAngle = -pi / 2;
|
||||
|
||||
final insideColor = new Color(r: 0, g: 0, b: 0);
|
||||
final outsideColor = new Color(r: 255, g: 255, b: 255);
|
||||
final decorator = new ArcLabelDecorator(
|
||||
final insideColor = Color(r: 0, g: 0, b: 0);
|
||||
final outsideColor = Color(r: 255, g: 255, b: 255);
|
||||
final decorator = ArcLabelDecorator(
|
||||
labelPadding: 0,
|
||||
insideLabelStyleSpec: new TextStyleSpec(
|
||||
insideLabelStyleSpec: TextStyleSpec(
|
||||
fontSize: 10, fontFamily: 'insideFont', color: insideColor),
|
||||
outsideLabelStyleSpec: new TextStyleSpec(
|
||||
outsideLabelStyleSpec: TextStyleSpec(
|
||||
fontSize: 8, fontFamily: 'outsideFont', color: outsideColor));
|
||||
|
||||
decorator.decorate(arcElements, canvas, graphicsFactory,
|
||||
@@ -281,18 +281,18 @@ void main() {
|
||||
|
||||
group('Null and empty label scenarios', () {
|
||||
test('Skip label if label accessor does not exist', () {
|
||||
final arcElements = new ArcRendererElementList()
|
||||
final arcElements = ArcRendererElementList()
|
||||
..arcs = [
|
||||
new FakeArcRendererElement(null, ['A'])
|
||||
FakeArcRendererElement(null, ['A'])
|
||||
..startAngle = -pi / 2
|
||||
..endAngle = pi / 2,
|
||||
]
|
||||
..center = new Point(100.0, 100.0)
|
||||
..center = Point(100.0, 100.0)
|
||||
..innerRadius = 30.0
|
||||
..radius = 40.0
|
||||
..startAngle = -pi / 2;
|
||||
|
||||
new ArcLabelDecorator().decorate(arcElements, canvas, graphicsFactory,
|
||||
ArcLabelDecorator().decorate(arcElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds, animationPercent: 1.0);
|
||||
|
||||
verifyNever(canvas.drawText(any, any, any));
|
||||
@@ -300,21 +300,21 @@ void main() {
|
||||
|
||||
test('Skip label if label is null or empty', () {
|
||||
final data = ['A', 'B'];
|
||||
final arcElements = new ArcRendererElementList()
|
||||
final arcElements = ArcRendererElementList()
|
||||
..arcs = [
|
||||
new FakeArcRendererElement(null, data)
|
||||
FakeArcRendererElement(null, data)
|
||||
..startAngle = -pi / 2
|
||||
..endAngle = pi / 2,
|
||||
new FakeArcRendererElement((_) => '', data)
|
||||
FakeArcRendererElement((_) => '', data)
|
||||
..startAngle = pi / 2
|
||||
..endAngle = 3 * pi / 2,
|
||||
]
|
||||
..center = new Point(100.0, 100.0)
|
||||
..center = Point(100.0, 100.0)
|
||||
..innerRadius = 30.0
|
||||
..radius = 40.0
|
||||
..startAngle = -pi / 2;
|
||||
|
||||
new ArcLabelDecorator().decorate(arcElements, canvas, graphicsFactory,
|
||||
ArcLabelDecorator().decorate(arcElements, canvas, graphicsFactory,
|
||||
drawBounds: drawBounds, animationPercent: 1.0);
|
||||
|
||||
verifyNever(canvas.drawText(any, any, any));
|
||||
|
||||
@@ -38,14 +38,14 @@ void main() {
|
||||
Rectangle bounds;
|
||||
|
||||
setUp(() {
|
||||
decorator = new TestComparisonPointsDecorator<num>();
|
||||
bounds = new Rectangle<int>(0, 0, 100, 100);
|
||||
decorator = TestComparisonPointsDecorator<num>();
|
||||
bounds = Rectangle<int>(0, 0, 100, 100);
|
||||
});
|
||||
|
||||
group('compute bounded points', () {
|
||||
test('with line inside bounds', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 10.0,
|
||||
xLower: 5.0,
|
||||
xUpper: 50.0,
|
||||
@@ -66,8 +66,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with line entirely above bounds', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 10.0,
|
||||
xLower: 5.0,
|
||||
xUpper: 50.0,
|
||||
@@ -82,8 +82,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with line entirely below bounds', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 10.0,
|
||||
xLower: 5.0,
|
||||
xUpper: 50.0,
|
||||
@@ -98,8 +98,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with line entirely left of bounds', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: -10.0,
|
||||
xLower: -5.0,
|
||||
xUpper: -50.0,
|
||||
@@ -114,8 +114,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with line entirely right of bounds', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 110.0,
|
||||
xLower: 105.0,
|
||||
xUpper: 150.0,
|
||||
@@ -130,8 +130,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with horizontal line extending beyond bounds', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 10.0,
|
||||
xLower: -10.0,
|
||||
xUpper: 110.0,
|
||||
@@ -152,8 +152,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with vertical line extending beyond bounds', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 20.0,
|
||||
xLower: 20.0,
|
||||
xUpper: 20.0,
|
||||
@@ -174,8 +174,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with diagonal from top left to bottom right', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 50.0,
|
||||
xLower: -50.0,
|
||||
xUpper: 150.0,
|
||||
@@ -196,8 +196,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with diagonal from bottom left to top right', () {
|
||||
final element = new PointRendererElement<num>()
|
||||
..point = new DatumPoint<num>(
|
||||
final element = PointRendererElement<num>()
|
||||
..point = DatumPoint<num>(
|
||||
x: 50.0,
|
||||
xLower: -50.0,
|
||||
xUpper: 150.0,
|
||||
|
||||
@@ -42,19 +42,19 @@ void main() {
|
||||
setUp(() {
|
||||
var myFakeDesktopData = [
|
||||
// This datum should get a default bounds line radius value.
|
||||
new MyRow('MyCampaign1', 0, 5, 3.0, null, null),
|
||||
new MyRow('MyCampaign2', 10, 25, 5.0, 4.0, 'shape 1'),
|
||||
new MyRow('MyCampaign3', 12, 75, 4.0, 4.0, 'shape 2'),
|
||||
MyRow('MyCampaign1', 0, 5, 3.0, null, null),
|
||||
MyRow('MyCampaign2', 10, 25, 5.0, 4.0, 'shape 1'),
|
||||
MyRow('MyCampaign3', 12, 75, 4.0, 4.0, 'shape 2'),
|
||||
// This datum should always get default radius values.
|
||||
new MyRow('MyCampaign4', 13, 225, null, null, null),
|
||||
MyRow('MyCampaign4', 13, 225, null, null, null),
|
||||
];
|
||||
|
||||
final maxMeasure = 300;
|
||||
|
||||
numericSeriesList = [
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Desktop',
|
||||
colorFn: (MyRow row, _) {
|
||||
colorFn: (row, _) {
|
||||
// Color bucket the measure column value into 3 distinct colors.
|
||||
final bucket = row.clickCount / maxMeasure;
|
||||
|
||||
@@ -66,20 +66,20 @@ void main() {
|
||||
return MaterialPalette.green.shadeDefault;
|
||||
}
|
||||
},
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
measureFn: (MyRow row, _) => row.clickCount,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
radiusPxFn: (MyRow row, _) => row.radius,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
measureFn: (row, _) => row.clickCount,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
radiusPxFn: (row, _) => row.radius,
|
||||
data: myFakeDesktopData)
|
||||
// Define a bounds line radius function.
|
||||
..setAttribute(boundsLineRadiusPxFnKey,
|
||||
(int index) => myFakeDesktopData[index].boundsRadius))
|
||||
(index) => myFakeDesktopData[index].boundsRadius))
|
||||
];
|
||||
});
|
||||
|
||||
group('preprocess', () {
|
||||
test('with numeric data and simple points', () {
|
||||
renderer = new PointRenderer<int>(config: new PointRendererConfig());
|
||||
renderer = PointRenderer<int>(config: PointRendererConfig());
|
||||
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
|
||||
@@ -115,9 +115,8 @@ void main() {
|
||||
});
|
||||
|
||||
test('with numeric data and missing radiusPxFn', () {
|
||||
renderer = new PointRenderer<int>(
|
||||
config:
|
||||
new PointRendererConfig(radiusPx: 2.0, boundsLineRadiusPx: 1.5));
|
||||
renderer = PointRenderer<int>(
|
||||
config: PointRendererConfig(radiusPx: 2.0, boundsLineRadiusPx: 1.5));
|
||||
|
||||
// Remove the radius functions to test configured defaults.
|
||||
numericSeriesList[0].radiusPxFn = null;
|
||||
@@ -145,10 +144,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('with custom symbol renderer ID in data', () {
|
||||
renderer = new PointRenderer<int>(config: new PointRendererConfig());
|
||||
renderer = PointRenderer<int>(config: PointRendererConfig());
|
||||
|
||||
numericSeriesList[0].setAttr(pointSymbolRendererFnKey,
|
||||
(int index) => numericSeriesList[0].data[index].shape as String);
|
||||
(index) => numericSeriesList[0].data[index].shape as String);
|
||||
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
|
||||
@@ -167,10 +166,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('with custom symbol renderer ID in series and data', () {
|
||||
renderer = new PointRenderer<int>(config: new PointRendererConfig());
|
||||
renderer = PointRenderer<int>(config: PointRendererConfig());
|
||||
|
||||
numericSeriesList[0].setAttr(pointSymbolRendererFnKey,
|
||||
(int index) => numericSeriesList[0].data[index].shape as String);
|
||||
(index) => numericSeriesList[0].data[index].shape as String);
|
||||
numericSeriesList[0].setAttr(pointSymbolRendererIdKey, 'shape 0');
|
||||
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
|
||||
@@ -44,34 +44,34 @@ void main() {
|
||||
setUp(() {
|
||||
var myFakeDesktopData = [
|
||||
// This datum should get a default bounds line radius value.
|
||||
new MyRow('MyCampaign1', 0, 0, 0, 3.0, null, null),
|
||||
new MyRow('MyCampaign2', 10, 10, 12, 5.0, 4.0, 'shape 1'),
|
||||
new MyRow('MyCampaign3', 10, 10, 14, 4.0, 4.0, 'shape 2'),
|
||||
MyRow('MyCampaign1', 0, 0, 0, 3.0, null, null),
|
||||
MyRow('MyCampaign2', 10, 10, 12, 5.0, 4.0, 'shape 1'),
|
||||
MyRow('MyCampaign3', 10, 10, 14, 4.0, 4.0, 'shape 2'),
|
||||
// This datum should always get default radius values.
|
||||
new MyRow('MyCampaign4', 13, 12, 15, null, null, null),
|
||||
MyRow('MyCampaign4', 13, 12, 15, null, null, null),
|
||||
];
|
||||
|
||||
numericSeriesList = [
|
||||
new MutableSeries<int>(new Series<MyRow, int>(
|
||||
MutableSeries<int>(Series<MyRow, int>(
|
||||
id: 'Desktop',
|
||||
colorFn: (MyRow row, _) => MaterialPalette.blue.shadeDefault,
|
||||
domainFn: (MyRow row, _) => row.campaign,
|
||||
domainLowerBoundFn: (MyRow row, _) => row.campaignLower,
|
||||
domainUpperBoundFn: (MyRow row, _) => row.campaignUpper,
|
||||
measureFn: (MyRow row, _) => 0,
|
||||
measureOffsetFn: (MyRow row, _) => 0,
|
||||
radiusPxFn: (MyRow row, _) => row.radius,
|
||||
colorFn: (row, _) => MaterialPalette.blue.shadeDefault,
|
||||
domainFn: (row, _) => row.campaign,
|
||||
domainLowerBoundFn: (row, _) => row.campaignLower,
|
||||
domainUpperBoundFn: (row, _) => row.campaignUpper,
|
||||
measureFn: (row, _) => 0,
|
||||
measureOffsetFn: (row, _) => 0,
|
||||
radiusPxFn: (row, _) => row.radius,
|
||||
data: myFakeDesktopData)
|
||||
// Define a bounds line radius function.
|
||||
..setAttribute(boundsLineRadiusPxFnKey,
|
||||
(int index) => myFakeDesktopData[index].boundsRadius))
|
||||
(index) => myFakeDesktopData[index].boundsRadius))
|
||||
];
|
||||
});
|
||||
|
||||
group('preprocess', () {
|
||||
test('with numeric data and simple points', () {
|
||||
renderer = new SymbolAnnotationRenderer<int>(
|
||||
config: new SymbolAnnotationRendererConfig());
|
||||
renderer = SymbolAnnotationRenderer<int>(
|
||||
config: SymbolAnnotationRendererConfig());
|
||||
|
||||
renderer.preprocessSeries(numericSeriesList);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user