@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/cjs.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var axiomUiDataServices = require('@axdspub/axiom-ui-data-services');
4
4
  var d3Array = require('d3-array');
5
- var lodash = require('lodash');
5
+ var _ = require('lodash');
6
6
  var require$$0 = require('react');
7
7
 
8
8
  /******************************************************************************
@@ -281,7 +281,7 @@ class ChartRoot {
281
281
  return param;
282
282
  }
283
283
  getPlotImplementationGroups(plots, axis) {
284
- const groups = lodash.groupBy(plots, p => {
284
+ const groups = _.groupBy(plots, p => {
285
285
  const param = this.getDimensionAxisParam(p, axis);
286
286
  return `${param}${this.reversePlotAxis(p, axis) ? '.reverse' : ''}`;
287
287
  });
@@ -321,13 +321,13 @@ class ChartRoot {
321
321
  this.runtime.resizeEventHandler.cancel();
322
322
  console.log('cancel');
323
323
  }
324
- this.runtime.resizeEventHandler = lodash.debounce(() => { this.onResize(this.runtime.prevWidth, this.runtime.prevHeight); }, 1000);
324
+ this.runtime.resizeEventHandler = _.debounce(() => { this.onResize(this.runtime.prevWidth, this.runtime.prevHeight); }, 1000);
325
325
  this.runtime.resizeEventHandler();
326
326
  }
327
327
  init(drawImmediately = false) {
328
328
  var _a;
329
329
  return __awaiter(this, void 0, void 0, function* () {
330
- this.runtime.resizeEventHandler = lodash.debounce(() => { this.onResize(this.runtime.prevWidth, this.runtime.prevHeight); }, 1000);
330
+ this.runtime.resizeEventHandler = _.debounce(() => { this.onResize(this.runtime.prevWidth, this.runtime.prevHeight); }, 1000);
331
331
  window.addEventListener('resize', () => { this.debouncedResize(); });
332
332
  (_a = this.plotImplementations) === null || _a === void 0 ? void 0 : _a.forEach(plot => { plot.destroy(); });
333
333
  this.plotImplementations = this.createPlots();
@@ -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