Skip to content

Commit

Permalink
Support percentage charts
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Feb 10, 2022
1 parent fca4ebc commit 5d85886
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/plugins/vis_types/timeseries/public/trigger_action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ export const triggerTSVBtoLensConfiguration = async (

const timeShift = layer.offset_time;
// translate to Lens seriesType
const chartType = layer.chart_type === 'line' && layer.fill !== '0' ? 'area' : layer.chart_type;
const layerChartType =
layer.chart_type === 'line' && layer.fill !== '0' ? 'area' : layer.chart_type;
let chartType = layerChartType;

if (layer.stacked !== 'none' && layer.stacked !== 'percent') {
chartType = layerChartType !== 'line' ? `${layerChartType}_stacked` : 'line';
}
if (layer.stacked === 'percent') {
chartType = layerChartType !== 'line' ? `${layerChartType}_percentage_stacked` : 'line';
}

// handle multiple metrics
let metricsArray = getSeries(layer.metrics);
Expand Down Expand Up @@ -103,12 +112,7 @@ export const triggerTSVBtoLensConfiguration = async (
const layerConfiguration: VisualizeEditorLayersContext = {
indexPatternId,
timeFieldName: timeField,
chartType:
layer.stacked === 'none'
? chartType
: chartType !== 'line'
? `${chartType}_stacked`
: 'line',
chartType,
axisPosition: layer.separate_axis ? layer.axis_position : model.axis_position,
...(layer.terms_field && { splitField: layer.terms_field }),
splitWithDateHistogram,
Expand Down

0 comments on commit 5d85886

Please sign in to comment.