impaktapps-design 0.1.4 → 0.1.6

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.
@@ -11658,17 +11658,11 @@ function DrawBarGraph({
11658
11658
  hideTooltip
11659
11659
  } = useTooltip();
11660
11660
  const handleMouse = (event, datum2) => {
11661
- var _a3;
11662
11661
  console.log(datum2);
11663
11662
  showTooltip({
11664
11663
  tooltipLeft: event.clientX,
11665
11664
  tooltipTop: event.clientY,
11666
- tooltipData: ((_a3 = value == null ? void 0 : value.main) == null ? void 0 : _a3.type) === "StackBarGraph" ? {
11667
- label: datum2.bar.data.label,
11668
- key: datum2.key,
11669
- value: datum2.bar.data[datum2.key],
11670
- color: datum2.color
11671
- } : [datum2.key, datum2.value, datum2.color]
11665
+ tooltipData: [datum2.key, datum2.value, datum2.color]
11672
11666
  });
11673
11667
  };
11674
11668
  const {
@@ -11678,11 +11672,10 @@ function DrawBarGraph({
11678
11672
  detectBounds: true,
11679
11673
  scroll: true
11680
11674
  });
11681
- const stachHandleMouse = (event, datum2) => {
11682
- console.log(datum2);
11675
+ const stackhHandleMouse = (event, datum2) => {
11683
11676
  showTooltip({
11684
- tooltipLeft: event.clientX,
11685
- tooltipTop: event.clientY,
11677
+ tooltipLeft: datum2.x + datum2.width / 2,
11678
+ tooltipTop: datum2.y + datum2.height / 2,
11686
11679
  tooltipData: {
11687
11680
  label: datum2.bar.data.label,
11688
11681
  key: datum2.key,
@@ -11732,7 +11725,7 @@ function DrawBarGraph({
11732
11725
  if (events)
11733
11726
  alert(`clicked: ${JSON.stringify(bar)}`);
11734
11727
  },
11735
- onMouseOver: (e3) => stachHandleMouse(e3, bar),
11728
+ onMouseOver: (e3) => stackhHandleMouse(e3, bar),
11736
11729
  onMouseOut: hideTooltip
11737
11730
  }, `bar-stack-${barStack.index}-${bar.index}`)))
11738
11731
  }) : /* @__PURE__ */ jsx(BarGroup, {
@@ -12061,9 +12054,9 @@ const finalDataProvider = (type2, value) => {
12061
12054
  var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s, _t2, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
12062
12055
  switch (type2) {
12063
12056
  case "BarGraph":
12057
+ case "StackBarGraph":
12064
12058
  return {
12065
12059
  main: {
12066
- type: "barGraph",
12067
12060
  data: ((_a2 = value == null ? void 0 : value.main) == null ? void 0 : _a2.data) || [{ x: "ASM", y: 100 }, { x: "SDM", y: 60 }, { x: "DCM", y: 40 }, { x: "RCM", y: 70 }],
12068
12061
  header: "Bar Graph",
12069
12062
  bottomLabel: "Name of Employe",
@@ -12330,16 +12323,16 @@ const finalDataProvider = (type2, value) => {
12330
12323
  const BarGraph = ({
12331
12324
  value
12332
12325
  }) => {
12333
- var _a2, _b2, _c2, _d;
12334
- const barData = finalDataProvider("BarGraph", value);
12326
+ var _a2, _b2, _c2, _d, _e2;
12327
+ const barData = finalDataProvider((_a2 = value == null ? void 0 : value.main) == null ? void 0 : _a2.type, value);
12335
12328
  let GraphRender = /* @__PURE__ */ jsx(ParentSize$1, {
12336
12329
  children: (parent) => {
12337
- var _a3, _b3, _c3, _d2, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2;
12330
+ var _a3, _b3, _c3, _d2, _e3, _f, _g, _h, _i, _j, _k, _l, _m, _n2;
12338
12331
  return /* @__PURE__ */ jsx(DrawBarGraph, {
12339
12332
  width: parent.width || 400,
12340
12333
  height: ((_b3 = (_a3 = barData == null ? void 0 : barData.style) == null ? void 0 : _a3.containerStyle) == null ? void 0 : _b3.height) | 400,
12341
12334
  margin: {
12342
- top: ((_e2 = (_d2 = (_c3 = barData == null ? void 0 : barData.style) == null ? void 0 : _c3.labelStyle) == null ? void 0 : _d2.margin) == null ? void 0 : _e2.top) || 10,
12335
+ top: ((_e3 = (_d2 = (_c3 = barData == null ? void 0 : barData.style) == null ? void 0 : _c3.labelStyle) == null ? void 0 : _d2.margin) == null ? void 0 : _e3.top) || 10,
12343
12336
  right: ((_h = (_g = (_f = barData == null ? void 0 : barData.style) == null ? void 0 : _f.labelStyle) == null ? void 0 : _g.margin) == null ? void 0 : _h.right) || 10,
12344
12337
  bottom: ((_k = (_j = (_i = barData == null ? void 0 : barData.style) == null ? void 0 : _i.labelStyle) == null ? void 0 : _j.margin) == null ? void 0 : _k.bottom) || 20,
12345
12338
  left: ((_n2 = (_m = (_l = barData == null ? void 0 : barData.style) == null ? void 0 : _l.labelStyle) == null ? void 0 : _m.margin) == null ? void 0 : _n2.left) || 60
@@ -12349,8 +12342,8 @@ const BarGraph = ({
12349
12342
  }
12350
12343
  });
12351
12344
  return /* @__PURE__ */ jsxs("div", {
12352
- style: (_a2 = barData == null ? void 0 : barData.style) == null ? void 0 : _a2.containerStyle,
12353
- children: [((_b2 = barData == null ? void 0 : barData.main) == null ? void 0 : _b2.header) && /* @__PURE__ */ jsx("div", {
12345
+ style: (_b2 = barData == null ? void 0 : barData.style) == null ? void 0 : _b2.containerStyle,
12346
+ children: [((_c2 = barData == null ? void 0 : barData.main) == null ? void 0 : _c2.header) && /* @__PURE__ */ jsx("div", {
12354
12347
  style: {
12355
12348
  fontWeight: 500,
12356
12349
  textAlign: "left",
@@ -12359,9 +12352,9 @@ const BarGraph = ({
12359
12352
  padding: "15px 0 1px 20px",
12360
12353
  fontSize: "18px",
12361
12354
  color: "#121926",
12362
- ...(_c2 = barData == null ? void 0 : barData.style) == null ? void 0 : _c2.headerStyle
12355
+ ...(_d = barData == null ? void 0 : barData.style) == null ? void 0 : _d.headerStyle
12363
12356
  },
12364
- children: (_d = barData == null ? void 0 : barData.main) == null ? void 0 : _d.header
12357
+ children: (_e2 = barData == null ? void 0 : barData.main) == null ? void 0 : _e2.header
12365
12358
  }), GraphRender]
12366
12359
  });
12367
12360
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-design",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "dependencies": {
5
5
  "@babel/core": "^7.16.12",
6
6
  "@visx/visx": "^3.1.2",
@@ -4,7 +4,7 @@ import { ParentSize } from "@visx/responsive";
4
4
  import { finalDataProvider } from "../../utils/finalDataProvider";
5
5
 
6
6
  const BarGraph = ({ value }:any) => {
7
- const barData:any = finalDataProvider("BarGraph",value)
7
+ const barData:any = finalDataProvider(value?.main?.type,value)
8
8
  let GraphRender = (
9
9
  <ParentSize>
10
10
  {(parent) => (
@@ -86,10 +86,7 @@ const colorScale = scaleOrdinal<string, string>({
86
86
  showTooltip({
87
87
  tooltipLeft: event.clientX,
88
88
  tooltipTop: event.clientY,
89
- tooltipData: value?.main?.type === "StackBarGraph"?
90
- {label:datum.bar.data.label,key:datum.key,value:datum.bar.data[datum.key],color:datum.color}
91
- :
92
- [datum.key,datum.value,datum.color],
89
+ tooltipData:[datum.key,datum.value,datum.color],
93
90
 
94
91
  });
95
92
  };
@@ -97,11 +94,10 @@ const colorScale = scaleOrdinal<string, string>({
97
94
  detectBounds: true,
98
95
  scroll: true,
99
96
  });
100
- const stachHandleMouse = (event: any, datum: any) => {
101
- console.log(datum)
97
+ const stackhHandleMouse = (event: any, datum: any) => {
102
98
  showTooltip({
103
- tooltipLeft: event.clientX,
104
- tooltipTop: event.clientY,
99
+ tooltipLeft: datum.x+(datum.width/2),
100
+ tooltipTop: datum.y+(datum.height/2),
105
101
  tooltipData:{label:datum.bar.data.label,key:datum.key,value:datum.bar.data[datum.key],color:datum.color}
106
102
 
107
103
  });
@@ -151,8 +147,8 @@ const colorScale = scaleOrdinal<string, string>({
151
147
  onClick={() => {
152
148
  if (events) alert(`clicked: ${JSON.stringify(bar)}`);
153
149
  }}
154
- onMouseOver={(e) => stachHandleMouse(e, bar)}
155
- onMouseOut={hideTooltip}
150
+ onMouseOver={(e) => stackhHandleMouse(e, bar)}
151
+ onMouseOut={hideTooltip}
156
152
 
157
153
  />
158
154
  )),
@@ -9,9 +9,10 @@ const Product1 = [
9
9
  export const finalDataProvider = (type: string, value: any) => {
10
10
  switch (type) {
11
11
  case "BarGraph":
12
+ case "StackBarGraph":
12
13
  return {
13
14
  main: {
14
- type: "barGraph",
15
+
15
16
  data: value?.main?.data || [{ x: "ASM", y: 100 }, { x: "SDM", y: 60 }, { x: "DCM", y: 40 }, { x: "RCM", y: 70 }],
16
17
  // [{}] ,
17
18
  header: "Bar Graph",