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

in percentage mode tooltip should also show percentages (#13217) #13235

Merged
merged 1 commit into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ui/public/vislib/lib/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export function VislibLibDispatchProvider(Private, config) {
const slices = isSlices ? data.slices : undefined;
const handler = this.handler;
const color = _.get(handler, 'data.color');
const isPercentage = (handler && handler.visConfig.get('mode', 'normal') === 'percentage');

const eventData = {
value: d.y,
Expand All @@ -59,11 +58,13 @@ export function VislibLibDispatchProvider(Private, config) {

if (isSeries) {
// Find object with the actual d value and add it to the point object
const aggId = d3.event.target.parentElement.__data__.aggId;
const percentageMode = handler.charts[0].getSeries(aggId).getValueAxis().axisConfig.isPercentage();
const object = _.find(series, { 'label': label });
if (object) {
eventData.value = +object.values[i].y;

if (isPercentage) {
if (percentageMode) {
// Add the formatted percentage to the point object
eventData.percent = (100 * d.y).toFixed(1) + '%';
}
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/vislib/visualizations/point_series.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export function VislibVisualizationsPointSeriesProvider(Private) {
return charts[chartIndex];
}

getSeries(seriesId) {
return this.series.find(series => series.chartData.aggId === seriesId);
}

addBackground(svg, width, height) {
const startX = 0;
const startY = 0;
Expand Down