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 for #3443 - bar chart click function broken in usage dashboard #3444

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v4.2.1

### Fixed
- Fixed bar chart click function in the Usage dashboard (GitHub issue #3443)
## v4.2.0

**Note this upgrade is mainly a migration from Bootstrap 3 to Bootstrap 5.**
Expand Down
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 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bar chart click function is now working. :) Given these code changes, I think no-underscore-dangle, can now be removed from eslint-disable throughout the file (can be double-checked by executing yarn run eslint app/javascript/src/usage/index.js).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Aaron! I didn't know that. I'll create another commit to remove it now.

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
Loading