+
{label}
+ {payload.map((entry: any, index: any) => (
+
+ {entry.name}:
+ {entry.value}
+
+ ))}
+
+ );
+ }
+
+ return null;
+}
+
+const getYAxisLabel = (unit: string) => {
+ if (unit !== "") {
+ return unit
+ }
+ return "Units"
+};
+
+const getDefaultFormatter = (value: number, metricName: string) => {
+ const formatValue = (value: number, suffix: string) => {
+ const formattedValue = parseFloat(value.toFixed(2));
+ return formattedValue % 1 === 0
+ ? `${Math.floor(formattedValue)}${suffix}`
+ : `${formattedValue}${suffix}`;
+ };
+ switch(metricName){
+ case "monovtx_ack_time_bucket":
+ case "monovtx_read_time_bucket":
+ case "monovtx_processing_time_bucket":
+ case "monovtx_sink_time_bucket":
+ case "numaflow_monovtx_processing_time_bucket":
+ case "numaflow_monovtx_sink_time_bucket":
+ case "numaflow_monovtx_read_time_bucket":
+ case "numaflow_monovtx_ack_time_bucket":
+ if (value === 0){
+ return "0";
+ } else if (value < 1000) {
+ return `${value} μs`;
+ } else if (value < 1000000) {
+ return formatValue(value / 1000, " ms");
+ } else {
+ return formatValue(value / 1000000, " s");
+ }
+ default:
+ if (value === 0){
+ return "0";
+ } else if (value < 1000) {
+ return `${value}`;
+ } else if (value < 1000000) {
+ return formatValue(value / 1000, " k");
+ } else {
+ return formatValue(value / 1000000, " M");
+ }
+ }
+}
+
+const getTickFormatter = (unit: string, metricName: string) => {
+ const formatValue = (value: number) => {
+ const formattedValue = parseFloat(value.toFixed(2)); // Format to 2 decimal places
+ return formattedValue % 1 === 0 ? Math.floor(formattedValue) : formattedValue; // Remove trailing .0
+ };
+ return (value: number) => {
+ switch (unit) {
+ case 's':
+ return `${formatValue(value / 1000000)}`;
+ case 'ms':
+ return `${formatValue(value / 1000)}`;
+ default:
+ return getDefaultFormatter(value, metricName);
+ }
+ }
+};
+
// TODO have a check for metricReq against metric object to ensure required fields are passed
const LineChartComponent = ({
namespaceId,
@@ -40,7 +129,7 @@ const LineChartComponent = ({
const getRandomColor = useCallback((index: number) => {
const hue = (index * 137.508) % 360;
- return `hsl(${hue}, 70%, 50%)`;
+ return `hsl(${hue}, 50%, 50%)`;
}, []);
const getFilterValue = useCallback(
@@ -226,29 +315,29 @@ const LineChartComponent = ({
{filtersList?.filter((filterEle: any) => !filterEle?.required)?.length >
0 && (
-