synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
73 lines (72 loc) • 1.62 kB
JavaScript
import { jsx as p } from "react/jsx-runtime";
import c from "lodash-es/cloneDeep";
import u from "lodash-es/noop";
import x from "lodash-es/uniq";
import { Plot as h } from "./Plot.js";
function g(e, n, i) {
n && (e = e.filter((o) => o.y === n));
const a = x(e.map((o) => o.group)).sort(), t = [], s = ["(28,118,175,1)", "rgba(91,176,181,1)"];
return a.forEach((o, f) => {
const l = e.filter((r) => r.group === o);
t.push({
x: l.map((r) => r.x),
y: l.map((r) => r.y),
name: o,
orientation: "h",
marker: {
color: i ? i[o] : s[f],
width: 1
},
text: [o],
hovertemplate: "%{x} %{text}<extra></extra>",
textposition: "none",
type: "bar"
});
}), t;
}
function L(e, { isTop: n, maxValue: i, backgroundColor: a }) {
const t = c(e);
return t.xaxis = {
visible: !1,
range: [0, i]
}, a && (t.plot_bgcolor = a, t.paper_bgcolor = a), n || (t.hoverlabel = {
font: {
size: 10
}
}), t.showlegend = !1, t.height = n ? 40 : 20, t;
}
const b = { backgroundColor: "transparent" }, y = {
width: "100%",
height: "100%"
};
function A({
plotData: e,
optionsConfig: n,
isTop: i,
layoutConfig: a,
label: t,
xMax: s,
colors: o,
plotStyle: f = b,
style: l = y,
onClick: r
}) {
return /* @__PURE__ */ p(
h,
{
style: l,
layout: L(a, {
isTop: i,
maxValue: s,
backgroundColor: f.backgroundColor
}),
config: n,
data: g(e, t, o),
onClick: (m) => r ? r(m) : u
}
);
}
export {
A as default
};
//# sourceMappingURL=BarPlot.js.map