nanoplot 0.0.80 → 0.0.82
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.css +120 -32
- package/dist/src/components/Bars/Bars.d.ts +22 -0
- package/dist/src/components/Bars/Bars.js +2 -0
- package/dist/src/components/Bars/components/BarsMouse.d.ts +25 -0
- package/dist/src/components/Bars/components/BarsMouse.js +12 -0
- package/dist/src/components/Bars/components/HorizontalBars.d.ts +5 -1
- package/dist/src/components/Bars/components/HorizontalBars.js +32 -15
- package/dist/src/components/Bars/components/Rect.js +2 -2
- package/dist/src/components/Bars/components/VerticalBars.d.ts +12 -5
- package/dist/src/components/Bars/components/VerticalBars.js +26 -11
- package/dist/src/components/GradientLegend/GradientLegend.d.ts +1 -5
- package/dist/src/components/GradientLegend/GradientLegend.js +19 -18
- package/dist/src/components/GridLines/GridLines.js +3 -3
- package/dist/src/components/Heatmap/Heatmap.js +1 -1
- package/dist/src/components/Lines/Lines.js +3 -4
- package/dist/src/components/Lines/components/LinesMouse.js +5 -5
- package/dist/src/components/Lines/components/LinesTooltip.js +3 -3
- package/dist/src/components/Pie/Pie.d.ts +2 -1
- package/dist/src/components/Pie/Pie.js +49 -25
- package/dist/src/components/Pie/components/PieTooltip.js +1 -1
- package/dist/src/components/Worldmap/Worldmap.d.ts +9 -5
- package/dist/src/components/Worldmap/Worldmap.js +13 -11
- package/dist/src/components/Worldmap/components/WorldmapTooltip.js +2 -3
- package/dist/src/components/XAxis/XAxis.d.ts +2 -1
- package/dist/src/components/XAxis/XAxis.js +19 -17
- package/dist/src/components/YAxis/YAxis.d.ts +2 -1
- package/dist/src/components/YAxis/YAxis.js +8 -3
- package/dist/src/hooks/use-mouse-coordinates.d.ts +55 -1
- package/dist/src/hooks/use-mouse-coordinates.js +61 -20
- package/dist/src/models/domain/domain.d.ts +1 -0
- package/dist/src/utils/coordinates/coordinates.js +9 -9
- package/dist/src/utils/domain/domain.d.ts +2 -2
- package/dist/src/utils/domain/domain.js +4 -4
- package/dist/src/utils/domain/utils/date-domain.js +1 -1
- package/dist/src/utils/domain/utils/range.d.ts +1 -1
- package/dist/src/utils/domain/utils/range.js +9 -1
- package/dist/src/utils/gradient/gradient.d.ts +6 -5
- package/dist/src/utils/gradient/gradient.js +18 -6
- package/dist/src/utils/path/path.js +3 -3
- package/dist/tsconfig.typings.tsbuildinfo +1 -1
- package/package.json +11 -3
package/dist/index.css
CHANGED
|
@@ -64,10 +64,6 @@
|
|
|
64
64
|
bottom: 0px;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
.left-0 {
|
|
68
|
-
left: 0px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
67
|
.left-2 {
|
|
72
68
|
left: 0.5rem;
|
|
73
69
|
}
|
|
@@ -76,6 +72,10 @@
|
|
|
76
72
|
left: 50%;
|
|
77
73
|
}
|
|
78
74
|
|
|
75
|
+
.right-0 {
|
|
76
|
+
right: 0px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
79
|
.right-2 {
|
|
80
80
|
right: 0.5rem;
|
|
81
81
|
}
|
|
@@ -108,6 +108,10 @@
|
|
|
108
108
|
z-index: 10;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
.z-\[-1\] {
|
|
112
|
+
z-index: -1;
|
|
113
|
+
}
|
|
114
|
+
|
|
111
115
|
.z-\[2\] {
|
|
112
116
|
z-index: 2;
|
|
113
117
|
}
|
|
@@ -182,10 +186,6 @@
|
|
|
182
186
|
aspect-ratio: 1090/539;
|
|
183
187
|
}
|
|
184
188
|
|
|
185
|
-
.aspect-square {
|
|
186
|
-
aspect-ratio: 1 / 1;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
189
|
.size-4 {
|
|
190
190
|
width: 1rem;
|
|
191
191
|
height: 1rem;
|
|
@@ -195,10 +195,6 @@
|
|
|
195
195
|
height: 0.5rem;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
.h-\[1\.25em\] {
|
|
199
|
-
height: 1.25em;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
198
|
.h-\[14px\] {
|
|
203
199
|
height: 14px;
|
|
204
200
|
}
|
|
@@ -207,12 +203,12 @@
|
|
|
207
203
|
height: 16px;
|
|
208
204
|
}
|
|
209
205
|
|
|
210
|
-
.h-\[
|
|
211
|
-
height:
|
|
206
|
+
.h-\[1px\] {
|
|
207
|
+
height: 1px;
|
|
212
208
|
}
|
|
213
209
|
|
|
214
|
-
.h
|
|
215
|
-
height:
|
|
210
|
+
.h-\[8px\] {
|
|
211
|
+
height: 8px;
|
|
216
212
|
}
|
|
217
213
|
|
|
218
214
|
.h-full {
|
|
@@ -235,6 +231,10 @@
|
|
|
235
231
|
width: 250px;
|
|
236
232
|
}
|
|
237
233
|
|
|
234
|
+
.w-\[8px\] {
|
|
235
|
+
width: 8px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
238
|
.w-auto {
|
|
239
239
|
width: auto;
|
|
240
240
|
}
|
|
@@ -373,6 +373,11 @@
|
|
|
373
373
|
background-color: currentColor;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
.bg-gray-200 {
|
|
377
|
+
--tw-bg-opacity: 1;
|
|
378
|
+
background-color: rgb(229 231 235 / var(--tw-bg-opacity, 1));
|
|
379
|
+
}
|
|
380
|
+
|
|
376
381
|
.bg-gray-400 {
|
|
377
382
|
--tw-bg-opacity: 1;
|
|
378
383
|
background-color: rgb(156 163 175 / var(--tw-bg-opacity, 1));
|
|
@@ -395,6 +400,14 @@
|
|
|
395
400
|
fill: #efefef;
|
|
396
401
|
}
|
|
397
402
|
|
|
403
|
+
.fill-\[url\(\#bar-shadow-light\)\] {
|
|
404
|
+
fill: url(#bar-shadow-light);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.fill-\[var\(--worldmap-fill-light\)\] {
|
|
408
|
+
fill: var(--worldmap-fill-light);
|
|
409
|
+
}
|
|
410
|
+
|
|
398
411
|
.fill-gray-200 {
|
|
399
412
|
fill: #e5e7eb;
|
|
400
413
|
}
|
|
@@ -407,12 +420,12 @@
|
|
|
407
420
|
fill: transparent;
|
|
408
421
|
}
|
|
409
422
|
|
|
410
|
-
.stroke
|
|
411
|
-
stroke: #
|
|
423
|
+
.stroke-\[\#2d2d2d\] {
|
|
424
|
+
stroke: #2d2d2d;
|
|
412
425
|
}
|
|
413
426
|
|
|
414
|
-
.stroke-
|
|
415
|
-
stroke:
|
|
427
|
+
.stroke-black {
|
|
428
|
+
stroke: #000;
|
|
416
429
|
}
|
|
417
430
|
|
|
418
431
|
.stroke-gray-200 {
|
|
@@ -581,10 +594,20 @@
|
|
|
581
594
|
opacity: 0;
|
|
582
595
|
}
|
|
583
596
|
|
|
597
|
+
.opacity-40 {
|
|
598
|
+
opacity: 0.4;
|
|
599
|
+
}
|
|
600
|
+
|
|
584
601
|
.opacity-\[0\.8\] {
|
|
585
602
|
opacity: 0.8;
|
|
586
603
|
}
|
|
587
604
|
|
|
605
|
+
.shadow {
|
|
606
|
+
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
607
|
+
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
|
608
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
609
|
+
}
|
|
610
|
+
|
|
588
611
|
.shadow-md {
|
|
589
612
|
--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
590
613
|
--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);
|
|
@@ -627,6 +650,10 @@
|
|
|
627
650
|
transition-duration: 200ms;
|
|
628
651
|
}
|
|
629
652
|
|
|
653
|
+
.duration-300 {
|
|
654
|
+
transition-duration: 300ms;
|
|
655
|
+
}
|
|
656
|
+
|
|
630
657
|
.ease-in-out {
|
|
631
658
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
632
659
|
}
|
|
@@ -635,6 +662,10 @@
|
|
|
635
662
|
will-change: transform;
|
|
636
663
|
}
|
|
637
664
|
|
|
665
|
+
.\@container-\[inline-size\] {
|
|
666
|
+
container-type: inline-size;
|
|
667
|
+
}
|
|
668
|
+
|
|
638
669
|
.\@container-\[size\] {
|
|
639
670
|
container-type: size;
|
|
640
671
|
}
|
|
@@ -748,6 +779,10 @@
|
|
|
748
779
|
line-height: 1rem;
|
|
749
780
|
}
|
|
750
781
|
|
|
782
|
+
.\[scale\:1\.02\] {
|
|
783
|
+
scale: 1.02;
|
|
784
|
+
}
|
|
785
|
+
|
|
751
786
|
.\[scale\:1\] {
|
|
752
787
|
scale: 1;
|
|
753
788
|
}
|
|
@@ -954,12 +989,8 @@
|
|
|
954
989
|
inset: calc(-1 * var(--b) - var(--h)) calc(-1 * var(--b)) calc(-1 * var(--b));
|
|
955
990
|
}
|
|
956
991
|
|
|
957
|
-
.hover\:stroke-
|
|
958
|
-
stroke:
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
.hover\:stroke-\[1\.2\]:hover {
|
|
962
|
-
stroke-width: 1.2;
|
|
992
|
+
.hover\:stroke-\[var\(--worldmap-stroke\)\]:hover {
|
|
993
|
+
stroke: var(--worldmap-stroke);
|
|
963
994
|
}
|
|
964
995
|
|
|
965
996
|
.hover\:\[fill-opacity\:0\.2\]:hover {
|
|
@@ -995,6 +1026,10 @@
|
|
|
995
1026
|
.\@\[width\:100ch\]\:\!\[writing-mode\:unset\] {
|
|
996
1027
|
writing-mode: unset !important;
|
|
997
1028
|
}
|
|
1029
|
+
|
|
1030
|
+
.\@\[width\:100ch\]\:\[writing-mode\:unset\] {
|
|
1031
|
+
writing-mode: unset;
|
|
1032
|
+
}
|
|
998
1033
|
}
|
|
999
1034
|
|
|
1000
1035
|
@container (min-width:10ch) {
|
|
@@ -1005,6 +1040,10 @@
|
|
|
1005
1040
|
.\@\[width\:10ch\]\:\!\[writing-mode\:unset\] {
|
|
1006
1041
|
writing-mode: unset !important;
|
|
1007
1042
|
}
|
|
1043
|
+
|
|
1044
|
+
.\@\[width\:10ch\]\:\[writing-mode\:unset\] {
|
|
1045
|
+
writing-mode: unset;
|
|
1046
|
+
}
|
|
1008
1047
|
}
|
|
1009
1048
|
|
|
1010
1049
|
@container (min-width:10ch) and (min-height:1.25em) {
|
|
@@ -1021,6 +1060,10 @@
|
|
|
1021
1060
|
.\@\[width\:130ch\]\:\!\[writing-mode\:unset\] {
|
|
1022
1061
|
writing-mode: unset !important;
|
|
1023
1062
|
}
|
|
1063
|
+
|
|
1064
|
+
.\@\[width\:130ch\]\:\[writing-mode\:unset\] {
|
|
1065
|
+
writing-mode: unset;
|
|
1066
|
+
}
|
|
1024
1067
|
}
|
|
1025
1068
|
|
|
1026
1069
|
@container (min-width:15ch) and (min-height:1.25em) {
|
|
@@ -1037,6 +1080,10 @@
|
|
|
1037
1080
|
.\@\[width\:160ch\]\:\!\[writing-mode\:unset\] {
|
|
1038
1081
|
writing-mode: unset !important;
|
|
1039
1082
|
}
|
|
1083
|
+
|
|
1084
|
+
.\@\[width\:160ch\]\:\[writing-mode\:unset\] {
|
|
1085
|
+
writing-mode: unset;
|
|
1086
|
+
}
|
|
1040
1087
|
}
|
|
1041
1088
|
|
|
1042
1089
|
@container (min-width:190ch) {
|
|
@@ -1047,6 +1094,10 @@
|
|
|
1047
1094
|
.\@\[width\:190ch\]\:\!\[writing-mode\:unset\] {
|
|
1048
1095
|
writing-mode: unset !important;
|
|
1049
1096
|
}
|
|
1097
|
+
|
|
1098
|
+
.\@\[width\:190ch\]\:\[writing-mode\:unset\] {
|
|
1099
|
+
writing-mode: unset;
|
|
1100
|
+
}
|
|
1050
1101
|
}
|
|
1051
1102
|
|
|
1052
1103
|
@container (min-width:20ch) {
|
|
@@ -1057,6 +1108,10 @@
|
|
|
1057
1108
|
.\@\[width\:20ch\]\:\!\[writing-mode\:unset\] {
|
|
1058
1109
|
writing-mode: unset !important;
|
|
1059
1110
|
}
|
|
1111
|
+
|
|
1112
|
+
.\@\[width\:20ch\]\:\[writing-mode\:unset\] {
|
|
1113
|
+
writing-mode: unset;
|
|
1114
|
+
}
|
|
1060
1115
|
}
|
|
1061
1116
|
|
|
1062
1117
|
@container (min-width:20ch) and (min-height:1.25em) {
|
|
@@ -1079,6 +1134,10 @@
|
|
|
1079
1134
|
.\@\[width\:30ch\]\:\!\[writing-mode\:unset\] {
|
|
1080
1135
|
writing-mode: unset !important;
|
|
1081
1136
|
}
|
|
1137
|
+
|
|
1138
|
+
.\@\[width\:30ch\]\:\[writing-mode\:unset\] {
|
|
1139
|
+
writing-mode: unset;
|
|
1140
|
+
}
|
|
1082
1141
|
}
|
|
1083
1142
|
|
|
1084
1143
|
@container (min-width:400px) {
|
|
@@ -1095,6 +1154,10 @@
|
|
|
1095
1154
|
.\@\[width\:40ch\]\:\!\[writing-mode\:unset\] {
|
|
1096
1155
|
writing-mode: unset !important;
|
|
1097
1156
|
}
|
|
1157
|
+
|
|
1158
|
+
.\@\[width\:40ch\]\:\[writing-mode\:unset\] {
|
|
1159
|
+
writing-mode: unset;
|
|
1160
|
+
}
|
|
1098
1161
|
}
|
|
1099
1162
|
|
|
1100
1163
|
@container (min-width:4ch) and (min-height:1.25em) {
|
|
@@ -1111,6 +1174,10 @@
|
|
|
1111
1174
|
.\@\[width\:50ch\]\:\!\[writing-mode\:unset\] {
|
|
1112
1175
|
writing-mode: unset !important;
|
|
1113
1176
|
}
|
|
1177
|
+
|
|
1178
|
+
.\@\[width\:50ch\]\:\[writing-mode\:unset\] {
|
|
1179
|
+
writing-mode: unset;
|
|
1180
|
+
}
|
|
1114
1181
|
}
|
|
1115
1182
|
|
|
1116
1183
|
@container (min-width:5ch) and (min-height:1.25em) {
|
|
@@ -1127,6 +1194,10 @@
|
|
|
1127
1194
|
.\@\[width\:60ch\]\:\!\[writing-mode\:unset\] {
|
|
1128
1195
|
writing-mode: unset !important;
|
|
1129
1196
|
}
|
|
1197
|
+
|
|
1198
|
+
.\@\[width\:60ch\]\:\[writing-mode\:unset\] {
|
|
1199
|
+
writing-mode: unset;
|
|
1200
|
+
}
|
|
1130
1201
|
}
|
|
1131
1202
|
|
|
1132
1203
|
@container (min-width:6ch) and (min-height:1.25em) {
|
|
@@ -1143,6 +1214,10 @@
|
|
|
1143
1214
|
.\@\[width\:70ch\]\:\!\[writing-mode\:unset\] {
|
|
1144
1215
|
writing-mode: unset !important;
|
|
1145
1216
|
}
|
|
1217
|
+
|
|
1218
|
+
.\@\[width\:70ch\]\:\[writing-mode\:unset\] {
|
|
1219
|
+
writing-mode: unset;
|
|
1220
|
+
}
|
|
1146
1221
|
}
|
|
1147
1222
|
|
|
1148
1223
|
@container (min-width:80ch) {
|
|
@@ -1153,6 +1228,10 @@
|
|
|
1153
1228
|
.\@\[width\:80ch\]\:\!\[writing-mode\:unset\] {
|
|
1154
1229
|
writing-mode: unset !important;
|
|
1155
1230
|
}
|
|
1231
|
+
|
|
1232
|
+
.\@\[width\:80ch\]\:\[writing-mode\:unset\] {
|
|
1233
|
+
writing-mode: unset;
|
|
1234
|
+
}
|
|
1156
1235
|
}
|
|
1157
1236
|
|
|
1158
1237
|
@container (min-width:8ch) and (min-height:1.25em) {
|
|
@@ -1169,6 +1248,15 @@
|
|
|
1169
1248
|
.\@\[width\:90ch\]\:\!\[writing-mode\:unset\] {
|
|
1170
1249
|
writing-mode: unset !important;
|
|
1171
1250
|
}
|
|
1251
|
+
|
|
1252
|
+
.\@\[width\:90ch\]\:\[writing-mode\:unset\] {
|
|
1253
|
+
writing-mode: unset;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
.dark\:bg-\[\#2d2d2d\]:where(.dark, .dark *) {
|
|
1258
|
+
--tw-bg-opacity: 1;
|
|
1259
|
+
background-color: rgb(45 45 45 / var(--tw-bg-opacity, 1));
|
|
1172
1260
|
}
|
|
1173
1261
|
|
|
1174
1262
|
.dark\:fill-\[\#111111\]:where(.dark, .dark *) {
|
|
@@ -1183,8 +1271,12 @@
|
|
|
1183
1271
|
fill: #2d2d2d;
|
|
1184
1272
|
}
|
|
1185
1273
|
|
|
1186
|
-
.dark\:fill-dark
|
|
1187
|
-
fill:
|
|
1274
|
+
.dark\:fill-\[url\(\#bar-shadow-dark\)\]:where(.dark, .dark *) {
|
|
1275
|
+
fill: url(#bar-shadow-dark);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
.dark\:fill-\[var\(--worldmap-fill-dark\)\]:where(.dark, .dark *) {
|
|
1279
|
+
fill: var(--worldmap-fill-dark);
|
|
1188
1280
|
}
|
|
1189
1281
|
|
|
1190
1282
|
.dark\:fill-gray-400:where(.dark, .dark *) {
|
|
@@ -1199,10 +1291,6 @@
|
|
|
1199
1291
|
stroke: #2d2d2d;
|
|
1200
1292
|
}
|
|
1201
1293
|
|
|
1202
|
-
.dark\:stroke-dark-priority-100:where(.dark, .dark *) {
|
|
1203
|
-
stroke: rgb(45, 45, 45);
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
1294
|
.dark\:stroke-white:where(.dark, .dark *) {
|
|
1207
1295
|
stroke: #fff;
|
|
1208
1296
|
}
|
|
@@ -11,5 +11,27 @@ type HorizontalProps = {
|
|
|
11
11
|
export declare const Bars: {
|
|
12
12
|
({ horizontal, ...props }: VerticalProps | HorizontalProps): React.JSX.Element;
|
|
13
13
|
context(ctx: InternalGraphContext): InternalGraphContext;
|
|
14
|
+
Mouse: ({ onMove, onLeave, onEnter, className }: {
|
|
15
|
+
className?: string;
|
|
16
|
+
onMove?: (mouse: null | {
|
|
17
|
+
coordinates: SVGPoint;
|
|
18
|
+
px: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
closest: {
|
|
23
|
+
datapoint: {
|
|
24
|
+
x: Date | string | number;
|
|
25
|
+
y: Date | string | number;
|
|
26
|
+
};
|
|
27
|
+
tick: {
|
|
28
|
+
x: string | number | Date;
|
|
29
|
+
y: string | number | Date;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}, e: React.MouseEvent<SVGSVGElement>) => void;
|
|
33
|
+
onEnter?: (e: React.MouseEvent<SVGSVGElement>) => void;
|
|
34
|
+
onLeave?: (e: React.MouseEvent<SVGSVGElement>) => void;
|
|
35
|
+
}) => React.JSX.Element;
|
|
14
36
|
};
|
|
15
37
|
export {};
|
|
@@ -13,6 +13,7 @@ import React from "react";
|
|
|
13
13
|
import { HorizontalBars } from "./components/HorizontalBars";
|
|
14
14
|
import { VerticalBars } from "./components/VerticalBars";
|
|
15
15
|
import { ColorUtils } from "../../utils/color/color";
|
|
16
|
+
import { BarsMouse } from "./components/BarsMouse";
|
|
16
17
|
export const Bars = (_a) => {
|
|
17
18
|
var { horizontal } = _a, props = __rest(_a, ["horizontal"]);
|
|
18
19
|
return horizontal ? React.createElement(HorizontalBars, Object.assign({}, props)) : React.createElement(VerticalBars, Object.assign({}, props));
|
|
@@ -20,3 +21,4 @@ export const Bars = (_a) => {
|
|
|
20
21
|
Bars.context = (ctx) => {
|
|
21
22
|
return Object.assign(Object.assign({}, ctx), { colors: ColorUtils.scheme.contrast });
|
|
22
23
|
};
|
|
24
|
+
Bars.Mouse = BarsMouse;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MouseEvent } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
className?: string;
|
|
4
|
+
onMove?: (mouse: null | {
|
|
5
|
+
coordinates: SVGPoint;
|
|
6
|
+
px: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
closest: {
|
|
11
|
+
datapoint: {
|
|
12
|
+
x: Date | string | number;
|
|
13
|
+
y: Date | string | number;
|
|
14
|
+
};
|
|
15
|
+
tick: {
|
|
16
|
+
x: string | number | Date;
|
|
17
|
+
y: string | number | Date;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}, e: MouseEvent<SVGSVGElement>) => void;
|
|
21
|
+
onEnter?: (e: MouseEvent<SVGSVGElement>) => void;
|
|
22
|
+
onLeave?: (e: MouseEvent<SVGSVGElement>) => void;
|
|
23
|
+
};
|
|
24
|
+
export declare const BarsMouse: ({ onMove, onLeave, onEnter, className }: Props) => import("react").JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMouseCoordinates } from "../../../hooks/use-mouse-coordinates";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { useGraph, useIsZooming } from "../../../hooks/use-graph/use-graph";
|
|
5
|
+
import { tw } from "../../../utils/cx/cx";
|
|
6
|
+
export const BarsMouse = ({ onMove, onLeave, onEnter, className }) => {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const isZooming = useIsZooming();
|
|
9
|
+
const { viewbox } = useGraph();
|
|
10
|
+
const mouse = useMouseCoordinates(ref, { x: true, y: true, lazy: true });
|
|
11
|
+
return (React.createElement("svg", { ref: ref, viewBox: `0 0 ${viewbox.x} ${viewbox.y}`, preserveAspectRatio: "none", className: tw("bars-mouse h-full w-full [grid-area:graph] absolute overflow-visible [backface-visibility:hidden]", isZooming && "block overflow-hidden", className), onMouseEnter: onEnter, onMouseLeave: onLeave, onMouseMove: (e) => onMove === null || onMove === void 0 ? void 0 : onMove(mouse, e) }));
|
|
12
|
+
};
|
|
@@ -18,8 +18,12 @@ type Props = Omit<React.SVGAttributes<SVGSVGElement>, "onMouseEnter" | "onMouseL
|
|
|
18
18
|
*/
|
|
19
19
|
fill?: (segment: Segment) => string;
|
|
20
20
|
stroke?: (segment: Segment) => string;
|
|
21
|
+
interactions?: {
|
|
22
|
+
y?: number | string | Date;
|
|
23
|
+
shadow?: boolean;
|
|
24
|
+
};
|
|
21
25
|
onMouseEnter?: (rect: Segment, event: MouseEvent) => void;
|
|
22
26
|
onMouseLeave?: (event: MouseEvent) => void;
|
|
23
27
|
};
|
|
24
|
-
export declare const HorizontalBars: ({ children, fill, stroke, labels, size, radius, anchor, onMouseEnter, onMouseLeave, className, }: Props) => React.JSX.Element | null;
|
|
28
|
+
export declare const HorizontalBars: ({ children, fill, stroke, labels, size, radius, anchor, interactions, onMouseEnter, onMouseLeave, className, }: Props) => React.JSX.Element | null;
|
|
25
29
|
export {};
|
|
@@ -19,32 +19,49 @@ import { Rect } from "./Rect";
|
|
|
19
19
|
import { scale } from "../../../utils/math/math";
|
|
20
20
|
import { overlay } from "../../Overlay/Overlay";
|
|
21
21
|
import { ColorUtils } from "../../../utils/color/color";
|
|
22
|
-
|
|
22
|
+
import { LinearGradient } from "../../LinearGradient/LinearGradient";
|
|
23
|
+
export const HorizontalBars = ({ children, fill, stroke, labels, size = 50, radius = 0, anchor = 0, interactions, onMouseEnter, onMouseLeave, className, }) => {
|
|
23
24
|
const context = useGraph();
|
|
24
25
|
if (!GraphUtils.isXYData(context.data))
|
|
25
26
|
return null;
|
|
26
27
|
const xForValue = CoordinatesUtils.xCoordinateFor(context);
|
|
28
|
+
const yForValue = CoordinatesUtils.yCoordinateFor(context);
|
|
27
29
|
const bars = context.data.flatMap((bar, i) => bar.data.map((xy) => {
|
|
28
|
-
var _a
|
|
29
|
-
return (Object.assign(Object.assign({}, bar), {
|
|
30
|
-
}));
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const dataset =
|
|
34
|
-
.flatMap((
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}).map((segment,
|
|
40
|
-
const
|
|
41
|
-
|
|
30
|
+
var _a;
|
|
31
|
+
return (Object.assign(Object.assign({}, bar), { group: (_a = bar.group) !== null && _a !== void 0 ? _a : bar.id, data: xy }));
|
|
32
|
+
}));
|
|
33
|
+
const BAR_HEIGHT = Math.floor(context.viewbox.y / context.domain.y.length / new Set(bars.map((bar) => { var _a; return (_a = bar.group) !== null && _a !== void 0 ? _a : "no-group"; })).size) * (size / 100);
|
|
34
|
+
const yValues = new Set(bars.map((bar) => (bar.data.y instanceof Date ? bar.data.y.getTime() : bar.data.y)));
|
|
35
|
+
const dataset = Array.from(yValues)
|
|
36
|
+
.flatMap((y) => {
|
|
37
|
+
const coordinate = yForValue(y);
|
|
38
|
+
const barsForTick = bars.filter((bar) => (bar.data.y instanceof Date ? bar.data.y.getTime() : bar.data.y) === y);
|
|
39
|
+
return Object.entries(ObjectUtils.groupBy(barsForTick, ({ group }) => group)).flatMap(([, barsForGroup], i, groups) => {
|
|
40
|
+
const y1 = coordinate + BAR_HEIGHT * i - (BAR_HEIGHT * Object.keys(groups).length) / 2;
|
|
41
|
+
return barsForGroup === null || barsForGroup === void 0 ? void 0 : barsForGroup.map((bar) => (Object.assign(Object.assign({}, bar), { x1: xForValue(anchor), x2: xForValue(bar.data.x), y1, y2: y1 + BAR_HEIGHT }))).map((segment, ii, segments) => {
|
|
42
|
+
const isAboveAnchor = Math.min(segment.x1, segment.x2) < xForValue(anchor);
|
|
43
|
+
const prevWidth = segments.slice(0, ii).reduce((acc, { x1, x2 }) => {
|
|
44
|
+
if (isAboveAnchor ? x1 >= xForValue(anchor) : xForValue(anchor) >= x1)
|
|
45
|
+
return acc;
|
|
46
|
+
return isAboveAnchor ? acc + Math.abs(x1 - x2) : acc - Math.abs(x1 - x2);
|
|
47
|
+
}, 0);
|
|
48
|
+
const x1 = segment.x1 - prevWidth;
|
|
49
|
+
const x2 = segment.x2 - prevWidth;
|
|
50
|
+
return Object.assign(Object.assign({}, segment), { x1: Math.max(x1, x2), x2: Math.min(x1, x2), radius: ii === segments.length - 1 ? radius : undefined });
|
|
42
51
|
});
|
|
43
52
|
});
|
|
44
53
|
})
|
|
45
54
|
.filter((x) => !!x);
|
|
46
55
|
return (React.createElement(React.Fragment, null,
|
|
47
56
|
React.createElement("svg", { viewBox: `0 0 ${context.viewbox.x} ${context.viewbox.y}`, className: cx("horizontal-bars [grid-area:graph] h-full w-full", className), preserveAspectRatio: "none" },
|
|
57
|
+
React.createElement(LinearGradient, { gradient: "linear-gradient(to left, rgba(45, 45, 45, 0) 0%, rgba(45, 45, 45, 0.35) 65%, rgba(45, 45, 45, 1) 100%)", id: "bar-shadow-dark" }),
|
|
58
|
+
React.createElement(LinearGradient, { gradient: "linear-gradient(to left, rgba(180, 180, 180, 0) 0%, rgba(180, 180, 180, 0.15) 65%, rgba(180, 180, 180, 0.2) 100%)", id: "bar-shadow-light" }),
|
|
59
|
+
context.domain.y.map(({ coordinate }, i) => {
|
|
60
|
+
const isShadowed = (interactions === null || interactions === void 0 ? void 0 : interactions.shadow) && (interactions === null || interactions === void 0 ? void 0 : interactions.y) && yForValue(interactions.y) === coordinate;
|
|
61
|
+
if (!(interactions === null || interactions === void 0 ? void 0 : interactions.shadow))
|
|
62
|
+
return null;
|
|
63
|
+
return (React.createElement(Rect, { key: i, x1: 0, x2: context.viewbox.x, y2: coordinate + context.viewbox.x / context.domain.x.length / 2, y1: coordinate - context.viewbox.x / context.domain.x.length / 2, stroke: "transparent", className: cx("bars__bar bars__bar--shadow transition-all duration-300 opacity-0 fill-[url(#bar-shadow-light)]", isShadowed && "opacity-1", `dark:fill-[url(#bar-shadow-dark)]`) }));
|
|
64
|
+
}),
|
|
48
65
|
dataset.map((_a, index) => {
|
|
49
66
|
var { x1, x2, y1, y2 } = _a, bar = __rest(_a, ["x1", "x2", "y1", "y2"]);
|
|
50
67
|
const fillColor = fill ? fill(bar) : bar.fill;
|
|
@@ -27,12 +27,12 @@ export const Rect = (_a) => {
|
|
|
27
27
|
return (React.createElement(React.Fragment, null,
|
|
28
28
|
isFillGradient && rest.fill && React.createElement(LinearGradient, { id: fillId, gradient: rest.fill }),
|
|
29
29
|
isGradientStroke && rest.stroke && React.createElement(LinearGradient, { id: strokeId, gradient: rest.stroke }),
|
|
30
|
-
React.createElement("path", { id: clipId, d: path, fill: isFillGradient ? `url(#${fillId})` : rest.fill, stroke: isGradientStroke ? `url(#${strokeId})` : rest.stroke }),
|
|
30
|
+
React.createElement("path", { id: clipId, d: path, fill: isFillGradient ? `url(#${fillId})` : rest.fill, stroke: isGradientStroke ? `url(#${strokeId})` : rest.stroke, className: rest.className }),
|
|
31
31
|
React.createElement("clipPath", { id: clip },
|
|
32
32
|
React.createElement("use", { xlinkHref: "#" + clipId })),
|
|
33
33
|
glow && (React.createElement(React.Fragment, null,
|
|
34
34
|
React.createElement("use", { xlinkHref: `#${glowId}`, filter: "blur(45px)", opacity: 0.5 }),
|
|
35
35
|
React.createElement("g", { id: glowId },
|
|
36
36
|
React.createElement("path", { fill: isFillGradient ? `url(#${fillId})` : rest.fill, stroke: "transparent", d: path, vectorEffect: "non-scaling-stroke", className: rest.className, strokeWidth: 5 })))),
|
|
37
|
-
isFillMasked ? (React.createElement("rect", Object.assign({}, rest, { x: x1, y: 0, width: x2 - x1, height: "100%", fill: `url(#${fillId})`, clipPath: `url(#${clip})
|
|
37
|
+
isFillMasked ? (React.createElement("rect", Object.assign({}, rest, { x: x1, y: 0, width: x2 - x1, height: "100%", fill: `url(#${fillId})`, clipPath: `url(#${clip})`, className: rest.className }))) : (React.createElement("path", Object.assign({}, rest, { fill: isFillGradient ? `url(#${fillId})` : rest.fill, stroke: isGradientStroke ? `url(#${strokeId})` : rest.stroke, d: path, vectorEffect: "non-scaling-stroke", strokeWidth: (_e = rest.strokeWidth) !== null && _e !== void 0 ? _e : 10, clipPath: `url(#${clip})`, className: rest.className })))));
|
|
38
38
|
};
|
|
@@ -4,10 +4,8 @@ type Segment = Simplify<Omit<InternalCartesianDataset[number], "data"> & {
|
|
|
4
4
|
data: InternalCartesianDataset[number]["data"][number];
|
|
5
5
|
}>;
|
|
6
6
|
type Props = Omit<React.SVGAttributes<SVGSVGElement>, "onMouseEnter" | "onMouseLeave" | "fill" | "stroke"> & {
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
loading?: boolean;
|
|
9
|
-
glow?: boolean;
|
|
10
7
|
size?: number;
|
|
8
|
+
glow?: boolean;
|
|
11
9
|
radius?: number;
|
|
12
10
|
anchor?: number;
|
|
13
11
|
labels?: boolean | ((segment: Segment) => string) | {
|
|
@@ -15,13 +13,22 @@ type Props = Omit<React.SVGAttributes<SVGSVGElement>, "onMouseEnter" | "onMouseL
|
|
|
15
13
|
collision?: boolean;
|
|
16
14
|
display: (segment: Segment) => string;
|
|
17
15
|
};
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
children?: ReactNode;
|
|
18
18
|
/**
|
|
19
|
-
* Function that can change the 'fill' for individual segments based on some condition.
|
|
19
|
+
* Function that can change the 'fill' for individual bar segments based on some condition.
|
|
20
20
|
*/
|
|
21
21
|
fill?: (segment: Segment) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Function that can change the 'stroke' for individual bar segments based on some condition.
|
|
24
|
+
*/
|
|
22
25
|
stroke?: (segment: Segment) => string;
|
|
26
|
+
interactions?: {
|
|
27
|
+
x?: number | string | Date;
|
|
28
|
+
shadow?: boolean;
|
|
29
|
+
};
|
|
23
30
|
onMouseEnter?: (rect: Segment, event: MouseEvent) => void;
|
|
24
31
|
onMouseLeave?: (event: MouseEvent) => void;
|
|
25
32
|
};
|
|
26
|
-
export declare const VerticalBars: ({ children, fill, stroke, size, anchor, labels, radius, glow, className, loading, onMouseEnter, onMouseLeave, ...rest }: Props) => React.JSX.Element | null;
|
|
33
|
+
export declare const VerticalBars: ({ children, fill, stroke, size, anchor, labels, radius, glow, className, loading, interactions, onMouseEnter, onMouseLeave, ...rest }: Props) => React.JSX.Element | null;
|
|
27
34
|
export {};
|
|
@@ -20,26 +20,30 @@ import { cx } from "../../../utils/cx/cx";
|
|
|
20
20
|
import { scale } from "../../../utils/math/math";
|
|
21
21
|
import { overlay } from "../../Overlay/Overlay";
|
|
22
22
|
import { ColorUtils } from "../../../utils/color/color";
|
|
23
|
+
import { LinearGradient } from "../../LinearGradient/LinearGradient";
|
|
23
24
|
export const VerticalBars = (_a) => {
|
|
24
|
-
var { children, fill, stroke, size = 50, anchor = 0, labels, radius = 0, glow, className, loading, onMouseEnter, onMouseLeave } = _a, rest = __rest(_a, ["children", "fill", "stroke", "size", "anchor", "labels", "radius", "glow", "className", "loading", "onMouseEnter", "onMouseLeave"]);
|
|
25
|
+
var { children, fill, stroke, size = 50, anchor = 0, labels, radius = 0, glow, className, loading, interactions, onMouseEnter, onMouseLeave } = _a, rest = __rest(_a, ["children", "fill", "stroke", "size", "anchor", "labels", "radius", "glow", "className", "loading", "interactions", "onMouseEnter", "onMouseLeave"]);
|
|
25
26
|
const context = useGraph();
|
|
27
|
+
const { interactions: { hovered, pinned }, } = context;
|
|
26
28
|
if (!GraphUtils.isXYData(context.data))
|
|
27
29
|
return null;
|
|
28
30
|
if (loading)
|
|
29
31
|
return React.createElement(BarsVerticalLoading, null);
|
|
30
32
|
const yForValue = CoordinatesUtils.yCoordinateFor(context);
|
|
33
|
+
const xForValue = CoordinatesUtils.xCoordinateFor(context);
|
|
31
34
|
const bars = context.data.flatMap((bar, i) => bar.data.map((xy) => {
|
|
32
35
|
var _a, _b, _c, _d, _e;
|
|
33
36
|
return (Object.assign(Object.assign({}, bar), { fill: (_c = (_b = (_a = bar.fill) !== null && _a !== void 0 ? _a : bar.stroke) !== null && _b !== void 0 ? _b : context.colors[i]) !== null && _c !== void 0 ? _c : context.colors.at(-1), group: (_e = (_d = bar.group) !== null && _d !== void 0 ? _d : bar.id) !== null && _e !== void 0 ? _e : bar.name, data: xy }));
|
|
34
37
|
}));
|
|
35
|
-
const BAR_WIDTH = Math.floor(
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const BAR_WIDTH = Math.floor(context.viewbox.x / context.domain.x.length / new Set(bars.map((bar) => { var _a; return (_a = bar.group) !== null && _a !== void 0 ? _a : "no-group"; })).size) * (size / 100); // this divided by number of unique groups?
|
|
39
|
+
const xValues = new Set(bars.map((bar) => (bar.data.x instanceof Date ? bar.data.x.getTime() : bar.data.x)));
|
|
40
|
+
const dataset = Array.from(xValues)
|
|
41
|
+
.flatMap((x) => {
|
|
42
|
+
const coordinate = xForValue(x);
|
|
43
|
+
const barsForTick = bars.filter((bar) => (bar.data.x instanceof Date ? bar.data.x.getTime() : bar.data.x) === x);
|
|
44
|
+
return Object.entries(ObjectUtils.groupBy(barsForTick, ({ group }) => group)).flatMap(([, barsForGroup], i, groups) => {
|
|
39
45
|
const x1 = coordinate + BAR_WIDTH * i - (BAR_WIDTH * Object.keys(groups).length) / 2;
|
|
40
|
-
return barsForGroup === null || barsForGroup === void 0 ? void 0 : barsForGroup.map((bar) => {
|
|
41
|
-
return Object.assign(Object.assign({}, bar), { x1, x2: x1 + BAR_WIDTH, y1: yForValue(bar.data.y), y2: yForValue(anchor) });
|
|
42
|
-
}).map((segment, ii, segments) => {
|
|
46
|
+
return barsForGroup === null || barsForGroup === void 0 ? void 0 : barsForGroup.map((bar) => (Object.assign(Object.assign({}, bar), { x1, x2: x1 + BAR_WIDTH, y1: yForValue(bar.data.y), y2: yForValue(anchor) }))).map((segment, ii, segments) => {
|
|
43
47
|
/* this stacks segments in same group */
|
|
44
48
|
const isAboveAnchor = Math.min(segment.y1, segment.y2) < yForValue(anchor);
|
|
45
49
|
const prevHeight = segments.slice(0, ii).reduce((acc, { y1, y2 }) => {
|
|
@@ -57,13 +61,24 @@ export const VerticalBars = (_a) => {
|
|
|
57
61
|
const isBelowAnchor = bars.some((bar) => +bar.data.y < anchor); /* is any bar below the anchor */
|
|
58
62
|
return (React.createElement(React.Fragment, null,
|
|
59
63
|
React.createElement("svg", Object.assign({}, rest, { viewBox: `0 0 ${context.viewbox.x} ${context.viewbox.y}`, className: cx("vertical-bars [grid-area:graph] h-full w-full bars", className), preserveAspectRatio: "none" }),
|
|
64
|
+
React.createElement(LinearGradient, { gradient: "linear-gradient(to bottom, rgba(45, 45, 45, 0) 0%, rgba(45, 45, 45, 0.35) 65%, rgba(45, 45, 45, 1) 100%)", id: "bar-shadow-dark" }),
|
|
65
|
+
React.createElement(LinearGradient, { gradient: "linear-gradient(to bottom, rgba(180, 180, 180, 0) 0%, rgba(180, 180, 180, 0.15) 65%, rgba(180, 180, 180, 0.2) 100%)", id: "bar-shadow-light" }),
|
|
66
|
+
context.domain.x.map(({ coordinate }, i) => {
|
|
67
|
+
const isShadowed = (interactions === null || interactions === void 0 ? void 0 : interactions.shadow) && (interactions === null || interactions === void 0 ? void 0 : interactions.x) && xForValue(interactions.x) === coordinate;
|
|
68
|
+
if (!(interactions === null || interactions === void 0 ? void 0 : interactions.shadow))
|
|
69
|
+
return null;
|
|
70
|
+
return (React.createElement(Rect, { key: i, x1: coordinate - context.viewbox.x / context.domain.x.length / 2, x2: coordinate + context.viewbox.x / context.domain.x.length / 2, y2: context.viewbox.y, y1: 0, stroke: "transparent", className: cx("bars__bar bars__bar--shadow transition-all duration-300 opacity-0 fill-[url(#bar-shadow-light)]", isShadowed && "opacity-1", `dark:fill-[url(#bar-shadow-dark)]`) }));
|
|
71
|
+
}),
|
|
60
72
|
dataset.map((_a, index) => {
|
|
61
73
|
var { x1, x2, y1, y2 } = _a, bar = __rest(_a, ["x1", "x2", "y1", "y2"]);
|
|
74
|
+
const disabled = Boolean(pinned.concat(hovered).length && !pinned.includes(bar.id) && !hovered.includes(bar.id)) ||
|
|
75
|
+
((interactions === null || interactions === void 0 ? void 0 : interactions.x) ? xForValue(interactions.x) !== xForValue(bar.data.x) : false);
|
|
62
76
|
const fillColor = fill ? fill(bar) : bar.fill;
|
|
63
77
|
const strokeColor = stroke ? stroke(bar) : bar.stroke;
|
|
64
|
-
return (React.createElement(
|
|
78
|
+
return (React.createElement(React.Fragment, { key: index },
|
|
79
|
+
React.createElement(Rect, { key: index, x1: x1, x2: x2, y2: y2, y1: y1, fill: fillColor, stroke: strokeColor, radius: bar.radius, glow: glow, onMouseEnter: onMouseEnter ? (event) => onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(bar, event) : undefined, onMouseLeave: onMouseLeave, className: cx("bars__bar transition-all duration-300", disabled && "opacity-40", onMouseEnter && "cursor-pointer") })));
|
|
65
80
|
}),
|
|
66
|
-
isBelowAnchor && (React.createElement("path", { strokeWidth: 2, vectorEffect: "non-scaling-stroke", stroke: "red", className: "stroke-
|
|
81
|
+
isBelowAnchor && (React.createElement("path", { strokeWidth: 2, vectorEffect: "non-scaling-stroke", stroke: "red", className: "stroke-[#2d2d2d]", d: `M 0 ${yForValue(anchor)} L ${context.viewbox.x} ${yForValue(anchor)}` })),
|
|
67
82
|
children),
|
|
68
83
|
labels &&
|
|
69
84
|
dataset.map((bar, i) => {
|
|
@@ -82,7 +97,7 @@ export const VerticalBars = (_a) => {
|
|
|
82
97
|
return (React.createElement(overlay.div, { key: i, className: "bars__label @container-[size] absolute text-center", style: {
|
|
83
98
|
width,
|
|
84
99
|
height: Math.abs(height - (position === "above" ? 100 : 0)) + "%",
|
|
85
|
-
left:
|
|
100
|
+
left: scale(bar.x1, context.viewbox.x, 100) + "%",
|
|
86
101
|
top: top,
|
|
87
102
|
} },
|
|
88
103
|
React.createElement("div", { className: "h-full w-full relative" },
|