Skip to content

Commit

Permalink
Fix for #3443 - bar chart click function broken in usage dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
gjacob24 committed Jul 31, 2024
1 parent 56759df commit 76cbb2b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/javascript/src/usage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ $(() => {
const usersData = JSON.parse($('#users_joined').val());
if (isObject(usersData)) {
const chart = createChart('#yearly_users', usersData, '', (event) => {
const segment = chart.getElementAtEvent(event)[0];
const points = chart.getElementsAtEventForMode(event, 'nearest', { intersect: true }, true);
const segment = points[0];
if (!isUndefined(segment)) {
const target = $('#users_click_target').val();
/* eslint-disable no-underscore-dangle, no-restricted-globals */
const label = chart.data.labels[segment._index];
const label = chart.data.labels[segment.index];
$(location).attr('href', `${target}?${labelToUrl(label)}`);
/* eslint-enable no-underscore-dangle, no-restricted-globals */
}
Expand All @@ -59,11 +60,12 @@ $(() => {
const plansData = JSON.parse($('#plans_created').val());
if (isObject(plansData)) {
const chart = createChart('#yearly_plans', plansData, '', (event) => {
const segment = chart.getElementAtEvent(event)[0];
const points = chart.getElementsAtEventForMode(event, 'nearest', { intersect: true }, true);
const segment = points[0];
if (!isUndefined(segment)) {
const target = $('#plans_click_target').val();
/* eslint-disable no-underscore-dangle, no-restricted-globals */
const label = chart.data.labels[segment._index];
const label = chart.data.labels[segment.index];
$(location).attr('href', `${target}?${labelToUrl(label)}`);
/* eslint-enable no-underscore-dangle, no-restricted-globals */
}
Expand Down

0 comments on commit 76cbb2b

Please sign in to comment.