Difficulty arises when attempting to conceal the pointer in ngx-charts without a click event being present

For the past day, I have been experimenting with the swimlane/ngx-charts library to remove the pointer from the graphs when hovered over. Our use case involves using a pie chart from this library, and the default cursor appearance when hovering over the chart is causing confusion for many of our clients:

https://i.sstatic.net/e6H0p.png

Some users mistakenly believe there is a clickable action associated with the hand pointer icon, when in fact it does nothing on click. Is it possible to modify this behavior so that the hand pointer is hidden and only the default arrow pointer is shown unless there is a specific call to action tied to a click?

We display multiple graphs; some do not trigger any action on click (should show default arrow pointer) while others lead users to internal routes upon being clicked (hand pointer should appear in these instances).

Attempts so far:

I researched a similar issue linked here:

https://github.com/swimlane/ngx-charts/issues/525

The solution involved modifying the library files, which are located within the node_modules directory. Editing these files could potentially cause future complications, so I am seeking an alternative approach.

I also experimented with adding CSS code like the following snippet to my styles.scss:

.ngx-charts {
  .circle,
  .bar,
  .arc {
    cursor: default !important;
  }
}

However, this resulted in hiding the hand pointer completely, even on graphs where a click action was assigned.

Desired outcome:

It would be beneficial if someone could guide me on enabling the hand pointer only when there is a specific action tied to clicking on the graph. For all other scenarios without a designated click action, I prefer displaying just the default arrow pointer.

UPDATE

In response to comments by @Naren below, I attempted manually adding a "no pointer" class to the desired chart. However, navigating through the nested structure depicted here:

https://i.sstatic.net/xaLse.png

I encountered difficulty as the desired results were only visible when the class was added to elements at the 6th position within the SVG, making the process quite complicated.

Answer №1

I haven't personally tested this solution, but I believe it should be effective in your situation. Firstly, include the following CSS:

.no-pointer {
  cursor: default !important;
}

Next, apply the 'no-pointer' class to elements that have a clickable action associated with them:

<ngx-charts-bar-vertical
  [results]="barChartData"
  [xAxis]="showXAxis"
  [yAxis]="showYAxis"
  [showXAxisLabel]="showXAxisLabel"
  [showYAxisLabel]="showYAxisLabel"
  [xAxisLabel]="xAxisLabel"
  [yAxisLabel]="yAxisLabel"
  [gradient]="gradient"
  [noPointer]="true" <!-- Add this line -->
></ngx-charts-bar-vertical>

By adding the [noPointer]="true" attribute to the ngx-charts-bar-vertical component, you can selectively apply the 'no-pointer' class. Lastly, update the CSS to only target elements with the '.no-pointer' class for the cursor style adjustment:

.ngx-charts .circle,
.ngx-charts .bar,
.ngx-charts .arc {
  cursor: pointer;
}

.ngx-charts .no-pointer {
  cursor: default !important;
}

Give it a try and share your feedback with us.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Cut an image using CSS while maintaining its original quality

I am currently working on an upload page where users can upload images. Here is the link to the page: MyPage. However, I would like to implement image cropping functionality that displays more of the image rather than just a small portion as it does now. A ...

CSS transitions that smoothly adjust with min-width media queries

In my design, there is a sidebar navigation that collapses to make room for more content in a flex layout. When the user triggers the collapse action, the content area div .ca expands to fill the space, and the flex layout adjusts using media queries. To ...

Utilize the FormData from a Node.js application to call the 'PostFiles' endpoint instead of using a website

