UNPKG

@frontify/fondue-charts

Version:

Frontify's data viz library

85 lines (84 loc) • 3.22 kB
import { jsxs as p, jsx as t } from "react/jsx-runtime"; import { XYChart as x } from "@visx/xychart"; import { Axes as O } from "../LineChart/components/Axes.es.js"; import { MarkLine as G } from "../LineChart/components/MarkLine.es.js"; import { createBackfilledSeries as _ } from "../LineChart/helpers/createBackfilledSeries.es.js"; import { getAreaFillColors as C } from "../LineChart/helpers/getAreaFillColors.es.js"; import { Legend as S } from "../common/components/Legend.es.js"; import { colorAccessorByKey as I } from "../common/helpers/accessors.es.js"; import { getLinearScaleTicks as b } from "../common/helpers/getLinearScaleTicks.es.js"; import { getNonZeroLinearStackingScaleDomain as E } from "../common/helpers/getNonZeroLinearStackingScaleDomain.es.js"; import { getTransformedScaleTicks as L } from "../common/helpers/getTransformedScaleTicks.es.js"; import { transformDomainToStorageDomain as M } from "../common/helpers/transformDomainToStorageDomain.es.js"; import { useMargin as u } from "../common/hooks/useMargin.es.js"; import { createTheme as Y } from "../../theme/createTheme.es.js"; import j from "./AreaStackChart.module.scss.es.js"; import { AreaStack as B } from "./components/AreaStack.es.js"; import { GridRows as H } from "./components/GridRows.es.js"; import { Tooltip as K } from "../common/components/Tooltip/Tooltip.es.js"; const R = 5, w = "storage", P = "storage", y = "top", co = ({ width: g, height: T, series: o, missingValueLabel: h, locale: l, hideLegend: s = !1, legendPosition: n = y, markLine: r, valueFormatter: m, childSumLabel: k, domain: d = P }) => { const A = _(o), a = Y(C(o.length, A.length)), f = E(o, (r == null ? void 0 : r.value) ?? 0), c = d === w ? M(f) : f, D = b(c, R), i = L(c, D.length), N = u({ ticks: i, tickLabelStyle: a.axisStyles.y.left.tickLabel, valueFormatter: m, tickLength: a.axisStyles.y.left.tickLength }); return /* @__PURE__ */ p("div", { className: j.root, children: [ !s && n === y && /* @__PURE__ */ t(S, { names: o.map((e) => e.name), style: "line" }), /* @__PURE__ */ p( x, { theme: a, xScale: { type: "time" }, yScale: { type: "linear", domain: c }, height: T, width: g, margin: N, children: [ /* @__PURE__ */ t(H, { tickValues: i }), /* @__PURE__ */ t(B, { series: o }), /* @__PURE__ */ t( O, { linearScaleTicks: i, valueFormatter: m, locale: l, series: o } ), r && /* @__PURE__ */ t(G, { ...r }), /* @__PURE__ */ t( K, { crossHairStyle: "line", hideGlyphs: !1, colorAccessor: (e) => I(e, o), missingValueLabel: h, childSumLabel: k, valueFormatter: m, locale: l, stackingGlyphs: !0 } ) ] } ), !s && n === "bottom" && /* @__PURE__ */ t(S, { names: o.map((e) => e.name), style: "line" }) ] }); }; export { co as AreaStackChart }; //# sourceMappingURL=AreaStackChart.es.js.map