@d3plus/docs 3.0.0-alpha.3

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 (225) hide show
  1. package/.storybook/main.js +51 -0
  2. package/.storybook/manager-head.html +46 -0
  3. package/.storybook/manager.js +10 -0
  4. package/.storybook/preview-head.html +69 -0
  5. package/.storybook/preview.jsx +134 -0
  6. package/.storybook/theme.js +16 -0
  7. package/README.md +1 -0
  8. package/args/color/colorAdd.args.jsx +71 -0
  9. package/args/color/colorAssign.args.jsx +40 -0
  10. package/args/color/colorContrast.args.jsx +40 -0
  11. package/args/color/colorDefaults.args.jsx +8 -0
  12. package/args/color/colorLegible.args.jsx +24 -0
  13. package/args/color/colorLighter.args.jsx +40 -0
  14. package/args/color/colorSubtract.args.jsx +71 -0
  15. package/args/core/charts/AreaPlot.args.jsx +72 -0
  16. package/args/core/charts/BarChart.args.jsx +88 -0
  17. package/args/core/charts/BoxWhisker.args.jsx +73 -0
  18. package/args/core/charts/BumpChart.args.jsx +133 -0
  19. package/args/core/charts/Donut.args.jsx +58 -0
  20. package/args/core/charts/Geomap.args.jsx +363 -0
  21. package/args/core/charts/LinePlot.args.jsx +57 -0
  22. package/args/core/charts/Matrix.args.jsx +194 -0
  23. package/args/core/charts/Network.args.jsx +310 -0
  24. package/args/core/charts/Pack.args.jsx +171 -0
  25. package/args/core/charts/Pie.args.jsx +148 -0
  26. package/args/core/charts/Plot.args.jsx +685 -0
  27. package/args/core/charts/Priestley.args.jsx +118 -0
  28. package/args/core/charts/Radar.args.jsx +120 -0
  29. package/args/core/charts/RadialMatrix.args.jsx +197 -0
  30. package/args/core/charts/Rings.args.jsx +228 -0
  31. package/args/core/charts/Sankey.args.jsx +248 -0
  32. package/args/core/charts/StackedArea.args.jsx +26 -0
  33. package/args/core/charts/Tree.args.jsx +88 -0
  34. package/args/core/charts/Treemap.args.jsx +181 -0
  35. package/args/core/charts/Viz.args.jsx +1383 -0
  36. package/args/core/components/Axis.args.jsx +600 -0
  37. package/args/core/components/AxisBottom.args.jsx +42 -0
  38. package/args/core/components/AxisLeft.args.jsx +42 -0
  39. package/args/core/components/AxisRight.args.jsx +42 -0
  40. package/args/core/components/AxisTop.args.jsx +42 -0
  41. package/args/core/components/ColorScale.args.jsx +456 -0
  42. package/args/core/components/Legend.args.jsx +289 -0
  43. package/args/core/components/TextBox.args.jsx +554 -0
  44. package/args/core/components/Timeline.args.jsx +401 -0
  45. package/args/core/components/Tooltip.args.jsx +453 -0
  46. package/args/core/shapes/Area.args.jsx +190 -0
  47. package/args/core/shapes/Bar.args.jsx +176 -0
  48. package/args/core/shapes/Box.args.jsx +248 -0
  49. package/args/core/shapes/Circle.args.jsx +84 -0
  50. package/args/core/shapes/Image.args.jsx +177 -0
  51. package/args/core/shapes/Line.args.jsx +127 -0
  52. package/args/core/shapes/Path.args.jsx +84 -0
  53. package/args/core/shapes/Rect.args.jsx +85 -0
  54. package/args/core/shapes/Shape.args.jsx +633 -0
  55. package/args/core/shapes/Whisker.args.jsx +204 -0
  56. package/args/core/utils/BaseClass.args.jsx +65 -0
  57. package/args/core/utils/RESET.args.jsx +8 -0
  58. package/args/core/utils/accessor.args.jsx +39 -0
  59. package/args/core/utils/configPrep.args.jsx +56 -0
  60. package/args/core/utils/constant.args.jsx +24 -0
  61. package/args/core/utils/uuid.args.jsx +8 -0
  62. package/args/data/dataConcat.args.jsx +40 -0
  63. package/args/data/dataFold.args.jsx +56 -0
  64. package/args/data/dataLoad.args.jsx +65 -0
  65. package/args/data/isData.args.jsx +24 -0
  66. package/args/data/merge.args.jsx +39 -0
  67. package/args/data/unique.args.jsx +37 -0
  68. package/args/dom/assign.args.jsx +23 -0
  69. package/args/dom/attrize.args.jsx +39 -0
  70. package/args/dom/date.args.jsx +23 -0
  71. package/args/dom/elem.args.jsx +135 -0
  72. package/args/dom/fontExists.args.jsx +24 -0
  73. package/args/dom/htmlDecode.args.jsx +23 -0
  74. package/args/dom/isObject.args.jsx +23 -0
  75. package/args/dom/parseSides.args.jsx +24 -0
  76. package/args/dom/prefix.args.jsx +8 -0
  77. package/args/dom/rtl.args.jsx +8 -0
  78. package/args/dom/stylize.args.jsx +39 -0
  79. package/args/dom/textWidth.args.jsx +39 -0
  80. package/args/export/saveElement.args.jsx +99 -0
  81. package/args/format/format.args.jsx +24 -0
  82. package/args/format/formatAbbreviate.args.jsx +39 -0
  83. package/args/format/formatDate.args.jsx +53 -0
  84. package/args/format/formatDefaultLocale.args.jsx +24 -0
  85. package/args/locales/dictionaries/formatLocale.args.jsx +8 -0
  86. package/args/math/closest.args.jsx +39 -0
  87. package/args/math/largestRect.args.jsx +56 -0
  88. package/args/math/lineIntersection.args.jsx +69 -0
  89. package/args/math/path2polygon.args.jsx +40 -0
  90. package/args/math/pointDistance.args.jsx +39 -0
  91. package/args/math/pointDistanceSquared.args.jsx +39 -0
  92. package/args/math/pointRotate.args.jsx +55 -0
  93. package/args/math/polygonInside.args.jsx +39 -0
  94. package/args/math/polygonRayCast.args.jsx +55 -0
  95. package/args/math/polygonRotate.args.jsx +55 -0
  96. package/args/math/segmentBoxContains.args.jsx +54 -0
  97. package/args/math/segmentsIntersect.args.jsx +69 -0
  98. package/args/math/shapeEdgePoint.args.jsx +39 -0
  99. package/args/react/D3plusContext.args.jsx +8 -0
  100. package/args/react/Renderer.args.jsx +53 -0
  101. package/args/text/fontFamily.args.jsx +8 -0
  102. package/args/text/fontFamilyStringify.args.jsx +23 -0
  103. package/args/text/stringify.args.jsx +23 -0
  104. package/args/text/strip.args.jsx +38 -0
  105. package/args/text/textSplit.args.jsx +23 -0
  106. package/args/text/textWrap.args.jsx +8 -0
  107. package/args/text/titleCase.args.jsx +24 -0
  108. package/args/text/trim.args.jsx +23 -0
  109. package/args/text/trimLeft.args.jsx +23 -0
  110. package/args/text/trimRight.args.jsx +23 -0
  111. package/docs/Accessibility.mdx +70 -0
  112. package/docs/HomeChart.jsx +38 -0
  113. package/docs/Introduction.mdx +130 -0
  114. package/docs/Logo-Frames.js +352 -0
  115. package/docs/Logo.jsx +30 -0
  116. package/helpers/configify.js +18 -0
  117. package/helpers/funcify.js +14 -0
  118. package/helpers/stringify.js +30 -0
  119. package/package.json +44 -0
  120. package/packages/color/colorAdd.stories.jsx +23 -0
  121. package/packages/color/colorAssign.stories.jsx +23 -0
  122. package/packages/color/colorContrast.stories.jsx +23 -0
  123. package/packages/color/colorDefaults.stories.jsx +23 -0
  124. package/packages/color/colorLegible.stories.jsx +23 -0
  125. package/packages/color/colorLighter.stories.jsx +23 -0
  126. package/packages/color/colorSubtract.stories.jsx +23 -0
  127. package/packages/core/charts/AreaPlot.stories.jsx +74 -0
  128. package/packages/core/charts/BarChart.stories.jsx +307 -0
  129. package/packages/core/charts/BoxWhisker.stories.jsx +204 -0
  130. package/packages/core/charts/BumpChart.stories.jsx +52 -0
  131. package/packages/core/charts/Donut.stories.jsx +41 -0
  132. package/packages/core/charts/Geomap.stories.jsx +186 -0
  133. package/packages/core/charts/LinePlot.stories.jsx +564 -0
  134. package/packages/core/charts/Matrix.stories.jsx +36 -0
  135. package/packages/core/charts/Network.stories.jsx +99 -0
  136. package/packages/core/charts/Pack.stories.jsx +40 -0
  137. package/packages/core/charts/Pie.stories.jsx +40 -0
  138. package/packages/core/charts/Plot.stories.jsx +180 -0
  139. package/packages/core/charts/Priestley.stories.jsx +60 -0
  140. package/packages/core/charts/Radar.stories.jsx +60 -0
  141. package/packages/core/charts/RadialMatrix.stories.jsx +36 -0
  142. package/packages/core/charts/Rings.stories.jsx +41 -0
  143. package/packages/core/charts/Sankey.stories.jsx +41 -0
  144. package/packages/core/charts/StackedArea.stories.jsx +107 -0
  145. package/packages/core/charts/Tree.stories.jsx +27 -0
  146. package/packages/core/charts/Treemap.stories.jsx +81 -0
  147. package/packages/core/charts/Viz.stories.jsx +27 -0
  148. package/packages/core/components/Axis.stories.jsx +27 -0
  149. package/packages/core/components/AxisBottom.stories.jsx +27 -0
  150. package/packages/core/components/AxisLeft.stories.jsx +27 -0
  151. package/packages/core/components/AxisRight.stories.jsx +27 -0
  152. package/packages/core/components/AxisTop.stories.jsx +27 -0
  153. package/packages/core/components/ColorScale.stories.jsx +44 -0
  154. package/packages/core/components/Legend.stories.jsx +49 -0
  155. package/packages/core/components/TextBox.stories.jsx +222 -0
  156. package/packages/core/components/Timeline.stories.jsx +37 -0
  157. package/packages/core/components/Tooltip.stories.jsx +40 -0
  158. package/packages/core/shapes/Area.stories.jsx +27 -0
  159. package/packages/core/shapes/Bar.stories.jsx +27 -0
  160. package/packages/core/shapes/Box.stories.jsx +27 -0
  161. package/packages/core/shapes/Circle.stories.jsx +27 -0
  162. package/packages/core/shapes/Image.stories.jsx +27 -0
  163. package/packages/core/shapes/Line.stories.jsx +27 -0
  164. package/packages/core/shapes/Path.stories.jsx +27 -0
  165. package/packages/core/shapes/Rect.stories.jsx +27 -0
  166. package/packages/core/shapes/Shape.stories.jsx +27 -0
  167. package/packages/core/shapes/Whisker.stories.jsx +27 -0
  168. package/packages/core/utils/BaseClass.stories.jsx +27 -0
  169. package/packages/core/utils/RESET.stories.jsx +23 -0
  170. package/packages/core/utils/accessor.stories.jsx +23 -0
  171. package/packages/core/utils/configPrep.stories.jsx +23 -0
  172. package/packages/core/utils/constant.stories.jsx +23 -0
  173. package/packages/core/utils/uuid.stories.jsx +23 -0
  174. package/packages/data/dataConcat.stories.jsx +23 -0
  175. package/packages/data/dataFold.stories.jsx +23 -0
  176. package/packages/data/dataLoad.stories.jsx +23 -0
  177. package/packages/data/isData.stories.jsx +23 -0
  178. package/packages/data/merge.stories.jsx +23 -0
  179. package/packages/data/unique.stories.jsx +23 -0
  180. package/packages/dom/assign.stories.jsx +23 -0
  181. package/packages/dom/attrize.stories.jsx +23 -0
  182. package/packages/dom/date.stories.jsx +23 -0
  183. package/packages/dom/elem.stories.jsx +23 -0
  184. package/packages/dom/fontExists.stories.jsx +23 -0
  185. package/packages/dom/htmlDecode.stories.jsx +23 -0
  186. package/packages/dom/isObject.stories.jsx +23 -0
  187. package/packages/dom/parseSides.stories.jsx +23 -0
  188. package/packages/dom/prefix.stories.jsx +23 -0
  189. package/packages/dom/rtl.stories.jsx +23 -0
  190. package/packages/dom/stylize.stories.jsx +23 -0
  191. package/packages/dom/textWidth.stories.jsx +23 -0
  192. package/packages/export/saveElement.stories.jsx +23 -0
  193. package/packages/format/format.stories.jsx +23 -0
  194. package/packages/format/formatAbbreviate.stories.jsx +23 -0
  195. package/packages/format/formatDate.stories.jsx +23 -0
  196. package/packages/format/formatDefaultLocale.stories.jsx +23 -0
  197. package/packages/locales/dictionaries/formatLocale.stories.jsx +23 -0
  198. package/packages/math/closest.stories.jsx +23 -0
  199. package/packages/math/largestRect.stories.jsx +23 -0
  200. package/packages/math/lineIntersection.stories.jsx +23 -0
  201. package/packages/math/path2polygon.stories.jsx +23 -0
  202. package/packages/math/pointDistance.stories.jsx +23 -0
  203. package/packages/math/pointDistanceSquared.stories.jsx +23 -0
  204. package/packages/math/pointRotate.stories.jsx +23 -0
  205. package/packages/math/polygonInside.stories.jsx +23 -0
  206. package/packages/math/polygonRayCast.stories.jsx +23 -0
  207. package/packages/math/polygonRotate.stories.jsx +23 -0
  208. package/packages/math/segmentBoxContains.stories.jsx +23 -0
  209. package/packages/math/segmentsIntersect.stories.jsx +23 -0
  210. package/packages/math/shapeEdgePoint.stories.jsx +23 -0
  211. package/packages/react/D3plusContext.stories.jsx +23 -0
  212. package/packages/react/Renderer.stories.jsx +23 -0
  213. package/packages/text/fontFamily.stories.jsx +23 -0
  214. package/packages/text/fontFamilyStringify.stories.jsx +23 -0
  215. package/packages/text/stringify.stories.jsx +23 -0
  216. package/packages/text/strip.stories.jsx +23 -0
  217. package/packages/text/textSplit.stories.jsx +23 -0
  218. package/packages/text/textWrap.stories.jsx +23 -0
  219. package/packages/text/titleCase.stories.jsx +23 -0
  220. package/packages/text/trim.stories.jsx +23 -0
  221. package/packages/text/trimLeft.stories.jsx +23 -0
  222. package/packages/text/trimRight.stories.jsx +23 -0
  223. package/static/data/city_coords.json +224 -0
  224. package/static/images/favicon.ico +0 -0
  225. package/static/images/touchicon.png +0 -0
