@frontify/fondue-charts
Version:
Frontify's data viz library
99 lines (98 loc) • 3.16 kB
JavaScript
import { jsxs as p, jsx as t } from "react/jsx-runtime";
import { XYChart as u, Grid as A } from "@visx/xychart";
import { Legend as y } from "../common/components/Legend.es.js";
import { colorAccessorByKey as C } from "../common/helpers/accessors.es.js";
import { getLinearScaleTicks as G } from "../common/helpers/getLinearScaleTicks.es.js";
import { getNonZeroLinearScaleDomain as L } from "../common/helpers/getNonZeroLinearScaleDomain.es.js";
import { useMargin as N } from "../common/hooks/useMargin.es.js";
import { createTheme as j } from "../../theme/createTheme.es.js";
import B from "./LineChart.module.scss.es.js";
import { Axes as D } from "./components/Axes.es.js";
import { MarkLine as H } from "./components/MarkLine.es.js";
import { createBackfilledSeries as K } from "./helpers/createBackfilledSeries.es.js";
import { getAreaFillColors as M } from "./helpers/getAreaFillColors.es.js";
import { Series as Y } from "./components/Series/Series.es.js";
import { Tooltip as _ } from "../common/components/Tooltip/Tooltip.es.js";
const S = 5, $ = ({
width: h,
height: g,
series: o,
missingValueLabel: d,
locale: m,
hideGlyphs: k = !1,
hideArea: x = !1,
hideLegend: c = !1,
legendPosition: s = "top",
highlightNegativeValues: T = !1,
markLine: r,
valueFormatter: l
}) => {
const a = K(o), i = j(M(o.length, a.length)), n = L(o, (r == null ? void 0 : r.value) ?? 0), f = G(n, S), b = N({
ticks: f,
tickLabelStyle: i.axisStyles.y.left.tickLabel,
valueFormatter: l,
tickLength: i.axisStyles.y.left.tickLength
});
return /* @__PURE__ */ p("div", { className: B.root, children: [
!c && s === "top" && /* @__PURE__ */ t(y, { names: o.map((e) => e.name), style: "line" }),
/* @__PURE__ */ p(
u,
{
theme: i,
xScale: { type: "time" },
yScale: { type: "linear", domain: n },
height: g,
width: h,
margin: b,
children: [
/* @__PURE__ */ t(
A,
{
rows: !0,
columns: !1,
numTicks: S,
stroke: "var(--fc-grid-stroke-color)"
},
"grid"
),
/* @__PURE__ */ t(
D,
{
linearScaleTicks: f,
valueFormatter: l,
locale: m,
series: o
}
),
/* @__PURE__ */ t(
Y,
{
series: o,
backfilledSeries: a,
hideGlyphs: k,
hideArea: x,
highlightNegativeValues: T
}
),
r && /* @__PURE__ */ t(H, { ...r }),
/* @__PURE__ */ t(
_,
{
crossHairStyle: "line",
hideGlyphs: !1,
colorAccessor: (e) => C(e, o),
missingValueLabel: d,
valueFormatter: l,
locale: m
}
)
]
}
),
!c && s === "bottom" && /* @__PURE__ */ t(y, { names: o.map((e) => e.name), style: "line" })
] });
};
export {
$ as LineChart
};
//# sourceMappingURL=LineChart.es.js.map