Currently, I am working on sending files from a website to an endpoint using an <input> field. The Angular code implementation for this functionality is as follows: @Injectable() export class FileUploadService { constructor(private http: HttpClie ...

Is there a way to change the images displayed in a JavaFXML Button?

I'm attempting to create a button that toggles between displaying an image of a red circle and an image of a blue circle when clicked. In my CSS, I've set up styles for the different states of the button: #button-debit { -fx-background-image ...

Dynamic content cannot have classes added to them using jQuery

When adding content dynamically, it is necessary to use an event handler for a parent element using on(). However, I am facing an issue where the class added with addClass on dynamically generated content disappears immediately. Let's take a look at ...

Error encountered while reading JSON data using Angular4 and TypeScript: Json

When a user selects one or more checkboxes and submits a form, data in the database is updated. At that moment, I call location.reload() from the code to reload the page and display the correct data. Below is the backend web API code: [HttpGet] public as ...

I'm having an issue with my link hover effect - it seems to be causing my link to disappear, despite the fact that the hover effect

Greetings and many thanks in advance for lending your assistance and patience. I am fairly new to the world of CSS and have yet to navigate the realm of transitions. Present before you is a modest div encompassing a background image with a text-block over ...

What is preventing me from merging font sub properties?

When working with CSS, you have the option to combine sub-properties. For example, instead of defining a border like this: border-style: solid; border-width: 1px; border-color: #555; You can use a single declaration for the border property as a shorthand ...

Can you provide guidance on how to perfectly align a div within another div both vertically and horizontally?

Similar Inquiry: Method to center an image both vertically and horizontally within a larger div I'm working on positioning a div that is 300px in both height and length. My goal is to have another div inside it, sized at 100px for both dimensions ...

Tips for Eliminating Unnecessary Space Above the Navigation Bar

I have a problem with the top navbar on my test site. There is some extra space above it that I want to remove so that the navigation extends all the way up to cover the viewport. Here is an image of what I'm trying to achieve: https://i.stack.imgur.c ...

Syncing data between local storage and a remote server using Ionic5 provider

I've been considering implementing a data provider that could store a duplicate of the backend data locally for quick access. I believe this concept is referred to as mirroring or something similar. Nevertheless, it must be synchronized and updated r ...

Missing sidebar display

Hi there! I am having an issue with my sidebar not appearing correctly when I click on the toggle button. It seems to be moving to the side, but the sidebar itself is blank or transparent. I suspect that the problem lies within my JavaScript file. As a beg ...

Implementing authentication using http.post in Angular 2 with Django-Rest-Framework

I have spent more time than I care to admit trying to find a solution to this particular issue, but unfortunately, I am unable to resolve it on my own. Currently, I have a Django-rest-api that I set up using this tutorial. I can successfully interact with ...

How to retrieve text from ion-textarea in Ionic 3 upon clicking a button

One of my tasks involves utilizing an ion-textarea for users to input content, with the objective of retrieving this text upon clicking a button. Below is the corresponding HTML code snippet: <ion-row> <ion-item> <ion-textarea ...

The division is refusing to make an appearance

As I embark on creating my very first website, I'm encountering some obstacles in translating my vision into reality. The #invokeryolo div is proving to be elusive and no matter how hard I try, I can't seem to make it appear on the screen. Below ...

Tips for aligning content vertically within a header:

I'm currently working on creating a responsive header with two columns. My goal is to have the button in the right column vertically centered. I am aware of the method for centering items using 'top: 50%; margin-top: -xy px', but my button ...

Error occurred while initiating Angular frontend application with npm

https://i.sstatic.net/JCy3s.png > ng serve sh: ng: command not found npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file sh npm ERR! errno ENOENT npm ERR! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4b2a ...

The height attribute in HTML tables fails to restrict height in Firefox

Is there a way to restrict the height of a table while still being able to scroll through the hidden elements? I've tried a few methods but none seem to work as intended: http://www.example.com/code/example table.ex1 { table-layout: auto; h ...

Is it possible to incorporate shadows on a pie chart using recharts?

Does anyone know how to enhance a pie chart with shadows using the recharts library? https://i.sstatic.net/JLGVF.png https://i.sstatic.net/f5qv4.png If you have any solutions, please share. Thank you! ...

Tips for setting up the image as the header background in HTML5 and CSS3

I am currently designing a website. I'm wondering if there is a way to create a div with a curved bottom using HTML5, CSS3 and JavaScript. It should resemble the design of the curved header bottom ...