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

Better tooltips for charts; ability to change formats for numbers and dates (WIP) #2468

Closed
wants to merge 1 commit into from
Closed

Better tooltips for charts; ability to change formats for numbers and dates (WIP) #2468

wants to merge 1 commit into from

Conversation

kravets-levko
Copy link
Collaborator

Issue #728

Don't merge it!
This PR introduces a lot of changes, I need to be sure that everything works correctly.

Some screenshots:

image
image
image
image

@kravets-levko kravets-levko added this to the Next milestone Apr 17, 2018
@@ -2,6 +2,8 @@ import moment from 'moment/moment';
import numeral from 'numeral';
import _ from 'underscore';

numeral.options.scalePercentBy100 = false;
Copy link
Member

Choose a reason for hiding this comment

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

What's this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By default, for formats like 0[.]00% numeral will multiply value by 100 - so 0.5 will become 50%. This option disables this behavior so 0.5 will become 0.5%, and 50 - 50%.

@@ -34,6 +40,10 @@ const PlotlyChart = () => ({
let layout = {};
let data = [];

const tooltip = $('<div>')
.addClass('plotly-chart-tooltip')
.appendTo('body');
Copy link
Member

Choose a reason for hiding this comment

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

So we render our own tooltip... I can see how this can become a maintenance nightmare, chasing various Plotly edge cases 🤔

What do we lose if we go with Plotly's builtin tooltip?

Copy link
Collaborator Author

@kravets-levko kravets-levko Apr 23, 2018

Choose a reason for hiding this comment

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

I tried a lot of settings, and noticed only two edge cases: bar charts with stacking enabled, and pie charts. for both we just need to compute position for tooltip in a different way (for pie we already receive position in event data).

Own tooltip allows to show all data in a single place (like in Highcharts) - x-axis value, all y values, etc. With default tooltip, we can customize text for y-values but not for x, and (if you remember) Plotly shows tooltip for each series for the same x value , and one more tooltip for x value (which also has a different style).

If you're afraid that it may be a nightmare - of course, I can simplify it, but we will lose some formatting and styling.

Copy link
Member

Choose a reason for hiding this comment

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

Past experience shows that there are always unexpected scenarios with charts :) Once we merge and deploy this, we're committed to it. But I don't think we need this distraction right now (having to maintain and fix issues related to the tooltip) -- we have more interesting stuff to do.

So let's shelf this for now, and implement something simpler:

  • First step: expose the ability to set hoverformat for the X and Y axes.
  • Second step: feature to set the hovertext property using data from the current point.

While it's not as complete as what you implemented here, it will serve most of the cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants