Skip to content

Commit

Permalink
Ensure year_built labels do not have commas, adjust width of scatterc…
Browse files Browse the repository at this point in the history
…hart (#4859)

* fix year_built labels to not have commas, set x min/max according to data provided, +/- half a percent

* linter changes
  • Loading branch information
crutan authored Oct 18, 2024
1 parent b345318 commit 28f063d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions seed/static/seed/js/controllers/inventory_reports_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,26 @@ angular.module('SEED.controller.inventory_reports', []).controller('inventory_re

if ($scope.chartData.chartData.every((d) => typeof d.x === 'number')) {
$scope.scatterChart.options.scales.x.type = 'linear';

// Set the min / max for the axis to be the min/max values -/+ 0.5 percent
$scope.scatterChart.options.scales.x.min = Math.min(...$scope.chartData.chartData.map((d) => d.x));
$scope.scatterChart.options.scales.x.min -= Math.round(Math.abs($scope.scatterChart.options.scales.x.min * 0.005));

$scope.scatterChart.options.scales.x.max = Math.max(...$scope.chartData.chartData.map((d) => d.x));
$scope.scatterChart.options.scales.x.max += Math.round(Math.abs($scope.scatterChart.options.scales.x.max * 0.005));

if ($scope.xAxisSelectedItem.varName === 'year_built') {
$scope.scatterChart.options.scales.x.ticks.callback = (value) => String(value);
}
} else {
$scope.scatterChart.options.scales.x = {
type: 'category',
labels: Array.from([...new Set($scope.chartData.chartData.map((d) => d.x))]).sort()
};
}
if ($scope.yAxisSelectedItem.varName === 'year_built') {
$scope.scatterChart.options.scales.y.ticks.callback = (value) => String(value);
}
$scope.scatterChart.data.datasets[0].data = $scope.chartData.chartData;
// add the colors to the datapoints, need to create a hash map first
const colorMap = new Map(colorsArr.map((object) => [object.seriesName, object.color]));
Expand Down

0 comments on commit 28f063d

Please sign in to comment.