question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customizing tooltip's contents *updated: Aug 1st*

See original GitHub issue

I’m submitting a … (check one with “x”)

  • bug report - search github for a similar issue or PR before submitting
  • feature request
  • support request - use StackOverflow (add the ngx-charts tag) or the gitter chat for support questions

Hello everyone,

I’ve been trying to set a custom label in a custom line chart’s tooltip , e.g., modified number of minutes in HH:mm format (77 min --> 1:17), for quite some time now, but unfortunately without any success. Displaying the value as 1.2833…(3) is not an alternative.

float_to_hh_mm

Does anybody know how to preserve the x and y axis values (a date and a number respectively), and modify the tooltip display value?

For example: https://swimlane.github.io/ngx-charts/#/ngx-charts/line-chart

Instead of having a tooltip that displays:

Color, Country name and Number

–>

Color, Country name and a String (e.g. Number > 3000 ? ‘high’ : 'low’😉

Show old issues (from beginning up to Jul 31st, incl.)

Current situation, Jul 31th:

Adding the [tooltipTemplate]=“seriesTooltipTemplate” to ngx-charts-circle-series solved one of the problems and created another - minutes will be dispalyed as HH:mm via a custom pipe, but the name of the parameter is lost along the way.

float_to_hh_mm_pipe_1

As pseudo code intended:

<ngx-my-chart 
   [options]="options_values"
   <svgs.../>
   
   <svg:g ngx-charts-circle-series
      ...
      [tooltipTemplate]="seriesTooltipTemplate"
      ...
        />
       <ng-template #seriesTooltipTemplate let-model="model">
          {{model.name | date: 'dd.MM.yyyy'}} &diams; {{model.value | durationHhmm}}
        </ng-template>
   
   <svgs.../>
</ngx-my-chart>

Second issue is still there, unchanged. The vertical line’s tooltip would still not find a “defined” value, thus the NaN:NaN. The durationHhmm pipe takes a number and returns its string equivalent in HH:mm format.

float_to_hh_mm_pipe_2

<ngx-charts-line-chart id='chart' 
    ...
    ...
    ...
   >
    <ng-template #tooltipTemplate let-model="model">
          write your custom tooltip html here. the data is in model
    </ng-template>
 </ngx-charts-line-chart>

After having the code above implemented, the tooltip value was indeed overwritten ( only for the vertical line values, not when I hover over a data point ) and now shows nothing, i.e. the data binding fails.

float_to_hh_mm_2

As pseudo code intended:

<ngx-my-chart 
   [options]="options_values"
   <svgs.../>
   
   <svg:g ngx-charts-tooltip-area
      ...
      [tooltipTemplate]="tooltipTemplate"
      ...
        />
       <ng-template #tooltipTemplate let-model="model">
          {{model.name}}Name: {{model.value}}Value
        </ng-template>
   
   <svgs.../>
</ngx-my-chart>

And in the component.ts:

 @ContentChild('tooltipTemplate') tooltipTemplate: TemplateRef<any>;
 @ContentChild('seriesTooltipTemplate') seriesTooltipTemplate: TemplateRef<any>;

Any help/suggestion is very welcome.

Sorry for posting in the wrong section.

Current behavior Works as intended.

Expected behavior To display custom labels.

Reproduction of the problem Link in the description above

What is the motivation / use case for changing the behavior? Being able to customize tooltips’ contents

Please tell us about your environment: OS: Win 10 x64, IDE: Eclipse EE

  • ngx-charts version: 3.0.2

  • Angular version: 6.0.2

  • Browser: [all]

  • Language: [TypeScript 2.3.3]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
marjan-georgievcommented, Aug 1, 2018

I replied to your stackoverflow comment. Here’s a stackblitz that shows how to use tooltip templates: https://stackblitz.com/edit/vertical-bar-chart-yvy5bx?file=app%2Fapp.component.ts

Also, any custom properties you assign are not passed down. There is an open issue around that.

0reactions
marjan-georgievcommented, Aug 1, 2018

A fellow Berliner! I occasionally attend the Angular and Data Visualization meetups here. If you’re ever at those and see me, come say hi. 🍻

Glad we resolved the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tooltips | Charts - Google Developers
Customizing tooltip content ​​ In this example, we add custom content to the tooltips by adding a new column to the DataTable and...
Read more >
Custom tooltips ‒ Qlik Sense on Windows
Create a custom tooltip to add extra information to a visualization. You can include measures, a master visualization chart, or an image. Tooltips...
Read more >
Customizing tooltips in Power BI Desktop - Microsoft Learn
Create custom tooltips for visuals using drag-and-drop. ... You can customize tooltips in Power BI Desktop and in the Power BI service.
Read more >
Change the design of the Tooltip - Flows - Whatfix - support
Use the following steps to set a default Tooltip for your account,. Navigate to the Whatfix Desktop Dashboard. GotoDashboard_Desktop.
Read more >
Building a tooltip component - web.dev
Oct 25, 2022 ... I chose to use a custom element <tool-tip> . ... no users will accidentally find this tooltip content in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found