impaktapps-design 0.1.5 → 0.1.7

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.
@@ -11142,6 +11142,7 @@ const ToolTip = ({
11142
11142
  left: left2,
11143
11143
  children: /* @__PURE__ */ jsxs("div", {
11144
11144
  style: {
11145
+ minWidth: 60,
11145
11146
  textAlign: "center",
11146
11147
  background: "black",
11147
11148
  padding: "10px",
@@ -11658,17 +11659,11 @@ function DrawBarGraph({
11658
11659
  hideTooltip
11659
11660
  } = useTooltip();
11660
11661
  const handleMouse = (event, datum2) => {
11661
- var _a3;
11662
11662
  console.log(datum2);
11663
11663
  showTooltip({
11664
11664
  tooltipLeft: event.clientX,
11665
11665
  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]
11666
+ tooltipData: [datum2.key, datum2.value, datum2.color]
11672
11667
  });
11673
11668
  };
11674
11669
  const {
@@ -11678,11 +11673,10 @@ function DrawBarGraph({
11678
11673
  detectBounds: true,
11679
11674
  scroll: true
11680
11675
  });
11681
- const stachHandleMouse = (event, datum2) => {
11682
- console.log(datum2);
11676
+ const stackhHandleMouse = (event, datum2) => {
11683
11677
  showTooltip({
11684
- tooltipLeft: event.clientX,
11685
- tooltipTop: event.clientY,
11678
+ tooltipLeft: datum2.x + datum2.width / 2,
11679
+ tooltipTop: datum2.y + datum2.height / 2,
11686
11680
  tooltipData: {
11687
11681
  label: datum2.bar.data.label,
11688
11682
  key: datum2.key,
@@ -11693,11 +11687,7 @@ function DrawBarGraph({
11693
11687
  };
11694
11688
  return width < 10 ? null : /* @__PURE__ */ jsxs("div", {
11695
11689
  style: {},
11696
- children: [((_l = value == null ? void 0 : value.main) == null ? void 0 : _l.legendAvailable) && /* @__PURE__ */ jsx(Legend, {
11697
- dataKeyArray: keys2,
11698
- colorRange: [((_o = (_n2 = (_m = value.style) == null ? void 0 : _m.barStyle) == null ? void 0 : _n2.color) == null ? void 0 : _o.firstBarColor) || "#aeeef8", ((_r = (_q = (_p = value.style) == null ? void 0 : _p.barStyle) == null ? void 0 : _q.color) == null ? void 0 : _r.secondBarColor) || "#e5fd3d", ((_u = (_t2 = (_s = value.style) == null ? void 0 : _s.barStyle) == null ? void 0 : _t2.color) == null ? void 0 : _u.thirdBarColor) || "#9caff6"],
11699
- value
11700
- }), /* @__PURE__ */ jsxs("svg", {
11690
+ children: [/* @__PURE__ */ jsxs("svg", {
11701
11691
  ref: containerRef,
11702
11692
  width,
11703
11693
  height,
@@ -11715,7 +11705,7 @@ function DrawBarGraph({
11715
11705
  value,
11716
11706
  yScale: tempScale,
11717
11707
  parentWidth: width
11718
- }), ((_v = value == null ? void 0 : value.main) == null ? void 0 : _v.type) === "StackBarGraph" ? /* @__PURE__ */ jsx(BarStack, {
11708
+ }), ((_l = value == null ? void 0 : value.main) == null ? void 0 : _l.type) === "StackBarGraph" ? /* @__PURE__ */ jsx(BarStack, {
11719
11709
  data,
11720
11710
  keys: keys2,
11721
11711
  x: getDate,
@@ -11732,7 +11722,7 @@ function DrawBarGraph({
11732
11722
  if (events)
11733
11723
  alert(`clicked: ${JSON.stringify(bar)}`);
11734
11724
  },
11735
- onMouseOver: (e3) => stachHandleMouse(e3, bar),
11725
+ onMouseOver: (e3) => stackhHandleMouse(e3, bar),
11736
11726
  onMouseOut: hideTooltip
11737
11727
  }, `bar-stack-${barStack.index}-${bar.index}`)))
11738
11728
  }) : /* @__PURE__ */ jsx(BarGroup, {
@@ -11777,20 +11767,34 @@ function DrawBarGraph({
11777
11767
  xScale: dateScale,
11778
11768
  parentWidth: width
11779
11769
  })]
11770
+ }), ((_m = value == null ? void 0 : value.main) == null ? void 0 : _m.legendAvailable) && keys2.length > 1 && /* @__PURE__ */ jsx(Legend, {
11771
+ dataKeyArray: keys2,
11772
+ colorRange: [((_p = (_o = (_n2 = value.style) == null ? void 0 : _n2.barStyle) == null ? void 0 : _o.color) == null ? void 0 : _p.firstBarColor) || "#aeeef8", ((_s = (_r = (_q = value.style) == null ? void 0 : _q.barStyle) == null ? void 0 : _r.color) == null ? void 0 : _s.secondBarColor) || "#e5fd3d", ((_v = (_u = (_t2 = value.style) == null ? void 0 : _t2.barStyle) == null ? void 0 : _u.color) == null ? void 0 : _v.thirdBarColor) || "#9caff6"],
11773
+ value
11780
11774
  }), ((_w = value == null ? void 0 : value.main) == null ? void 0 : _w.type) === "StackBarGraph" ? tooltipOpen && tooltipData && /* @__PURE__ */ jsxs(TooltipInPortal, {
11781
11775
  top: tooltipTop,
11782
11776
  left: tooltipLeft,
11783
11777
  style: tooltipStyles,
11784
11778
  children: [/* @__PURE__ */ jsx("div", {
11785
11779
  style: {
11786
- color: tooltipData.color
11780
+ color: tooltipData.color,
11781
+ marginBottom: "10px",
11782
+ width: "100%",
11783
+ padding: "2px 1px",
11784
+ borderBottom: "1px solid gray"
11787
11785
  },
11788
11786
  children: /* @__PURE__ */ jsx("strong", {
11789
11787
  children: tooltipData.label
11790
11788
  })
11791
11789
  }), /* @__PURE__ */ jsx("div", {
11790
+ style: {
11791
+ padding: "1px 1px 5px 5px"
11792
+ },
11792
11793
  children: tooltipData.key
11793
11794
  }), /* @__PURE__ */ jsx("div", {
11795
+ style: {
11796
+ padding: "1px 1px 5px 5px"
11797
+ },
11794
11798
  children: /* @__PURE__ */ jsx("small", {
11795
11799
  children: tooltipData.value
11796
11800
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-design",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "dependencies": {
5
5
  "@babel/core": "^7.16.12",
6
6
  "@visx/visx": "^3.1.2",
@@ -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,26 +94,17 @@ 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
  });
108
104
  };
109
105
  return width < 10 ? null : (
110
106
  <div style={{ }}>
111
- {value?.main?.legendAvailable &&
112
- <Legend
113
- dataKeyArray={keys}
114
- colorRange={[value.style?.barStyle?.color?.firstBarColor||"#aeeef8" ,
115
- value.style?.barStyle?.color?.secondBarColor||"#e5fd3d" ,
116
- value.style?.barStyle?.color?.thirdBarColor||"#9caff6" ]}
117
- value={value}
118
- />
119
- }
107
+
120
108
  <svg ref={containerRef} width={width} height={height}>
121
109
  <rect
122
110
  x={0}
@@ -151,8 +139,8 @@ const colorScale = scaleOrdinal<string, string>({
151
139
  onClick={() => {
152
140
  if (events) alert(`clicked: ${JSON.stringify(bar)}`);
153
141
  }}
154
- onMouseOver={(e) => stachHandleMouse(e, bar)}
155
- onMouseOut={hideTooltip}
142
+ onMouseOver={(e) => stackhHandleMouse(e, bar)}
143
+ onMouseOut={hideTooltip}
156
144
 
157
145
  />
158
146
  )),
@@ -208,23 +196,31 @@ const colorScale = scaleOrdinal<string, string>({
208
196
  />
209
197
 
210
198
  </svg>
199
+ {value?.main?.legendAvailable && keys.length >1 &&
200
+ <Legend
201
+ dataKeyArray={keys}
202
+ colorRange={[value.style?.barStyle?.color?.firstBarColor||"#aeeef8" ,
203
+ value.style?.barStyle?.color?.secondBarColor||"#e5fd3d" ,
204
+ value.style?.barStyle?.color?.thirdBarColor||"#9caff6" ]}
205
+ value={value}
206
+ />
207
+ }
211
208
  {
212
209
  value?.main?.type === "StackBarGraph"?
213
210
  tooltipOpen && tooltipData && (
214
-
215
211
  <TooltipInPortal
216
- top={tooltipTop}
217
- left={tooltipLeft}
218
- style={tooltipStyles}
219
- >
220
- <div style={{ color:tooltipData.color }}>
221
- <strong>{tooltipData.label}</strong>
222
- </div>
223
- <div>{tooltipData.key}</div>
224
- <div>
225
- <small>{tooltipData.value}</small>
226
- </div>
227
- </TooltipInPortal>
212
+ top={tooltipTop}
213
+ left={tooltipLeft}
214
+ style={tooltipStyles}
215
+ >
216
+ <div style={{ color:tooltipData.color,marginBottom:"10px",width:"100%",padding:"2px 1px",borderBottom:"1px solid gray" }}>
217
+ <strong>{tooltipData.label}</strong>
218
+ </div>
219
+ <div style={{padding:"1px 1px 5px 5px"}}>{tooltipData.key}</div>
220
+ <div style={{padding:"1px 1px 5px 5px"}}>
221
+ <small>{tooltipData.value}</small>
222
+ </div>
223
+ </TooltipInPortal>
228
224
  ):
229
225
  tooltipOpen &&
230
226
  <ToolTip
@@ -13,15 +13,13 @@ const ToolTip = ({ style, top, left, tooltipData }: tooltipProps) => {
13
13
  >
14
14
  <div
15
15
  style={{
16
- // height: "50px",
16
+ minWidth:60,
17
17
  textAlign:"center",
18
18
  background:"black",
19
19
  padding:"10px",
20
20
  boxShadow:"2px 2px 5px black",
21
21
  color:"#6c5efb",
22
22
  backgroundColor:"black",
23
- // padding:"5px",
24
- // backgroundColor:style?.tooltipbackground||"black",
25
23
  ...style?.tooltipStyle,
26
24
  margin:"-20px",
27
25
  }}