Skip to content

Commit

Permalink
Merge branch 'main' into goldens
Browse files Browse the repository at this point in the history
  • Loading branch information
MelbourneDeveloper authored Sep 25, 2024
2 parents c9bbd67 + 216286d commit 6e9b540
Show file tree
Hide file tree
Showing 49 changed files with 155 additions and 98 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# cspell:words subosito
name: build_and_test
on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
cspell:
name: 🔤 Check Spelling
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/spell_check.yml@v1
with:
config: cspell.config.yaml

build:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Ensure that your contributions include appropriate tests and that all existing t

Unit tests are not enough. All UI changes require widget tests, and even better if those widget tests double as integration tests.

It's sually a good idea to capture at least one golden of the charts, and there are plenty of examples of that in the existing tests.
It's usually a good idea to capture at least one golden of the charts, and there are plenty of examples of that in the existing tests.

## Community

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This project is a resurrection of the discontinued [charts_flutter](https://pub.

### Dart 3, Type Safety, Tests, and Bug Fixes

Type safety and rigourous tests ensure that this package is reliable and maintainable. We applied thousands of automatic and manual fixes to the code to bring type safety up, and ensure that it's harder to break this library. There are also many new widget tests with goldens, which means that changes should not affect the UI behavior.
Type safety and rigorous tests ensure that this package is reliable and maintainable. We applied thousands of automatic and manual fixes to the code to bring type safety up, and ensure that it's harder to break this library. There are also many new widget tests with goldens, which means that changes should not affect the UI behavior.

This fork provides the most solid foundation for future development, and we will continue to maintain this library.

Expand Down
2 changes: 1 addition & 1 deletion charts_common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This project is a resurrection of the discontinued [charts_flutter](https://pub.

### Dart 3, Type Safety, Tests, and Bug Fixes

Type safety and rigourous tests ensure that this package is reliable and maintainable. We applied thousands of automatic and manual fixes to the code to bring type safety up, and ensure that it's harder to break this library. There are also many new widget tests with goldens, which means that changes should not affect the UI behavior.
Type safety and rigorous tests ensure that this package is reliable and maintainable. We applied thousands of automatic and manual fixes to the code to bring type safety up, and ensure that it's harder to break this library. There are also many new widget tests with goldens, which means that changes should not affect the UI behavior.

This fork provides the most solid foundation for future development, and we will continue to maintain this library.

Expand Down
1 change: 1 addition & 0 deletions charts_common/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# cspell:words runtimetype tostring
include: package:austerity/analysis_options.yaml

analyzer:
Expand Down
4 changes: 2 additions & 2 deletions charts_common/lib/src/chart/bar/bar_label_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
: defaultStyle;
}

/// Helper function to get the bar label anchor when BarLabelPostion is
/// Helper function to get the bar label anchor when BarLabelPosition is
/// inside.
BarLabelAnchor _resolveLabelAnchor(num measure, BarLabelAnchor anchor) {
if (labelPlacement == BarLabelPlacement.opposeAxisBaseline) {
Expand Down Expand Up @@ -484,7 +484,7 @@ enum BarLabelPlacement {
followMeasureAxis,

/// Places the label with respect to the zero baseline. The bar end is the
/// absolute value aways from the zero baseline.
/// absolute value always from the zero baseline.
opposeAxisBaseline,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:nimble_charts_common/src/chart/bar/bar_label_decorator.dart'
import 'package:nimble_charts_common/src/chart/bar/bar_lane_renderer.dart'
show BarLaneRenderer;
import 'package:nimble_charts_common/src/chart/bar/bar_renderer_config.dart'
show BarRendererConfig, CornerStrategy;
show BarRendererConfig;
import 'package:nimble_charts_common/src/chart/bar/base_bar_renderer_config.dart'
show BarGroupingType;
import 'package:nimble_charts_common/src/common/color.dart' show Color;
Expand Down
5 changes: 2 additions & 3 deletions charts_common/lib/src/chart/bar/bar_renderer_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ class BarRendererConfig<D> extends BaseBarRendererConfig<D> {

@override
int get hashCode {
var hash = super.hashCode;
hash = hash * 31 + cornerStrategy.hashCode;
return hash;
final hash = super.hashCode;
return hash * 31 + cornerStrategy.hashCode;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class BarTargetLineRenderer<D> extends BaseBarRenderer<D,
@override
Rectangle<int> getBoundsForBar(BarTargetLineRendererElement bar) {
final points = bar.points;
assert(points.isNotEmpty);
assert(points.isNotEmpty, 'Bar must have at least one point.');
var top = points.first.y;
var bottom = points.first.y;
var left = points.first.x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import 'package:nimble_charts_common/src/chart/bar/bar_target_line_renderer.dart'
show BarTargetLineRenderer;
import 'package:nimble_charts_common/src/chart/bar/base_bar_renderer_config.dart'
show BarGroupingType, BaseBarRendererConfig;
show BaseBarRendererConfig;
import 'package:nimble_charts_common/src/chart/layout/layout_view.dart'
show LayoutViewPaintOrder;
import 'package:nimble_charts_common/src/common/symbol_renderer.dart'
Expand Down
4 changes: 2 additions & 2 deletions charts_common/lib/src/chart/bar/base_bar_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,

final barStackList = _barStackMap.putIfAbsent(barStackMapKey, () => []);

// If we already have an AnimatingBarfor that index, use it.
// If we already have an AnimatingBar for that index, use it.
var animatingBar =
barStackList.firstWhereOrNull((bar) => bar.key == barKey);

Expand Down Expand Up @@ -830,7 +830,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
bool get isRtl => chart.context.isRtl;
}

/// Iterable wrapping the seriesList that returns the ReversedSeriesItertor.
/// Iterable wrapping the seriesList that returns the ReversedSeriesIterator.
class _ReversedSeriesIterable<S extends ImmutableSeries<Object?>>
extends Iterable<S> {
_ReversedSeriesIterable(this.seriesList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ abstract class BaseBarRendererConfig<D> extends LayoutViewConfig
}
}

/// Defines the way multiple series of bars are renderered per domain.
/// Defines the way multiple series of bars are rendered per domain.
///
/// * [grouped] - Render bars for each series that shares a domain value
/// side-by-side.
Expand Down
2 changes: 1 addition & 1 deletion charts_common/lib/src/chart/cartesian/axis/axis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ abstract class Axis<D> extends ImmutableAxis<D> implements LayoutView {
final domainLocation = scale[domain]!.toDouble();

// If domain location is outside of scale range but only outside by less
// than epsilon, correct the potential mislocation caused by floating
// than epsilon, correct the potential mis-location caused by floating
// point computation by moving it inside of scale range.
if (domainLocation > range.max && domainLocation - epsilon < range.max) {
return domainLocation - epsilon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RangeTickRendererSpec<D> extends SmallTickRendererSpec<D> {
final int? rangeTickLengthPx;
// Specifies range shade's height.
final int? rangeShadeHeightPx;
// Specifies the starting offet of range shade from axis in pixels.
// Specifies the starting offset of range shade from axis in pixels.
final int? rangeShadeOffsetFromAxisPx;
// A range tick offset from the original location. The start point offset is
// toward the origin and end point offset is toward the end of axis.
Expand Down Expand Up @@ -268,7 +268,7 @@ class RangeTickDrawStrategy<D> extends SmallTickDrawStrategy<D> {
getLabelWidth(labelElements),
) +
labelOffsetFromAxisPx(collision: collision),
//TODO: possible precission loss
//TODO: possible precision loss
).toInt(),
labelOffsetFromAxisPx(collision: collision) + rangeShadeHeightPx,
);
Expand All @@ -281,7 +281,7 @@ class RangeTickDrawStrategy<D> extends SmallTickDrawStrategy<D> {
getLabelWidth(labelElements),
) +
labelOffsetFromAxisPx(collision: collision),
//TODO: possible precission loss
//TODO: possible precision loss
).toInt();
}
});
Expand Down Expand Up @@ -314,7 +314,7 @@ class RangeTickDrawStrategy<D> extends SmallTickDrawStrategy<D> {
getLabelWidth(labelElements),
) +
rangeShadeOffsetFromAxisPx,
//TODO: possible precission loss
//TODO: possible precision loss
).toInt(),
rangeShadeOffsetFromAxisPx + rangeShadeHeightPx,
);
Expand All @@ -326,7 +326,7 @@ class RangeTickDrawStrategy<D> extends SmallTickDrawStrategy<D> {
getLabelHeight(labelElements),
getLabelWidth(labelElements),
),
//TODO: possible precission loss
//TODO: possible precision loss
).toInt() +
labelOffsetFromAxisPx(collision: collision);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.

