Skip to content

Commit 0574640

Browse files
perryr16Ross Perrykflemin
authored
Reset scale bounds on report change (#5111)
* reset bounds on report change * reset bounds for bar chart --------- Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: Katherine Fleming <2205659+kflemin@users.noreply.github.com>
1 parent 54bbcee commit 0574640

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

seed/static/seed/js/controllers/inventory_reports_controller.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ angular.module('SEED.controller.inventory_reports', []).controller('inventory_re
245245
246246
$scope.xAxisVars consists of columns specified as numeric types.
247247
248-
$scope.uAxisVars consists of manually defined columns specified.
248+
$scope.yAxisVars consists of manually defined columns specified.
249249
Ideally, if we need to add new variables, we should just be able to add a new object to
250250
either of these arrays. (However, at first when adding new variables we might need to add
251251
new functionality to the directive to handle any idiosyncrasies of graphing that new variable.)
@@ -616,7 +616,6 @@ angular.module('SEED.controller.inventory_reports', []).controller('inventory_re
616616
.then(
617617
(data) => {
618618
data = data.data;
619-
620619
const propertyCounts = data.property_counts;
621620
const colorsArr = mapColors(propertyCounts);
622621
$scope.propertyCounts = propertyCounts;
@@ -629,12 +628,16 @@ angular.module('SEED.controller.inventory_reports', []).controller('inventory_re
629628
yAxisVarName: $scope.yAxisSelectedItem.varName,
630629
yAxisType: $scope.yAxisSelectedItem.axisType,
631630
yAxisMin: $scope.yAxisSelectedItem.axisMin,
631+
yAxisMax: $scope.yAxisSelectedItem.axisMax,
632632
xAxisTickFormat: $scope.xAxisSelectedItem.axisTickFormat,
633633
yAxisTickFormat: $scope.yAxisSelectedItem.axisTickFormat
634634
};
635635

636-
// new chartJS chart data
636+
// yAxisVars.axisMin and axisMax are unused and will remain 'undefined'.
637+
// They may be placeholders for future functionality.
638+
// Leaving them undefined is ideal, as it lets Chart.js automatically determine the proper min/max values.
637639
$scope.scatterChart.options.scales.y.min = $scope.yAxisSelectedItem.axisMin;
640+
$scope.scatterChart.options.scales.y.max = $scope.yAxisSelectedItem.axisMax;
638641
$scope.scatterChart.options.scales.y.type = $scope.chartData.chartData.every((d) => typeof d.y === 'number') ? 'linear' : 'category';
639642

640643
if ($scope.chartData.chartData.every((d) => typeof d.x === 'number')) {
@@ -745,6 +748,10 @@ angular.module('SEED.controller.inventory_reports', []).controller('inventory_re
745748

746749
// new agg chart
747750
const the_data = $scope.aggChartData.chartData;
751+
$scope.barChart.options.scales.y.min = undefined;
752+
$scope.barChart.options.scales.y.max = undefined;
753+
$scope.barChart.options.scales.x.min = undefined;
754+
$scope.barChart.options.scales.x.max = undefined;
748755
$scope.barChart.data.labels = the_data.map((a) => a.y);
749756
$scope.barChart.data.datasets[0].data = the_data.map((a) => a.x);
750757
// add the colors to the datapoints, need to create a hash map first

0 commit comments

Comments
 (0)