Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix submission map chloropeth #1716

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ import GeoJSON from 'ol/format/GeoJSON';
import { get } from 'ol/proj';
import environment from '@/environment';
import { getStyles } from '@/components/MapComponent/OpenLayersComponent/helpers/styleUtils';
import { ProjectActions } from '@/store/slices/ProjectSlice';
import { basicGeojsonTemplate } from '@/utilities/mapUtils';
import TaskSubmissionsMapLegend from '@/components/ProjectSubmissions/TaskSubmissionsMapLegend';
import Accordion from '@/components/common/Accordion';
import AsyncPopup from '@/components/MapComponent/OpenLayersComponent/AsyncPopup/AsyncPopup';
import {
colorCodesType,
federalWiseProjectCount,
taskWiseSubmissionCount,
legendColorArrayType,
taskBoundariesType,
taskFeaturePropertyType,
taskSubmissionInfoType,
} from '@/models/task/taskModel';
import { isValidUrl } from '@/utilfunctions/urlChecker';
import { projectInfoType, projectTaskBoundriesType } from '@/models/project/projectModel';
Expand Down Expand Up @@ -122,13 +120,13 @@ const TaskSubmissionsMap = () => {
);

const taskInfo = useAppSelector((state) => state.task.taskInfo);
const federalWiseProjectCount: federalWiseProjectCount[] = taskInfo?.map((task) => ({
const taskWiseSubmissionCount: taskWiseSubmissionCount[] = taskInfo?.map((task) => ({
code: task.task_id,
count: task.submission_count,
}));

const selectedTask: number = CoreModules.useAppSelector((state) => state.task.selectedTask);
const legendColorArray: legendColorArrayType[] = colorRange(federalWiseProjectCount, '4');
const legendColorArray: legendColorArrayType[] = colorRange(taskWiseSubmissionCount, '4');
const { mapRef, map } = useOLMap({
center: [0, 0],
zoom: 4,
Expand Down Expand Up @@ -191,21 +189,19 @@ const TaskSubmissionsMap = () => {
(style, feature, resolution) => {
const stylex = { ...style };
stylex.fillOpacity = 80;
const getFederal = federalWiseProjectCount?.find((d) => d.code == feature.getProperties().uid);
const getFederalCount = getFederal?.count;
const getTask = taskWiseSubmissionCount?.find((d) => d.code == feature.getProperties().fid);
const getTaskSubmissionCount = getTask?.count;
stylex.labelMaxResolution = 1000;
stylex.showLabel = true;
// stylex.labelField = 'district_code';
// stylex.customLabelText = getFederalName;
const choroplethColor = getChoroplethColor(getFederalCount, legendColorArray);
const choroplethColor = getChoroplethColor(getTaskSubmissionCount, legendColorArray);
stylex.fillColor = choroplethColor;
return getStyles({
style: stylex,
feature,
resolution,
});
},
[federalWiseProjectCount],
[taskWiseSubmissionCount],
);

map?.on('loadstart', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/models/task/taskModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type taskFeaturePropertyType = {
uid: number;
};

export type federalWiseProjectCount = {
export type taskWiseSubmissionCount = {
code: string;
count: number;
};
Expand Down
Loading