@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
@@ -147,6 +147,9 @@ function getMarkType(mark) {
147
147
  }
148
148
  return [];
149
149
  }
150
+ function getOwnDataValue(row, field) {
151
+ return Object.prototype.hasOwnProperty.call(row, field) ? row[field] : undefined;
152
+ }
150
153
  /**
151
154
  * Applies a fold transform to convert wide-format data to long-format
152
155
  * The fold transform unpivots specified fields into key-value pairs
@@ -163,7 +166,7 @@ function getMarkType(mark) {
163
166
  const result = [];
164
167
  for (const row of data){
165
168
  // Create a base row without the fields being folded
166
- const baseRow = {};
169
+ const baseRow = Object.create(null);
167
170
  for (const [key, value] of Object.entries(row)){
168
171
  if (!foldFields.includes(key)) {
169
172
  baseRow[key] = value;
@@ -171,7 +174,7 @@ function getMarkType(mark) {
171
174
  }
172
175
  // Create a new row for each folded field
173
176
  for (const field of foldFields){
174
- if (field in row) {
177
+ if (Object.prototype.hasOwnProperty.call(row, field)) {
175
178
  result.push({
176
179
  ...baseRow,
177
180
  [keyField]: field,
@@ -239,19 +242,20 @@ function getMarkType(mark) {
239
242
  const groupby = transform.groupby || [];
240
243
  const groups = new Map();
241
244
  result.forEach((row)=>{
242
- const key = groupby.map((g)=>String(row[g])).join('|');
245
+ const key = groupby.map((g)=>String(getOwnDataValue(row, g))).join('|');
243
246
  if (!groups.has(key)) {
244
247
  groups.set(key, []);
245
248
  }
246
249
  groups.get(key).push(row);
247
250
  });
248
251
  result = Array.from(groups.entries()).map(([key, rows])=>{
252
+ // Grouping fields and aggregate aliases are data keys, including "__proto__".
249
253
  const baseRow = Object.create(null);
250
254
  groupby.forEach((g, i)=>{
251
- baseRow[g] = rows[0][g];
255
+ baseRow[g] = getOwnDataValue(rows[0], g);
252
256
  });
253
257
  aggSpecs.forEach((spec)=>{
254
- const values = spec.field ? rows.map((r)=>Number(r[spec.field])).filter((v)=>!isNaN(v)) : [];
258
+ const values = spec.field ? rows.map((r)=>Number(getOwnDataValue(r, spec.field))).filter((v)=>!isNaN(v)) : [];
255
259
  switch(spec.op){
256
260
  case 'count':
257
261
  baseRow[spec.as] = rows.length;
@@ -276,7 +280,10 @@ function getMarkType(mark) {
276
280
  baseRow[spec.as] = rows.length;
277
281
  }
278
282
  });
279
- return baseRow;
283
+ // Preserve ordinary row coercion without invoking setters for data keys.
284
+ return {
285
+ ...baseRow
286
+ };
280
287
  });
281
288
  }
282
289
  // Handle window transform
@@ -287,7 +294,7 @@ function getMarkType(mark) {
287
294
  // Group data
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
  }
@@ -299,8 +306,8 @@ function getMarkType(mark) {
299
306
  if (sortFields.length > 0) {
300
307
  rows.sort((a, b)=>{
301
308
  for (const sf of sortFields){
302
- const va = Number(a[sf.field]) || 0;
303
- const vb = Number(b[sf.field]) || 0;
309
+ const va = Number(getOwnDataValue(a, sf.field)) || 0;
310
+ const vb = Number(getOwnDataValue(b, sf.field)) || 0;
304
311
  const cmp = sf.order === 'descending' ? vb - va : va - vb;
305
312
  if (cmp !== 0) {
306
313
  return cmp;
@@ -311,13 +318,11 @@ function getMarkType(mark) {
311
318
  }
312
319
  let runningSum = 0;
313
320
  rows.forEach((row, idx)=>{
314
- const newRow = {
315
- ...row
316
- };
321
+ const newRow = Object.assign(Object.create(null), row);
317
322
  windowOps.forEach((op)=>{
318
323
  switch(op.op){
319
324
  case 'sum':
320
- runningSum += Number(row[op.field]) || 0;
325
+ runningSum += Number(getOwnDataValue(row, op.field)) || 0;
321
326
  newRow[op.as] = runningSum;
322
327
  break;
323
328
  case 'rank':
@@ -333,7 +338,9 @@ function getMarkType(mark) {
333
338
  newRow[op.as] = idx + 1;
334
339
  }
335
340
  });
336
- newResult.push(newRow);
341
+ newResult.push({
342
+ ...newRow
343
+ });
337
344
  });
338
345
  });
339
346
  result = newResult;
@@ -345,7 +352,7 @@ function getMarkType(mark) {
345
352
  // Compute aggregates
346
353
  const groups = new Map();
347
354
  result.forEach((row)=>{
348
- const key = groupby.length > 0 ? groupby.map((g)=>String(row[g])).join('|') : '__all__';
355
+ const key = groupby.length > 0 ? groupby.map((g)=>String(getOwnDataValue(row, g))).join('|') : '__all__';
349
356
  if (!groups.has(key)) {
350
357
  groups.set(key, []);
351
358
  }
@@ -353,9 +360,9 @@ function getMarkType(mark) {
353
360
  });
354
361
  const aggResults = new Map();
355
362
  groups.forEach((rows, key)=>{
356
- const aggs = {};
363
+ const aggs = Object.create(null);
357
364
  aggSpecs.forEach((spec)=>{
358
- const values = spec.field ? rows.map((r)=>Number(r[spec.field])).filter((v)=>!isNaN(v)) : [];
365
+ const values = spec.field ? rows.map((r)=>Number(getOwnDataValue(r, spec.field))).filter((v)=>!isNaN(v)) : [];
359
366
  switch(spec.op){
360
367
  case 'mean':
361
368
  case 'average':
@@ -384,7 +391,7 @@ function getMarkType(mark) {
384
391
  });
385
392
  // Join back: add aggregate values to each row
386
393
  result = result.map((row)=>{
387
- const key = groupby.length > 0 ? groupby.map((g)=>String(row[g])).join('|') : '__all__';
394
+ const key = groupby.length > 0 ? groupby.map((g)=>String(getOwnDataValue(row, g))).join('|') : '__all__';
388
395
  return {
389
396
  ...row,
390
397
  ...aggResults.get(key) || {}
@@ -396,8 +403,8 @@ function getMarkType(mark) {
396
403
  const yField = transform.regression;
397
404
  const xField = transform.on;
398
405
  const points = result.map((r)=>({
399
- x: Number(r[xField]),
400
- y: Number(r[yField])
406
+ x: Number(getOwnDataValue(r, xField)),
407
+ y: Number(getOwnDataValue(r, yField))
401
408
  })).filter((p)=>!isNaN(p.x) && !isNaN(p.y));
402
409
  if (points.length >= 2) {
403
410
  const n = points.length;
@@ -429,16 +436,16 @@ function getMarkType(mark) {
429
436
  const xField = transform.on;
430
437
  const sorted = [
431
438
  ...result
432
- ].filter((r)=>!isNaN(Number(r[xField])) && !isNaN(Number(r[yField]))).sort((a, b)=>Number(a[xField]) - Number(b[xField]));
439
+ ].filter((r)=>!isNaN(Number(getOwnDataValue(r, xField))) && !isNaN(Number(getOwnDataValue(r, yField)))).sort((a, b)=>Number(getOwnDataValue(a, xField)) - Number(getOwnDataValue(b, xField)));
433
440
  const windowSize = Math.max(3, Math.floor(sorted.length / 4));
434
441
  result = sorted.map((row, i)=>{
435
442
  const start = Math.max(0, i - Math.floor(windowSize / 2));
436
443
  const end = Math.min(sorted.length, start + windowSize);
437
444
  const windowSlice = sorted.slice(start, end);
438
445
  var _d3Mean;
439
- const avgY = (_d3Mean = (0, _d3array.mean)(windowSlice.map((r)=>Number(r[yField])))) !== null && _d3Mean !== void 0 ? _d3Mean : Number(row[yField]);
446
+ const avgY = (_d3Mean = (0, _d3array.mean)(windowSlice.map((r)=>Number(getOwnDataValue(r, yField))))) !== null && _d3Mean !== void 0 ? _d3Mean : Number(getOwnDataValue(row, yField));
440
447
  return {
441
- [xField]: row[xField],
448
+ [xField]: getOwnDataValue(row, xField),
442
449
  [yField]: avgY
443
450
  };
444
451
  });
@@ -449,11 +456,11 @@ function getMarkType(mark) {
449
456
  const groupby = transform.groupby || [];
450
457
  const groups = new Map();
451
458
  result.forEach((row)=>{
452
- const key = groupby.length > 0 ? groupby.map((g)=>String(row[g])).join('|') : '__all__';
459
+ const key = groupby.length > 0 ? groupby.map((g)=>String(getOwnDataValue(row, g))).join('|') : '__all__';
453
460
  if (!groups.has(key)) {
454
461
  groups.set(key, []);
455
462
  }
456
- groups.get(key).push(Number(row[field]));
463
+ groups.get(key).push(Number(getOwnDataValue(row, field)));
457
464
  });
458
465
  const densityResult = [];
459
466
  groups.forEach((values, key)=>{
@@ -464,11 +471,11 @@ function getMarkType(mark) {
464
471
  const range = max - min || 1;
465
472
  const bins = 20;
466
473
  const bandwidth = range / bins;
467
- const groupFields = {};
474
+ const groupFields = Object.create(null);
468
475
  if (groupby.length > 0) {
469
- const sampleRow = result.find((r)=>groupby.map((g)=>String(r[g])).join('|') === key);
476
+ const sampleRow = result.find((r)=>groupby.map((g)=>String(getOwnDataValue(r, g))).join('|') === key);
470
477
  groupby.forEach((g)=>{
471
- groupFields[g] = sampleRow === null || sampleRow === void 0 ? void 0 : sampleRow[g];
478
+ groupFields[g] = sampleRow ? getOwnDataValue(sampleRow, g) : undefined;
472
479
  });
473
480
  }
474
481
  for(let i = 0; i <= bins; i++){
@@ -492,7 +499,7 @@ function getMarkType(mark) {
492
499
  0.5,
493
500
  0.75
494
501
  ];
495
- const values = result.map((r)=>Number(r[field])).filter((v)=>!isNaN(v)).sort((a, b)=>a - b);
502
+ const values = result.map((r)=>Number(getOwnDataValue(r, field))).filter((v)=>!isNaN(v)).sort((a, b)=>a - b);
496
503
  if (values.length > 0) {
497
504
  result = probs.map((p)=>{
498
505
  const idx = Math.min(Math.floor(p * values.length), values.length - 1);
@@ -510,8 +517,8 @@ function getMarkType(mark) {
510
517
  const method = transform.method || 'value';
511
518
  var _transform_value;
512
519
  const fillValue = (_transform_value = transform.value) !== null && _transform_value !== void 0 ? _transform_value : 0;
513
- const existingKeys = new Set(result.map((r)=>r[keyField]));
514
- const allKeyValues = result.map((r)=>Number(r[keyField])).filter((v)=>!isNaN(v));
520
+ const existingKeys = new Set(result.map((r)=>getOwnDataValue(r, keyField)));
521
+ const allKeyValues = result.map((r)=>Number(getOwnDataValue(r, keyField))).filter((v)=>!isNaN(v));
515
522
  if (allKeyValues.length > 0) {
516
523
  var _d3Min1;
517
524
  const minKey = (_d3Min1 = (0, _d3array.min)(allKeyValues)) !== null && _d3Min1 !== void 0 ? _d3Min1 : 0;
@@ -520,13 +527,13 @@ function getMarkType(mark) {
520
527
  for(let k = minKey; k <= maxKey; k++){
521
528
  if (!existingKeys.has(k)) {
522
529
  const imputed = {
523
- [keyField]: k
530
+ [keyField]: k,
531
+ [field]: method === 'value' ? fillValue : 0
524
532
  };
525
- imputed[field] = method === 'value' ? fillValue : 0;
526
533
  result.push(imputed);
527
534
  }
528
535
  }
529
- result.sort((a, b)=>Number(a[keyField]) - Number(b[keyField]));
536
+ result.sort((a, b)=>Number(getOwnDataValue(a, keyField)) - Number(getOwnDataValue(b, keyField)));
530
537
  }
531
538
  }
532
539
  // Handle lookup transform (join with secondary dataset)
@@ -537,14 +544,14 @@ function getMarkType(mark) {
537
544
  if (((_fromSpec_data = fromSpec.data) === null || _fromSpec_data === void 0 ? void 0 : _fromSpec_data.values) && fromSpec.key && fromSpec.fields) {
538
545
  const lookupMap = new Map();
539
546
  fromSpec.data.values.forEach((row)=>{
540
- lookupMap.set(String(row[fromSpec.key]), row);
547
+ lookupMap.set(String(getOwnDataValue(row, fromSpec.key)), row);
541
548
  });
542
549
  result = result.map((row)=>{
543
- const lookupRow = lookupMap.get(String(row[lookupField]));
550
+ const lookupRow = lookupMap.get(String(getOwnDataValue(row, lookupField)));
544
551
  if (lookupRow) {
545
- const extra = {};
552
+ const extra = Object.create(null);
546
553
  fromSpec.fields.forEach((f)=>{
547
- extra[f] = lookupRow[f];
554
+ extra[f] = getOwnDataValue(lookupRow, f);
548
555
  });
549
556
  return {
550
557
  ...row,
@@ -1085,7 +1092,7 @@ function getMarkType(mark) {
1085
1092
  const yAgg = ((_encoding_y1 = encoding.y) === null || _encoding_y1 === void 0 ? void 0 : _encoding_y1.aggregate) || (yField ? 'mean' : 'count');
1086
1093
  const groups = new Map();
1087
1094
  dataValues.forEach((row)=>{
1088
- const dateVal = new Date(row[field]);
1095
+ const dateVal = new Date(getOwnDataValue(row, field));
1089
1096
  if (isNaN(dateVal.getTime())) {
1090
1097
  return;
1091
1098
  }
@@ -1117,17 +1124,18 @@ function getMarkType(mark) {
1117
1124
  groups.get(key).push(row);
1118
1125
  });
1119
1126
  dataValues = Array.from(groups.entries()).map(([key, rows])=>{
1120
- const result = {
1121
- [field]: key
1122
- };
1127
+ const result = Object.create(null);
1128
+ result[field] = key;
1123
1129
  if (yField && yAgg !== 'count') {
1124
- const vals = rows.map((r)=>Number(r[yField])).filter((v)=>!isNaN(v));
1130
+ const vals = rows.map((r)=>Number(getOwnDataValue(r, yField))).filter((v)=>!isNaN(v));
1125
1131
  var _d3Mean;
1126
1132
  result[yField] = yAgg === 'sum' ? (0, _d3array.sum)(vals) : (_d3Mean = (0, _d3array.mean)(vals)) !== null && _d3Mean !== void 0 ? _d3Mean : 0;
1127
1133
  } else {
1128
1134
  result[yField || '__count'] = rows.length;
1129
1135
  }
1130
- return result;
1136
+ return {
1137
+ ...result
1138
+ };
1131
1139
  });
1132
1140
  // Switch x from temporal to ordinal since we've aggregated
1133
1141
  encoding.x.type = 'ordinal';