Skip to content

Commit

Permalink
[Presentation] Minor fix in the region chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Aug 28, 2022
1 parent 68208c6 commit 259cee7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
Binary file modified assets/characters/candace.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/characters/cyno.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/characters/tighnari.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions lib/presentation/charts/charts_page.dart
Expand Up @@ -220,10 +220,10 @@ class _ChartPagination extends StatelessWidget {
final bool canGoToNextPage;
final bool canGoToLastPage;

final Function onFirstPagePressed;
final Function onPreviousPagePressed;
final Function onNextPagePressed;
final Function onLastPagePressed;
final VoidCallback onFirstPagePressed;
final VoidCallback onPreviousPagePressed;
final VoidCallback onNextPagePressed;
final VoidCallback onLastPagePressed;

const _ChartPagination({
Key? key,
Expand Down Expand Up @@ -701,7 +701,15 @@ class _Regions extends StatelessWidget {
? NothingFoundColumn(msg: s.nothingToShow)
: VerticalBarChart(
items: state.items
.mapIndex((e, i) => VerticalBarDataModel(i, theme.colorScheme.primary, e.regionType.index, e.quantity.toDouble()))
.mapIndex(
(e, i) => VerticalBarDataModel(
i,
theme.colorScheme.primary,
e.regionType.index,
e.quantity.toDouble(),
useIndexAsX: true,
),
)
.toList(),
maxY: state.maxCount.toDouble(),
interval: (state.maxCount * 0.2).roundToDouble(),
Expand Down
8 changes: 5 additions & 3 deletions lib/presentation/charts/widgets/vertical_bar_chart.dart
Expand Up @@ -11,8 +11,9 @@ class VerticalBarDataModel {
final Color color;
final int x;
final double y;
final bool useIndexAsX;

VerticalBarDataModel(this.index, this.color, this.x, this.y);
VerticalBarDataModel(this.index, this.color, this.x, this.y, {this.useIndexAsX = false});
}

const _textStyle = TextStyle(
Expand Down Expand Up @@ -71,7 +72,8 @@ class VerticalBarChart extends StatelessWidget {
),
touchCallback: (FlTouchEvent event, response) {
if (event is FlTapUpEvent && response?.spot?.touchedBarGroupIndex != null) {
onBarChartTap?.call(response!.spot!.touchedBarGroupIndex, response.spot!.touchedRodDataIndex);
final spot = response!.spot!;
onBarChartTap?.call(spot.touchedBarGroupIndex, spot.touchedRodDataIndex);
}
},
),
Expand Down Expand Up @@ -104,7 +106,7 @@ class VerticalBarChart extends StatelessWidget {
barGroups: items
.map(
(e) => BarChartGroupData(
x: e.x,
x: e.useIndexAsX ? e.index : e.x,
barRods: getBarChartRodData?.call(e.x) ??
[
BarChartRodData(
Expand Down

0 comments on commit 259cee7

Please sign in to comment.