Skip to content

Commit 8eecd1a

Browse files
Make charted strong-mode clean
1 parent 19801c6 commit 8eecd1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+288
-266
lines changed

.analysis_options

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
analyzer:
2+
strong-mode: true
3+
exclude:
4+
- test.disabled/**

examples/charts/components/demo_custom_axis.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'dart:html';
1212
import 'package:charted/charts/charts.dart';
1313
import 'package:charted/core/scales.dart';
1414

15-
List COLUMNS = [
15+
List<ChartColumnSpec> COLUMNS = <ChartColumnSpec>[
1616
new ChartColumnSpec(label:'Month', type:ChartColumnSpec.TYPE_STRING),
1717
new ChartColumnSpec(label:'Precipitation'),
1818
new ChartColumnSpec(label:'High Temperature'),
@@ -23,7 +23,7 @@ List COLUMNS = [
2323
new ChartColumnSpec(label:'Extra3'),
2424
];
2525

26-
List DATA = [
26+
List<List> DATA = <List>[
2727
['January', 4.50, 27, 46, 1, 20, 23, 1],
2828
['February', 4.61, 60, 28, 10, 15, 45, 23],
2929
['March', 3.26, 32, 49, 100, 4, 34, 1],

examples/charts/demo_charts.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ library charted.demo.charts;
33
import "package:charted/charts/charts.dart";
44

55
/// Helper method to create default behaviors for cartesian chart demos.
6-
Iterable<ChartBehavior> createDefaultCartesianBehaviors() =>
6+
List<ChartBehavior> createDefaultCartesianBehaviors() =>
77
new List.from([
88
new Hovercard(isMultiValue: true),
99
new AxisLabelTooltip()
1010
]);
1111

1212
/// Helper method to create default behaviors for layout chart demos.
13-
Iterable<ChartBehavior> createDefaultLayoutBehaviors() =>
13+
List<ChartBehavior> createDefaultLayoutBehaviors() =>
1414
new List.from([new ChartTooltip()]);
1515

1616
/// Sample columns used by demos with quantitative dimension scale
17-
Iterable ORDINAL_DATA_COLUMNS = [
17+
List<ChartColumnSpec> ORDINAL_DATA_COLUMNS = <ChartColumnSpec>[
1818
new ChartColumnSpec(label: 'Month', type: ChartColumnSpec.TYPE_STRING),
1919
new ChartColumnSpec(label: 'Grains'),
2020
new ChartColumnSpec(label: 'Fruits'),
2121
new ChartColumnSpec(label: 'Vegetables')
2222
];
2323

2424
/// Sample values used by demos with quantitative dimension scale
25-
Iterable ORDINAL_DATA = const [
25+
List<List> ORDINAL_DATA = const <List>[
2626
const ['January', 4.50, 7, 6],
2727
const ['February', 5.61, 16, 8],
2828
const ['March', 8.26, 36, 9],
@@ -38,7 +38,7 @@ Iterable ORDINAL_DATA = const [
3838
];
3939

4040
/// Sample values used by RTL demos with quantitative dimension scale
41-
Iterable ORDINAL_DATA_RTL = const [
41+
List<List> ORDINAL_DATA_RTL = const <List>[
4242
const ['كانون الثاني', 4.50, 7, 6],
4343
const ['شباط', 5.61, 16, 8],
4444
const ['آذار', 8.26, 36, 9],
@@ -53,7 +53,7 @@ Iterable ORDINAL_DATA_RTL = const [
5353
const ['كانون الأول', 8.46, 19, 3]
5454
];
5555

56-
Iterable ORDINAL_DATA_WITH_NEGATIVE = const [
56+
List<List> ORDINAL_DATA_WITH_NEGATIVE = const <List>[
5757
const ['January', 4.50, -7, 6],
5858
const ['February', 5.61, -16, 8],
5959
const ['March', 8.26, 36, 9],
@@ -68,7 +68,7 @@ Iterable ORDINAL_DATA_WITH_NEGATIVE = const [
6868
const ['December', 8.46, 19, 3]
6969
];
7070

71-
Iterable ORDINAL_DATA_WITH_BREAKS = const [
71+
List<List> ORDINAL_DATA_WITH_BREAKS = const <List>[
7272
const ['January', 4.50, -7, 6],
7373
const ['February', 5.61, -16, 8],
7474
const ['March', 8.26, 36, 9],
@@ -84,14 +84,14 @@ Iterable ORDINAL_DATA_WITH_BREAKS = const [
8484
];
8585

8686
/// Sample columns used by demos with quantitative dimension scale
87-
Iterable TIMESERIES_DATA_COLUMNS = [
87+
List<ChartColumnSpec> TIMESERIES_DATA_COLUMNS = <ChartColumnSpec>[
8888
new ChartColumnSpec(label: 'Time', type: ChartColumnSpec.TYPE_TIMESTAMP),
8989
new ChartColumnSpec(label: 'New York'),
9090
new ChartColumnSpec(label: 'San Fransisco'),
9191
new ChartColumnSpec(label: 'Austin')
9292
];
9393

94-
Iterable TIMESERIES_DATA = const [
94+
List<List<num>> TIMESERIES_DATA = const <List<num>>[
9595
const [1317452400000, 63.4, 62.7, 72.2],
9696
const [1317538800000, 58.0, 59.9, 67.7],
9797
const [1317625200000, 53.3, 59.1, 69.4],

examples/charts/demo_interactive.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'package:charted/charts/charts.dart';
1414

1515
import 'demo_charts.dart';
1616

17-
const List DIMENSION_COLUMNS = const[0, 4];
17+
const List<int> DIMENSION_COLUMNS = const <int>[0, 4];
1818

1919
int customSeriesCounter = 0;
2020

@@ -40,14 +40,14 @@ String getTypeForRenderer(CartesianRenderer renderer) {
4040
}
4141

4242
main() {
43-
List DATA_SOURCE = ORDINAL_DATA;
43+
List<List> DATA_SOURCE = ORDINAL_DATA;
4444
ChartSeries activeSeries,
4545
defaultSeries = new ChartSeries("Default series",
4646
new ObservableList.from([ 2, 3 ]), new BarChartRenderer());
4747

48-
ObservableList rows = new ObservableList.from(DATA_SOURCE.sublist(0, 10)),
49-
columns = new ObservableList.from(ORDINAL_DATA_COLUMNS),
50-
seriesList = new ObservableList.from([ defaultSeries ]);
48+
var rows = new ObservableList<List>.from(DATA_SOURCE.sublist(0, 10));
49+
var columns = new ObservableList<ChartColumnSpec>.from(ORDINAL_DATA_COLUMNS);
50+
var seriesList = new ObservableList<ChartSeries>.from([ defaultSeries ]);
5151

5252
ChartData data = new ChartData(columns, rows);
5353
ChartConfig config = new ChartConfig(seriesList, DIMENSION_COLUMNS);
@@ -71,7 +71,6 @@ main() {
7171
removeSeriesButton = querySelector('#remove-series');
7272

7373
InputElement useRTLScriptCheckBox = querySelector('#rtl-use-script'),
74-
switchAxesForRTLCheckBox = querySelector('#rtl-switch-axes'),
7574
useRTLLayoutCheckBox = querySelector('#rtl-use-layout');
7675

7776
SelectElement seriesSelect = querySelector('#select-series'),
@@ -192,7 +191,9 @@ main() {
192191
int index = buttons.indexOf(e.target) + 1;
193192
if ((e.target as InputElement).checked) {
194193
measures.add(index);
195-
buttons.forEach((InputElement b) => b.disabled = false);
194+
buttons.forEach((Element b) {
195+
(b as InputElement).disabled = false;
196+
});
196197
} else {
197198
measures.remove(index);
198199
if (measures.length <= 1) firstChecked.disabled = true;

examples/charts/renderers/demo_cartesian_renderers.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ main() {
188188

189189
Element chartsContainer = querySelector('.demos-container');
190190
InputElement useRTLScriptCheckBox = querySelector('#rtl-use-script'),
191-
switchAxesForRTLCheckBox = querySelector('#rtl-switch-axes'),
192191
useRTLLayoutCheckBox = querySelector('#rtl-use-layout');
193192

194193
useRTLLayoutCheckBox.onChange.listen((_) {
@@ -199,7 +198,7 @@ main() {
199198

200199
useRTLScriptCheckBox.onChange.listen((_) {
201200
bool isRTL = useRTLScriptCheckBox.checked;
202-
Iterable DATA_SOURCE = isRTL
201+
List<List> DATA_SOURCE = isRTL
203202
? ORDINAL_DATA_RTL
204203
: ORDINAL_DATA;
205204
charts.forEach((ChartDemo x) {

lib/charts/behaviors/axis_label_tooltip.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class AxisLabelTooltip implements ChartBehavior {
3838
void _subscribe() {
3939
var elements = _area.host.querySelectorAll(_AXIS_SELECTOR);
4040
_disposer.dispose();
41-
_disposer
42-
.addAll(elements.map((x) => x.onMouseOver.listen(_handleMouseOver)));
41+
_disposer.addAll(
42+
elements.map((Element x) => x.onMouseOver.listen(_handleMouseOver)));
4343
_disposer.addAll(elements.map((x) => x.onMouseOut.listen(_handleMouseOut)));
4444
}
4545

@@ -88,7 +88,7 @@ class AxisLabelTooltip implements ChartBehavior {
8888
void ensureRenderAreaRect() {
8989
var layout = _area.layout;
9090
_hostAreaRect = _area.host.getBoundingClientRect();
91-
_renderAreaRect = new math.Rectangle(
91+
_renderAreaRect = new math.Rectangle<num>(
9292
_hostAreaRect.left + layout.chartArea.x + layout.renderArea.x,
9393
_hostAreaRect.top + layout.chartArea.y + layout.renderArea.y,
9494
layout.renderArea.width,

lib/charts/behaviors/hovercard.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Hovercard implements ChartBehavior {
7878
{bool isMouseTracking,
7979
bool isMultiValue: false,
8080
bool showDimensionTitle: false,
81-
List columnsToShow: const [],
81+
List<int> columnsToShow: const <int>[],
8282
this.builder}) {
8383
_isMouseTracking = isMouseTracking;
8484
_isMultiValue = isMultiValue;
@@ -205,7 +205,7 @@ class Hovercard implements ChartBehavior {
205205
// update position and offset accordingly.
206206
if (area.dimensionsUsingBands.contains(dimensionCol)) {
207207
assert(dimensionScale is OrdinalScale);
208-
dimensionOffset = (dimensionScale as OrdinalScale).rangeBand / 2;
208+
dimensionOffset = (dimensionScale as OrdinalScale).rangeBand ~/ 2;
209209
dimensionCenterOffset = dimensionOffset;
210210
}
211211

lib/charts/cartesian_renderers/bar_chart_renderer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BarChartRenderer extends CartesianRendererBase {
4747

4848
var bars = new OrdinalScale()
4949
..domain = new Range(series.measures.length).toList()
50-
..rangeRoundBands([0, dimensionScale.rangeBand]);
50+
..rangeRoundBands([0, (dimensionScale as OrdinalScale).rangeBand]);
5151

5252
// Create and update the bar groups.
5353

lib/charts/cartesian_renderers/bubble_chart_renderer.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class BubbleChartRenderer extends CartesianRendererBase {
7171
group.enter.append('g')..classed('measure-group');
7272
group.each((d, i, e) {
7373
e.style.setProperty('fill', color(i));
74-
e.attributes['data-column'] = series.measures.elementAt(i);
74+
e.attributes['data-column'] = series.measures.elementAt(i).toString();
7575
});
7676
group.exit.remove();
7777

@@ -85,7 +85,7 @@ class BubbleChartRenderer extends CartesianRendererBase {
8585
'${xDimensionScale.scale(xDimensionVals[i])},'
8686
'${yDimensionScale.scale(yDimensionVals[i])})'
8787
..['r'] = '${bubbleRadiusScale.scale(d) * bubbleRadiusFactor}'
88-
..['data-row'] = i;
88+
..['data-row'] = i.toString();
8989
});
9090
measures.exit.remove();
9191
handleStateChanges([]);
@@ -107,7 +107,9 @@ class BubbleChartRenderer extends CartesianRendererBase {
107107
@override
108108
Extent get extent {
109109
assert(series != null && area != null);
110-
var rows = area.data.rows, max = rows[0][series.measures.first], min = max;
110+
var rows = area.data.rows,
111+
max = rows.first[series.measures.first],
112+
min = max;
111113

112114
rows.forEach((row) {
113115
series.measures.forEach((idx) {

lib/charts/cartesian_renderers/cartesian_base_renderer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ abstract class CartesianRendererBase implements CartesianRenderer {
182182
if (state == null || area.useRowColoring) {
183183
_columnStylesCache[column] = const [];
184184
} else {
185-
var styles = [], flags = _columnStateCache[column];
185+
var styles = <String>[], flags = _columnStateCache[column];
186186

187187
if (flags & ChartState.COL_SELECTED != 0) {
188188
styles.add(ChartState.COL_SELECTED_CLASS);

lib/charts/cartesian_renderers/line_chart_renderer.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ part of charted.charts;
1010

1111
class LineChartRenderer extends CartesianRendererBase {
1212
final Iterable<int> dimensionsUsingBand = const [];
13-
final SubscriptionsDisposer _disposer = new SubscriptionsDisposer();
1413

1514
final bool alwaysAnimate;
1615
final bool trackDataPoints;
@@ -249,7 +248,7 @@ class LineChartRenderer extends CartesianRendererBase {
249248
}
250249
}
251250

252-
void _mouseOverHandler(d, i, e) {
251+
void _mouseOverHandler(d, int i, Element e) {
253252
if (area.state != null) {
254253
area.state.preview = int.parse(e.dataset['column']);
255254
}
@@ -261,7 +260,7 @@ class LineChartRenderer extends CartesianRendererBase {
261260
}
262261
}
263262

264-
void _mouseOutHandler(d, i, e) {
263+
void _mouseOutHandler(d, int i, Element e) {
265264
if (area.state != null &&
266265
area.state.preview == int.parse(e.dataset['column'])) {
267266
area.state.preview = null;

lib/charts/cartesian_renderers/stackedbar_chart_renderer.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ class StackedBarChartRenderer extends CartesianRendererBase {
2626
/// Returns false if the number of dimension axes on the area is 0.
2727
/// Otherwise, the first dimension scale is used to render the chart.
2828
@override
29-
bool prepare(CartesianArea area, ChartSeries series) {
29+
bool prepare(ChartArea area, ChartSeries series) {
30+
if (area is! CartesianArea) {
31+
throw new ArgumentError.value(area, 'area',
32+
"ChartArea for StackedBarChartRenderer must be a CartesianArea");
33+
}
3034
_ensureAreaAndSeries(area, series);
3135
return true;
3236
}
@@ -89,7 +93,8 @@ class StackedBarChartRenderer extends CartesianRendererBase {
8993
});
9094
}
9195

92-
var barWidth = dimensionScale.rangeBand - theme.defaultStrokeWidth;
96+
var barWidth =
97+
(dimensionScale as OrdinalScale).rangeBand - theme.defaultStrokeWidth;
9398

9499
// Calculate height of each segment in the bar.
95100
// Uses prevAllZeroHeight and prevOffset to track previous segments

lib/charts/chart_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class ChartData {
1717
Iterable<ChartColumnSpec> get columns;
1818

1919
/// Read-only access to rows
20-
Iterable<Iterable> get rows;
20+
Iterable<List> get rows;
2121

2222
/// Create a new instance of [ChartData]'s internal implementation
2323
factory ChartData(Iterable<ChartColumnSpec> columns,

lib/charts/chart_events.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ abstract class ChartEvent {
8282
num get chartY;
8383

8484
factory ChartEvent(Event source, ChartArea area,
85-
[ChartSeries series, int row, int column, value]) = DefaultChartEventImpl;
85+
[ChartSeries series,
86+
int row,
87+
int column,
88+
num value]) = DefaultChartEventImpl;
8689
}
8790

8891
/// Interface implemented by chart behaviors.

lib/charts/chart_state.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class ChartState implements ChangeNotifier {
3535
static const VAL_UNHIGHLIGHTED_CLASS = 'row-unhighlighted';
3636
static const VAL_HOVERED_CLASS = 'row-hovered';
3737

38-
static const COLUMN_CLASS_NAMES = const [
38+
static const COLUMN_CLASS_NAMES = const <String>[
3939
COL_SELECTED_CLASS,
4040
COL_UNSELECTED_CLASS,
4141
COL_PREVIEW_CLASS,
@@ -45,7 +45,7 @@ abstract class ChartState implements ChangeNotifier {
4545
COL_HOVERED_CLASS
4646
];
4747

48-
static const VALUE_CLASS_NAMES = const [
48+
static const VALUE_CLASS_NAMES = const <String>[
4949
COL_SELECTED_CLASS,
5050
COL_UNSELECTED_CLASS,
5151
COL_PREVIEW_CLASS,
@@ -76,7 +76,7 @@ abstract class ChartState implements ChangeNotifier {
7676

7777
/// Currently highlighted value, if any, represented as column and row.
7878
/// Highlight is result of a click on certain value.
79-
Iterable<Pair<int, int>> highlights;
79+
Iterable<Pair<int, int>> get highlights;
8080

8181
/// Currently hovered value, if any, represented as column and row.
8282
/// Hover is result of mouse moving over a certian value in chart.

lib/charts/chart_theme.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class ChartTheme {
3030

3131
/// Markup for filters that is added to all chart elements. These filters
3232
/// can be referenced using url() in values returned by [getFilterForState].
33-
String filters;
33+
String get filters;
3434

3535
/// Returns any filters that must be applied based on the element's state
3636
String getFilterForState(int state);

lib/charts/charts.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ library charted.charts;
1010

1111
import 'dart:async';
1212
import 'dart:collection';
13-
import 'dart:html' show Element, document, window, Event, MouseEvent;
13+
import 'dart:html' show Element, window, Event, MouseEvent;
1414
import 'dart:math' as math;
1515
import 'dart:svg' hide Rect;
1616
import 'dart:typed_data';

0 commit comments

Comments
 (0)