mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-1000] fix: handled edge case for color on custom analytics state_group (#4185)
* chore: handled edge case for color on custom analytics state_group * fix: error handler
This commit is contained in:
parent
8b6035d315
commit
251a432d8a
@ -1,12 +1,12 @@
|
|||||||
// nivo
|
// nivo
|
||||||
import { BarDatum } from "@nivo/bar";
|
import { BarDatum } from "@nivo/bar";
|
||||||
|
import { IAnalyticsData, IAnalyticsParams, IAnalyticsResponse, TStateGroups } from "@plane/types";
|
||||||
// helpers
|
// helpers
|
||||||
import { DATE_KEYS } from "@/constants/analytics";
|
import { DATE_KEYS } from "@/constants/analytics";
|
||||||
import { MONTHS_LIST } from "@/constants/calendar";
|
import { MONTHS_LIST } from "@/constants/calendar";
|
||||||
import { STATE_GROUPS } from "@/constants/state";
|
import { STATE_GROUPS } from "@/constants/state";
|
||||||
import { addSpaceIfCamelCase, capitalizeFirstLetter, generateRandomColor } from "@/helpers/string.helper";
|
import { addSpaceIfCamelCase, capitalizeFirstLetter, generateRandomColor } from "@/helpers/string.helper";
|
||||||
// types
|
// types
|
||||||
import { IAnalyticsData, IAnalyticsParams, IAnalyticsResponse, TStateGroups } from "@plane/types";
|
|
||||||
// constants
|
// constants
|
||||||
|
|
||||||
export const convertResponseToBarGraphData = (
|
export const convertResponseToBarGraphData = (
|
||||||
@ -36,8 +36,8 @@ export const convertResponseToBarGraphData = (
|
|||||||
name: DATE_KEYS.includes(params.x_axis)
|
name: DATE_KEYS.includes(params.x_axis)
|
||||||
? renderMonthAndYear(key)
|
? renderMonthAndYear(key)
|
||||||
: params.x_axis === "priority" || params.x_axis === "state__group"
|
: params.x_axis === "priority" || params.x_axis === "state__group"
|
||||||
? capitalizeFirstLetter(key)
|
? capitalizeFirstLetter(key)
|
||||||
: key,
|
: key,
|
||||||
...segments,
|
...segments,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -49,8 +49,8 @@ export const convertResponseToBarGraphData = (
|
|||||||
name: DATE_KEYS.includes(params.x_axis)
|
name: DATE_KEYS.includes(params.x_axis)
|
||||||
? renderMonthAndYear(item.dimension)
|
? renderMonthAndYear(item.dimension)
|
||||||
: params.x_axis === "priority" || params.x_axis === "state__group"
|
: params.x_axis === "priority" || params.x_axis === "state__group"
|
||||||
? capitalizeFirstLetter(item.dimension ?? "None")
|
? capitalizeFirstLetter(item.dimension ?? "None")
|
||||||
: item.dimension ?? "None",
|
: item.dimension ?? "None",
|
||||||
[yAxisKey]: item[yAxisKey] ?? 0,
|
[yAxisKey]: item[yAxisKey] ?? 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ export const generateBarColor = (
|
|||||||
if (params[type] === "labels__id")
|
if (params[type] === "labels__id")
|
||||||
color = analytics?.extras.label_details.find((l) => l.labels__id === value)?.labels__color ?? undefined;
|
color = analytics?.extras.label_details.find((l) => l.labels__id === value)?.labels__color ?? undefined;
|
||||||
|
|
||||||
if (params[type] === "state__group") color = STATE_GROUPS[value.toLowerCase() as TStateGroups].color;
|
if (params[type] === "state__group") color = STATE_GROUPS[value.toLowerCase() as TStateGroups]?.color ?? undefined;
|
||||||
|
|
||||||
if (params[type] === "priority") {
|
if (params[type] === "priority") {
|
||||||
const priority = value.toLowerCase();
|
const priority = value.toLowerCase();
|
||||||
@ -84,12 +84,12 @@ export const generateBarColor = (
|
|||||||
priority === "urgent"
|
priority === "urgent"
|
||||||
? "#ef4444"
|
? "#ef4444"
|
||||||
: priority === "high"
|
: priority === "high"
|
||||||
? "#f97316"
|
? "#f97316"
|
||||||
: priority === "medium"
|
: priority === "medium"
|
||||||
? "#eab308"
|
? "#eab308"
|
||||||
: priority === "low"
|
: priority === "low"
|
||||||
? "#22c55e"
|
? "#22c55e"
|
||||||
: "#ced4da";
|
: "#ced4da";
|
||||||
}
|
}
|
||||||
|
|
||||||
return color ?? generateRandomColor(value);
|
return color ?? generateRandomColor(value);
|
||||||
|
Loading…
Reference in New Issue
Block a user