@@ -0,0 +1,352 @@
1
+ import {colorDefaults, colorLegible} from "@d3plus/color";
2
+ const darkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
3
+ const background = darkMode ? "#1B1C1D" : "white";
4
+ const tickColor = darkMode ? "#dee2e6" : "#495057";
5
+ const gridColor = darkMode ? "#495057" : "#dee2e6";
6
+ const colors = colorDefaults.scale.range();
7
+ const dColor = colors[0];
8
+ const dAccent = colorLegible(dColor);
9
+ const threeColor = colors[1];
10
+ const threeAccent = colorLegible(threeColor);
11
+ const plusColor = colors[2];
12
+
13
+ const height = 200;
14
+ const yAxisOffset = 35;
15
+ const xAxisOffset = 46;
16
+ const ySquares = 12;
17
+ const xSquares = 30;
18
+ const middle = ySquares / 2;
19
+ const cellSize = (height - xAxisOffset) / ySquares;
20
+ const width = cellSize * xSquares + yAxisOffset;
21
+ const barSpacing = Math.ceil(xSquares / 5);
22
+
23
+ const stemCenter = 2;
24
+ const arcCenter = stemCenter + 3.5;
25
+ const threeCenter = arcCenter + 10;
26
+ const plusCenter = threeCenter + 8;
27
+ const plusSize = ySquares / 4;
28
+
29
+ export const sharedConfig = {
30
+ height,
31
+ noDataMessage: false,
32
+ width,
33
+ xDomain: [0, xSquares],
34
+ yDomain: [0, ySquares]
35
+ };
36
+
37
+ const hiddenAxis = {
38
+ barConfig: {
39
+ opacity: 0,
40
+ stroke: tickColor
41
+ },
42
+ gridConfig: {
43
+ opacity: 0,
44
+ stroke: gridColor
45
+ },
46
+ shapeConfig: {
47
+ fill: tickColor,
48
+ opacity: 0,
49
+ labelConfig: {
50
+ fontColor: tickColor
51
+ },
52
+ stroke: tickColor
53
+ }
54
+ }
55
+
56
+ const visibleAxis = {
57
+ barConfig: {
58
+ opacity: 1,
59
+ stroke: tickColor
60
+ },
61
+ gridConfig: {
62
+ opacity: 1,
63
+ stroke: gridColor
64
+ },
65
+ shapeConfig: {
66
+ fill: tickColor,
67
+ duration: 250,
68
+ opacity: 1,
69
+ labelConfig: {
70
+ fontColor: tickColor
71
+ },
72
+ stroke: tickColor
73
+ }
74
+ }
75
+
76
+ const dCircles = [
77
+ {id: "curve", r: cellSize * 5, x: arcCenter, y: middle, fill: dColor},
78
+ {id: "curve-mask", r: cellSize * 3, x: arcCenter, y: middle, fill: background}
79
+ ];
80
+
81
+ const threeLabelConfig = {
82
+ fontMax: cellSize * ySquares * 2,
83
+ fontResize: true,
84
+ fontWeight: 700,
85
+ lineHeight: ySquares + 0.6,
86
+ textAnchor: "middle",
87
+ verticalAlign: "middle"
88
+ };
89
+
90
+ const plusLines = [
91
+ {shape: "Line", id: "plus-horizontal", x: plusCenter - plusSize, y: middle, fill: plusColor},
92
+ {shape: "Line", id: "plus-horizontal", x: plusCenter + plusSize, y: middle, fill: plusColor},
93
+ {shape: "Line", id: "plus-vertical", x: plusCenter, y: middle + plusSize, fill: plusColor},
94
+ {shape: "Line", id: "plus-vertical", x: plusCenter, y: middle - plusSize, fill: plusColor}
95
+ ];
96
+
97
+ function randomY(x) { // min and max included
98
+ const clamp = x / xSquares;
99
+ const max = (ySquares - 1) * clamp;
100
+ return Math.random() * (max - 1 + 1) + 1;
101
+ }
102
+
103
+ const createLines = id => Array.from({length: xSquares}, (_, index) => ({id, x: index, y: randomY(index)}));
104
+
105
+ const iconCenter = threeCenter;
106
+ const iconDCenter = iconCenter - 2;
107
+ const iconThreeCenter = iconCenter + 2;
108
+ export const icon = {
109
+ annotations: [
110
+
111
+ {
112
+ data: dCircles
113
+ .filter(d => !d.id.includes("mask"))
114
+ .map(d => {
115
+ const copy = {...d, x: d.x + (iconDCenter - arcCenter)};
116
+ return copy;
117
+ }),
118
+ fill: d => d.fill,
119
+ shape: "Circle",
120
+ strokeWidth: 0
121
+ },
122
+
123
+ {
124
+ data: [
125
+ {id: "curve-mask", height: cellSize * 11, width: cellSize * 5.2, x: iconDCenter - 2.65, y: middle, fill: background},
126
+ {id: "ascender", height: cellSize * 10, width: cellSize * 3, x: iconDCenter - 1.5, y: middle, fill: dColor},
127
+ // {id: "ascender-mask", height: cellSize * 6, width: cellSize * 1, x: iconDCenter - 0.45, y: middle, fill: background},
128
+ {id: "3", height: cellSize * 36, width: cellSize * 9, x: iconThreeCenter, y: middle, fill: "transparent"},
129
+ ],
130
+ fill: d => d.fill,
131
+ label: d => d.id === "3" ? 3 : false,
132
+ labelConfig: {
133
+ ...threeLabelConfig,
134
+ fontColor: dColor
135
+ },
136
+ padding: 0,
137
+ shape: "Rect",
138
+ strokeWidth: 0
139
+ },
140
+ {
141
+ data: plusLines.map(d => {
142
+ const copy = {...d, x: d.x - (plusCenter - iconCenter)};
143
+ return copy;
144
+ }),
145
+ shape: "Line",
146
+ stroke: background,
147
+ strokeWidth: cellSize * 1.5
148
+ }
149
+ ],
150
+ xConfig: hiddenAxis,
151
+ yConfig: hiddenAxis
152
+ };
153
+
154
+ export const animationFrames = [
155
+ {
156
+ annotations: [
157
+
158
+ {
159
+ data: dCircles,
160
+ fill: d => d.fill,
161
+ shape: "Circle",
162
+ strokeWidth: 0
163
+ },
164
+
165
+ {
166
+ data: [
167
+ {id: "curve-mask", height: cellSize * 11, width: cellSize * 5.2, x: arcCenter - 2.65, y: middle, fill: background},
168
+ {id: "ascender", height: cellSize * 10, width: cellSize * 3, x: arcCenter - 1.5, y: middle, fill: dColor},
169
+ {id: "ascender-mask", height: cellSize * 6, width: cellSize * 1, x: arcCenter - 0.45, y: middle, fill: background},
170
+ {id: "3", height: cellSize * 36, width: cellSize * 9, x: threeCenter, y: middle, fill: "transparent"},
171
+ ],
172
+ fill: d => d.fill,
173
+ label: d => d.id === "3" ? 3 : false,
174
+ labelConfig: {
175
+ ...threeLabelConfig,
176
+ fontColor: threeColor
177
+ },
178
+ padding: 0,
179
+ shape: "Rect",
180
+ strokeWidth: 0
181
+ },
182
+ {
183
+ data: plusLines,
184
+ shape: "Line",
185
+ stroke: plusColor,
186
+ strokeWidth: cellSize * 1.5
187
+ }
188
+ ],
189
+ xConfig: hiddenAxis,
190
+ yConfig: hiddenAxis
191
+ },
192
+
193
+
194
+
195
+
196
+ {
197
+ annotations: [
198
+
199
+ {
200
+ data: dCircles,
201
+ fill: "transparent",
202
+ shape: "Circle",
203
+ stroke: dColor,
204
+ strokeDasharray: d => d.id.includes("mask") ? "4 1" : false,
205
+ strokeWidth: 2
206
+ },
207
+
208
+ {
209
+ data: [
210
+ {id: "curve-mask", height: cellSize * 8, width: cellSize * 5.2, x: arcCenter, y: middle},
211
+ {id: "ascender", height: cellSize * 6, width: cellSize * 3, x: arcCenter, y: middle},
212
+ {id: "ascender-mask", height: cellSize * 4, width: cellSize * 1, x: arcCenter, y: middle},
213
+ {id: "3", height: (cellSize - 4) * ySquares, width: cellSize * 8, x: threeCenter + 1, y: middle},
214
+ ],
215
+ fill: d => d.id === "3" ? threeColor : "transparent",
216
+ label: d => d.id === "3" ? 3 : false,
217
+ labelConfig: {
218
+ ...threeLabelConfig,
219
+ fontColor: colorDefaults.light,
220
+ fontStroke: threeAccent,
221
+ fontStrokeWidth: 2
222
+ },
223
+ shape: "Rect",
224
+ stroke: d => d.id === "3" ? threeAccent : dColor,
225
+ strokeDasharray: d => d.id.includes("mask") ? "4 1" : false,
226
+ strokeWidth: 2,
227
+ },
228
+ {
229
+ data: plusLines
230
+ .map(d => {
231
+ const copy = {...d, x: d.x + 2};
232
+ return copy;
233
+ }),
234
+ shape: "Line",
235
+ stroke: plusColor,
236
+ strokeWidth: cellSize / 2
237
+ }
238
+ ],
239
+ xConfig: visibleAxis,
240
+ yConfig: visibleAxis
241
+ },
242
+
243
+
244
+
245
+
246
+ {
247
+ annotations: [
248
+
249
+ {
250
+ data: [
251
+ {id: "curve", r: cellSize, x: 17, y: 10},
252
+ {id: "curve-mask", r: cellSize * 0.75, x: 5, y: 7}
253
+ ],
254
+ fill: dColor,
255
+ shape: "Circle"
256
+ },
257
+
258
+ {
259
+ data: [
260
+ {id: "curve-mask", width: cellSize * 2, height: cellSize * 2, x: barSpacing * 1, y: 1},
261
+ {id: "ascender", width: cellSize * 2, height: cellSize * 5, x: barSpacing * 2, y: 2.5},
262
+ {id: "ascender-mask", width: cellSize * 2, height: cellSize * 3, x: barSpacing * 3, y: 1.5},
263
+ {id: "3", width: cellSize * 2, height: cellSize * 8, x: barSpacing * 4, y: 4},
264
+ ],
265
+ fill: threeColor,
266
+ label: false,
267
+ labelConfig: threeLabelConfig,
268
+ shape: "Rect",
269
+ stroke: threeAccent,
270
+ strokeWidth: 2,
271
+ texture: "nylon",
272
+ textureDefault: {size: cellSize / 2, background: threeColor, stroke: threeAccent, strokeWidth: 1},
273
+ },
274
+ {
275
+ data: [
276
+ ...createLines("plus-horizontal"),
277
+ ...createLines("plus-vertical")
278
+ ],
279
+ shape: "Line",
280
+ stroke: plusColor,
281
+ strokeDasharray: d => d.id.includes("horizontal") ? "10 2" : false,
282
+ strokeWidth: 2
283
+ }
284
+ ]
285
+ },
286
+ {
287
+ annotations: [
288
+
289
+ {
290
+ data: dCircles,
291
+ fill: d => d.fill,
292
+ shape: "Circle",
293
+ strokeWidth: 0
294
+ },
295
+
296
+ {
297
+ data: [
298
+ {id: "curve-mask", height: cellSize * 11, width: cellSize * 5.2, x: arcCenter - 2.65, y: middle, fill: background},
299
+ {id: "ascender", height: cellSize * 10, width: cellSize * 3, x: arcCenter - 1.5, y: middle, fill: dColor},
300
+ {id: "ascender-mask", height: cellSize * 6, width: cellSize * 1, x: arcCenter - 0.45, y: middle, fill: background},
301
+ {id: "3", height: cellSize * 36, width: cellSize * 9, x: threeCenter, y: middle, fill: "transparent"},
302
+ ],
303
+ fill: d => d.fill,
304
+ label: d => d.id === "3" ? 3 : false,
305
+ labelConfig: {
306
+ ...threeLabelConfig,
307
+ fontColor: threeColor
308
+ },
309
+ padding: 0,
310
+ shape: "Rect",
311
+ strokeWidth: 0
312
+ },
313
+ {
314
+ data: plusLines,
315
+ shape: "Line",
316
+ stroke: plusColor,
317
+ strokeWidth: cellSize * 1.5
318
+ }
319
+ ],
320
+ xConfig: hiddenAxis,
321
+ yConfig: hiddenAxis
322
+ },
323
+
324
+
325
+
326
+
327
+ // {
328
+ // annotations: [],
329
+ // data: [
330
+ // {shape: "Circle", id: "curve", r: cellSize, x: 17, y: 10, fill: dColor},
331
+ // {shape: "Circle", id: "curve-mask", r: cellSize * 0.75, x: 5, y: 7, fill: dColor},
332
+ // // {shape: "Bar", id: "curve-mask", x: barSpacing * 1, y: 1, fill: threeColor},
333
+ // // {shape: "Bar", id: "ascender", x: barSpacing * 2, y: 2.5, fill: threeColor},
334
+ // // {shape: "Bar", id: "ascender-mask", x: barSpacing * 3, y: 1.5, fill: threeColor},
335
+ // // {shape: "Bar", id: "3", x: barSpacing * 4, y: 4, fill: threeColor},
336
+ // // ...createLines("plus-horizontal"),
337
+ // // ...createLines("plus-vertical")
338
+ // ],
339
+ // label: false,
340
+ // shape: d => d.shape,
341
+ // shapeConfig: {
342
+ // Circle: {
343
+ // r: d => d.r
344
+ // },
345
+ // fill: d => d.fill,
346
+ // strokeDasharray: d => d.id.includes("horizontal") ? "10 2" : false,
347
+ // strokeWidth: 2,
348
+ // texture: d => d.shape === "Bar" ? "nylon" : false,
349
+ // textureDefault: {size: cellSize / 2, background: threeColor, stroke: threeAccent, strokeWidth: 1},
350
+ // }
351
+ // }
352
+ ];
package/docs/Logo.jsx ADDED
@@ -0,0 +1,30 @@
1
+ import React, {useEffect, useRef, useState} from "react";
2
+ import {Plot} from "@d3plus/react";
3
+ import {sharedConfig, animationFrames} from "./Logo-Frames.js";
4
+
5
+ const duration = 3000;
6
+
7
+ const Logo = () => {
8
+
9
+ const [frame, setFrame] = useState(0);
10
+ const intervalRef = useRef(null);
11
+
12
+ useEffect(() => {
13
+ if (animationFrames.length > 1) {
14
+ intervalRef.current = setInterval(() => {
15
+ setFrame(prevFrame => prevFrame + 1);
16
+ }, duration);
17
+ }
18
+ return () => clearInterval(intervalRef.current);
19
+ }, []);
20
+
21
+ useEffect(() => {
22
+ if (frame >= animationFrames.length - 1) {
23
+ clearInterval(intervalRef.current);
24
+ }
25
+ }, [frame]);
26
+
27
+ return frame >= 0 ? <Plot className="d3plus-logo" config={{...sharedConfig, ...animationFrames[frame]}} /> : null;
28
+ };
29
+
30
+ export default Logo;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * removes undefined config keys, which may cause issues with d3plus
3
+ * and also pollute the "Code" view in Docs
4
+ */
5
+ export default function(args, argTypes) {
6
+ return Object.keys(args).reduce((acc, key) => {
7
+ const _acc = acc;
8
+ if (
9
+ args[key] !== undefined && argTypes[key] !== undefined &&
10
+ (argTypes[key].defaultValue === undefined ||
11
+ typeof argTypes[key].defaultValue === "function"
12
+ ? argTypes[key].defaultValue !== args[key]
13
+ : JSON.stringify(argTypes[key].defaultValue) !== JSON.stringify(args[key])
14
+ )
15
+ ) _acc[key] = args[key];
16
+ return _acc;
17
+ }, {});
18
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * allows overwriting the default toString method of a function
3
+ * in order for pretty doc printouts
4
+ */
5
+ export default function(fn, str) {
6
+
7
+ /** A toString to render the function in storybook */
8
+ // eslint-disable-next-line no-param-reassign
9
+ fn.toString = () => str;
10
+ fn.toJSON = () => str;
11
+
12
+ return fn;
13
+
14
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * converts d3plus config to pretty string output
3
+ */
4
+ export default function(config, indent = 2) {
5
+
6
+ return JSON.stringify(config, replacer, indent)
7
+ // "data" cleanup
8
+ .replace(/\"(\{[^\}]+\})\"/g, "$1")
9
+ .replace(/\\"([A-z0-9]+)\\"\:/g, "$1:")
10
+ .replace(/([^\s]):([^\s^\/])/g, "$1: $2")
11
+ .replace(/([^\s]),([^\s])/g, "$1, $2")
12
+ .replace(/\[([^\]^\{]+)\]/g, str => str.replace(/ /gm, "").replace(/\n/gm, " "))
13
+
14
+ // remove parentheses from keys
15
+ .replace(/\"([A-z0-9]+)\"\:/g, "$1:")
16
+
17
+ // cleans up funcitons
18
+ .replace(/\"([^=].+=)> ([^\"].+)\"/g, "$1> $2")
19
+ .replace(/\:\s\"function\(([^\"].+)\"/g, "($1")
20
+ .replace(/\\n/g, "\n")
21
+ .replace(/\\"/g, "\"");
22
+
23
+ }
24
+
25
+ const replacer = (key, value) => {
26
+ if (!["annotations"].includes(key) && value instanceof Array && typeof value[0] === "object") {
27
+ return value.map(d => JSON.stringify(d));
28
+ }
29
+ return value;
30
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@d3plus/docs",
3
+ "version": "3.0.0-alpha.3",
4
+ "description": "Documentation and examples for the d3plus visualization library.",
5
+ "license": "MIT",
6
+ "homepage": "https://d3plus.org",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/d3plus/d3plus.git",
10
+ "directory": "packages/docs"
11
+ },
12
+ "keywords": [],
13
+ "scripts": {
14
+ "build": "storybook build --docs -o build",
15
+ "dev": "node ../../scripts/dev.js"
16
+ },
17
+ "dependencies": {
18
+ "@d3plus/core": "3.0.0-alpha.3",
19
+ "@d3plus/dom": "3.0.0-alpha.3",
20
+ "@d3plus/format": "3.0.0-alpha.3",
21
+ "@d3plus/locales": "3.0.0-alpha.3",
22
+ "@d3plus/react": "3.0.0-alpha.3",
23
+ "@storybook/blocks": "^8.6.12",
24
+ "@storybook/components": "^8.6.12",
25
+ "@storybook/icons": "^1.4.0",
26
+ "@storybook/manager-api": "^8.6.12",
27
+ "@storybook/test": "^8.6.12",
28
+ "@types/react": "^19.1.0",
29
+ "next": "^15.2.4",
30
+ "react": "^18.2.0",
31
+ "react-dom": "^18.2.0",
32
+ "typescript": "^5.8.2",
33
+ "vite": "^6.2.5"
34
+ },
35
+ "devDependencies": {
36
+ "@storybook/addon-controls": "^8.6.12",
37
+ "@storybook/addon-docs": "^8.6.12",
38
+ "@storybook/nextjs": "^8.6.12",
39
+ "@storybook/react": "^8.6.12",
40
+ "@storybook/theming": "^8.6.12",
41
+ "remark-gfm": "^4.0.1",
42
+ "storybook": "^8.6.12"
43
+ }
44
+ }
@@ -0,0 +1,23 @@
1
+ // WARNING: do not edit the top part of this file directly, it is generated
2
+ // from the source code. Scroll down to the next WARNING and places stories below it.
3
+
4
+ import React from "react";
5
+
6
+ import {argTypes} from "../../args/color/colorAdd.args";
7
+ import {colorAdd} from "@d3plus/color";
8
+
9
+ export default {
10
+ title: "Color/colorAdd",
11
+ argTypes,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "Adds two colors together.",
16
+ },
17
+ },
18
+ }
19
+ };
20
+
21
+ // WARNING: do not edit above this line of code directly, it is generated
22
+ // from the source code. Stories below this line can be modified.
23
+
@@ -0,0 +1,23 @@
1
+ // WARNING: do not edit the top part of this file directly, it is generated
2
+ // from the source code. Scroll down to the next WARNING and places stories below it.
3
+
4
+ import React from "react";
5
+
6
+ import {argTypes} from "../../args/color/colorAssign.args";
7
+ import {colorAssign} from "@d3plus/color";
8
+
9
+ export default {
10
+ title: "Color/colorAssign",
11
+ argTypes,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "Assigns a color to a value using a predefined set of defaults.",
16
+ },
17
+ },
18
+ }
19
+ };
20
+
21
+ // WARNING: do not edit above this line of code directly, it is generated
22
+ // from the source code. Stories below this line can be modified.
23
+
@@ -0,0 +1,23 @@
1
+ // WARNING: do not edit the top part of this file directly, it is generated
2
+ // from the source code. Scroll down to the next WARNING and places stories below it.
3
+
4
+ import React from "react";
5
+
6
+ import {argTypes} from "../../args/color/colorContrast.args";
7
+ import {colorContrast} from "@d3plus/color";
8
+
9
+ export default {
10
+ title: "Color/colorContrast",
11
+ argTypes,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "A set of default color values used when assigning colors based on data.",
16
+ },
17
+ },
18
+ }
19
+ };
20
+
21
+ // WARNING: do not edit above this line of code directly, it is generated
22
+ // from the source code. Stories below this line can be modified.
23
+
@@ -0,0 +1,23 @@
1
+ // WARNING: do not edit the top part of this file directly, it is generated
2
+ // from the source code. Scroll down to the next WARNING and places stories below it.
3
+
4
+ import React from "react";
5
+
6
+ import {argTypes} from "../../args/color/colorDefaults.args";
7
+ import {colorDefaults} from "@d3plus/color";
8
+
9
+ export default {
10
+ title: "Color/colorDefaults",
11
+ argTypes,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "A set of default color values used when assigning colors based on data.",
16
+ },
17
+ },
18
+ }
19
+ };
20
+
21
+ // WARNING: do not edit above this line of code directly, it is generated
22
+ // from the source code. Stories below this line can be modified.
23
+
@@ -0,0 +1,23 @@
1
+ // WARNING: do not edit the top part of this file directly, it is generated
2
+ // from the source code. Scroll down to the next WARNING and places stories below it.
3
+
4
+ import React from "react";
5
+
6
+ import {argTypes} from "../../args/color/colorLegible.args";
7
+ import {colorLegible} from "@d3plus/color";
8
+
9
+ export default {
10
+ title: "Color/colorLegible",
11
+ argTypes,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "Darkens a color so that it will appear legible on a white background.",
16
+ },
17
+ },
18
+ }
19
+ };
20
+
21
+ // WARNING: do not edit above this line of code directly, it is generated
22
+ // from the source code. Stories below this line can be modified.
23
+
@@ -0,0 +1,23 @@
1
+ // WARNING: do not edit the top part of this file directly, it is generated
2
+ // from the source code. Scroll down to the next WARNING and places stories below it.
3
+
4
+ import React from "react";
5
+
6
+ import {argTypes} from "../../args/color/colorLighter.args";
7
+ import {colorLighter} from "@d3plus/color";
8
+
9
+ export default {
10
+ title: "Color/colorLighter",
11
+ argTypes,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "Similar to d3.color.brighter, except that this also reduces saturation so that colors don't appear neon.",
16
+ },
17
+ },
18
+ }
19
+ };
20
+
21
+ // WARNING: do not edit above this line of code directly, it is generated
22
+ // from the source code. Stories below this line can be modified.
23
+
@@ -0,0 +1,23 @@
1
+ // WARNING: do not edit the top part of this file directly, it is generated
2
+ // from the source code. Scroll down to the next WARNING and places stories below it.
3
+
4
+ import React from "react";
5
+
6
+ import {argTypes} from "../../args/color/colorSubtract.args";
7
+ import {colorSubtract} from "@d3plus/color";
8
+
9
+ export default {
10
+ title: "Color/colorSubtract",
11
+ argTypes,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "Subtracts one color from another.",
16
+ },
17
+ },
18
+ }
19
+ };
20
+
21
+ // WARNING: do not edit above this line of code directly, it is generated
22
+ // from the source code. Stories below this line can be modified.
23
+