@opendata-ai/openchart-engine 7.2.4 → 7.3.0
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.d.ts +84 -36
- package/dist/index.js +4010 -2871
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/compile-snapshot.test.ts.snap +139 -63
- package/src/__tests__/axes.test.ts +67 -1
- package/src/__tests__/compile-chart.test.ts +6 -0
- package/src/__tests__/compile-layer.test.ts +49 -0
- package/src/__tests__/dimensions.test.ts +7 -2
- package/src/__tests__/helpers/invariants.ts +267 -0
- package/src/__tests__/known-bugs.test.ts +113 -0
- package/src/__tests__/layout-fuzz.test.ts +342 -0
- package/src/__tests__/layout-invariants.test.ts +533 -0
- package/src/__tests__/legend.test.ts +37 -0
- package/src/annotations/__tests__/compute.test.ts +8 -15
- package/src/annotations/__tests__/placement-fuzz.test.ts +256 -0
- package/src/annotations/__tests__/placement-invariants.test.ts +345 -0
- package/src/annotations/__tests__/placement.test.ts +316 -0
- package/src/annotations/collisions.ts +19 -7
- package/src/annotations/compute.ts +257 -16
- package/src/annotations/geometry.ts +73 -15
- package/src/annotations/placement.ts +588 -0
- package/src/annotations/resolve-text.ts +58 -10
- package/src/charts/__tests__/post-process.test.ts +3 -3
- package/src/charts/post-process.ts +21 -7
- package/src/compile/layer.ts +31 -9
- package/src/compile.ts +85 -148
- package/src/index.ts +9 -0
- package/src/layout/axes.ts +93 -1
- package/src/layout/dimensions.ts +80 -98
- package/src/layout/plan.ts +524 -0
- package/src/layout/shared.ts +44 -0
- package/src/legend/compute.ts +315 -78
- package/src/legend/wrap.ts +11 -7
- package/src/sankey/__tests__/node-label-wrap.test.ts +2 -2
- package/src/tables/__tests__/heatmap.test.ts +24 -20
- package/src/tables/heatmap.ts +25 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendata-ai/openchart-engine",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Headless compiler for openchart: spec validation, data compilation, scales, and layout",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Riley Hilliard",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@opendata-ai/openchart-core": "7.
|
|
51
|
+
"@opendata-ai/openchart-core": "7.3.0",
|
|
52
52
|
"d3-array": "^3.2.0",
|
|
53
53
|
"d3-format": "^3.1.2",
|
|
54
54
|
"d3-interpolate": "^3.0.0",
|
|
@@ -37,8 +37,8 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
37
37
|
"annotations": [],
|
|
38
38
|
"area": {
|
|
39
39
|
"height": 296.1,
|
|
40
|
-
"width":
|
|
41
|
-
"x":
|
|
40
|
+
"width": 540.058,
|
|
41
|
+
"x": 36.942,
|
|
42
42
|
"y": 60.9,
|
|
43
43
|
},
|
|
44
44
|
"axes": {
|
|
@@ -48,6 +48,7 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
48
48
|
"x": 577,
|
|
49
49
|
"y": 357,
|
|
50
50
|
},
|
|
51
|
+
"extent": 26,
|
|
51
52
|
"gridlines": [],
|
|
52
53
|
"label": undefined,
|
|
53
54
|
"labelFlush": undefined,
|
|
@@ -63,7 +64,7 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
63
64
|
"offset": undefined,
|
|
64
65
|
"orient": undefined,
|
|
65
66
|
"start": {
|
|
66
|
-
"x":
|
|
67
|
+
"x": 36.942,
|
|
67
68
|
"y": 357,
|
|
68
69
|
},
|
|
69
70
|
"tickAngle": undefined,
|
|
@@ -80,17 +81,17 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
80
81
|
"ticks": [
|
|
81
82
|
{
|
|
82
83
|
"label": "0",
|
|
83
|
-
"position":
|
|
84
|
+
"position": 36.942,
|
|
84
85
|
"value": 0,
|
|
85
86
|
},
|
|
86
87
|
{
|
|
87
88
|
"label": "20",
|
|
88
|
-
"position":
|
|
89
|
+
"position": 252.9652,
|
|
89
90
|
"value": 20,
|
|
90
91
|
},
|
|
91
92
|
{
|
|
92
93
|
"label": "40",
|
|
93
|
-
"position": 468.
|
|
94
|
+
"position": 468.9884,
|
|
94
95
|
"value": 40,
|
|
95
96
|
},
|
|
96
97
|
],
|
|
@@ -99,7 +100,7 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
99
100
|
"y": {
|
|
100
101
|
"domainLine": undefined,
|
|
101
102
|
"end": {
|
|
102
|
-
"x":
|
|
103
|
+
"x": 36.942,
|
|
103
104
|
"y": 357,
|
|
104
105
|
},
|
|
105
106
|
"gridlines": [
|
|
@@ -130,7 +131,7 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
130
131
|
"offset": undefined,
|
|
131
132
|
"orient": undefined,
|
|
132
133
|
"start": {
|
|
133
|
-
"x":
|
|
134
|
+
"x": 36.942,
|
|
134
135
|
"y": 60.9,
|
|
135
136
|
},
|
|
136
137
|
"tickAngle": undefined,
|
|
@@ -165,6 +166,7 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
165
166
|
},
|
|
166
167
|
},
|
|
167
168
|
"chrome": {
|
|
169
|
+
"bottomAnchorY": 383,
|
|
168
170
|
"bottomHeight": 0,
|
|
169
171
|
"title": {
|
|
170
172
|
"maxWidth": 561,
|
|
@@ -236,13 +238,13 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
236
238
|
},
|
|
237
239
|
"text": "10",
|
|
238
240
|
"visible": true,
|
|
239
|
-
"x":
|
|
241
|
+
"x": 138.9536,
|
|
240
242
|
"y": 297.33805970149257,
|
|
241
243
|
},
|
|
242
244
|
"orient": "horizontal",
|
|
243
245
|
"type": "rect",
|
|
244
|
-
"width": 108.
|
|
245
|
-
"x":
|
|
246
|
+
"width": 108.01159999999999,
|
|
247
|
+
"x": 36.942,
|
|
246
248
|
"y": 268.6119402985075,
|
|
247
249
|
},
|
|
248
250
|
{
|
|
@@ -269,13 +271,13 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
269
271
|
},
|
|
270
272
|
"text": "25",
|
|
271
273
|
"visible": true,
|
|
272
|
-
"x": 300.
|
|
274
|
+
"x": 300.971,
|
|
273
275
|
"y": 208.95000000000002,
|
|
274
276
|
},
|
|
275
277
|
"orient": "horizontal",
|
|
276
278
|
"type": "rect",
|
|
277
|
-
"width": 270.
|
|
278
|
-
"x":
|
|
279
|
+
"width": 270.029,
|
|
280
|
+
"x": 36.942,
|
|
279
281
|
"y": 180.22388059701493,
|
|
280
282
|
},
|
|
281
283
|
{
|
|
@@ -302,13 +304,13 @@ exports[`compileChart snapshot (Step 7 oracle) > clipped-domain bar chart (data
|
|
|
302
304
|
},
|
|
303
305
|
"text": "40",
|
|
304
306
|
"visible": true,
|
|
305
|
-
"x": 462.
|
|
307
|
+
"x": 462.9884,
|
|
306
308
|
"y": 120.56194029850745,
|
|
307
309
|
},
|
|
308
310
|
"orient": "horizontal",
|
|
309
311
|
"type": "rect",
|
|
310
|
-
"width":
|
|
311
|
-
"x":
|
|
312
|
+
"width": 432.0464,
|
|
313
|
+
"x": 36.942,
|
|
312
314
|
"y": 91.83582089552237,
|
|
313
315
|
},
|
|
314
316
|
],
|
|
@@ -582,7 +584,7 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
582
584
|
"annotations": [],
|
|
583
585
|
"area": {
|
|
584
586
|
"height": 305.4,
|
|
585
|
-
"width":
|
|
587
|
+
"width": 625.76115,
|
|
586
588
|
"x": 26,
|
|
587
589
|
"y": 105.2,
|
|
588
590
|
},
|
|
@@ -711,6 +713,7 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
711
713
|
},
|
|
712
714
|
},
|
|
713
715
|
"chrome": {
|
|
716
|
+
"bottomAnchorY": 436.59999999999997,
|
|
714
717
|
"bottomHeight": 43.4,
|
|
715
718
|
"source": {
|
|
716
719
|
"maxWidth": 755,
|
|
@@ -768,8 +771,8 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
768
771
|
"endpointLabels": {
|
|
769
772
|
"bounds": {
|
|
770
773
|
"height": 305.4,
|
|
771
|
-
"width":
|
|
772
|
-
"x":
|
|
774
|
+
"width": 48.95985,
|
|
775
|
+
"x": 669.76115,
|
|
773
776
|
"y": 105.2,
|
|
774
777
|
},
|
|
775
778
|
"entries": [
|
|
@@ -781,12 +784,12 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
781
784
|
],
|
|
782
785
|
"labelY": 105.2,
|
|
783
786
|
"marker": {
|
|
784
|
-
"dataX":
|
|
787
|
+
"dataX": 651.76115,
|
|
785
788
|
"fill": "transparent",
|
|
786
789
|
"radius": 4,
|
|
787
790
|
"stroke": "#06b6d4",
|
|
788
791
|
"strokeWidth": 2,
|
|
789
|
-
"x":
|
|
792
|
+
"x": 655.76115,
|
|
790
793
|
"y": 105.2,
|
|
791
794
|
},
|
|
792
795
|
"seriesKey": "US",
|
|
@@ -801,12 +804,12 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
801
804
|
],
|
|
802
805
|
"labelY": 139.95,
|
|
803
806
|
"marker": {
|
|
804
|
-
"dataX":
|
|
807
|
+
"dataX": 651.76115,
|
|
805
808
|
"fill": "transparent",
|
|
806
809
|
"radius": 4,
|
|
807
810
|
"stroke": "#ee4a73",
|
|
808
811
|
"strokeWidth": 2,
|
|
809
|
-
"x":
|
|
812
|
+
"x": 655.76115,
|
|
810
813
|
"y": 143.375,
|
|
811
814
|
},
|
|
812
815
|
"seriesKey": "UK",
|
|
@@ -821,12 +824,12 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
821
824
|
],
|
|
822
825
|
"labelY": 236.12999999999997,
|
|
823
826
|
"marker": {
|
|
824
|
-
"dataX":
|
|
827
|
+
"dataX": 651.76115,
|
|
825
828
|
"fill": "transparent",
|
|
826
829
|
"radius": 4,
|
|
827
830
|
"stroke": "#00b054",
|
|
828
831
|
"strokeWidth": 2,
|
|
829
|
-
"x":
|
|
832
|
+
"x": 655.76115,
|
|
830
833
|
"y": 242.62999999999997,
|
|
831
834
|
},
|
|
832
835
|
"seriesKey": "FR",
|
|
@@ -841,12 +844,12 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
841
844
|
],
|
|
842
845
|
"labelY": 190.32,
|
|
843
846
|
"marker": {
|
|
844
|
-
"dataX":
|
|
847
|
+
"dataX": 651.76115,
|
|
845
848
|
"fill": "transparent",
|
|
846
849
|
"radius": 4,
|
|
847
850
|
"stroke": "#a46bf5",
|
|
848
851
|
"strokeWidth": 2,
|
|
849
|
-
"x":
|
|
852
|
+
"x": 655.76115,
|
|
850
853
|
"y": 196.82,
|
|
851
854
|
},
|
|
852
855
|
"seriesKey": "DE",
|
|
@@ -876,8 +879,8 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
876
879
|
"legend": {
|
|
877
880
|
"bounds": {
|
|
878
881
|
"height": 85.2,
|
|
879
|
-
"width":
|
|
880
|
-
"x":
|
|
882
|
+
"width": 49.278999999999996,
|
|
883
|
+
"x": 659.76115,
|
|
881
884
|
"y": 105.2,
|
|
882
885
|
},
|
|
883
886
|
"entries": [
|
|
@@ -907,6 +910,40 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
907
910
|
},
|
|
908
911
|
],
|
|
909
912
|
"entryGap": 4,
|
|
913
|
+
"entryPositions": [
|
|
914
|
+
{
|
|
915
|
+
"labelX": 677.76115,
|
|
916
|
+
"labelY": 111.2,
|
|
917
|
+
"row": 0,
|
|
918
|
+
"width": 37.278999999999996,
|
|
919
|
+
"x": 659.76115,
|
|
920
|
+
"y": 105.2,
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
"labelX": 677.76115,
|
|
924
|
+
"labelY": 129.5,
|
|
925
|
+
"row": 1,
|
|
926
|
+
"width": 37.278999999999996,
|
|
927
|
+
"x": 659.76115,
|
|
928
|
+
"y": 123.5,
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
"labelX": 677.76115,
|
|
932
|
+
"labelY": 147.8,
|
|
933
|
+
"row": 2,
|
|
934
|
+
"width": 36.663,
|
|
935
|
+
"x": 659.76115,
|
|
936
|
+
"y": 141.8,
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"labelX": 677.76115,
|
|
940
|
+
"labelY": 166.10000000000002,
|
|
941
|
+
"row": 3,
|
|
942
|
+
"width": 37.278999999999996,
|
|
943
|
+
"x": 659.76115,
|
|
944
|
+
"y": 160.10000000000002,
|
|
945
|
+
},
|
|
946
|
+
],
|
|
910
947
|
"labelStyle": {
|
|
911
948
|
"fill": "#09090b",
|
|
912
949
|
"fontFamily": ""Inter Variable", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif",
|
|
@@ -915,6 +952,7 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
915
952
|
"lineHeight": 1.3,
|
|
916
953
|
},
|
|
917
954
|
"position": "right",
|
|
955
|
+
"rowHeight": 18.3,
|
|
918
956
|
"swatchChipFill": "rgba(0,0,0,0.04)",
|
|
919
957
|
"swatchGap": 6,
|
|
920
958
|
"swatchSize": 12,
|
|
@@ -991,19 +1029,19 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
991
1029
|
],
|
|
992
1030
|
"title": "2021",
|
|
993
1031
|
},
|
|
994
|
-
"x":
|
|
1032
|
+
"x": 651.76115,
|
|
995
1033
|
"y": 105.2,
|
|
996
1034
|
},
|
|
997
1035
|
],
|
|
998
1036
|
"opacity": undefined,
|
|
999
|
-
"path": "M47,334.
|
|
1037
|
+
"path": "M47,334.25L651.761,105.2",
|
|
1000
1038
|
"points": [
|
|
1001
1039
|
{
|
|
1002
1040
|
"x": 47,
|
|
1003
1041
|
"y": 334.25,
|
|
1004
1042
|
},
|
|
1005
1043
|
{
|
|
1006
|
-
"x":
|
|
1044
|
+
"x": 651.76115,
|
|
1007
1045
|
"y": 105.2,
|
|
1008
1046
|
},
|
|
1009
1047
|
],
|
|
@@ -1083,19 +1121,19 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
1083
1121
|
],
|
|
1084
1122
|
"title": "2021",
|
|
1085
1123
|
},
|
|
1086
|
-
"x":
|
|
1124
|
+
"x": 651.76115,
|
|
1087
1125
|
"y": 143.375,
|
|
1088
1126
|
},
|
|
1089
1127
|
],
|
|
1090
1128
|
"opacity": undefined,
|
|
1091
|
-
"path": "M47,296.
|
|
1129
|
+
"path": "M47,296.075L651.761,143.375",
|
|
1092
1130
|
"points": [
|
|
1093
1131
|
{
|
|
1094
1132
|
"x": 47,
|
|
1095
1133
|
"y": 296.075,
|
|
1096
1134
|
},
|
|
1097
1135
|
{
|
|
1098
|
-
"x":
|
|
1136
|
+
"x": 651.76115,
|
|
1099
1137
|
"y": 143.375,
|
|
1100
1138
|
},
|
|
1101
1139
|
],
|
|
@@ -1175,19 +1213,19 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
1175
1213
|
],
|
|
1176
1214
|
"title": "2021",
|
|
1177
1215
|
},
|
|
1178
|
-
"x":
|
|
1216
|
+
"x": 651.76115,
|
|
1179
1217
|
"y": 242.62999999999997,
|
|
1180
1218
|
},
|
|
1181
1219
|
],
|
|
1182
1220
|
"opacity": undefined,
|
|
1183
|
-
"path": "M47,349.
|
|
1221
|
+
"path": "M47,349.52L651.761,242.63",
|
|
1184
1222
|
"points": [
|
|
1185
1223
|
{
|
|
1186
1224
|
"x": 47,
|
|
1187
1225
|
"y": 349.52000000000004,
|
|
1188
1226
|
},
|
|
1189
1227
|
{
|
|
1190
|
-
"x":
|
|
1228
|
+
"x": 651.76115,
|
|
1191
1229
|
"y": 242.62999999999997,
|
|
1192
1230
|
},
|
|
1193
1231
|
],
|
|
@@ -1267,19 +1305,19 @@ exports[`compileChart snapshot (Step 7 oracle) > legend-heavy multi-series line
|
|
|
1267
1305
|
],
|
|
1268
1306
|
"title": "2021",
|
|
1269
1307
|
},
|
|
1270
|
-
"x":
|
|
1308
|
+
"x": 651.76115,
|
|
1271
1309
|
"y": 196.82,
|
|
1272
1310
|
},
|
|
1273
1311
|
],
|
|
1274
1312
|
"opacity": undefined,
|
|
1275
|
-
"path": "M47,318.
|
|
1313
|
+
"path": "M47,318.98L651.761,196.82",
|
|
1276
1314
|
"points": [
|
|
1277
1315
|
{
|
|
1278
1316
|
"x": 47,
|
|
1279
1317
|
"y": 318.97999999999996,
|
|
1280
1318
|
},
|
|
1281
1319
|
{
|
|
1282
|
-
"x":
|
|
1320
|
+
"x": 651.76115,
|
|
1283
1321
|
"y": 196.82,
|
|
1284
1322
|
},
|
|
1285
1323
|
],
|
|
@@ -1483,8 +1521,8 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1483
1521
|
"annotations": [],
|
|
1484
1522
|
"area": {
|
|
1485
1523
|
"height": 236.3,
|
|
1486
|
-
"width":
|
|
1487
|
-
"x":
|
|
1524
|
+
"width": 537.768,
|
|
1525
|
+
"x": 39.232,
|
|
1488
1526
|
"y": 60.9,
|
|
1489
1527
|
},
|
|
1490
1528
|
"axes": {
|
|
@@ -1494,6 +1532,7 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1494
1532
|
"x": 577,
|
|
1495
1533
|
"y": 297.2,
|
|
1496
1534
|
},
|
|
1535
|
+
"extent": 26,
|
|
1497
1536
|
"gridlines": [],
|
|
1498
1537
|
"label": undefined,
|
|
1499
1538
|
"labelFlush": undefined,
|
|
@@ -1509,7 +1548,7 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1509
1548
|
"offset": undefined,
|
|
1510
1549
|
"orient": undefined,
|
|
1511
1550
|
"start": {
|
|
1512
|
-
"x":
|
|
1551
|
+
"x": 39.232,
|
|
1513
1552
|
"y": 297.2,
|
|
1514
1553
|
},
|
|
1515
1554
|
"tickAngle": undefined,
|
|
@@ -1526,22 +1565,22 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1526
1565
|
"ticks": [
|
|
1527
1566
|
{
|
|
1528
1567
|
"label": "A",
|
|
1529
|
-
"position":
|
|
1568
|
+
"position": 122.67875862068962,
|
|
1530
1569
|
"value": "A",
|
|
1531
1570
|
},
|
|
1532
1571
|
{
|
|
1533
1572
|
"label": "B",
|
|
1534
|
-
"position":
|
|
1573
|
+
"position": 246.30358620689654,
|
|
1535
1574
|
"value": "B",
|
|
1536
1575
|
},
|
|
1537
1576
|
{
|
|
1538
1577
|
"label": "C",
|
|
1539
|
-
"position":
|
|
1578
|
+
"position": 369.92841379310346,
|
|
1540
1579
|
"value": "C",
|
|
1541
1580
|
},
|
|
1542
1581
|
{
|
|
1543
1582
|
"label": "D",
|
|
1544
|
-
"position": 493.
|
|
1583
|
+
"position": 493.55324137931035,
|
|
1545
1584
|
"value": "D",
|
|
1546
1585
|
},
|
|
1547
1586
|
],
|
|
@@ -1550,7 +1589,7 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1550
1589
|
"y": {
|
|
1551
1590
|
"domainLine": undefined,
|
|
1552
1591
|
"end": {
|
|
1553
|
-
"x":
|
|
1592
|
+
"x": 39.232,
|
|
1554
1593
|
"y": 297.2,
|
|
1555
1594
|
},
|
|
1556
1595
|
"gridlines": [
|
|
@@ -1558,18 +1597,34 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1558
1597
|
"major": true,
|
|
1559
1598
|
"position": 297.2,
|
|
1560
1599
|
},
|
|
1600
|
+
{
|
|
1601
|
+
"major": true,
|
|
1602
|
+
"position": 263.4428571428572,
|
|
1603
|
+
},
|
|
1561
1604
|
{
|
|
1562
1605
|
"major": true,
|
|
1563
1606
|
"position": 229.68571428571428,
|
|
1564
1607
|
},
|
|
1608
|
+
{
|
|
1609
|
+
"major": true,
|
|
1610
|
+
"position": 195.92857142857142,
|
|
1611
|
+
},
|
|
1565
1612
|
{
|
|
1566
1613
|
"major": true,
|
|
1567
1614
|
"position": 162.17142857142858,
|
|
1568
1615
|
},
|
|
1616
|
+
{
|
|
1617
|
+
"major": true,
|
|
1618
|
+
"position": 128.4142857142857,
|
|
1619
|
+
},
|
|
1569
1620
|
{
|
|
1570
1621
|
"major": true,
|
|
1571
1622
|
"position": 94.65714285714287,
|
|
1572
1623
|
},
|
|
1624
|
+
{
|
|
1625
|
+
"major": true,
|
|
1626
|
+
"position": 60.9,
|
|
1627
|
+
},
|
|
1573
1628
|
],
|
|
1574
1629
|
"label": undefined,
|
|
1575
1630
|
"labelFlush": undefined,
|
|
@@ -1585,7 +1640,7 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1585
1640
|
"offset": undefined,
|
|
1586
1641
|
"orient": undefined,
|
|
1587
1642
|
"start": {
|
|
1588
|
-
"x":
|
|
1643
|
+
"x": 39.232,
|
|
1589
1644
|
"y": 60.9,
|
|
1590
1645
|
},
|
|
1591
1646
|
"tickAngle": undefined,
|
|
@@ -1605,26 +1660,47 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1605
1660
|
"position": 297.2,
|
|
1606
1661
|
"value": 0,
|
|
1607
1662
|
},
|
|
1663
|
+
{
|
|
1664
|
+
"label": "10",
|
|
1665
|
+
"position": 263.4428571428572,
|
|
1666
|
+
"value": 10,
|
|
1667
|
+
},
|
|
1608
1668
|
{
|
|
1609
1669
|
"label": "20",
|
|
1610
1670
|
"position": 229.68571428571428,
|
|
1611
1671
|
"value": 20,
|
|
1612
1672
|
},
|
|
1673
|
+
{
|
|
1674
|
+
"label": "30",
|
|
1675
|
+
"position": 195.92857142857142,
|
|
1676
|
+
"value": 30,
|
|
1677
|
+
},
|
|
1613
1678
|
{
|
|
1614
1679
|
"label": "40",
|
|
1615
1680
|
"position": 162.17142857142858,
|
|
1616
1681
|
"value": 40,
|
|
1617
1682
|
},
|
|
1683
|
+
{
|
|
1684
|
+
"label": "50",
|
|
1685
|
+
"position": 128.4142857142857,
|
|
1686
|
+
"value": 50,
|
|
1687
|
+
},
|
|
1618
1688
|
{
|
|
1619
1689
|
"label": "60",
|
|
1620
1690
|
"position": 94.65714285714287,
|
|
1621
1691
|
"value": 60,
|
|
1622
1692
|
},
|
|
1693
|
+
{
|
|
1694
|
+
"label": "70",
|
|
1695
|
+
"position": 60.9,
|
|
1696
|
+
"value": 70,
|
|
1697
|
+
},
|
|
1623
1698
|
],
|
|
1624
1699
|
"titlePadding": undefined,
|
|
1625
1700
|
},
|
|
1626
1701
|
},
|
|
1627
1702
|
"chrome": {
|
|
1703
|
+
"bottomAnchorY": 323.2,
|
|
1628
1704
|
"bottomHeight": 59.8,
|
|
1629
1705
|
"byline": {
|
|
1630
1706
|
"maxWidth": 431,
|
|
@@ -1738,13 +1814,13 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1738
1814
|
},
|
|
1739
1815
|
"text": "30",
|
|
1740
1816
|
"visible": true,
|
|
1741
|
-
"x":
|
|
1817
|
+
"x": 122.67875862068962,
|
|
1742
1818
|
"y": 175.92857142857142,
|
|
1743
1819
|
},
|
|
1744
1820
|
"orient": "vertical",
|
|
1745
1821
|
"type": "rect",
|
|
1746
|
-
"width": 80.
|
|
1747
|
-
"x":
|
|
1822
|
+
"width": 80.3561379310345,
|
|
1823
|
+
"x": 82.50068965517238,
|
|
1748
1824
|
"y": 195.92857142857142,
|
|
1749
1825
|
},
|
|
1750
1826
|
{
|
|
@@ -1783,13 +1859,13 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1783
1859
|
},
|
|
1784
1860
|
"text": "55",
|
|
1785
1861
|
"visible": true,
|
|
1786
|
-
"x":
|
|
1862
|
+
"x": 246.30358620689654,
|
|
1787
1863
|
"y": 91.53571428571429,
|
|
1788
1864
|
},
|
|
1789
1865
|
"orient": "vertical",
|
|
1790
1866
|
"type": "rect",
|
|
1791
|
-
"width": 80.
|
|
1792
|
-
"x":
|
|
1867
|
+
"width": 80.3561379310345,
|
|
1868
|
+
"x": 206.1255172413793,
|
|
1793
1869
|
"y": 111.53571428571429,
|
|
1794
1870
|
},
|
|
1795
1871
|
{
|
|
@@ -1828,13 +1904,13 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1828
1904
|
},
|
|
1829
1905
|
"text": "70",
|
|
1830
1906
|
"visible": true,
|
|
1831
|
-
"x":
|
|
1907
|
+
"x": 369.92841379310346,
|
|
1832
1908
|
"y": 40.9,
|
|
1833
1909
|
},
|
|
1834
1910
|
"orient": "vertical",
|
|
1835
1911
|
"type": "rect",
|
|
1836
|
-
"width": 80.
|
|
1837
|
-
"x":
|
|
1912
|
+
"width": 80.3561379310345,
|
|
1913
|
+
"x": 329.7503448275862,
|
|
1838
1914
|
"y": 60.9,
|
|
1839
1915
|
},
|
|
1840
1916
|
{
|
|
@@ -1873,13 +1949,13 @@ exports[`compileChart snapshot (Step 7 oracle) > watermarked column chart with g
|
|
|
1873
1949
|
},
|
|
1874
1950
|
"text": "45",
|
|
1875
1951
|
"visible": true,
|
|
1876
|
-
"x": 493.
|
|
1952
|
+
"x": 493.55324137931035,
|
|
1877
1953
|
"y": 125.29285714285712,
|
|
1878
1954
|
},
|
|
1879
1955
|
"orient": "vertical",
|
|
1880
1956
|
"type": "rect",
|
|
1881
|
-
"width": 80.
|
|
1882
|
-
"x": 453.
|
|
1957
|
+
"width": 80.3561379310345,
|
|
1958
|
+
"x": 453.3751724137931,
|
|
1883
1959
|
"y": 145.29285714285712,
|
|
1884
1960
|
},
|
|
1885
1961
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxisTick, LayoutStrategy } from '@opendata-ai/openchart-core';
|
|
1
|
+
import type { AxisTick, Encoding, LayoutStrategy } from '@opendata-ai/openchart-core';
|
|
2
2
|
import { resolveTheme } from '@opendata-ai/openchart-core';
|
|
3
3
|
import { scaleLinear, scaleLog } from 'd3-scale';
|
|
4
4
|
import { describe, expect, it } from 'vitest';
|
|
@@ -1057,3 +1057,69 @@ describe('axis tickPosition', () => {
|
|
|
1057
1057
|
expect(axes.y!.tickPosition).toBe('gutter');
|
|
1058
1058
|
});
|
|
1059
1059
|
});
|
|
1060
|
+
|
|
1061
|
+
describe('axis extent and titlePosition', () => {
|
|
1062
|
+
it('emits x-axis extent for a basic line chart', () => {
|
|
1063
|
+
const scales = computeScales(lineSpec, chartArea, lineSpec.data);
|
|
1064
|
+
const axes = computeAxes(scales, chartArea, fullStrategy, theme);
|
|
1065
|
+
|
|
1066
|
+
expect(axes.x!.extent).toBeGreaterThan(0);
|
|
1067
|
+
expect(axes.x!.extent).toBeLessThan(200);
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
it('extent is larger when axis has a title', () => {
|
|
1071
|
+
const specWithTitle: NormalizedChartSpec = {
|
|
1072
|
+
...lineSpec,
|
|
1073
|
+
encoding: {
|
|
1074
|
+
...lineSpec.encoding,
|
|
1075
|
+
x: { ...lineSpec.encoding.x, axis: { title: 'Year' } },
|
|
1076
|
+
},
|
|
1077
|
+
};
|
|
1078
|
+
const scales = computeScales(specWithTitle, chartArea, specWithTitle.data);
|
|
1079
|
+
const axesWithTitle = computeAxes(scales, chartArea, fullStrategy, theme);
|
|
1080
|
+
|
|
1081
|
+
const scalesNoTitle = computeScales(lineSpec, chartArea, lineSpec.data);
|
|
1082
|
+
const axesNoTitle = computeAxes(scalesNoTitle, chartArea, fullStrategy, theme);
|
|
1083
|
+
|
|
1084
|
+
expect(axesWithTitle.x!.extent).toBeGreaterThan(axesNoTitle.x!.extent!);
|
|
1085
|
+
});
|
|
1086
|
+
|
|
1087
|
+
it('emits titlePosition for x-axis with title', () => {
|
|
1088
|
+
const specWithTitle: NormalizedChartSpec = {
|
|
1089
|
+
...lineSpec,
|
|
1090
|
+
encoding: {
|
|
1091
|
+
...lineSpec.encoding,
|
|
1092
|
+
x: { ...lineSpec.encoding.x, axis: { title: 'Year' } },
|
|
1093
|
+
},
|
|
1094
|
+
};
|
|
1095
|
+
const scales = computeScales(specWithTitle, chartArea, specWithTitle.data);
|
|
1096
|
+
const axes = computeAxes(scales, chartArea, fullStrategy, theme);
|
|
1097
|
+
|
|
1098
|
+
expect(axes.x!.titlePosition).toBeDefined();
|
|
1099
|
+
expect(axes.x!.titlePosition!.x).toBeCloseTo(chartArea.x + chartArea.width / 2, 0);
|
|
1100
|
+
expect(axes.x!.titlePosition!.y).toBeGreaterThan(chartArea.y + chartArea.height);
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
it('emits titlePosition for y-axis with title', () => {
|
|
1104
|
+
const specWithYTitle: NormalizedChartSpec = {
|
|
1105
|
+
...lineSpec,
|
|
1106
|
+
encoding: {
|
|
1107
|
+
...lineSpec.encoding,
|
|
1108
|
+
y: { ...lineSpec.encoding.y, axis: { title: 'Value' } },
|
|
1109
|
+
},
|
|
1110
|
+
};
|
|
1111
|
+
const scales = computeScales(specWithYTitle, chartArea, specWithYTitle.data);
|
|
1112
|
+
const axes = computeAxes(scales, chartArea, fullStrategy, theme, undefined, {
|
|
1113
|
+
data: specWithYTitle.data,
|
|
1114
|
+
encoding: specWithYTitle.encoding as Encoding,
|
|
1115
|
+
skipX: false,
|
|
1116
|
+
skipY: false,
|
|
1117
|
+
markType: 'line',
|
|
1118
|
+
totalWidth: 600,
|
|
1119
|
+
});
|
|
1120
|
+
|
|
1121
|
+
expect(axes.y!.titlePosition).toBeDefined();
|
|
1122
|
+
expect(axes.y!.titlePosition!.x).toBeLessThan(chartArea.x);
|
|
1123
|
+
expect(axes.y!.titlePosition!.angle).toBe(-90);
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
@@ -123,6 +123,12 @@ describe('compileChart', () => {
|
|
|
123
123
|
expect(layout.chrome.source!.style.fontSize).toBeGreaterThan(0);
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
it('emits bottomAnchorY below the chart area', () => {
|
|
127
|
+
const layout = compileChart(lineSpec, { width: 600, height: 400 });
|
|
128
|
+
expect(layout.chrome.bottomAnchorY).toBeDefined();
|
|
129
|
+
expect(layout.chrome.bottomAnchorY).toBeGreaterThanOrEqual(layout.area.y + layout.area.height);
|
|
130
|
+
});
|
|
131
|
+
|
|
126
132
|
it('has axes with ticks and valid positions for a line chart', () => {
|
|
127
133
|
const layout = compileChart(lineSpec, { width: 600, height: 400 });
|
|
128
134
|
|