Skip to content

Commit

Permalink
🐛 Fix float value id handling by point series
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Jul 15, 2020
1 parent a1c58e7 commit 7da7714
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@ import _ from 'lodash';
import { i18n } from '@kbn/i18n';

function getSeriId(seri) {
return seri.id && seri.id.indexOf('.') !== -1 ? seri.id.split('.')[0] : seri.id;
if (!seri.id) {
return;
}
// Ideally the format should be either ID or "ID.SERIES"
// but for some values the SERIES components gets a bit more complex

// Float values are serialized as strings tuples (i.e. ['99.1']) rather than regular numbers (99.1)
// so the complete ids are in the format ID.['SERIES']: hence the specific brackets handler
const bracketsMarker = seri.id.indexOf('[');
if (bracketsMarker > -1) {
return seri.id.substring(0, bracketsMarker);
}
// Here's the dot check is enough
if (seri.id.indexOf('.') > -1) {
return seri.id.split('.')[0];
}
return seri.id;
}

const createSeriesFromParams = (cfg, seri) => {
Expand Down

0 comments on commit 7da7714

Please sign in to comment.