From eb603f63f04195193b9f1aed29fb33230248e40f Mon Sep 17 00:00:00 2001 From: Levko Kravets Date: Wed, 5 Aug 2020 20:28:03 +0300 Subject: [PATCH] Bar chart with second y axis overlaps data series (#4150) --- .../chart/plotly/fixtures/prepareData/bar/default.json | 1 + .../chart/plotly/fixtures/prepareData/bar/normalized.json | 2 ++ .../chart/plotly/fixtures/prepareData/bar/stacked.json | 2 ++ .../src/visualizations/chart/plotly/prepareDefaultData.js | 5 +++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/default.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/default.json index 466b4d0a97..5e5317b66f 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/default.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/default.json @@ -38,6 +38,7 @@ "series": [ { "visible": true, + "offsetgroup": "0", "type": "bar", "name": "a", "x": ["x1", "x2", "x3", "x4"], diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/normalized.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/normalized.json index 647719734e..3ab34e8e8c 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/normalized.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/normalized.json @@ -48,6 +48,7 @@ "series": [ { "visible": true, + "offsetgroup": "0", "type": "bar", "name": "a", "x": ["x1", "x2", "x3", "x4"], @@ -63,6 +64,7 @@ }, { "visible": true, + "offsetgroup": "1", "type": "bar", "name": "b", "x": ["x1", "x2", "x3", "x4"], diff --git a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/stacked.json b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/stacked.json index 62df3e1a76..b17f637ff7 100644 --- a/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/stacked.json +++ b/viz-lib/src/visualizations/chart/plotly/fixtures/prepareData/bar/stacked.json @@ -48,6 +48,7 @@ "series": [ { "visible": true, + "offsetgroup": "0", "type": "bar", "name": "a", "x": ["x1", "x2", "x3", "x4"], @@ -63,6 +64,7 @@ }, { "visible": true, + "offsetgroup": "1", "type": "bar", "name": "b", "x": ["x1", "x2", "x3", "x4"], diff --git a/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.js b/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.js index d45e68e016..f2715061a4 100644 --- a/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.js +++ b/viz-lib/src/visualizations/chart/plotly/prepareDefaultData.js @@ -1,4 +1,4 @@ -import { isNil, extend, each, includes, map, sortBy } from "lodash"; +import { isNil, extend, each, includes, map, sortBy, toString } from "lodash"; import chooseTextColorForBackground from "@/lib/chooseTextColorForBackground"; import { ColorPaletteArray } from "@/visualizations/ColorPalette"; import { cleanNumber, normalizeValue, getSeriesAxis } from "./utils"; @@ -16,8 +16,9 @@ function getHoverInfoPattern(options) { return result; } -function prepareBarSeries(series, options) { +function prepareBarSeries(series, options, additionalOptions) { series.type = "bar"; + series.offsetgroup = toString(additionalOptions.index); if (options.showDataLabels) { series.textposition = "inside"; }