diff --git a/frontend/src/Components/Charts/Contraband/Contraband.js b/frontend/src/Components/Charts/Contraband/Contraband.js index 0d7e76ef..3c1dd868 100644 --- a/frontend/src/Components/Charts/Contraband/Contraband.js +++ b/frontend/src/Components/Charts/Contraband/Contraband.js @@ -139,7 +139,7 @@ function Contraband(props) { axios .get(url) .then((res) => { - const colors = ['#80d9d8', '#beb4fa', '#ca8794', '#ffeeb2', '#8598ac', '#cab6c7']; + const colors = ['#02bcbb', '#8879fc', '#9c0f2e', '#ffe066', '#0c3a66', '#9e7b9b']; const data = { labels: ['White', 'Black', 'Hispanic', 'Asian', 'Native American', 'Other'], datasets: [ @@ -150,6 +150,7 @@ function Contraband(props) { fill: false, backgroundColor: colors, borderColor: colors, + hoverBackgroundColor: colors, borderWidth: 1, }, ], @@ -168,9 +169,9 @@ function Contraband(props) { .get(url) .then((res) => { const colors = { - 'Safety Violation': '#CFA9D6', - 'Regulatory Equipment': '#ffa500', - Other: '#ACE1AF', + 'Safety Violation': '#b173bc', + 'Regulatory Equipment': '#e69500', + Other: '#7dd082', }; const stopPurposeDataSets = res.data.map((ds) => ({ axis: 'x', @@ -179,6 +180,7 @@ function Contraband(props) { fill: false, backgroundColor: colors[ds.stop_purpose], borderColor: colors[ds.stop_purpose], + hoverBackgroundColor: colors[ds.stop_purpose], borderWidth: 1, })); const data = { @@ -199,11 +201,11 @@ function Contraband(props) { .get(url) .then((res) => { const colors = { - Drugs: '#feaba6', - Alcohol: '#86c6dd', - Weapons: '#c2e9bf', - Money: '#dbc3df', - Other: '#ffd4a0', + Drugs: '#3C91E6', + Alcohol: '#9FD356', + Weapons: '#ED217C', + Money: '#EFCEFA', + Other: '#2F4858', }; const stopPurposeDataSets = res.data.map((sp) => ({ labels: ['W', 'B', 'H', 'A', 'NA', 'O'], @@ -211,6 +213,7 @@ function Contraband(props) { label: ds.contraband, data: ds.data, backgroundColor: colors[ds.contraband], + hoverBackgroundColor: colors[ds.contraband], })), })); setContrabandGroupedStopPurposeData(stopPurposeDataSets); diff --git a/frontend/src/Components/Charts/TrafficStops/TrafficStops.js b/frontend/src/Components/Charts/TrafficStops/TrafficStops.js index bf3a4ca0..ce4b7417 100644 --- a/frontend/src/Components/Charts/TrafficStops/TrafficStops.js +++ b/frontend/src/Components/Charts/TrafficStops/TrafficStops.js @@ -91,11 +91,14 @@ function TrafficStops(props) { STATIC_LEGEND_KEYS.map((k) => ({ ...k })) ); + const pieColors = ['#02bcbb', '#8879fc', '#9c0f2e', '#ffe066', '#0c3a66', '#9e7b9b']; + const [byPercentageLineData, setByPercentageLineData] = useState([]); const pieChartLabels = ['White', 'Black', 'Hispanic', 'Asian', 'Native American', 'Other']; const pieChartConfig = { - backgroundColor: ['#80d9d8', '#beb4fa', '#ca8794', '#ffeeb2', '#8598ac', '#cab6c7'], - borderColor: ['#02bcbb', '#8879fc', '#9c0f2e', '#ffe066', '#0c3a66', '#9e7b9b'], + backgroundColor: pieColors, + borderColor: pieColors, + hoverBackgroundColor: pieColors, borderWidth: 1, }; const [byPercentagePieData, setByPercentagePieData] = useState({ @@ -120,8 +123,9 @@ function TrafficStops(props) { max_step_size: null, }); const groupedPieChartConfig = { - backgroundColor: ['#80d9d8', '#beb4fa', '#ca8794', '#ffeeb2', '#8598ac', '#cab6c7'], - borderColor: ['#02bcbb', '#8879fc', '#9c0f2e', '#ffe066', '#0c3a66', '#9e7b9b'], + backgroundColor: pieColors, + borderColor: pieColors, + hoverBackgroundColor: pieColors, borderWidth: 1, }; const groupedPieChartLabels = ['White', 'Black', 'Hispanic', 'Asian', 'Native American', 'Other']; diff --git a/nc/views.py b/nc/views.py index fb88397d..2bb196b9 100644 --- a/nc/views.py +++ b/nc/views.py @@ -908,7 +908,7 @@ def create_dataset(self, contraband_qs, stop_purpose, *args, **kwargs): } for c in self.columns: searches_df = self.create_searches_df(searches_qs, year) - if not searches_df: + if not searches_df or searches_df.empty: continue contraband_df = self.create_contraband_df(contraband_qs, contraband) @@ -978,7 +978,7 @@ def get(self, request, agency_id): contraband_qs = self.get_qs(Q(stop__agency__id=agency_id, person__type="D"), year) contraband_df = self.create_contraband_df(contraband_qs, contraband_type) - if not contraband_df: + if not contraband_df or contraband_df.empty: return Response(data={}, status=200) contraband_df = contraband_df[contraband_df["stop_purpose_group"] == grouped_stop_purpose] contraband_df = contraband_df[contraband_df[contraband_type] == True] # noqa E712