smart-labels 0.0.7 → 0.0.8

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.
Files changed (2) hide show
  1. package/README.md +5 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -33,9 +33,9 @@ Receives the data, accessors for the x and y coordinates as well as the label. E
33
33
  y = (d) => d[1], // y coordinate accessor, expected to be in pixels
34
34
  r = () => 3, // radius accessor, expected to be in pixels
35
35
  label = (d, i) => i, // Accessor for the label
36
+ renderer = "svg", // canvas or svg
36
37
  fill = "#333", // label fill color
37
38
  stroke = "white", // label stroke color
38
- threshold = 2000, // Areas over this size would get labels
39
39
  width = null,
40
40
  height = null,
41
41
  target = null, // Where do you want it to draw
@@ -44,7 +44,9 @@ Receives the data, accessors for the x and y coordinates as well as the label. E
44
44
  onHover = (i) => i, // callback when hovered, will pass the index of the selected element
45
45
  hoverFont = "bolder 12px sans-serif",
46
46
  labelsInCentroids = true,
47
-
47
+ threshold = 2000, // Areas over this size would get labels
48
+ alwaysShow = (d) => false, // If returns true for the node, it will always show the label
49
+ showLabel = (d, cell) => alwaysShow(d) || -d3.polygonArea(cell) > threshold, // If true, show the label
48
50
  backgroundFill = "#fefefe01", // What to paint the bg rect of the labels. Needed for the onHover
49
51
  strokeWidth = 5,
50
52
 
@@ -63,10 +65,10 @@ Receives the data, accessors for the x and y coordinates as well as the label. E
63
65
  pointsFill = "#ccc",
64
66
  pointsSelectedFill = "firebrick",
65
67
  pointsStroke = "#ccc",
66
- renderer = "svg",
67
68
  debug = false,
68
69
  selected = null,
69
70
  padding = 3, // label padding in pixels
71
+
70
72
  }
71
73
  ```
72
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-labels",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "A basic library for adding labels to a visualization when there is enough space",
5
5
  "type": "module",
6
6
  "main": "dist/smartLabels.min.js",