@fluentui/react-charts 9.3.27 → 9.3.28

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 (78) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/dist/index.d.cts +51 -0
  3. package/dist/index.d.ts +51 -0
  4. package/lib/components/AreaChart/AreaChart.js +33 -3
  5. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  6. package/lib/components/CommonComponents/CartesianChart.js +6 -0
  7. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  8. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  9. package/lib/components/CommonComponents/ChartPopover.js +2 -1
  10. package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
  11. package/lib/components/GanttChart/GanttChart.js +1 -0
  12. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  13. package/lib/components/GaugeChart/GaugeChart.js +33 -12
  14. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  15. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
  16. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +25 -25
  17. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  18. package/lib/components/HeatMapChart/HeatMapChart.js +1 -0
  19. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  20. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -1
  21. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  22. package/lib/components/Legends/Legends.js +15 -18
  23. package/lib/components/Legends/Legends.js.map +1 -1
  24. package/lib/components/Legends/OverflowMenu.js +13 -10
  25. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  26. package/lib/components/LineChart/LineChart.js +17 -13
  27. package/lib/components/LineChart/LineChart.js.map +1 -1
  28. package/lib/components/ScatterChart/ScatterChart.js +2 -1
  29. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  30. package/lib/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.js +1 -0
  31. package/lib/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.js.map +1 -1
  32. package/lib/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.js +52 -44
  33. package/lib/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.js.map +1 -1
  34. package/lib/components/VerticalBarChart/VerticalBarChart.js +2 -1
  35. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  36. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -0
  37. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  38. package/lib/types/DataPoint.js.map +1 -1
  39. package/lib/utilities/test-data/specialChartNames.js +11 -0
  40. package/lib/utilities/test-data/specialChartNames.js.map +1 -0
  41. package/lib-commonjs/components/AreaChart/AreaChart.cjs +33 -3
  42. package/lib-commonjs/components/AreaChart/AreaChart.cjs.map +1 -1
  43. package/lib-commonjs/components/CommonComponents/CartesianChart.cjs +6 -0
  44. package/lib-commonjs/components/CommonComponents/CartesianChart.cjs.map +1 -1
  45. package/lib-commonjs/components/CommonComponents/CartesianChart.types.cjs.map +1 -1
  46. package/lib-commonjs/components/CommonComponents/ChartPopover.cjs +2 -1
  47. package/lib-commonjs/components/CommonComponents/ChartPopover.cjs.map +1 -1
  48. package/lib-commonjs/components/GanttChart/GanttChart.cjs +1 -0
  49. package/lib-commonjs/components/GanttChart/GanttChart.cjs.map +1 -1
  50. package/lib-commonjs/components/GaugeChart/GaugeChart.cjs +33 -12
  51. package/lib-commonjs/components/GaugeChart/GaugeChart.cjs.map +1 -1
  52. package/lib-commonjs/components/GaugeChart/GaugeChart.types.cjs.map +1 -1
  53. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.cjs +24 -23
  54. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.cjs.map +1 -1
  55. package/lib-commonjs/components/HeatMapChart/HeatMapChart.cjs +1 -0
  56. package/lib-commonjs/components/HeatMapChart/HeatMapChart.cjs.map +1 -1
  57. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.cjs +2 -1
  58. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.cjs.map +1 -1
  59. package/lib-commonjs/components/Legends/Legends.cjs +15 -17
  60. package/lib-commonjs/components/Legends/Legends.cjs.map +1 -1
  61. package/lib-commonjs/components/Legends/OverflowMenu.cjs +12 -9
  62. package/lib-commonjs/components/Legends/OverflowMenu.cjs.map +1 -1
  63. package/lib-commonjs/components/LineChart/LineChart.cjs +17 -13
  64. package/lib-commonjs/components/LineChart/LineChart.cjs.map +1 -1
  65. package/lib-commonjs/components/ScatterChart/ScatterChart.cjs +2 -1
  66. package/lib-commonjs/components/ScatterChart/ScatterChart.cjs.map +1 -1
  67. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.cjs +1 -0
  68. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteExpressionEvaluator.cjs.map +1 -1
  69. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.cjs +52 -44
  70. package/lib-commonjs/components/VegaDeclarativeChart/VegaLiteSchemaAdapter.cjs.map +1 -1
  71. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.cjs +2 -1
  72. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.cjs.map +1 -1
  73. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.cjs +1 -0
  74. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.cjs.map +1 -1
  75. package/lib-commonjs/types/DataPoint.cjs.map +1 -1
  76. package/lib-commonjs/utilities/test-data/specialChartNames.cjs +21 -0
  77. package/lib-commonjs/utilities/test-data/specialChartNames.cjs.map +1 -0
  78. package/package.json +9 -9
