@apia/charts 0.3.6 → 1.0.0

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/dist/index.js CHANGED
@@ -10,9 +10,8 @@ import { BarGroupHorizontal, BarGroup, LinePath, Line } from '@visx/shape';
10
10
  import { AxisLeft, AxisBottom } from '@visx/axis';
11
11
  import tinycolor from 'tinycolor2';
12
12
  import { localPoint } from '@visx/event';
13
- import { SimpleButton, useTooltip } from '@apia/components';
13
+ import { ApiaUtil, SimpleButton } from '@apia/components';
14
14
  import { icons } from '@apia/icons';
15
- import { ApiaUtil } from '@apia/objects';
16
15
  import Pie from '@visx/shape/lib/shapes/Pie';
17
16
  import { min, max, extent } from 'd3-array';
18
17
  import * as allCurves from '@visx/curve';
@@ -49,7 +48,7 @@ const ColoredLegendItem = ({
49
48
  if (avoidEvent) {
50
49
  return;
51
50
  }
52
- new ApiaUtil().tooltips.close();
51
+ new ApiaUtil().tooltips.closeAll();
53
52
  chartMethods(chartId, "highlight", "");
54
53
  }, [avoidEvent, chartId]);
55
54
  return /* @__PURE__ */ jsx(
@@ -59,7 +58,6 @@ const ColoredLegendItem = ({
59
58
  className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} ${isAnyHighlighted && !isHighlighted ? "isBlurred" : ""} legendItem`,
60
59
  iconColor: color || "black",
61
60
  icon: color === "transparent" ? void 0 : icons.SquareFilled,
62
- title,
63
61
  onMouseEnter: handleMouseEnter,
64
62
  onMouseLeave: handleMouseLeave,
65
63
  children: title
@@ -86,18 +84,17 @@ const NumberedLegendItem = ({
86
84
  if (avoidEvent) {
87
85
  return;
88
86
  }
89
- new ApiaUtil().tooltips.close();
87
+ new ApiaUtil().tooltips.closeAll();
90
88
  chartMethods(chartId, "highlight", "");
91
89
  }, [avoidEvent, chartId]);
92
90
  return /* @__PURE__ */ jsx(
93
91
  SimpleButton,
94
92
  {
95
93
  variant: "link",
96
- className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} legendItem`,
94
+ className: `${className != null ? className : ""} ${isHighlighted ? "highlight" : ""} ${isAnyHighlighted && !isHighlighted ? "isBlurred" : ""} legendItem`,
97
95
  sx: {
98
96
  opacity: isAnyHighlighted && !isHighlighted ? "0.15" : "1"
99
97
  },
100
- title,
101
98
  onMouseEnter: handleMouseEnter,
102
99
  onMouseLeave: handleMouseLeave,
103
100
  children: title
@@ -111,6 +108,7 @@ const [legendContainerMethods, , LegendContainer] = makeImperativeComponent()({
111
108
  },
112
109
  methods: {
113
110
  highlight(setState, highlightedBarGroup) {
111
+ console.log(highlightedBarGroup);
114
112
  setState({ highlightedBarGroup });
115
113
  }
116
114
  },
@@ -210,6 +208,9 @@ const Bar$1 = ({
210
208
  } else {
211
209
  setIsHighlighted(barName === bar.key);
212
210
  setIsAnyHighlighted(barName !== bar.key && barName !== "");
211
+ const currentBar = document.querySelector(
212
+ `.${parsedData[barGroup.index].columnName}__${bar.key}`
213
+ );
213
214
  if (barName === bar.key && columnName === parsedData[barGroup.index].columnName) {
214
215
  new ApiaUtil().tooltips.open({
215
216
  children: /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -228,6 +229,28 @@ const Bar$1 = ({
228
229
  attachToElement: () => ref.current,
229
230
  attachToElementAnchorPoint: "center"
230
231
  });
232
+ } else if (barName === bar.key && currentBar && columnName === "") {
233
+ new ApiaUtil().tooltips.open({
234
+ children: parsedData.map((dat, i) => {
235
+ return /* @__PURE__ */ jsxs("div", { children: [
236
+ /* @__PURE__ */ jsx(
237
+ "div",
238
+ {
239
+ style: {
240
+ color: currentBarColor
241
+ },
242
+ children: /* @__PURE__ */ jsx("strong", { children: dat.columnName })
243
+ }
244
+ ),
245
+ chart.showValues && /* @__PURE__ */ jsx("div", { children: dat[barName] }),
246
+ /* @__PURE__ */ jsx("div", { children: Object.keys(dat).find(
247
+ (key) => dat[key] === dat[barName]
248
+ ) }),
249
+ parsedData[i + 1] && /* @__PURE__ */ jsx("hr", {})
250
+ ] }, `${dat.columnName}_${dat[barName]}`);
251
+ }),
252
+ attachToMousePosition: true
253
+ });
231
254
  }
232
255
  }
233
256
  } else if (barName.split(" - ").length === 2) {
@@ -260,94 +283,79 @@ const Bar$1 = ({
260
283
  }
261
284
  });
262
285
  const { chartId } = useContext(ChartContext);
263
- return /* @__PURE__ */ jsxs("g", { children: [
264
- /* @__PURE__ */ jsx(
265
- "text",
266
- {
267
- x: bar.x + 5,
268
- y: bar.y - 5,
269
- width: bar.width,
270
- height: bar.height,
271
- textAnchor: "start",
272
- style: {
273
- display: isHighlighted ? "block" : "none",
274
- opacity: isHighlighted ? 1 : 0,
275
- transition: "opacity 500ms"
276
- },
277
- children: bar.value
278
- }
279
- ),
280
- /* @__PURE__ */ jsx(
281
- Box,
282
- {
283
- as: "rect",
284
- className: "chart__barRect",
285
- ref,
286
- sx: useMemo(
287
- () => ({
288
- fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
289
- "&:hover": {
290
- fill: `#${tinycolor(currentBarColor).saturate(25).toHex()}`
291
- },
292
- transition: "fill 500ms, opacity 500ms",
293
- x: bar.x,
294
- y: bar.y,
295
- width: bar.width - effectiveMargin.left,
296
- opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
297
- height: bar.height > 0 ? bar.height : 0
298
- }),
299
- [
300
- bar.height,
301
- bar.width,
302
- bar.x,
303
- bar.y,
304
- currentBarColor,
305
- effectiveMargin.left,
306
- isAnyHighlighted,
307
- isHighlighted
308
- ]
309
- ),
310
- onMouseEnter: (ev) => {
311
- var _a2, _b, _c;
312
- if (!isSingle) {
313
- legendContainerMethods.highlight(chartId, bar.key);
314
- }
315
- chartMethods(
286
+ return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx(
287
+ Box,
288
+ {
289
+ as: "rect",
290
+ className: `chart__barRect ${parsedData[barGroup.index].columnName}__${bar.key}`,
291
+ ref,
292
+ sx: useMemo(
293
+ () => ({
294
+ fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
295
+ "&:hover": {
296
+ fill: `#${tinycolor(currentBarColor).saturate(25).toHex()}`
297
+ },
298
+ transition: "fill 500ms, opacity 500ms",
299
+ x: bar.x,
300
+ y: bar.y,
301
+ width: bar.width - effectiveMargin.left,
302
+ opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
303
+ height: bar.height > 0 ? bar.height : 0
304
+ }),
305
+ [
306
+ bar.height,
307
+ bar.width,
308
+ bar.x,
309
+ bar.y,
310
+ currentBarColor,
311
+ effectiveMargin.left,
312
+ isAnyHighlighted,
313
+ isHighlighted
314
+ ]
315
+ ),
316
+ onMouseEnter: (ev) => {
317
+ var _a2, _b, _c;
318
+ if (!isSingle) {
319
+ legendContainerMethods.highlight(chartId, bar.key);
320
+ } else {
321
+ legendContainerMethods.highlight(
316
322
  chartId,
317
- "highlight",
318
- `${bar.key}_$_${parsedData[barGroup.index].columnName}`
323
+ parsedData[barGroup.index].columnName
319
324
  );
320
- (_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
321
- const point = {
322
- x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
323
- y: (_c = localPoint(ev)) == null ? void 0 : _c.y
324
- };
325
- if (!point || !chart.showValues)
326
- return;
327
- },
328
- onMouseLeave: (ev) => {
329
- var _a2;
330
- if (!isSingle) {
331
- legendContainerMethods.highlight(chartId, "");
332
- }
333
- chartMethods(chartId, "highlight", "");
334
- (_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
335
- },
336
- children: /* @__PURE__ */ jsx(
337
- "animate",
338
- {
339
- attributeName: "width",
340
- from: 0,
341
- to: bar.width,
342
- dur: "0.5s",
343
- calcMode: "paced",
344
- keySplines: "0.5 0 0.5 1;",
345
- keyTimes: "0; 1"
346
- }
347
- )
348
- }
349
- )
350
- ] });
325
+ }
326
+ chartMethods(
327
+ chartId,
328
+ "highlight",
329
+ `${bar.key}_$_${parsedData[barGroup.index].columnName}`
330
+ );
331
+ (_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
332
+ const point = {
333
+ x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
334
+ y: (_c = localPoint(ev)) == null ? void 0 : _c.y
335
+ };
336
+ if (!point || !chart.showValues)
337
+ return;
338
+ },
339
+ onMouseLeave: (ev) => {
340
+ var _a2;
341
+ legendContainerMethods.highlight(chartId, "");
342
+ chartMethods(chartId, "highlight", "");
343
+ (_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
344
+ },
345
+ children: /* @__PURE__ */ jsx(
346
+ "animate",
347
+ {
348
+ attributeName: "width",
349
+ from: 0,
350
+ to: bar.width,
351
+ dur: "0.5s",
352
+ calcMode: "paced",
353
+ keySplines: "0.5 0 0.5 1;",
354
+ keyTimes: "0; 1"
355
+ }
356
+ )
357
+ }
358
+ ) });
351
359
  };
352
360
 
353
361
  function getBarColor(colors, index, alwaysDiffer = false) {
@@ -363,7 +371,7 @@ function getBarColor(colors, index, alwaysDiffer = false) {
363
371
  innerIndex = index / module;
364
372
  count++;
365
373
  }
366
- barColor = tinycolor(colors[index % module]).desaturate(count * 5).toHex();
374
+ barColor = tinycolor(colors[index % module]).desaturate(count * 5).toHex().startsWith("#") ? tinycolor(colors[index % module]).desaturate(count * 5).toHex() : `#${tinycolor(colors[index % module]).desaturate(count * 5).toHex()}`;
367
375
  }
368
376
  } else {
369
377
  if (colors[index]) {
@@ -675,12 +683,12 @@ const HorizontalBars = ({
675
683
  transform: "rotate(45deg)",
676
684
  transformOrigin: "attr(x) 18px"
677
685
  },
678
- overflow: "auto",
686
+ overflow: "hidden",
679
687
  position: "relative",
680
- height: `${chart.ratio.height}px`,
681
- width: `${chart.ratio.width}px`
688
+ height: `${chart.ratio.height}px`
689
+ // width: `${chart.ratio.width}px`,
682
690
  };
683
- }, [chart.ratio.height, chart.ratio.width, chartId, outerClassName]),
691
+ }, [chart.ratio.height, chartId, outerClassName]),
684
692
  children: /* @__PURE__ */ jsxs(
685
693
  "svg",
686
694
  {
@@ -768,9 +776,8 @@ const HorizontalBars = ({
768
776
  top: innerHeight,
769
777
  scale: xScale,
770
778
  label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
771
- tickLabelProps: {
772
- className: "tickLabel"
773
- },
779
+ tickLabelProps: { display: "none" },
780
+ tickLineProps: { display: "none" },
774
781
  labelOffset: 30
775
782
  }
776
783
  )
@@ -1185,7 +1192,7 @@ const PieChart = ({
1185
1192
  return pie.path(arc);
1186
1193
  });
1187
1194
  const result = pie.arcs.map((arc) => {
1188
- var _a2, _b2;
1195
+ var _a2, _b2, _c2, _d2, _e;
1189
1196
  const name = arc.data;
1190
1197
  const arcPath = pie.path(arc);
1191
1198
  return /* @__PURE__ */ jsx(
@@ -1195,9 +1202,13 @@ const PieChart = ({
1195
1202
  chartId: id,
1196
1203
  arcPath,
1197
1204
  chart,
1198
- actualColor: (_b2 = (_a2 = colorReference.find((color) => {
1205
+ actualColor: ((_a2 = colorReference.find((color) => {
1199
1206
  return color.title === name.key;
1200
- })) == null ? void 0 : _a2.color) != null ? _b2 : ""
1207
+ })) == null ? void 0 : _a2.color.startsWith("#")) ? (_c2 = (_b2 = colorReference.find((color) => {
1208
+ return color.title === name.key;
1209
+ })) == null ? void 0 : _b2.color) != null ? _c2 : "" : `#${(_e = (_d2 = colorReference.find((color) => {
1210
+ return color.title === name.key;
1211
+ })) == null ? void 0 : _d2.color) != null ? _e : ""}`
1201
1212
  },
1202
1213
  `${name.key}_${name.value}`
1203
1214
  );
@@ -1269,7 +1280,7 @@ const Bar = ({
1269
1280
  setIsAnyHighlighted(
1270
1281
  barName !== parsedData[barGroup.index].columnName && barName !== ""
1271
1282
  );
1272
- if (barName === parsedData[barGroup.index].columnName && columnName === parsedData[barGroup.index].columnName) {
1283
+ if (barName === parsedData[barGroup.index].columnName || columnName === parsedData[barGroup.index].columnName) {
1273
1284
  new ApiaUtil().tooltips.open({
1274
1285
  children: /* @__PURE__ */ jsxs(Fragment, { children: [
1275
1286
  /* @__PURE__ */ jsx(
@@ -1291,6 +1302,9 @@ const Bar = ({
1291
1302
  } else {
1292
1303
  setIsHighlighted(barName === bar.key);
1293
1304
  setIsAnyHighlighted(barName !== bar.key && barName !== "");
1305
+ const currentBar = document.querySelector(
1306
+ `.${parsedData[barGroup.index].columnName}__${bar.key}`
1307
+ );
1294
1308
  if (barName === bar.key && columnName === parsedData[barGroup.index].columnName) {
1295
1309
  new ApiaUtil().tooltips.open({
1296
1310
  children: /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1309,6 +1323,28 @@ const Bar = ({
1309
1323
  attachToElement: () => ref.current,
1310
1324
  attachToElementAnchorPoint: "center"
1311
1325
  });
1326
+ } else if (barName === bar.key && currentBar && columnName === "") {
1327
+ new ApiaUtil().tooltips.open({
1328
+ children: parsedData.map((dat, i) => {
1329
+ return /* @__PURE__ */ jsxs("div", { children: [
1330
+ /* @__PURE__ */ jsx(
1331
+ "div",
1332
+ {
1333
+ style: {
1334
+ color: currentBarColor
1335
+ },
1336
+ children: /* @__PURE__ */ jsx("strong", { children: dat.columnName })
1337
+ }
1338
+ ),
1339
+ chart.showValues && /* @__PURE__ */ jsx("div", { children: dat[barName] }),
1340
+ /* @__PURE__ */ jsx("div", { children: Object.keys(dat).find(
1341
+ (key) => dat[key] === dat[barName]
1342
+ ) }),
1343
+ parsedData[i + 1] && /* @__PURE__ */ jsx("hr", {})
1344
+ ] }, `${dat.columnName}_${dat[barName]}`);
1345
+ }),
1346
+ attachToMousePosition: true
1347
+ });
1312
1348
  }
1313
1349
  }
1314
1350
  } else if (barName.split(" - ").length === 2) {
@@ -1341,107 +1377,93 @@ const Bar = ({
1341
1377
  }
1342
1378
  });
1343
1379
  const { chartId } = useContext(ChartContext);
1344
- return /* @__PURE__ */ jsxs("g", { children: [
1345
- /* @__PURE__ */ jsx(
1346
- "text",
1347
- {
1348
- x: bar.x + bar.width / 2,
1349
- y: bar.y - 5,
1350
- width: bar.width,
1351
- height: bar.height,
1352
- textAnchor: "middle",
1353
- style: {
1354
- display: isHighlighted ? "block" : "none",
1355
- opacity: isHighlighted ? 1 : 0,
1356
- transition: "opacity 500ms"
1357
- },
1358
- children: bar.value
1359
- }
1360
- ),
1361
- /* @__PURE__ */ jsxs(
1362
- Box,
1363
- {
1364
- as: "rect",
1365
- className: "chart__barRect",
1366
- ref,
1367
- sx: useMemo(
1368
- () => ({
1369
- fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
1370
- "&:hover": {
1371
- fill: `#${tinycolor(currentBarColor).saturate(25).toHex()}`
1372
- },
1373
- transition: "fill 500ms, opacity 500ms",
1374
- x: bar.x,
1375
- y: bar.y,
1376
- width: bar.width,
1377
- opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
1378
- height: bar.height > 0 ? bar.height : 0
1379
- }),
1380
- [
1381
- bar.height,
1382
- bar.width,
1383
- bar.x,
1384
- bar.y,
1385
- currentBarColor,
1386
- isAnyHighlighted,
1387
- isHighlighted
1388
- ]
1389
- ),
1390
- onMouseEnter: (ev) => {
1391
- var _a2, _b, _c;
1392
- if (!isSingle) {
1393
- legendContainerMethods.highlight(chartId, bar.key);
1394
- }
1395
- chartMethods(
1380
+ return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsxs(
1381
+ Box,
1382
+ {
1383
+ as: "rect",
1384
+ className: `chart__barRect ${parsedData[barGroup.index].columnName}__${bar.key}`,
1385
+ ref,
1386
+ sx: useMemo(
1387
+ () => ({
1388
+ fill: isAnyHighlighted ? `#${tinycolor(currentBarColor).desaturate(70).toHex()}` : currentBarColor,
1389
+ "&:hover": {
1390
+ fill: `#${tinycolor(currentBarColor).saturate(25).toHex()}`
1391
+ },
1392
+ transition: "fill 500ms, opacity 500ms",
1393
+ x: bar.x,
1394
+ y: bar.y,
1395
+ width: bar.width,
1396
+ opacity: isAnyHighlighted && !isHighlighted ? 0.15 : 1,
1397
+ height: bar.height > 0 ? bar.height : 0
1398
+ }),
1399
+ [
1400
+ bar.height,
1401
+ bar.width,
1402
+ bar.x,
1403
+ bar.y,
1404
+ currentBarColor,
1405
+ isAnyHighlighted,
1406
+ isHighlighted
1407
+ ]
1408
+ ),
1409
+ onMouseEnter: (ev) => {
1410
+ var _a2, _b, _c;
1411
+ console.log(bar.key, parsedData[barGroup.index].columnName);
1412
+ if (!isSingle) {
1413
+ legendContainerMethods.highlight(chartId, bar.key);
1414
+ } else {
1415
+ legendContainerMethods.highlight(
1396
1416
  chartId,
1397
- "highlight",
1398
- `${bar.key}_$_${parsedData[barGroup.index].columnName}`
1417
+ parsedData[barGroup.index].columnName
1399
1418
  );
1400
- (_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
1401
- const point = {
1402
- x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
1403
- y: (_c = localPoint(ev)) == null ? void 0 : _c.y
1404
- };
1405
- if (!point || !chart.showValues)
1406
- return;
1407
- },
1408
- onMouseLeave: (ev) => {
1409
- var _a2;
1410
- if (!isSingle) {
1411
- legendContainerMethods.highlight(chartId, "");
1419
+ }
1420
+ chartMethods(
1421
+ chartId,
1422
+ "highlight",
1423
+ `${bar.key}_$_${parsedData[barGroup.index].columnName}`
1424
+ );
1425
+ (_a2 = ev.target.classList) == null ? void 0 : _a2.add("over");
1426
+ const point = {
1427
+ x: (_b = localPoint(ev)) == null ? void 0 : _b.x,
1428
+ y: (_c = localPoint(ev)) == null ? void 0 : _c.y
1429
+ };
1430
+ if (!point || !chart.showValues)
1431
+ return;
1432
+ },
1433
+ onMouseLeave: (ev) => {
1434
+ var _a2;
1435
+ legendContainerMethods.highlight(chartId, "");
1436
+ chartMethods(chartId, "highlight", "");
1437
+ (_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
1438
+ },
1439
+ children: [
1440
+ /* @__PURE__ */ jsx(
1441
+ "animate",
1442
+ {
1443
+ attributeName: "height",
1444
+ from: 0,
1445
+ to: bar.height,
1446
+ dur: "0.5s",
1447
+ calcMode: "paced",
1448
+ keySplines: "0.5 0 0.5 1;",
1449
+ keyTimes: "0; 1"
1412
1450
  }
1413
- chartMethods(chartId, "highlight", "");
1414
- (_a2 = ev.target.classList) == null ? void 0 : _a2.remove("over");
1415
- },
1416
- children: [
1417
- /* @__PURE__ */ jsx(
1418
- "animate",
1419
- {
1420
- attributeName: "height",
1421
- from: 0,
1422
- to: bar.height,
1423
- dur: "0.5s",
1424
- calcMode: "paced",
1425
- keySplines: "0.5 0 0.5 1;",
1426
- keyTimes: "0; 1"
1427
- }
1428
- ),
1429
- /* @__PURE__ */ jsx(
1430
- "animate",
1431
- {
1432
- attributeName: "y",
1433
- from: bar.y + bar.height,
1434
- to: bar.y,
1435
- dur: "0.5s",
1436
- calcMode: "paced",
1437
- keySplines: "0.5 0 0.5 1;",
1438
- keyTimes: "0; 1"
1439
- }
1440
- )
1441
- ]
1442
- }
1443
- )
1444
- ] });
1451
+ ),
1452
+ /* @__PURE__ */ jsx(
1453
+ "animate",
1454
+ {
1455
+ attributeName: "y",
1456
+ from: bar.y + bar.height,
1457
+ to: bar.y,
1458
+ dur: "0.5s",
1459
+ calcMode: "paced",
1460
+ keySplines: "0.5 0 0.5 1;",
1461
+ keyTimes: "0; 1"
1462
+ }
1463
+ )
1464
+ ]
1465
+ }
1466
+ ) });
1445
1467
  };
1446
1468
 
1447
1469
  var __defProp$b = Object.defineProperty;
@@ -1486,7 +1508,7 @@ const VerticalBars = ({
1486
1508
  }) => {
1487
1509
  var _a;
1488
1510
  const effectiveMargin = parseMargin(margin);
1489
- if (!chart.showAxisYTitle) {
1511
+ if (!chart.showAxisYTitle && effectiveMargin.left > 50) {
1490
1512
  effectiveMargin.left = 50;
1491
1513
  }
1492
1514
  let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
@@ -1792,7 +1814,7 @@ const VerticalBars = ({
1792
1814
  stringValue = stringValue.replace(".", "");
1793
1815
  }
1794
1816
  const newValue = `${stringValue}${counter >= 0 ? units[counter] : ""}`;
1795
- return /* @__PURE__ */ jsx(
1817
+ return /* @__PURE__ */ jsx(Fragment, { children: chart.showAxisYTitle && /* @__PURE__ */ jsx(
1796
1818
  "text",
1797
1819
  {
1798
1820
  dx: props.dx,
@@ -1804,7 +1826,7 @@ const VerticalBars = ({
1804
1826
  y: props.y,
1805
1827
  children: newValue
1806
1828
  }
1807
- );
1829
+ ) });
1808
1830
  }
1809
1831
  }
1810
1832
  ),
@@ -1971,15 +1993,15 @@ function parseData(chart) {
1971
1993
  }
1972
1994
  const LineChart = ({
1973
1995
  chart,
1974
- margin = { top: 20, left: 100, bottom: 150, right: 70 },
1996
+ margin = { top: 20, left: 100, bottom: 24, right: 0 },
1975
1997
  chartId,
1976
1998
  allowZoom
1977
1999
  }) => {
1978
2000
  const effectiveMargin = parseMargin(margin);
1979
- if (!chart.showAxisYTitle) {
2001
+ if (!chart.showAxisYTitle && effectiveMargin.left > 50) {
1980
2002
  effectiveMargin.left = 50;
1981
2003
  }
1982
- let innerWidth = chart.ratio.width;
2004
+ let innerWidth = chart.ratio.width - (effectiveMargin.left + effectiveMargin.right) / 2;
1983
2005
  let innerHeight = chart.ratio.height - (effectiveMargin.top + effectiveMargin.bottom) / 2;
1984
2006
  if (innerWidth > chart.ratio.maxWidth) {
1985
2007
  const newValues = adjustDimensions$1({
@@ -2010,14 +2032,14 @@ const LineChart = ({
2010
2032
  const xScaleRange = useMemo(() => {
2011
2033
  const rangeArr = [
2012
2034
  typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.left,
2013
- innerWidth - effectiveMargin.left
2035
+ innerWidth
2014
2036
  ];
2015
2037
  return divideRangeBetweenStrings(rangeArr[0], rangeArr[1], longestLine);
2016
2038
  }, [effectiveMargin, innerWidth, longestLine]);
2017
2039
  xScale.range(xScaleRange);
2018
2040
  const yScaleRange = useMemo(() => {
2019
2041
  const rangeArr = [
2020
- innerHeight - (effectiveMargin.top + effectiveMargin.bottom) / 2,
2042
+ innerHeight - (effectiveMargin.top + effectiveMargin.bottom),
2021
2043
  typeof effectiveMargin === "number" ? effectiveMargin : effectiveMargin.top
2022
2044
  ];
2023
2045
  return rangeArr;
@@ -2234,7 +2256,7 @@ const LineChart = ({
2234
2256
  attachToElementAnchorPoint: "bottomRight"
2235
2257
  });
2236
2258
  } else {
2237
- new ApiaUtil().tooltips.close();
2259
+ new ApiaUtil().tooltips.closeAll();
2238
2260
  }
2239
2261
  } else if (nearNodes.length === 0) {
2240
2262
  setCurrentCircle([]);
@@ -2296,7 +2318,7 @@ const LineChart = ({
2296
2318
  (set) => set.columnName === column.name && set.key === coordinate.key
2297
2319
  )) == null ? void 0 : _a2.color;
2298
2320
  return /* @__PURE__ */ jsxs("g", { children: [
2299
- /* @__PURE__ */ jsx(
2321
+ chart.showValues && /* @__PURE__ */ jsx(
2300
2322
  "text",
2301
2323
  {
2302
2324
  x: xScale(getX(coordinate)) + 10,
@@ -2335,19 +2357,21 @@ const LineChart = ({
2335
2357
  {
2336
2358
  scale: actualYScale,
2337
2359
  left: effectiveMargin.left,
2338
- label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : ""
2360
+ label: chart.chartType !== "pie2D" && chart.showAxisYTitle ? chart.axisYTitle : "",
2361
+ tickLabelProps: {
2362
+ display: chart.showAxisYTitle ? "auto" : "none"
2363
+ }
2339
2364
  }
2340
2365
  ),
2341
2366
  /* @__PURE__ */ jsx(
2342
2367
  AxisBottom,
2343
2368
  {
2344
- top: innerHeight - (effectiveMargin.top + effectiveMargin.bottom) / 2,
2369
+ top: innerHeight - (effectiveMargin.top + effectiveMargin.bottom),
2345
2370
  scale: xScale,
2346
2371
  label: chart.chartType !== "pie2D" && chart.showAxisXTitle ? chart.axisXTitle : "",
2347
- tickLabelProps: {
2348
- className: "tickLabel"
2349
- },
2350
- labelOffset: 50
2372
+ tickLabelProps: { display: "none" },
2373
+ tickLineProps: { display: "none" },
2374
+ labelOffset: 10
2351
2375
  }
2352
2376
  )
2353
2377
  ]
@@ -2379,21 +2403,6 @@ const WaterfallBar = ({
2379
2403
  columnName,
2380
2404
  chart
2381
2405
  }) => {
2382
- const { open } = useTooltip({
2383
- children: /* @__PURE__ */ jsxs(Fragment, { children: [
2384
- /* @__PURE__ */ jsx(
2385
- "div",
2386
- {
2387
- style: {
2388
- color: step.color
2389
- },
2390
- children: /* @__PURE__ */ jsx("strong", { children: columnName })
2391
- }
2392
- ),
2393
- chart.showValues && /* @__PURE__ */ jsx("div", { children: step.y }),
2394
- /* @__PURE__ */ jsx("div", { children: step.x })
2395
- ] })
2396
- });
2397
2406
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2398
2407
  /* @__PURE__ */ jsx(
2399
2408
  Box,
@@ -2413,12 +2422,23 @@ const WaterfallBar = ({
2413
2422
  };
2414
2423
  }, [fill, height, width, x, y]),
2415
2424
  onMouseEnter: (ev) => {
2416
- open({
2425
+ new ApiaUtil().tooltips.open({
2426
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
2427
+ /* @__PURE__ */ jsx(
2428
+ "div",
2429
+ {
2430
+ style: {
2431
+ color: step.color
2432
+ },
2433
+ children: /* @__PURE__ */ jsx("strong", { children: columnName })
2434
+ }
2435
+ ),
2436
+ chart.showValues && /* @__PURE__ */ jsx("div", { children: step.y }),
2437
+ /* @__PURE__ */ jsx("div", { children: step.x })
2438
+ ] }),
2417
2439
  attachToElement: () => ev.target,
2418
2440
  attachToElementAnchorPoint: "center"
2419
2441
  });
2420
- },
2421
- onMouseLeave: () => {
2422
2442
  }
2423
2443
  }
2424
2444
  ),
@@ -2433,7 +2453,7 @@ const WaterfallBar = ({
2433
2453
  strokeDasharray: strokeDashArray
2434
2454
  }
2435
2455
  ),
2436
- /* @__PURE__ */ jsx("text", { textAnchor: "middle", x: textX, y: textY, children: textContent })
2456
+ chart.showValues && /* @__PURE__ */ jsx("text", { textAnchor: "middle", x: textX, y: textY, children: textContent })
2437
2457
  ] });
2438
2458
  };
2439
2459
 
@@ -2532,8 +2552,9 @@ const WaterfallBars = (_a) => {
2532
2552
  allowZoom
2533
2553
  } = _b;
2534
2554
  var _a2;
2555
+ console.log({ margin });
2535
2556
  const effectiveMargin = parseMargin(margin);
2536
- if (!chart.showAxisYTitle) {
2557
+ if (!chart.showAxisYTitle && effectiveMargin.left > 50) {
2537
2558
  effectiveMargin.left = 50;
2538
2559
  }
2539
2560
  let innerWidth = chart.ratio.width + (-effectiveMargin.left - effectiveMargin.right) / 2;
@@ -2668,11 +2689,11 @@ const WaterfallBars = (_a) => {
2668
2689
  {
2669
2690
  label: "",
2670
2691
  scale: yScale,
2671
- hideAxisLine: true,
2672
2692
  hideTicks: true,
2673
2693
  tickLabelProps: () => ({
2674
2694
  textAnchor: "end",
2675
- verticalAnchor: "middle"
2695
+ verticalAnchor: "middle",
2696
+ display: chart.showAxisYTitle ? "auto" : "none"
2676
2697
  })
2677
2698
  }
2678
2699
  ),
@@ -2681,11 +2702,8 @@ const WaterfallBars = (_a) => {
2681
2702
  {
2682
2703
  scale: xScale,
2683
2704
  top: innerHeight,
2684
- tickLabelProps: () => ({
2685
- textAnchor: "middle",
2686
- verticalAnchor: "middle",
2687
- className: "tickLabel"
2688
- })
2705
+ tickLabelProps: { display: "none" },
2706
+ tickLineProps: { display: "none" }
2689
2707
  }
2690
2708
  )
2691
2709
  ] })
@@ -3348,11 +3366,9 @@ const TLight = ({
3348
3366
  }
3349
3367
  const pathBox = pathElement.getBoundingClientRect();
3350
3368
  const svgBox = svgElement.getBoundingClientRect();
3351
- const pathWidth = pathBox.width;
3352
- const pathHeight = pathBox.height;
3353
3369
  const pathX = pathBox.x - svgBox.x;
3354
3370
  const pathY = pathBox.y - svgBox.y;
3355
- const viewBox = `${pathX - diameter / 2} ${pathY - diameter / 2} ${pathWidth} ${pathHeight}`;
3371
+ const viewBox = `${pathX - diameter / 2} ${pathY - diameter / 2} ${diameter} ${diameter}`;
3356
3372
  svgElement.setAttribute("viewBox", viewBox);
3357
3373
  svgElement.style.visibility = "visible";
3358
3374
  },