@axdspub/axiom-charts 0.0.38 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/library/cjs.js CHANGED
@@ -1851,6 +1851,26 @@ const AxiomChartComponent = (props) => {
1851
1851
  return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [error !== undefined ? jsxRuntimeExports.jsx("p", { children: error }) : '', jsxRuntimeExports.jsx("div", { className: "chart relative", style: { width: w, height: `${props.settings.height}px` }, ref: chartRef })] }));
1852
1852
  };
1853
1853
 
1854
+ const Popup = ({ plotScrubs, chartSettings, axis, followCursor, children }) => {
1855
+ const ref = require$$0.useRef(null);
1856
+ const getMean = (axis) => _.meanBy(Object.values(plotScrubs), scrubData => { var _a; return (_a = scrubData[axis]) === null || _a === void 0 ? void 0 : _a.position; });
1857
+ let x = 0;
1858
+ let y = 0;
1859
+ if (followCursor !== null && followCursor !== void 0 ? followCursor : false) {
1860
+ x = getMean(exports.EChartAxes.x);
1861
+ y = getMean(exports.EChartAxes.y) + 50; // TODO: fix
1862
+ }
1863
+ else {
1864
+ x = axis === exports.EChartAxes.x ? getMean(exports.EChartAxes.x) : Number(chartSettings.width) + chartSettings.margin.right;
1865
+ y = axis === exports.EChartAxes.y ? getMean(exports.EChartAxes.y) : chartSettings.height + chartSettings.margin.bottom;
1866
+ }
1867
+ const position = { x, y };
1868
+ if (Object.keys(plotScrubs).length === 0) {
1869
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
1870
+ }
1871
+ return (jsxRuntimeExports.jsx("div", { className: 'absolute z-30', style: { left: position.x, top: position.y }, children: jsxRuntimeExports.jsx("div", { ref: ref, children: children }) }));
1872
+ };
1873
+
1854
1874
  const Legend = ({ plotLegends, style }) => {
1855
1875
  return (jsxRuntimeExports.jsx("div", { className: 'flex gap-4 flex-wrap hover:cursor-pointer', style: style, children: Object.entries(plotLegends).map(([plotId, legendItems]) => (jsxRuntimeExports.jsx("div", { className: 'flex gap-4 flex-wrap', children: legendItems.map(item => (jsxRuntimeExports.jsxs("div", { className: 'flex gap-2 items-center', children: [jsxRuntimeExports.jsx("div", { className: 'w-4 h-4 rounded-full', style: item.style }), jsxRuntimeExports.jsx("div", { children: item.label })] }, item.id))) }, plotId))) }));
1856
1876
  };
@@ -1858,5 +1878,6 @@ const Legend = ({ plotLegends, style }) => {
1858
1878
  exports.Chart = AxiomChartComponent;
1859
1879
  exports.ChartRoot = ChartRoot;
1860
1880
  exports.Legend = Legend;
1881
+ exports.Popup = Popup;
1861
1882
  exports.RadialChartRoot = RadialChartRoot;
1862
1883
  //# sourceMappingURL=cjs.js.map