mirror of https://github.com/apache/superset.git
[bug fix] Fixed forced percentage format on tooltips and bubble chart tooltips format. (#5631)
* fixed forced percentage format on tooltip and correct reflection on bubble chart tooltip format * re-trigger build
This commit is contained in:
parent
4c2be71e83
commit
2171ffb630
|
@ -324,13 +324,15 @@ export default function nvd3Vis(slice, payload) {
|
|||
chart.showDistY(true);
|
||||
chart.tooltip.contentGenerator(function (obj) {
|
||||
const p = obj.point;
|
||||
const yAxisFormatter = d3FormatPreset(fd.y_axis_format);
|
||||
const xAxisFormatter = d3FormatPreset(fd.x_axis_format);
|
||||
let s = '<table>';
|
||||
s += (
|
||||
`<tr><td style="color: ${p.color};">` +
|
||||
`<strong>${p[fd.entity]}</strong> (${p.group})` +
|
||||
'</td></tr>');
|
||||
s += row(fd.x, formatter(p.x));
|
||||
s += row(fd.y, formatter(p.y));
|
||||
s += row(fd.x, xAxisFormatter(p.x));
|
||||
s += row(fd.y, yAxisFormatter(p.y));
|
||||
s += row(fd.size, formatter(p.size));
|
||||
s += '</table>';
|
||||
return s;
|
||||
|
@ -412,15 +414,13 @@ export default function nvd3Vis(slice, payload) {
|
|||
chart.xAxis.tickFormat(xAxisFormatter);
|
||||
}
|
||||
|
||||
const yAxisFormatter = d3FormatPreset(fd.y_axis_format);
|
||||
let yAxisFormatter = d3FormatPreset(fd.y_axis_format);
|
||||
if (chart.yAxis && chart.yAxis.tickFormat) {
|
||||
if (fd.contribution || fd.comparison_type === 'percentage') {
|
||||
// When computing a "Percentage" or "Contribution" selected, we force a percentage format
|
||||
const percentageFormat = d3.format('.1%');
|
||||
chart.yAxis.tickFormat(percentageFormat);
|
||||
} else {
|
||||
chart.yAxis.tickFormat(yAxisFormatter);
|
||||
yAxisFormatter = d3.format('.1%');
|
||||
}
|
||||
chart.yAxis.tickFormat(yAxisFormatter);
|
||||
}
|
||||
if (chart.y2Axis && chart.y2Axis.tickFormat) {
|
||||
chart.y2Axis.tickFormat(yAxisFormatter);
|
||||
|
|
Loading…
Reference in New Issue