@opendata-ai/openchart-vanilla 2.3.0 → 2.3.1

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
@@ -252,7 +252,7 @@ var GraphCanvasRenderer = class {
252
252
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
253
253
  const padding = theme.spacing.padding;
254
254
  const x = w - padding;
255
- const y = h - 4;
255
+ const y = h - padding;
256
256
  ctx.font = `600 20px ${theme.fonts.family}`;
257
257
  ctx.fillStyle = theme.colors.axis;
258
258
  ctx.globalAlpha = 0.5;
@@ -558,9 +558,14 @@ var GraphCanvasRenderer = class {
558
558
  if (!forced && node.labelPriority < threshold) continue;
559
559
  ctx.globalAlpha = dimmed ? SEARCH_NON_MATCH_ALPHA : 1;
560
560
  const labelY = node.y + node.radius + 3;
561
- ctx.strokeStyle = theme.colors.background === "transparent" ? "rgba(0, 0, 0, 0.7)" : theme.colors.background;
561
+ if (theme.colors.background !== "transparent") {
562
+ ctx.strokeStyle = theme.colors.background;
563
+ } else {
564
+ ctx.strokeStyle = isLightColor(theme.colors.text) ? "rgba(0, 0, 0, 0.7)" : "rgba(255, 255, 255, 0.85)";
565
+ }
562
566
  ctx.lineWidth = 3;
563
567
  ctx.lineJoin = "round";
568
+ ctx.miterLimit = 2;
564
569
  ctx.strokeText(node.label, node.x, labelY);
565
570
  ctx.fillStyle = theme.colors.text;
566
571
  ctx.fillText(node.label, node.x, labelY);
@@ -586,6 +591,16 @@ function brighten(color) {
586
591
  }
587
592
  return color;
588
593
  }
594
+ function isLightColor(color) {
595
+ const hex = color.replace("#", "");
596
+ const full = hex.length === 3 ? hex.split("").map((c) => c + c).join("") : hex;
597
+ if (full.length !== 6) return false;
598
+ const r = parseInt(full.slice(0, 2), 16) / 255;
599
+ const g = parseInt(full.slice(2, 4), 16) / 255;
600
+ const b = parseInt(full.slice(4, 6), 16) / 255;
601
+ const toLinear = (c) => c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
602
+ return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b) > 0.5;
603
+ }
589
604
 
590
605
  // src/graph/zoom.ts
591
606
  var ZoomTransform = class _ZoomTransform {