Skip to content
Snippets Groups Projects
Unverified Commit 66e93821 authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by GitHub
Browse files

show stacked charts and stacking options with one series (#10067)

parent 7bc2edbe
No related branches found
No related tags found
No related merge requests found
......@@ -132,10 +132,8 @@ export const isOrdinal = settings =>
export const isHistogramBar = ({ settings, chartType }) =>
isHistogram(settings) && chartType === "bar";
export const isStacked = (settings, datas) =>
settings["stackable.stack_type"] && datas.length > 1;
export const isStacked = (settings, datas) => settings["stackable.stack_type"];
export const isNormalized = (settings, datas) =>
isStacked(settings, datas) &&
settings["stackable.stack_type"] === "normalized";
// find the first nonempty single series
......
......@@ -273,9 +273,6 @@ export const STACKABLE_SETTINGS = {
? "stacked"
: null,
getHidden: (series, settings) => {
if (series.length < 2) {
return true;
}
const displays = series.map(single => settings.series(single).display);
return !_.any(displays, display => STACKABLE_DISPLAY_TYPES.has(display));
},
......
......@@ -27,7 +27,7 @@ const DEFAULT_COLUMN_SETTINGS = {
date_style: "MMMM D, YYYY",
};
function MainSeries(chartType, settings = {}) {
function MainSeries(chartType, settings = {}, value = 1) {
return {
card: {
display: chartType,
......@@ -41,7 +41,7 @@ function MainSeries(chartType, settings = {}) {
StringColumn({ display_name: "Category", source: "breakout" }),
NumberColumn({ display_name: "Sum", source: "aggregation" }),
],
rows: [["A", 1]],
rows: [["A", value]],
},
};
}
......@@ -159,6 +159,23 @@ describe("LineAreaBarRenderer-bar", () => {
]);
});
it(`should render an bar normalized chart with just one series`, () => {
const onHoverChange = jest.fn();
renderLineAreaBar(
element,
[MainSeries("bar", { "stackable.stack_type": "normalized" }, 3)],
{ onHoverChange },
);
dispatchUIEvent(qsa(".bar, .dot")[0], "mousemove");
const { calls } = onHoverChange.mock;
expect(getDataKeyValues(calls[0][0])).toEqual([
{ key: "Category", value: "A" },
{ key: "% Sum", value: "100%" },
]);
});
it("should replace the aggregation name with the series name", () => {
const onHoverChange = jest.fn();
renderLineAreaBar(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment