@spteck/fluentui-react-charts 1.0.14 → 1.1.1

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.
@@ -789,7 +789,7 @@ var lightenColor = function lightenColor(hex, amount) {
789
789
  var getFluentPalette = function getFluentPalette(theme) {
790
790
  // Check if theme is dark by looking at global color tokens
791
791
  var isDark = theme.colorNeutralBackground1.startsWith('#1') || theme.colorNeutralBackground1 === '#000000';
792
- return isDark ? ['#2899f5', '#ff8c00', '#32cd32', '#f06b71', '#c390f2', '#00b7c3', '#ffb900', '#b4a0ff', '#60cdff', '#92c353'] : ['#0078d4', '#d83b01', '#097223', '#a4262c', '#3f0c7aff', '#024339ff', '#791d2dff', '#005a9e', '#8764b8', '#376102ff'];
792
+ return isDark ? ['#2899f5', '#ff8c00', '#32cd32', '#f06b71', '#c390f2', '#00b7c3', '#ffb900', '#b4a0ff', '#60cdff', '#92c353'] : ['#289CEF', '#f05075ff', '#45B0A2', '#a4262c', '#F49E31', '#A366FF', '#FCCE51', '#062843ff', '#7f7f82ff', '#376102ff'];
793
793
  };
794
794
  /**
795
795
  * Returns animation configuration for instant interactions.
@@ -866,11 +866,24 @@ function createFluentTooltip(theme) {
866
866
  afterLabel: function afterLabel() {
867
867
  return '';
868
868
  },
869
- labelColor: function labelColor() {
870
- return undefined;
869
+ // Provide sensible defaults for tooltip label colors using dataset colors when available
870
+ labelColor: function labelColor(item) {
871
+ var _item$dataIndex, _item$dataIndex2, _ref, _ref2;
872
+ var ds = item.dataset || {};
873
+ // dataset colors can be a single value or an array per data point
874
+ var bg = ds.backgroundColor;
875
+ if (Array.isArray(bg)) bg = bg[(_item$dataIndex = item.dataIndex) != null ? _item$dataIndex : 0];
876
+ var border = ds.borderColor;
877
+ if (Array.isArray(border)) border = border[(_item$dataIndex2 = item.dataIndex) != null ? _item$dataIndex2 : 0];
878
+ var backgroundColor = (_ref = bg != null ? bg : ds.pointBackgroundColor) != null ? _ref : tooltipBg;
879
+ var borderColorOut = (_ref2 = border != null ? border : ds.pointBorderColor) != null ? _ref2 : borderColor;
880
+ return {
881
+ borderColor: borderColorOut,
882
+ backgroundColor: backgroundColor
883
+ };
871
884
  },
872
885
  labelTextColor: function labelTextColor() {
873
- return '';
886
+ return tooltipTitleColor;
874
887
  },
875
888
  footer: function footer() {
876
889
  return '';
@@ -919,13 +932,13 @@ function createFluentTooltip(theme) {
919
932
  /**
920
933
  * Returns a Chart.js ticks callback to truncate long labels and add optional prefix/suffix.
921
934
  */
922
- var createAxisLabelFormatter = function createAxisLabelFormatter(_ref) {
923
- var _ref$maxLength = _ref.maxLength,
924
- maxLength = _ref$maxLength === void 0 ? 12 : _ref$maxLength,
925
- _ref$suffix = _ref.suffix,
926
- suffix = _ref$suffix === void 0 ? '' : _ref$suffix,
927
- _ref$prefix = _ref.prefix,
928
- prefix = _ref$prefix === void 0 ? '' : _ref$prefix;
935
+ var createAxisLabelFormatter = function createAxisLabelFormatter(_ref3) {
936
+ var _ref3$maxLength = _ref3.maxLength,
937
+ maxLength = _ref3$maxLength === void 0 ? 12 : _ref3$maxLength,
938
+ _ref3$suffix = _ref3.suffix,
939
+ suffix = _ref3$suffix === void 0 ? '' : _ref3$suffix,
940
+ _ref3$prefix = _ref3.prefix,
941
+ prefix = _ref3$prefix === void 0 ? '' : _ref3$prefix;
929
942
  return function (value) {
930
943
  var label = typeof value === 'number' ? this.getLabelForValue(value) : String(value);
931
944
  var trimmed = label.length > maxLength ? label.slice(0, maxLength) + '…' : label;
@@ -1864,7 +1877,6 @@ function ComboChart(_ref) {
1864
1877
  type: 'linear',
1865
1878
  position: 'left',
1866
1879
  stacked: true,
1867
- offset: true,
1868
1880
  ticks: {
1869
1881
  color: labelColor,
1870
1882
  font: {
@@ -3436,7 +3448,8 @@ var chartProps = function chartProps(chart) {
3436
3448
  };
3437
3449
  var getChartComponent = function getChartComponent(chart, theme) {
3438
3450
  var _chart$axesMode;
3439
- var type = chart.type;
3451
+ var type = chart.type,
3452
+ showDataLabels = chart.showDataLabels;
3440
3453
  var fuiTheme = theme != null ? theme : reactComponents.webLightTheme;
3441
3454
  switch (type) {
3442
3455
  case 'bar':
@@ -3445,7 +3458,9 @@ var getChartComponent = function getChartComponent(chart, theme) {
3445
3458
  theme: fuiTheme
3446
3459
  }));
3447
3460
  case 'line':
3448
- return React__default.createElement(LineChart, Object.assign({}, chartProps(chart), {
3461
+ return React__default.createElement(LineChart, Object.assign({
3462
+ showDataLabels: showDataLabels != null ? showDataLabels : false
3463
+ }, chartProps(chart), {
3449
3464
  theme: fuiTheme
3450
3465
  }));
3451
3466
  case 'area':
@@ -3459,7 +3474,9 @@ var getChartComponent = function getChartComponent(chart, theme) {
3459
3474
  theme: fuiTheme
3460
3475
  }));
3461
3476
  case 'bubble':
3462
- return React__default.createElement(BubbleChart, Object.assign({}, chartProps(chart), {
3477
+ return React__default.createElement(BubbleChart, Object.assign({
3478
+ showDataLabels: showDataLabels != null ? showDataLabels : false
3479
+ }, chartProps(chart), {
3463
3480
  getRadius: function getRadius(d) {
3464
3481
  var _d$radius;
3465
3482
  return (_d$radius = d.radius) != null ? _d$radius : 1;
@@ -3471,6 +3488,7 @@ var getChartComponent = function getChartComponent(chart, theme) {
3471
3488
  theme: fuiTheme,
3472
3489
  // allow the originating chart descriptor to opt into dual axes
3473
3490
  axesMode: (_chart$axesMode = chart.axesMode) != null ? _chart$axesMode : 'dual',
3491
+ showDataLabels: showDataLabels != null ? showDataLabels : false,
3474
3492
  data: chart.data.map(function (series) {
3475
3493
  var _series$type;
3476
3494
  return {
@@ -3490,7 +3508,8 @@ var getChartComponent = function getChartComponent(chart, theme) {
3490
3508
  getRange: function getRange(d) {
3491
3509
  var _d$min, _d$max;
3492
3510
  return [(_d$min = d.min) != null ? _d$min : 0, (_d$max = d.max) != null ? _d$max : 0];
3493
- }
3511
+ },
3512
+ showDataLabels: showDataLabels != null ? showDataLabels : false
3494
3513
  }, chartProps(chart), {
3495
3514
  theme: fuiTheme
3496
3515
  }));
@@ -3506,7 +3525,8 @@ var getChartComponent = function getChartComponent(chart, theme) {
3506
3525
  getValue: function getValue(datum) {
3507
3526
  var _datum$value;
3508
3527
  return (_datum$value = datum.value) != null ? _datum$value : 0;
3509
- }
3528
+ },
3529
+ showDataLabels: showDataLabels != null ? showDataLabels : false
3510
3530
  }, chartProps(chart), {
3511
3531
  theme: fuiTheme
3512
3532
  }));
@@ -3519,7 +3539,7 @@ var getChartComponent = function getChartComponent(chart, theme) {
3519
3539
  var _datum$value2;
3520
3540
  return (_datum$value2 = datum.value) != null ? _datum$value2 : 0;
3521
3541
  },
3522
- showDataLabels: true
3542
+ showDataLabels: showDataLabels != null ? showDataLabels : false
3523
3543
  }, chartProps(chart), {
3524
3544
  theme: fuiTheme
3525
3545
  }));
@@ -3536,7 +3556,7 @@ var getChartComponent = function getChartComponent(chart, theme) {
3536
3556
  }
3537
3557
  }, chartProps(chart), {
3538
3558
  theme: fuiTheme,
3539
- showDataLabels: false
3559
+ showDataLabels: showDataLabels != null ? showDataLabels : false
3540
3560
  }));
3541
3561
  case 'polar':
3542
3562
  return React__default.createElement(PolarChart, {
@@ -3549,7 +3569,7 @@ var getChartComponent = function getChartComponent(chart, theme) {
3549
3569
  return (_d$value = d.value) != null ? _d$value : 0;
3550
3570
  },
3551
3571
  title: chart.title,
3552
- showDataLabels: true,
3572
+ showDataLabels: showDataLabels != null ? showDataLabels : false,
3553
3573
  theme: fuiTheme
3554
3574
  });
3555
3575
  case 'radar':
@@ -3563,7 +3583,8 @@ var getChartComponent = function getChartComponent(chart, theme) {
3563
3583
  return (_d$value2 = d.value) != null ? _d$value2 : 0;
3564
3584
  },
3565
3585
  title: chart.title,
3566
- theme: fuiTheme
3586
+ theme: fuiTheme,
3587
+ showDataLabels: showDataLabels != null ? showDataLabels : false
3567
3588
  });
3568
3589
  default:
3569
3590
  throw new Error("Unsupported chart type: " + type);
@@ -4179,7 +4200,8 @@ var Dashboard = function Dashboard(_ref) {
4179
4200
  }), React__default.createElement("div", {
4180
4201
  className: styles.chartContainer,
4181
4202
  style: {
4182
- height: containerHeight
4203
+ height: containerHeight,
4204
+ paddingTop: cardContainer.chart.title ? 0 : 16
4183
4205
  }
4184
4206
  }, theme && theme.fontSizeBase100 && getChartComponent(cardContainer.chart, theme))));
4185
4207
  });