Skip to content

Commit

Permalink
in percentage mode tooltip should also show percentages (#13217)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored Aug 1, 2017
1 parent baabbdf commit 5703ffc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit 5703ffc

Please sign in to comment.