Skip to content

Commit

Permalink
[frontend] fix clickable horizontal bar for labels (#6264)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Mar 11, 2024
1 parent c8dd164 commit 6383c56
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions opencti-platform/opencti-front/src/utils/Charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,25 +349,29 @@ export const horizontalBarsChartOptions = (
xAxisLabelClick: (event, chartContext, config) => {
if (redirectionUtils) {
const { labelIndex } = config;
const link = resolveLink(redirectionUtils[labelIndex].entity_type);
const entityId = redirectionUtils[labelIndex].id;
navigate(`${link}/${entityId}`);
const entityType = redirectionUtils[labelIndex].entity_type;
const link = resolveLink(entityType);
if (link) {
const entityId = redirectionUtils[labelIndex].id;
navigate(`${link}/${entityId}`);
}
}
},
mouseMove: (event, chartContext, config) => {
if (
redirectionUtils
&& ((config.dataPointIndex >= 0
&& ((config.seriesIndex >= 0
&& redirectionUtils[config.dataPointIndex].series?.[
config.seriesIndex
]?.entity_type)
|| !(
config.seriesIndex >= 0
&& redirectionUtils[config.dataPointIndex].series
)))
|| event.target.parentNode.className.baseVal
=== 'apexcharts-text apexcharts-yaxis-label ')
&& config.dataPointIndex >= 0
&& (
(config.seriesIndex >= 0
&& redirectionUtils[config.dataPointIndex].series?.[config.seriesIndex]?.entity_type
&& resolveLink(
redirectionUtils[config.dataPointIndex].series?.[config.seriesIndex]?.entity_type,
))
|| (
!config.seriesIndex >= 0
&& redirectionUtils[config.dataPointIndex].entity_type
&& resolveLink(redirectionUtils[config.dataPointIndex].entity_type)
))
) {
// for clickable parts of the graphs
// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -396,15 +400,19 @@ export const horizontalBarsChartOptions = (
redirectionUtils[dataPointIndex].series[seriesIndex]
.entity_type,
);
const entityId = redirectionUtils[dataPointIndex].series[seriesIndex].id;
navigate(`${link}/${entityId}`);
if (link) {
const entityId = redirectionUtils[dataPointIndex].series[seriesIndex].id;
navigate(`${link}/${entityId}`);
}
}
} else {
const link = resolveLink(
redirectionUtils[dataPointIndex].entity_type,
);
const entityId = redirectionUtils[dataPointIndex].id;
navigate(`${link}/${entityId}`);
if (link) {
const entityId = redirectionUtils[dataPointIndex].id;
navigate(`${link}/${entityId}`);
}
}
}
}
Expand Down

0 comments on commit 6383c56

Please sign in to comment.