smart-labels 0.0.7 → 0.0.9
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/README.md +5 -3
- package/package.json +1 -1
- package/src/index.js +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
package/src/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export default function smartLabels(
|
|
|
28
28
|
height = null,
|
|
29
29
|
target = null, // Where do you want it to draw
|
|
30
30
|
renderer = "svg", // canvas or svg
|
|
31
|
-
font = () => "
|
|
31
|
+
font = () => "10px sans-serif",
|
|
32
32
|
hover = true, // Show label of the hovered point
|
|
33
33
|
onHover = (i) => i, // callback when hovered, will pass the index of the selected element
|
|
34
34
|
hoverFont = () => "bolder 12px sans-serif",
|