Skip to content

Commit

Permalink
added isDefault to GridAxisDatas, painting `defaultDivisionInterval…
Browse files Browse the repository at this point in the history
…` if data is default
  • Loading branch information
OlehMarch committed Aug 19, 2024
1 parent e0c49fe commit aa26045
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.2.1 - 19.08.2024

* Changes of the `GridAxis` based charts (`LineChart`/`CandlestickChart`):
* Added extra condition (if data is default alongside with empty data) for painting `GridAxisSettings.defaultDivisionInterval`.

## 6.2.0 - 19.08.2024

* Changes of the `GridAxis` based charts (`LineChart`/`CandlestickChart`):
Expand Down
4 changes: 4 additions & 0 deletions lib/src/candlestick/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class CandlestickChartData extends GridAxisData<CandlestickData> {
@override
double minValuePredicate(CandlestickData value) => value.low;

@override
bool get isDefault =>
data.values.every((v) => v == const CandlestickData.zero());

/// Creates a copy of the current object with new values specified in
/// arguments.
CandlestickChartData copyWith({
Expand Down
3 changes: 3 additions & 0 deletions lib/src/common/chart.data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ abstract class ChartData<T> {
/// It checks for [data] length to be greater than or equal to 1.
bool get canDraw => data.isNotEmpty;

/// Checks whether every data entry is a default value ot not.
bool get isDefault;

/// Checks whether every data entry is less than or equal to `0` and any of
/// it strictly less than `0` or not.
bool get isNegative =>
Expand Down
2 changes: 1 addition & 1 deletion lib/src/common/gridaxis/painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class GridAxisPainter extends CustomPainter {
}

double labelValue;
if (data.data.isEmpty) {
if (data.data.isEmpty || data.isDefault) {
labelValue =
mult(math.max(settings.defaultDivisionInterval, 1), yEnd - i - 1);
} else if (data.isNegative) {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/line/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class LineChartData extends GridAxisData<double> {
@override
double minValuePredicate(double value) => value;

@override
bool get isDefault => data.values.every((v) => v == 0);

/// {@macro ChartData.maxValue}
/// (Omitting [limit] value)
///
Expand Down

0 comments on commit aa26045

Please sign in to comment.