@axdspub/axiom-charts 0.0.37 → 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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RequestItem } from '@axdspub/axiom-ui-data-services';
2
2
  import { extent } from 'd3-array';
3
- import { groupBy, debounce } from 'lodash';
3
+ import _, { groupBy, debounce } from 'lodash';
4
4
  import require$$0, { useRef, useState, useEffect } from 'react';
5
5
 
6
6
  /******************************************************************************
@@ -1849,9 +1849,29 @@ const AxiomChartComponent = (props) => {
1849
1849
  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 })] }));
1850
1850
  };
1851
1851
 
1852
+ const Popup = ({ plotScrubs, chartSettings, axis, followCursor, children }) => {
1853
+ const ref = useRef(null);
1854
+ const getMean = (axis) => _.meanBy(Object.values(plotScrubs), scrubData => { var _a; return (_a = scrubData[axis]) === null || _a === void 0 ? void 0 : _a.position; });
1855
+ let x = 0;
1856
+ let y = 0;
1857
+ if (followCursor !== null && followCursor !== void 0 ? followCursor : false) {
1858
+ x = getMean(EChartAxes.x);
1859
+ y = getMean(EChartAxes.y) + 50; // TODO: fix
1860
+ }
1861
+ else {
1862
+ x = axis === EChartAxes.x ? getMean(EChartAxes.x) : Number(chartSettings.width) + chartSettings.margin.right;
1863
+ y = axis === EChartAxes.y ? getMean(EChartAxes.y) : chartSettings.height + chartSettings.margin.bottom;
1864
+ }
1865
+ const position = { x, y };
1866
+ if (Object.keys(plotScrubs).length === 0) {
1867
+ return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
1868
+ }
1869
+ return (jsxRuntimeExports.jsx("div", { className: 'absolute z-30', style: { left: position.x, top: position.y }, children: jsxRuntimeExports.jsx("div", { ref: ref, children: children }) }));
1870
+ };
1871
+
1852
1872
  const Legend = ({ plotLegends, style }) => {
1853
1873
  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))) }));
1854
1874
  };
1855
1875
 
1856
- export { AxiomChartComponent as Chart, ChartRoot, EChartAxes, EPlotTypes, Legend, RadialChartRoot };
1876
+ export { AxiomChartComponent as Chart, ChartRoot, EChartAxes, EPlotTypes, Legend, Popup, RadialChartRoot };
1857
1877
  //# sourceMappingURL=index.js.map