@@ -89,6 +89,9 @@ const DEFAULT_TRUNCATE_CHARS = 20;
89
89
  }
90
90
  return [];
91
91
  }
92
+ function getOwnDataValue(row, field) {
93
+ return Object.prototype.hasOwnProperty.call(row, field) ? row[field] : undefined;
94
+ }
92
95
  /**
93
96
  * Applies a fold transform to convert wide-format data to long-format
94
97
  * The fold transform unpivots specified fields into key-value pairs
@@ -105,7 +108,7 @@ const DEFAULT_TRUNCATE_CHARS = 20;
105
108
  const result = [];
106
109
  for (const row of data){
107
110
  // Create a base row without the fields being folded
108
- const baseRow = {};
111
+ const baseRow = Object.create(null);
109
112
  for (const [key, value] of Object.entries(row)){
110
113
  if (!foldFields.includes(key)) {
111
114
  baseRow[key] = value;
@@ -113,7 +116,7 @@ const DEFAULT_TRUNCATE_CHARS = 20;
113
116
  }
114
117
  // Create a new row for each folded field
115
118
  for (const field of foldFields){
116
- if (field in row) {
119
+ if (Object.prototype.hasOwnProperty.call(row, field)) {
117
120
  result.push({
118
121
  ...baseRow,
119
122
  [keyField]: field,
@@ -181,19 +184,20 @@ const DEFAULT_TRUNCATE_CHARS = 20;
181
184
  const groupby = transform.groupby || [];
182
185
  const groups = new Map();
183
186
  result.forEach((row)=>{
184
- const key = groupby.map((g)=>String(row[g])).join('|');
187
+ const key = groupby.map((g)=>String(getOwnDataValue(row, g))).join('|');
185
188
  if (!groups.has(key)) {
186
189
  groups.set(key, []);
187
190
  }
188
191
  groups.get(key).push(row);
189
192
  });
190
193
  result = Array.from(groups.entries()).map(([key, rows])=>{
194
+ // Grouping fields and aggregate aliases are data keys, including "__proto__".
191
195
  const baseRow = Object.create(null);
192
196
  groupby.forEach((g, i)=>{
193
- baseRow[g] = rows[0][g];
197
+ baseRow[g] = getOwnDataValue(rows[0], g);
194
198
  });
195
199
  aggSpecs.forEach((spec)=>{
196
- const values = spec.field ? rows.map((r)=>Number(r[spec.field])).filter((v)=>!isNaN(v)) : [];
200
+ const values = spec.field ? rows.map((r)=>Number(getOwnDataValue(r, spec.field))).filter((v)=>!isNaN(v)) : [];
197
201
  switch(spec.op){
198
202
  case 'count':
199
203
  baseRow[spec.as] = rows.length;
@@ -218,7 +222,10 @@ const DEFAULT_TRUNCATE_CHARS = 20;
218
222
  baseRow[spec.as] = rows.length;
219
223
  }
220
224
  });
221
- return baseRow;
225
+ // Preserve ordinary row coercion without invoking setters for data keys.
226
+ return {
227
+ ...baseRow
228
+ };
222
229
  });
223
230
  }
224
231
  // Handle window transform
@@ -229,7 +236,7 @@ const DEFAULT_TRUNCATE_CHARS = 20;
229
236
  // Group data
230
237
  const groups = new Map();
231
238
  result.forEach((row)=>{
232
- const key = groupby.length > 0 ? groupby.map((g)=>String(row[g])).join('|') : '__all__';
239
+ const key = groupby.length > 0 ? groupby.map((g)=>String(getOwnDataValue(row, g))).join('|') : '__all__';
233
240
  if (!groups.has(key)) {
234
241
  groups.set(key, []);
235
242
  }
@@ -241,8 +248,8 @@ const DEFAULT_TRUNCATE_CHARS = 20;
241
248
  if (sortFields.length > 0) {
242
249
  rows.sort((a, b)=>{
243
250
  for (const sf of sortFields){
244
- const va = Number(a[sf.field]) || 0;
245
- const vb = Number(b[sf.field]) || 0;
251
+ const va = Number(getOwnDataValue(a, sf.field)) || 0;
252
+ const vb = Number(getOwnDataValue(b, sf.field)) || 0;
246
253
  const cmp = sf.order === 'descending' ? vb - va : va - vb;
247
254
  if (cmp !== 0) {
248
255
  return cmp;
@@ -253,13 +260,11 @@ const DEFAULT_TRUNCATE_CHARS = 20;
253
260
  }
254
261
  let runningSum = 0;
255
262
  rows.forEach((row, idx)=>{
256
- const newRow = {
257
- ...row
258
- };
263
+ const newRow = Object.assign(Object.create(null), row);
259
264
  windowOps.forEach((op)=>{
260
265
  switch(op.op){
261
266
  case 'sum':
262
- runningSum += Number(row[op.field]) || 0;
267
+ runningSum += Number(getOwnDataValue(row, op.field)) || 0;
263
268
  newRow[op.as] = runningSum;
264
269
  break;
265
270
  case 'rank':
@@ -275,7 +280,9 @@ const DEFAULT_TRUNCATE_CHARS = 20;
275
280
  newRow[op.as] = idx + 1;
276
281
  }
277
282
  });
278
- newResult.push(newRow);
283
+ newResult.push({
284
+ ...newRow
285
+ });
279
286
  });
280
287
  });
281
288
  result = newResult;
@@ -287,7 +294,7 @@ const DEFAULT_TRUNCATE_CHARS = 20;
287
294
  // Compute aggregates
288
295
  const groups = new Map();
289
296
  result.forEach((row)=>{
290
- const key = groupby.length > 0 ? groupby.map((g)=>String(row[g])).join('|') : '__all__';
297
+ const key = groupby.length > 0 ? groupby.map((g)=>String(getOwnDataValue(row, g))).join('|') : '__all__';
291
298
  if (!groups.has(key)) {
292
299
  groups.set(key, []);
293
300
  }
@@ -295,9 +302,9 @@ const DEFAULT_TRUNCATE_CHARS = 20;
295
302
  });
296
303
  const aggResults = new Map();
297
304
  groups.forEach((rows, key)=>{
298
- const aggs = {};
305
+ const aggs = Object.create(null);
299
306
  aggSpecs.forEach((spec)=>{
300
- const values = spec.field ? rows.map((r)=>Number(r[spec.field])).filter((v)=>!isNaN(v)) : [];
307
+ const values = spec.field ? rows.map((r)=>Number(getOwnDataValue(r, spec.field))).filter((v)=>!isNaN(v)) : [];
301
308
  switch(spec.op){
302
309
  case 'mean':
303
310
  case 'average':
@@ -326,7 +333,7 @@ const DEFAULT_TRUNCATE_CHARS = 20;
326
333
  });
327
334
  // Join back: add aggregate values to each row
328
335
  result = result.map((row)=>{
329
- const key = groupby.length > 0 ? groupby.map((g)=>String(row[g])).join('|') : '__all__';
336
+ const key = groupby.length > 0 ? groupby.map((g)=>String(getOwnDataValue(row, g))).join('|') : '__all__';
330
337
  return {
331
338
  ...row,
332
339
  ...aggResults.get(key) || {}
@@ -338,8 +345,8 @@ const DEFAULT_TRUNCATE_CHARS = 20;
338
345
  const yField = transform.regression;
339
346
  const xField = transform.on;
340
347
  const points = result.map((r)=>({
341
- x: Number(r[xField]),
342
- y: Number(r[yField])
348
+ x: Number(getOwnDataValue(r, xField)),
349
+ y: Number(getOwnDataValue(r, yField))
343
350
  })).filter((p)=>!isNaN(p.x) && !isNaN(p.y));
344
351
  if (points.length >= 2) {
345
352
  const n = points.length;
@@ -371,16 +378,16 @@ const DEFAULT_TRUNCATE_CHARS = 20;
371
378
  const xField = transform.on;
372
379
  const sorted = [
373
380
  ...result
374
- ].filter((r)=>!isNaN(Number(r[xField])) && !isNaN(Number(r[yField]))).sort((a, b)=>Number(a[xField]) - Number(b[xField]));
381
+ ].filter((r)=>!isNaN(Number(getOwnDataValue(r, xField))) && !isNaN(Number(getOwnDataValue(r, yField)))).sort((a, b)=>Number(getOwnDataValue(a, xField)) - Number(getOwnDataValue(b, xField)));
375
382
  const windowSize = Math.max(3, Math.floor(sorted.length / 4));
376
383
  result = sorted.map((row, i)=>{
377
384
  const start = Math.max(0, i - Math.floor(windowSize / 2));
378
385
  const end = Math.min(sorted.length, start + windowSize);
379
386
  const windowSlice = sorted.slice(start, end);
380
387
  var _d3Mean;
381
- const avgY = (_d3Mean = d3Mean(windowSlice.map((r)=>Number(r[yField])))) !== null && _d3Mean !== void 0 ? _d3Mean : Number(row[yField]);
388
+ const avgY = (_d3Mean = d3Mean(windowSlice.map((r)=>Number(getOwnDataValue(r, yField))))) !== null && _d3Mean !== void 0 ? _d3Mean : Number(getOwnDataValue(row, yField));
382
389
  return {
383
- [xField]: row[xField],
390
+ [xField]: getOwnDataValue(row, xField),
384
391
  [yField]: avgY
385
392
  };
386
393
  });
@@ -391,11 +398,11 @@ const DEFAULT_TRUNCATE_CHARS = 20;
391
398
  const groupby = transform.groupby || [];
392
399
  const groups = new Map();
393
400
  result.forEach((row)=>{
394
- const key = groupby.length > 0 ? groupby.map((g)=>String(row[g])).join('|') : '__all__';
401
+ const key = groupby.length > 0 ? groupby.map((g)=>String(getOwnDataValue(row, g))).join('|') : '__all__';
395
402
  if (!groups.has(key)) {
396
403
  groups.set(key, []);
397
404
  }
398
- groups.get(key).push(Number(row[field]));
405
+ groups.get(key).push(Number(getOwnDataValue(row, field)));
399
406
  });
400
407
  const densityResult = [];
401
408
  groups.forEach((values, key)=>{
@@ -406,11 +413,11 @@ const DEFAULT_TRUNCATE_CHARS = 20;
406
413
  const range = max - min || 1;
407
414
  const bins = 20;
408
415
  const bandwidth = range / bins;
409
- const groupFields = {};
416
+ const groupFields = Object.create(null);
410
417
  if (groupby.length > 0) {
411
- const sampleRow = result.find((r)=>groupby.map((g)=>String(r[g])).join('|') === key);
418
+ const sampleRow = result.find((r)=>groupby.map((g)=>String(getOwnDataValue(r, g))).join('|') === key);
412
419
  groupby.forEach((g)=>{
413
- groupFields[g] = sampleRow === null || sampleRow === void 0 ? void 0 : sampleRow[g];
420
+ groupFields[g] = sampleRow ? getOwnDataValue(sampleRow, g) : undefined;
414
421
  });
415
422
  }
416
423
  for(let i = 0; i <= bins; i++){
@@ -434,7 +441,7 @@ const DEFAULT_TRUNCATE_CHARS = 20;
434
441
  0.5,
435
442
  0.75
436
443
  ];
437
- const values = result.map((r)=>Number(r[field])).filter((v)=>!isNaN(v)).sort((a, b)=>a - b);
444
+ const values = result.map((r)=>Number(getOwnDataValue(r, field))).filter((v)=>!isNaN(v)).sort((a, b)=>a - b);
438
445
  if (values.length > 0) {
439
446
  result = probs.map((p)=>{
440
447
  const idx = Math.min(Math.floor(p * values.length), values.length - 1);
@@ -452,8 +459,8 @@ const DEFAULT_TRUNCATE_CHARS = 20;
452
459
  const method = transform.method || 'value';
453
460
  var _transform_value;
454
461
  const fillValue = (_transform_value = transform.value) !== null && _transform_value !== void 0 ? _transform_value : 0;
455
- const existingKeys = new Set(result.map((r)=>r[keyField]));
456
- const allKeyValues = result.map((r)=>Number(r[keyField])).filter((v)=>!isNaN(v));
462
+ const existingKeys = new Set(result.map((r)=>getOwnDataValue(r, keyField)));
463
+ const allKeyValues = result.map((r)=>Number(getOwnDataValue(r, keyField))).filter((v)=>!isNaN(v));
457
464
  if (allKeyValues.length > 0) {
458
465
  var _d3Min1;
459
466
  const minKey = (_d3Min1 = d3Min(allKeyValues)) !== null && _d3Min1 !== void 0 ? _d3Min1 : 0;
@@ -462,13 +469,13 @@ const DEFAULT_TRUNCATE_CHARS = 20;
462
469
  for(let k = minKey; k <= maxKey; k++){
463
470
  if (!existingKeys.has(k)) {
464
471
  const imputed = {
465
- [keyField]: k
472
+ [keyField]: k,
473
+ [field]: method === 'value' ? fillValue : 0
466
474
  };
467
- imputed[field] = method === 'value' ? fillValue : 0;
468
475
  result.push(imputed);
469
476
  }
470
477
  }
471
- result.sort((a, b)=>Number(a[keyField]) - Number(b[keyField]));
478
+ result.sort((a, b)=>Number(getOwnDataValue(a, keyField)) - Number(getOwnDataValue(b, keyField)));
472
479
  }
473
480
  }
474
481
  // Handle lookup transform (join with secondary dataset)
@@ -479,14 +486,14 @@ const DEFAULT_TRUNCATE_CHARS = 20;
479
486
  if (((_fromSpec_data = fromSpec.data) === null || _fromSpec_data === void 0 ? void 0 : _fromSpec_data.values) && fromSpec.key && fromSpec.fields) {
480
487
  const lookupMap = new Map();
481
488
  fromSpec.data.values.forEach((row)=>{
482
- lookupMap.set(String(row[fromSpec.key]), row);
489
+ lookupMap.set(String(getOwnDataValue(row, fromSpec.key)), row);
483
490
  });
484
491
  result = result.map((row)=>{
485
- const lookupRow = lookupMap.get(String(row[lookupField]));
492
+ const lookupRow = lookupMap.get(String(getOwnDataValue(row, lookupField)));
486
493
  if (lookupRow) {
487
- const extra = {};
494
+ const extra = Object.create(null);
488
495
  fromSpec.fields.forEach((f)=>{
489
- extra[f] = lookupRow[f];
496
+ extra[f] = getOwnDataValue(lookupRow, f);
490
497
  });
491
498
  return {
492
499
  ...row,
@@ -1027,7 +1034,7 @@ const DEFAULT_TRUNCATE_CHARS = 20;
1027
1034
  const yAgg = ((_encoding_y1 = encoding.y) === null || _encoding_y1 === void 0 ? void 0 : _encoding_y1.aggregate) || (yField ? 'mean' : 'count');
1028
1035
  const groups = new Map();
1029
1036
  dataValues.forEach((row)=>{
1030
- const dateVal = new Date(row[field]);
1037
+ const dateVal = new Date(getOwnDataValue(row, field));
1031
1038
  if (isNaN(dateVal.getTime())) {
1032
1039
  return;
1033
1040
  }
@@ -1059,17 +1066,18 @@ const DEFAULT_TRUNCATE_CHARS = 20;
1059
1066
  groups.get(key).push(row);
1060
1067
  });
1061
1068
  dataValues = Array.from(groups.entries()).map(([key, rows])=>{
1062
- const result = {
1063
- [field]: key
1064
- };
1069
+ const result = Object.create(null);
1070
+ result[field] = key;
1065
1071
  if (yField && yAgg !== 'count') {
1066
- const vals = rows.map((r)=>Number(r[yField])).filter((v)=>!isNaN(v));
1072
+ const vals = rows.map((r)=>Number(getOwnDataValue(r, yField))).filter((v)=>!isNaN(v));
1067
1073
  var _d3Mean;
1068
1074
  result[yField] = yAgg === 'sum' ? d3Sum(vals) : (_d3Mean = d3Mean(vals)) !== null && _d3Mean !== void 0 ? _d3Mean : 0;
1069
1075
  } else {
1070
1076
  result[yField || '__count'] = rows.length;
1071
1077
  }
1072
- return result;
1078
+ return {
1079
+ ...result
1080
+ };
1073
1081
  });
1074
1082
  // Switch x from temporal to ordinal since we've aggregated
1075
1083
  encoding.x.type = 'ordinal';