import 'dart:collection' show HashSet;

import 'package:nimble_charts_common/src/chart/cartesian/axis/scale.dart'
show Extents;

Expand All @@ -22,8 +23,6 @@ class OrdinalExtents extends Extents<String> {
/// The extents representing the ordinal values in [range].
///
/// The elements of [range] must all be unique.
///
/// [D] is the domain class type for the elements in the extents.
OrdinalExtents(List<String> range) : _range = range {
// This asserts that all elements in [range] are unique.
assert(() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import 'package:nimble_charts_common/src/chart/cartesian/axis/ordinal_scale.dart

/// A domain processor for [OrdinalScale].
///
/// [D] domain class type of the values being tracked.
///
/// Unique domain values are kept, so duplicates will not increase the extent.
class OrdinalScaleDomainInfo {
OrdinalScaleDomainInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,5 @@ class EndPointsTimeAxisSpec extends DateTimeAxisSpec {
(other is EndPointsTimeAxisSpec && super == other);

@override
int get hashCode {
var hashcode = super.hashCode;
hashcode = (hashcode * 37) + runtimeType.hashCode;
return hashcode;
}
int get hashCode => (super.hashCode * 37) + runtimeType.hashCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ class NumericAxisSpec extends AxisSpec<num> {
other is NumericAxisSpec && viewport == other.viewport && super == other;

@override
int get hashCode {
var hashcode = super.hashCode;
hashcode = (hashcode * 37) + viewport.hashCode;
return hashcode;
}
int get hashCode => (super.hashCode * 37) + viewport.hashCode;
}

abstract class NumericTickProviderSpec extends TickProviderSpec<num> {}
Expand Down Expand Up @@ -239,9 +235,5 @@ class BasicNumericTickFormatterSpec implements NumericTickFormatterSpec {
numberFormat == other.numberFormat);

@override
int get hashCode {
var hashcode = formatter.hashCode;
hashcode = (hashcode * 37) + numberFormat.hashCode;
return hashcode;
}
int get hashCode => (formatter.hashCode * 37) + numberFormat.hashCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ class OrdinalAxisSpec extends AxisSpec<String> {
super == other);

@override
int get hashCode {
var hashcode = super.hashCode;
hashcode = (hashcode * 37) + viewport.hashCode;
return hashcode;
}
int get hashCode => (super.hashCode * 37) + viewport.hashCode;
}

abstract class OrdinalTickProviderSpec extends TickProviderSpec<String> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:meta/meta.dart' show immutable;
import 'package:nimble_charts_common/src/chart/cartesian/axis/numeric_extents.dart'
show NumericExtents;
import 'package:nimble_charts_common/src/chart/cartesian/axis/spec/axis_spec.dart'
show AxisSpec, RenderSpec;
show AxisSpec;
import 'package:nimble_charts_common/src/chart/cartesian/axis/spec/numeric_axis_spec.dart'
show
BasicNumericTickFormatterSpec,
Expand Down Expand Up @@ -51,9 +51,5 @@ class PercentAxisSpec extends NumericAxisSpec {
bool operator ==(Object other) => other is PercentAxisSpec && super == other;

@override
int get hashCode {
var hashcode = super.hashCode;
hashcode = (hashcode * 37) + runtimeType.hashCode;
return hashcode;
}
int get hashCode => (super.hashCode * 37) + runtimeType.hashCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import 'package:nimble_charts_common/src/common/graphics_factory.dart'
class AutoAdjustingDateTimeTickProvider implements TickProvider<DateTime> {
AutoAdjustingDateTimeTickProvider._internal(
List<TimeRangeTickProvider> tickProviders,
) : assert(tickProviders.isNotEmpty),
) : assert(tickProviders.isNotEmpty, 'At least one tick provider required'),
_potentialTickProviders = tickProviders;

/// Creates a default [AutoAdjustingDateTimeTickProvider] for day and time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ class DayTimeStepper extends BaseTimeStepper {
// Set the default increments if null.
allowedTickIncrements ??= _defaultIncrements;

assert(allowedTickIncrements.every((increment) => increment > 0));
assert(
allowedTickIncrements.every((increment) => increment > 0),
'Tick increments must be greater than 0.',
);

return DayTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MinuteTimeStepper extends BaseTimeStepper {
assert(
allowedTickIncrements
.every((increment) => increment >= 1 && increment <= 60),
'Tick increments must be between 1 and 60.',
);

return MinuteTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ class MonthTimeStepper extends BaseTimeStepper {
// Set the default increments if null.
allowedTickIncrements ??= _defaultIncrements;

assert(allowedTickIncrements.every((increment) => increment > 0));
assert(
allowedTickIncrements.every((increment) => increment > 0),
'Tick increments must be greater than 0.',
);

return MonthTimeStepper._internal(dateTimeFactory, allowedTickIncrements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TimeRangeTickProviderImpl extends TimeRangeTickProvider {
int? minDifference;
late int closestIncrement;

assert(timeStepper.allowedTickIncrements.isNotEmpty);
assert(timeStepper.allowedTickIncrements.isNotEmpty, 'No increments set.');
for (final increment in timeStepper.allowedTickIncrements) {
final difference =
(stepSize - (timeStepper.typicalStepSizeMs * increment)).abs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ abstract class BaseCartesianRenderer<D> extends BaseSeriesRenderer<D>
AccessorFn<D> domainFn,
List<Object?> data,
) {
assert(data.isNotEmpty);
assert(data.isNotEmpty, 'Data must not be empty.');

// Quick optimization for full viewport (likely).
if (domainAxis.compareDomainValueToViewport(domainFn(0)) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class A11yExploreBehavior<D> implements ChartBehavior<D> {
this.exploreModeDisabledAnnouncement,
}) : exploreModeTrigger = exploreModeTrigger ?? ExploreModeTrigger.pressHold,
minimumWidth = minimumWidth ?? 1.0 {
assert(this.minimumWidth >= 1.0);
assert(this.minimumWidth >= 1.0, 'minimumWidth must be 1 or greater.');

switch (this.exploreModeTrigger) {
case ExploreModeTrigger.pressHold:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import 'package:nimble_charts_common/src/chart/cartesian/cartesian_chart.dart'
import 'package:nimble_charts_common/src/chart/common/base_chart.dart'
show BaseChart, LifecycleListener;
import 'package:nimble_charts_common/src/chart/common/behavior/a11y/a11y_explore_behavior.dart'
show A11yExploreBehavior, ExploreModeTrigger;
show A11yExploreBehavior;
import 'package:nimble_charts_common/src/chart/common/behavior/a11y/a11y_node.dart'
show A11yNode, OnFocus;
import 'package:nimble_charts_common/src/chart/common/processed_series.dart'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ abstract class KeyboardDomainNavigator<D> implements ChartBehavior<D> {
}

// If the currentIndex is the same as the firstSelectedDetail we don't have
// to do a linear seach to find the domain.
// to do a linear search to find the domain.
final firstDomain = details.first.domain as D;

if (0 <= _currentIndex &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class LegendCategory<D> extends LegendEntryBase {

/// Holder for the information used for a legend row.
///
/// [T] the datum class type for the series passed in.
/// [D] the domain class type for the datum.
class LegendEntry<D> extends LegendEntryBase {
// TODO: Forward the default formatters from series and allow for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {

if (chart is CartesianChart) {
// Only vertical rendering is supported by this behavior.
assert((chart as CartesianChart).vertical);
assert(
(chart as CartesianChart).vertical,
'Only vertical charts are supported for LinePointHighlighter.',
);
}

chart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'dart:math';

import 'package:nimble_charts_common/common.dart';

/// Chart behavior that listens to tap event trigges and locks the specified
/// Chart behavior that listens to tap event triggers and locks the specified
/// [SelectionModel]. This is used to prevent further updates to the selection
/// model, until it is unlocked again.
///
Expand Down
Loading

0 comments on commit 6e9b540

Please sign in to comment.