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

Axis formatter should default to global Axis #676

Open
Tracked by #2320
nickofthyme opened this issue May 14, 2020 · 1 comment
Open
Tracked by #2320

Axis formatter should default to global Axis #676

nickofthyme opened this issue May 14, 2020 · 1 comment
Labels
:axis Axis related issue enhancement New feature or request :xy Bar/Line/Area chart related

Comments

@nickofthyme
Copy link
Collaborator

nickofthyme commented May 14, 2020

When using multiple y-axes and a single global x-axis. Each of the supplied series will use their respective y-axis per groupId and share the x-axis as a fallback.

However, the tick formatter for the x-axis is not associated to the global x-axis, and leaves the tooltip header values unformatted even though the series is using the global x-axis as a default.

Screenshot

Notice the x-axis time has ticks formatted given the tickFormat on the AxisSpec. However, the header value is not formatted.

image

Solution

The code below, chooses the x or y axis based on rotation or uses the explicit tooltipHeaderFormatter

if (!header) {
// if we have a tooltipHeaderFormatter, then don't pass in the xAxis as the user will define a formatter
const xAxisFormatSpec = [0, 180].includes(chartRotation) ? xAxis : yAxis;
const formatterAxis = tooltipHeaderFormatter ? undefined : xAxisFormatSpec;
header = formatTooltip(indexedGeometry, spec, true, false, hasSingleSeries, formatterAxis);
}

However, given this configuration the xAxis will always be undefined as getAxesSpecForSpecId will only associate axis to their groudId.

const { xAxis, yAxis } = getAxesSpecForSpecId(axesSpecs, spec.groupId);

Currently, this is fixed by supplying the tooltipHeaderFormatter to the tooltip but this seems unnecessary.

I think the fix, in this case, is to change getAxesSpecForSpecId to return global spec as a fallback possibly optionally based on an argument.

Note: The global tooltipHeaderFormatter should always override any axis formatter.

@nickofthyme nickofthyme added enhancement New feature or request :axis Axis related issue labels May 14, 2020
@nickofthyme nickofthyme changed the title Axis formatter default to global Axis Axis formatter should default to global Axis May 14, 2020
@markov00 markov00 added the :xy Bar/Line/Area chart related label May 29, 2020
@markov00 markov00 added this to the Kibana 7.10 milestone Aug 26, 2020
@markov00 markov00 modified the milestones: Kibana 7.10, Kibana 7.11 Oct 22, 2020
@markov00 markov00 removed this from the Kibana 7.11 milestone May 26, 2021
@nickofthyme
Copy link
Collaborator Author

A temporary workaround would be to use the headerFormatter on the Tooltip spec.

<Tooltip
  headerFormatter={(pointerValue) =>
    timeFormatter('DD-MM-YYYY hh:mm A')(pointerValue.value)
  }
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:axis Axis related issue enhancement New feature or request :xy Bar/Line/Area chart related
Projects
None yet
Development

No branches or pull requests

2 participants