Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Enabled advanced tooltip text configuration and tooltip date format #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JoabMendes
Copy link

I was needing some extra configuration for the tooltip display and I added some advanced options in the library to enable it. (All the changes work along with the current version and doesn't change the current interface).
screen shot 2018-10-02 at 5 07 02 pm

This PR will enable 3 new parameters:

  • tooltipTextEnabled: Enables the advanced tooltip configuration (Overwrites any configuration done for tooltipUnit and tooltipEnabled).
  • tooltipText: Enables any text to be specified for the tooltips. This options should be an object containing 3 properties: singular, plural and none. Each should have a string with the keys to be replaced by the actual item counting and dates, with the format: {count} and {date}. Example:
.tooltipText({
        plural: 'You sold {count} items on {date}',
        singular: 'You sold {count} item on {date}',
        none: 'No item was sold on {date}' // {count} isn't necessary in this one
})
  • tooltipDateFormat: this allows the user to set a different date format for the tooltips.
.tooltipDateFormat('MM/DD/YYYY');

I updated the documentation, but English isn't my first language. So feel free to fix any typo or grammar mistake 😂.

I tested for both D3 versions and it works fine. Here is a demo using these new configurations.

2018-10-02 17 31 30

@jzabroski
Copy link

jzabroski commented Oct 3, 2018 via email

@JoabMendes
Copy link
Author

That's a cool idea, @jzabroski . Displaying rich contents on the tooltips like a popover would be awesome. But this PR came from a personal implementation and changing the text / date was all I needed. I might do a PR soon with that upgrade If I find the time. 🚀

@jzabroski
Copy link

Thank you very much for the kind words. It's always nice to receive words of appreciation for my unique thinking.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants